summaryrefslogtreecommitdiff
path: root/src/script/api
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.14' into 5.15v5.15.0-beta1Qt Forward Merge Bot2020-02-1532-256/+768
|\ | | | | | | Change-Id: Ib26f2a7d33bc1823f13765dda22ef574f4fd55df
| * Fix license headers in src/scriptKai Koehne2020-02-1232-256/+768
| | | | | | | | | | | | | | | | | | | | | | The LGPL-ONLY header is outdated, and the referenced LICENSE.LGPL file does not exist anymore. Anyhow, the module is documented to be available under Commercial/LGPLv3/GPLv2; that the JavaScriptCore dependency is LGPLv2.1 or later is separate. Fixes: QTBUG-80883 Change-Id: Ic76c127a7643fb90ebd99b6472f84c81a7dc2eee Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* | Avoid initializing QFlags with 0 or nullptrFriedemann Kleint2019-11-265-8/+8
| | | | | | | | | | | | | | It is being deprecated. Change-Id: I772c028967f3c986674081992f569bd7bbba81a5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Fix crash in QScriptEngine::reportAdditionalMemoryCostLars Knoll2019-10-081-1/+3
|/ | | | | | Fixes: QTBUG-76176 Change-Id: Id48e21b7e2617f34e4ae3e9d09e56641d1d1654a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QScriptValueIterator: replace a QLinkedList with a std::listMarc Mutz2019-06-061-6/+6
| | | | | | | | | | | | The payload type apparently doesn't like to be destroyed unless some magic foo is enabled (cf. ~QScriptValueIteratorPrivate()). Since the code also allows to remove items in the middle, we need a container that guarantees no copies (thus, deletions) happen at all. That leaves a vector<unique_ptr>, or a std::list. Since this is a deprecated module, use the least-intrusive option: std::list Change-Id: Iaadc71959814959bf7ba1a225f375d64edbd9785 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* Fix thisObject() of QScriptable argument for String(), etcAlexandra Cherdantseva2019-04-171-1/+1
| | | | | | | | | | When `String(object)` is evaluated, and `object` is a QObject or some custom object with native prototype, then `object.toString()` will be called with incorrect `this`. This also applies for Number(), Boolean() and other built-in constructors. Change-Id: I0219f0e119c1e29d80e4c0f856421352715e9e6e Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
* Doc: Fix documentation warningsv5.11.0-beta4Topi Reinio2018-04-133-24/+21
| | | | | | | | | | | Use complete function signatures for \fn commands (including template specifiers) as Clang parser now reads them. Convert internal class documentation comments to standard C-style comments. Change-Id: Ie67eb054171139db12f7e74d077b7dc8453582df Reviewed-by: Martin Smith <martin.smith@qt.io>
* Merge remote-tracking branch 'origin/5.10' into devLiang Qi2018-01-181-14/+20
|\ | | | | | | | | | | | | Conflicts: .qmake.conf Change-Id: I77f29cac3182808e0b9601f3415c9740b8f0fa88
| * Fix license headersJani Heikkinen2018-01-151-14/+20
| | | | | | | | | | | | | | | | | | | | old header.LGPL21 was used in some src and test files. Replace ones in src/ with correct header.LGPL one and ones in tests/ with correct header.GLP-EXCEPT one. Also add correct license files and remove unnecessary ones Change-Id: Ifc7bb0f25bd9df652ddafe0faceaebd52b495bef Reviewed-by: Liang Qi <liang.qi@qt.io>
* | Replace Q_NULLPTR with nullptrKevin Funk2017-09-273-3/+3
|/ | | | | Change-Id: I9b2a6ce4a0278520fd95042a1b2736cc5a0d4be6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Make more ctors explicitMarc Mutz2016-03-061-1/+1
| | | | | | | | | | | Added explicit where it was missing. This is not a source- incompatible change, because code that breaks by this is a bug. Let's not have this sitting around in an LTS. One is even a protected ctor. Change-Id: I114b26332ba0e2752f5d02ebcd6090fc2b562b40 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Make public headers compile with -Wzero-as-null-pointer-constantMarc Mutz2016-03-063-5/+5
| | | | | | | | | | | ... or equivalent. QtBase 5.6 headers already compile that way, so let the other modules follow suit. Change-Id: I7e007ee907c479320a885af329745563c080467d Task-number: QTBUG-45291 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Doc: corrected invalid qdoc \relates statementNico Vertriest2016-01-251-2/+0
| | | | | | Change-Id: I6a73ed6b4eeb241be574f0ddc041f554e120003b Task-number: QTBUG-43810 Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
* doc: Remove uses of \mainclassMartin Smith2015-06-054-5/+0
| | | | | | | | This qdoc command is deprecated. Change-Id: I50ebdbfb6d0c445ae4ead0556b9b1b1b0259f860 Task-number: QTBUG-46476 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2015-02-131-1/+1
|\ | | | | | | Change-Id: Ic32f5bd17782285305aaa01694f1a78851b882eb
| * Doc: Moved the example documentation to correct locationsNico Vertriest2015-01-191-1/+1
| | | | | | | | | | | | | | | | | | | | And fix the \snippet commands to use the correct paths. Also edited dependencies qdocconf files Task-number: QTBUG-43810 Change-Id: I3c2fb6d2a48900a9b5651225381707c9ec25065a Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* | Update copyright headersJani Heikkinen2015-02-1233-134/+134
|/ | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: Iffc10aac2cdaf7c7ceba051ec447f15758c3d8e0 Reviewed-by: Sergio Ahumada <sahumada@texla.cl>
* Update license headers and add new license filesAntti Kokko2014-08-241-18/+10
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I8b229a6405aefe7951ad0d13d6432d01a4ec8263 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Fix recursive calling of QScriptProgramv5.3.0-rc1v5.3.0-beta1v5.3.0release5.3.0Lars Knoll2014-03-111-1/+1
| | | | | | | | | | | | The first time a QScriptProgram is evaluated, it gets compiled and then executed. If the execution would somehow trigger another evaluation of the script program, it would run into the compile stage again (even though it already was compiled), and then trigger and assertion in debug mode (or leak memory in release builds). Task-number: QTBUG-37317 Change-Id: I83e7efd5f238d021e200258826e2e4a9520c3a7d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* WS fix in qscriptcontext.cppv5.2.0-beta1Jerome Pasion2013-10-081-1/+1
| | | | | | | -produced by git-split-ws Change-Id: I1661678174c62971a7bbf4acb2890fdf590d2f3d Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Doc: Adding "\inmodule QtScript" to Qt Script classes.Jerome Pasion2013-10-0812-9/+13
| | | | | | | | -reduces QDoc warnings -lists the classes in the C++ pages Change-Id: I97db6b8bec4d44d1ee37ed2925ef7309cd0d420f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Remove QtAlgorithms usage from QtScript.Friedemann Kleint2013-09-261-2/+3
| | | | | | | | | QtAlgorithms is getting deprecated, see http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: If4dc8f69fd75315390a4850be732715064f5fdd8 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Remove deprecation of QScriptContextInfo::columnNumber().Friedemann Kleint2013-03-071-3/+1
| | | | | | | | The module is done, there is no need to deprecate functions. Fix deprecation warning occurring in build. Change-Id: I01fb9d91ccc3cb4d6fb4e2134960436f18376e3e Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-02-057-33/+33
|\ | | | | | | Change-Id: Ib100dac4eccddf7a72382b7d1ead7d504a572347
| * Merge branch 'release' into stableSergio Ahumada2013-01-311-1/+1
| |\ | | | | | | | | | Change-Id: If3a1efe3888b872702d75e25d1943ff79d57e9c6
| | * Fix QtScript crash on 64bit with JIT.v5.0.1Friedemann Kleint2013-01-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During back-trace generation we calculate a code offset towards JIT generated code. Using JITCode::offsetOf() will crash/assert if the offset doesn't fit into 32 bits, because the generated code can only encode relative offsets in 32-bits and not 64-bits. However in this context - backtrace generation - we just want to calculate the offset and are not interested in this architectural limitation, therefore we can just calculate the offset ourselves using the fully sized uintptr_t. Initial-patch-by: Simon.Hausmann@digia.com Task-number: QTCREATORBUG-8629 Task-number: QTBUG-23463 Change-Id: I0efadd5ed20855409122e1fcc9236fdfbc4f62a4 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
| * | Doc: Fix module name formatSze Howe Koh2013-01-266-32/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow the conventions at http://qt-project.org/wiki/Spelling_Module_Names_in_Qt_Documentation QtScript -> Qt Script QtScriptTools -> Qt Script Tools Change-Id: Icf6b2ea3829247475f8902334b615f9a9206cc51 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* | | Remove QT_{BEGIN,END}_HEADER macro usageSergio Ahumada2013-01-2814-56/+0
|/ / | | | | | | | | | | | | | | | | The macro was made empty in qtbase/ba3dc5f3b56d1fab6fe37fe7ae08096d7dc68bcb and is no longer necessary or used. Discussed-on: http://lists.qt-project.org/pipermail/development/2013-January/009284.html Change-Id: I7fed9ff47fd84f6cf2b418658a1ee3e7130539ac Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* | Update copyright year in Digia's license headersSergio Ahumada2013-01-1032-32/+32
|/ | | | | | Change-Id: Ic4a2739c8caf2eac95e4a72d8d38cfb912d5fe2b Reviewed-by: Akseli Salovaara <akseli.salovaara@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Doc: Replace outdated macroChristian Stenger2012-12-071-2/+2
| | | | | Change-Id: I7750e9af3eee8cee5be202094acd1d3efc4b52b0 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Fix header guardLars Knoll2012-09-251-0/+1
| | | | | Change-Id: I22bba8d2d175d787913d1e2269ad2ca8ff762043 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-2433-87/+87
| | | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: Id0b72b8c895b0eab04a740bf83859c9b646dd911 Reviewed-by: Janne Anttila <janne.anttila@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Capture full backtrace when a native function calls back into JSKent Hansen2012-08-221-2/+10
| | | | | | | | | | | | | | | | | | | | | | Commit df0ec196031d33850324dc5eeed2d71f61413885 assumed that JSC's Interpreter::throwException function is called exactly once when an exception occurs. That's wrong. If there is a native call inbetween two JS calls on the stack, the call stack will be unwound to the point of the native call frame, and throwException will return. After the native (C) call frame has been unwound, throwException will be called again to unwind remaining JS call frames, and so on. This was causing QtScript to discard the backtrace belonging to the inner-most JS frames; the backtrace would be regenerated from a partially unwound state. Fix this by ignoring subsequent calls to the uncaughtException() callback once a backtrace has been captured; the backtrace is already cleared before each evaluation is started. Task-number: QTBUG-26889 Change-Id: I03e1d60fbac5e592cff1dd5ef70f397cf94454ae Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* Remove the use of the QWidgetStar metatypeid.Stephen Kelly2012-08-151-9/+5
| | | | | | | | | | It is to be removed, and is obsoleted by QMetaType::PointerToQObject. By using QMetaType::PointerToQObject, we also gain the feature that all pointers to types derived from QObject return true for QScriptValue::isQObject(). Change-Id: I18392b5b6cde3a45d060c37612d987a5cf8e8f18 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Make QScriptEngine::uncaughtExceptionBacktrace() work againKent Hansen2012-08-154-21/+80
| | | | | | | | | | | This function has been broken since Qt 4.6 (when the JavaScriptCore- based back-end was introduced). Fix it by introducing a callback in JSC that allows us to capture the stack when an uncaught exception occurs. Task-number: QTBUG-6139 Change-Id: I4a829323c9fb0c8b2f16a2e5d6f0aeb13cc32561 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Add default conversion for types long and ulongKent Hansen2012-08-141-0/+22
| | | | | | | | | | | | | | Such conversion is not guaranteed to be lossless on all platforms, but it's still reasonable to support these types by default. JSC::JSValue already had constructors for them. The type matching / overload resolution in the QObject binding already handled long and ulong, but the value conversion itself was missing, for some reason. Task-number: QTBUG-2124 Change-Id: I14ff29a8e949403234b7659c0aca8b48bcdbda0e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix GC issues related to QObject connections and ownershipKent Hansen2012-08-092-8/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue 1: Even if a sender object was only weakly referenced, the connection's slot function would still get marked. If the slot was a closure, its scope could hold a reference to the sender object, so by marking the closure, the sender would get marked, too - even if there were no other references to the closure outside of the QObject connection structure. This would cause the sender object to stay alive, rather than being garbage-collected (i.e., it leaked). Issue 2: It's possible that a closure used as a slot in a connection for one QObject holds the only reference to another QObject that has connections of its own. In that case, if the first object is explicitly referenced, the second object (and its connections) should get marked. But depending on the order in which the connections were marked, the second object might get treated incorrectly. This commit solves both issues by introducing an iterative scheme for marking connections. The first pass marks only connections whose sender object is referenced elsewhere in the JS environment. The second pass marks connections whose sender object is referenced by slots of the connections marked in the first pass. And so on, until no more connections should be marked. At that point, any remaining unmarked connections are effectively dead (belonging to QObjects that can be reclaimed by the GC). Task-number: QTBUG-26590 Change-Id: I50aa66f7fe407a6827b6f2a12e027275a2fb4655 Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
* Add qtscriptglobal.h for the qtscript.git module EXPORT macrosThiago Macieira2012-08-099-1/+79
| | | | | | | | No library other than the core libraries should depend on their export macros being in qglobal.h. Change-Id: I6ded70813f6296ca5aa1d7d3cdb38503a5538424 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* QScriptEngine::pushContext(): Don't inherit parent context's scopeKent Hansen2012-08-082-8/+3
| | | | | | | | | | | | | | This was a regression introduced in Qt 4.6 (JavaScriptCore-based backend). pushContext() should always create a context with a "clean" scope (only the Global Object and the context's own activation object should be in the scope chain). The scope chain API is internal, but the wrong behavior could still be observed e.g. through QScriptEngine::evaluate(). Task-number: QTBUG-18188 Change-Id: I138dabc665d7275fb85d3b5e1b473d56096a989e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix QScriptContextInfo::functionMetaIndex() for overloaded slotsKent Hansen2012-07-131-2/+1
| | | | | | | | | | | | | | | | | | This was a regression against the pre-JavaScriptCore implementation, where we used to store the selected method index as an internal member of the QScriptContext(Private). But in the JSC-based implementation, QScriptContext is implemented as a pointer to a JSC::CallFrame, and there are no unused fields in CallFrame where the method index can be stashed. Refactor the Qt method call logic so that the method selection is separate from the actual processing of the target method. This way, QScriptContextInfo can compute the method index the same way that the actual method call did. Task-number: QTBUG-6133 Change-Id: I619fa8b91542d0b6ab5a44b00266cc0705c95823 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Ensure QObject wrappers are garbage-collected if appropriateKent Hansen2012-07-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address the "###" comment. When QScriptEngine::newQObject() is called with the option PreferExistingWrapperObject, the resulting wrapper object is cached by the engine, in case it will be needed later (e.g., by a subsequent newQObject() call for the same QObject, with the same wrap options). But if a QObject wrapper object is only referenced by the QtScript internals (i.e., not reachable from the JSC stack/heap, or kept in a QScriptValue), the wrapper should not be kept alive if the ownership is ScriptOwnership, or if the ownership is AutoOwnership and the C++ object has no parent. If the wrapper is marked in that case, it won't get collected, and hence the C++ object will be kept alive, too. In practice, QtScript appears to leak memory (the objects will only be destroyed when the engine is destroyed). Our copy of JSC doesn't have a concept of weak references; the ClientData callback in the JSC markRoots() function (which causes QScriptEnginePrivate::mark() to be called) was moved to the end. This enables the wrapper and connection marking logic to determine whether a wrapper can be safely discarded (if it hasn't been marked by JSC by this point, it must be a weak reference). Task-number: QTBUG-21993 Change-Id: I61f6aafc91f080b80d3f5859148e645b80d9b653 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Doc: Modularize QtScript documentation.Casper van Donderen2012-06-057-43/+43
| | | | | Change-Id: I042d9bafe4f48a8cd23306f0864b6872776d0153 Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Fix crash when converting invalid JSValue to stringKent Hansen2012-06-011-0/+2
| | | | | | | | JSC::JSValue::toString() expects that the input is valid. Task-number: QTBUG-21896 Change-Id: I3199fcba94be5426cb3d193b57d16176daae83a0 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix crash when accessing QObject properties through activation objectKent Hansen2012-06-011-0/+4
| | | | | | | | | | | | | | | | Since objects in the scope chain have to be JSActivationObjects, QScriptContext::setActivationObject() creates a proxy object that should delegate access to the actual object. This case was not handled in the toQObject() conversion function, so for activation property access through evaluation (where the this-object would be the proxy object, not the actual QObject), the this-object conversion to QObject would fail, and the assert "this-object must be a QObject" was triggered. Task-number: QTBUG-21760 Change-Id: I40e868d9717ec76e0df18d5848c6ad99546ba34f Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Deprecate the Encoding argument of qsTranslateLars Knoll2012-05-211-19/+19
| | | | | | | | | | This is the same as change 4822a821facbbf834c6aab5a8a7da2b3e43f09f7 in qtdeclarative. We always assume the js source code is Utf8 encoded, as also on the C++ side. Change-Id: I4f49484241718dfc4a2bb39a674b54df46aa8c8d Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Simplify QVariant::convert and QVariant::canConvert calls.Jędrzej Nowacki2012-05-211-2/+2
| | | | | | | QVariant::Type casts are not necessary in Qt5. Change-Id: I43833e869379db8937839612dfb6162f878870cb Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Change uses of {to,from}Ascii to {to,from}Latin1Thiago Macieira2012-05-031-2/+2
| | | | | | | | | | This operation should be a no-op anyway, since at this point in time, the fromAscii and toAscii functions simply call their fromLatin1 and toLatin1 counterparts. Task-number: QTBUG-21872 Change-Id: I4f44512856ea99112d8eb6d341d6058c1fc439dc Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
* Fix some deprecation warnings in QtScript.Friedemann Kleint2012-04-302-5/+9
| | | | | Change-Id: I98d4826fcc2e3687d45edfccca956891ca0466cf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add missing case in QScriptEnginePrivate::createJędrzej Nowacki2012-04-171-0/+1
| | | | | | | | | Currently QMetaType::UnknownType, instead of QMetaType::Void, is used to check if a type id is valid or not. Change-Id: Ib185e3f28ef675c57d9b8b0d2eb4e4f124999131 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Adapt qtscript to QMetaMethod::signature() renamingKent Hansen2012-04-171-6/+6
| | | | | | | | | | QMetaMethod::methodSignature() should be used instead, and it returns a QByteArray. Change-Id: I81150e238dab7eda26d0466ac407a4f3ba79a7c7 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>