aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi
Commit message (Collapse)AuthorAgeFilesLines
* Move the engine() accessor from Object to ManagedLars Knoll2017-05-191-2/+2
| | | | | | | | | | | | We can easily do this now that Managed has a pointer to an internal class (which always has a back pointer to the ExecutionEngine). Remove the extra engine pointer from ExecutionContext, and clean up tow methods in String. Change-Id: I98d750b1afbdeadf42e66ae0c92c48db1a7adc31 Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
* Doc: Fix documentation warningsTopi Reinio2017-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | src/qml/jsapi/qjsengine.cpp:524: warning: Undocumented parameter 'metaObject' in QJSEngine::newQMetaObject() src/qml/qml/qqmlengine.cpp:1023: warning: Undocumented parameter 'retCode' in QQmlEngine::exit() src/qml/doc/src/qmlfunctions.qdoc:182: warning: Undocumented parameter 'reason' in qmlRegisterUncreatableMetaObject() src/qml/qml/qqmllist.cpp:393: warning: Undocumented parameter 'at' in QQmlListProperty::QQmlListProperty() src/qml/qml/qqmllist.cpp:393: warning: Undocumented parameter 'count' in QQmlListProperty::QQmlListProperty() src/qml/qml/qqmllist.cpp:402: warning: Undocumented parameter 'at' in QQmlListProperty::QQmlListProperty() src/qml/qml/qqmllist.cpp:402: warning: Undocumented parameter 'count' in QQmlListProperty::QQmlListProperty() src/qml/qml/qqmllist.cpp:402: warning: Undocumented parameter 'append' in QQmlListProperty::QQmlListProperty() src/qml/qml/qqmllist.cpp:402: warning: Undocumented parameter 'clear' in QQmlListProperty::QQmlListProperty() src/quick/items/qquickwindow.cpp:4461: warning: No such parameter 'backend' in QQuickWindow::setSceneGraphBackend() Also do some minor language editing. Change-Id: I2e806d1a77e3c4264d709c27d2bfc4542a782716 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* QJSValue: Mention how to construct QJSValue from other non-obvious typesRobin Burchell2017-01-121-1/+2
| | | | | | | This has come up in queries from users, so let's add a helping hand. Change-Id: If4e5efdd8969a71a78fc88ae168ede8d681858aa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up Value::isString()/stringValue() combinationsLars Knoll2016-11-291-8/+6
| | | | | | | | It's enough to just call stringValue(), as that already does the isString() check. Change-Id: I7be0e643a7975c0704b4c9c43b337deb8db9fce0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up duplicated checks whether a Value is a ManagedLars Knoll2016-11-291-4/+6
| | | | | Change-Id: Ib044be254dbb41bd9fb4a6e0baa3bd3c007e6a2a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QML: Make Heap::Object and all subclasses trivialErik Verbruggen2016-10-061-5/+5
| | | | | | | | | | | | GCC6 might dead-store-eliminate out our secret write to Base::mmdata, because it expects all memory content to be "undefined" before constructor calls. Clang might take the same approach if the constructor of Heap::Object is removed. By making these structs trivial, it also makes them memcpy-able. Change-Id: I055b2ad28311b997fbe059849ebda4d5894eaa9b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QJSValue: Adapt to introduction of QMetaType::NullptrChristian Kandeler2016-08-082-4/+8
| | | | | | | | | [ChangeLog][QtQml][Important Behavior Changes] A JS null value converted to a QVariant now has type QMetaType::Nullptr rather than QMetaType::VoidStar. Change-Id: I91a64e444ada0f1884fe807f9973348ba1a878ff Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Pass scope around as parameters inside the runtime.Erik Verbruggen2016-06-221-9/+9
| | | | | | | | | | | | | | | | The implementation of many (or all) runtime functions consist of first creating a QV4::Scope, which saves and restores the JS stack pointer. It also prevents tail-calls because of that restoring behavior. In many cases it suffices to do that at the entry-point of the runtime. The return value of a JS function call is now also stored in the scope. Previously, all return values were stored in a ScopedValue, got loaded on return, and immediately stored in another ScopedValue in the caller. This resulted in a lot of stores, where now there is only one store needed, and no extra ScopedValue for every function. Change-Id: I13d80fc0ce72c5702ef1536d41d12f710c5914fa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add QJSEngine::newQMetaObjectCorentin Jabot2016-06-054-0/+89
| | | | | | | | | | | | | QJSEngine::newQMetaObject let us expose QMetaObject to the QJSEngine, allowing to construct QObjects instance from javascript. Additionally, enums values are exposed as property of the QMetaObject wrapper. (The engine takes ownership of the created objects) Change-Id: I5428d4b7061cceacfa89f51e703dce3379b2c329 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-243-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4engine_p.h src/qml/jsruntime/qv4runtime_p.h src/qml/qml/qqmldelayedcallqueue.cpp src/qml/qml/qqmlvaluetypewrapper.cpp src/qml/qml/qqmlvmemetaobject.cpp src/qml/qml/v8/qv8engine_p.h tests/auto/quick/qquicktext/tst_qquicktext.cpp Change-Id: I3f0608c7beb88088cbbef4d0db59920f56deaea9
| * V4: allow inlining of ExecutionEngine::{qml,js}Engine()Erik Verbruggen2016-05-203-2/+2
| | | | | | | | | | | | | | | | All other changes are just to be able to include qv8engine_p.h in qv4engine_p.h Change-Id: I71ba2ec42cdc20d5c7d97a74b99b4d1ada1a5ed8 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-05-131-0/+8
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsapi/qjsengine.cpp src/qml/qml/qqmlengine_p.h src/quick/items/qquickanchors.cpp src/quick/items/qquickanimatedimage_p_p.h src/quick/items/qquickitem_p.h tests/auto/qml/qqmlecmascript/testtypes.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tests/benchmarks/qml/creation/tst_creation.cpp Change-Id: I65861e32f16e8a04c7090a90231627e1ebf6ba6f
| * Abort application if QJSEngine is constructed before QCoreApplicationMitch Curtis2016-04-281-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | QJSEngine requires a QCoreApplication instance in order to function correctly, and 57f7fe3e enforces this further. However, currently an application will simply crash because of accessing a non-existent QCoreApplication instance. This patch makes it clear to the user that they need to construct an instance first. Change-Id: Ieaef005ef03da250cc60457b4b1a4baa5db81215 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Introduce delegating constructors.Friedemann Kleint2016-05-061-3/+1
| | | | | | | | | | | | | | Reduce code duplication by chaining constructors. Change-Id: I8a0afd20ed13d4eb938536dcb05787ba2565a4cc Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Convert comparison methods to the new runtime syntaxLars Knoll2016-04-111-1/+1
|/ | | | | Change-Id: Iad4dadddefca2d6322d4f778272b75d64e1a746f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-03-071-1/+1
|\ | | | | | | Change-Id: Icfa1d61fcc286c3418d4a625de11d2191336fa60
| * Make public headers compile with -Wzero-as-null-pointer-constantMarc Mutz2016-03-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | ... or equivalent. QtBase 5.6 headers already compile that way, so let the other modules follow suit. Task-number: QTBUG-45291 Change-Id: Ied526fb2d7adc3a68946d6843a6bd6f475ebf864 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-199-126/+180
| | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: Ic36f1a0a1436fe6ac6eeca8c2375a79857e9cb12 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Support debugging and profiling for pure QJSEnginesUlf Hermann2015-12-152-0/+27
| | | | | | | | | | | | | | | | | | | | | | The engines will register themselves with the debug server whenever they are created without a private object. The assumption is that we get the latest possible registration like this. They try to deregister in all dtors, but they check if a different engine has done the same first. Change-Id: Ife7d7532d1de2e4a6ee21d9f7e673fcdfff2387b Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Remove dead fwd-dclFrank Meerkoetter2015-12-151-2/+0
| | | | | | | | | | Change-Id: Ifd9fe32b80cd1ebc8dc9fda7c252ecdaae42cb37 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Add missing nullptr checkFrank Meerkoetter2015-12-141-0/+3
|/ | | | | | | Fixes coverity CID85774. Change-Id: Id85c1c98254db3fb1934d166ce4ff3843f854251 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add missing "We mean it" comments to private headers.Friedemann Kleint2015-10-061-0/+11
| | | | | | Task-number: QTBUG-48594 Change-Id: Ifc207938de7f0c8995fc712df92665f222612647 Reviewed-by: Alan Alpert <aalpert@blackberry.com>
* Add extension API to QJSEngineMitch Curtis2015-09-252-15/+122
| | | | | | | | | | | | | | | | | | | | | | This allows users in a JavaScript-only environment to install extensions including: - Translation functions (qsTr(), etc.) - The console object (console.log(), print(), etc.) - Garbage collection functions (gc()) This deprecates installTranslatorFunctions(). This API results in less clutter in the API, as we'd otherwise need to have several functions for each type of extension. [ChangeLog][QJSEngine] Introduced an extension API that allows installing various function and object extensions (qsTr(), console.log(), etc.) to QJSEngine. [ChangeLog][QJSEngine] installTranslatorFunctions() was deprecated in favor of the new extension API (see installExtensions()). Change-Id: I4d6eb2097c3eda6810e967b2e8f6441c28c91a16 Task-number: QTBUG-40772 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Rename currentExecutionContext to currentContextLars Knoll2015-09-151-1/+1
| | | | | | | | Now that the other method is gone, let's use the shorter currentContext Change-Id: I2a6fb3b77f83a1ffdf314ad29081e303d17030ed Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup usage of ExecutionEngine::currentContextLars Knoll2015-09-151-3/+4
| | | | | Change-Id: Ic79d6da162375928ec25871cd0341daeab6483d2 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Doc: Fixed several link errorsNico Vertriest2015-09-071-1/+1
| | | | | | | Change-Id: I684b8c0d238b7592b49abc0156bbc9791fdf6991 Task-number: QTBUG-43810 Reviewed-by: Martin Smith <martin.smith@digia.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Simon Hausmann2015-09-021-0/+12
|\ | | | | | | Change-Id: Ibc7a47f7ce6d15dff79fdc59f8ded297d1b8d50d
| * Doc: broken links and missing doc for functionsNico Vertriest2015-09-021-0/+12
| | | | | | | | | | | | | | Task-number. QTBUG-43810 Change-Id: I14e03317d7470f33a899ba05b62b3d68fdb03734 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* | Hold a pointer to the QV4::ExecutionEngine in the property cacheLars Knoll2015-08-191-1/+1
| | | | | | | | | | | | | | This makes more sense than a pointer to the QQmlEngine. Change-Id: Ic6037b0df63b6cf1585539bc3ac78822f0e69d02 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Simplify QJSValueIterator code and make it GC safeLars Knoll2015-06-172-12/+10
| | | | | | | | | | Change-Id: Ie6e4c0d9b8a0b10bedfe32aa6344a2fa8a9a3eac Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Store rootcontext in a GC safe wayLars Knoll2015-06-171-2/+2
| | | | | | | | | | Change-Id: If81d638c0ccd2b34df918ae5055e309f4eae031f Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Get rid of StringValue usage in QJSValueIteratorLars Knoll2015-06-102-15/+12
| | | | | | | | | | Change-Id: I86badf9944b335041d16423be9a5434d1098cbb0 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Move the StringValue members of ExecutionEngine onto the JS stackLars Knoll2015-06-101-2/+2
| | | | | | | | | | Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | doc: Remove uses of \mainclassMartin Smith2015-06-072-2/+0
| | | | | | | | | | | | | | | | This qdoc command is deprecated. Change-Id: I4fd7ab301f1fa5b5b9b5db6a7d710ee2f147dfcb Task-number: QTBUG-46476 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* | Move more objects from the v4 engine to the js stackLars Knoll2015-04-241-1/+1
| | | | | | | | | | | | | | Convert most of the prototype objects in the v4 engine. Change-Id: I365f290493c20973bc991b6a383649836e42a16a Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Move exceptionValue and globalObject from the Engine onto the JS stackLars Knoll2015-04-242-3/+3
| | | | | | | | | | | | | | | | | | We'll need to move all GC'ed objects currently stored in ExecutionEngine onto the JS stack for easier management in a new garbage collection scheme. This is the start of that change. Change-Id: Ib3ad8e846875dade8a807ea79f063173d40e4aad Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Get rid of qv4value_inl_p.h and replace it by qv4typedvalue_p.hLars Knoll2015-04-242-2/+2
| | | | | | | | | | | | | | | | This is a cleaner separation and further reduces include dependencies in the definitions of our basic data structured. Change-Id: I18aa86cdea0c0dfbc16075d4d617af97e638811e Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-222-9/+21
|\| | | | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlbinding.cpp src/qml/jsruntime/qv4arraybuffer.cpp src/qml/jsruntime/qv4functionobject.cpp Change-Id: Ic752e9dfd69b282093651c9234c110a49762f06d
| * Doc: Expand on QJSEngine exception handlingSze Howe Koh2015-04-182-9/+21
| | | | | | | | | | | | | | | | | | | | | | - List the properties provided by the Error object. They consist of the standard properties and a subset of the Mozilla extensions. - Add QJSValue::property() usage to the example code. - Add cross-referencing. - Some rephrasing for clarity and conciseness. Change-Id: I1eb6943899fee2bd81851ccb03660a7a474a975d Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
* | Get rid of asFunctionObject()Lars Knoll2015-04-211-4/+4
| | | | | | | | | | Change-Id: Ib4858376dc0ec57fa473c80696abc66a570c90ec Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | More cleanupsLars Knoll2015-04-212-4/+4
| | | | | | | | | | | | | | | | Get rid of Value::asObject(), and pass const Managed pointers into some more vtable methods. Change-Id: Ia4f427d5fd8868f77b4015d1ce5424d32bfc2115 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Get rid of Value::asDateObject()Lars Knoll2015-04-161-2/+2
| | | | | | | | | | Change-Id: I71816a784b5175f600c5a870318b16c0d84c42fb Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* | Further cleanupsLars Knoll2015-04-161-3/+3
|/ | | | | | | | | The get and getIndexed vtable methods should take a const Managed pointer. Start cleaning up the asFoo() methods in Value and Managed by removing asArrayObject() and asErrorObject(). Change-Id: Ibd49bf20773ef84c15785b7ac37a7bc9fd4745d5 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* QtQml: Micro-optimize iterator loops.Friedemann Kleint2015-02-261-1/+3
| | | | | | | Avoid repeated instantiation of end() in loops, use variable instead. Change-Id: I3bb1c6918cfd16a5dcefbcc03c442e99fe9bf76b Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-129-63/+63
| | | | | | | | | 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: I61120571787870c0ed17066afb31779b1e6e30e9 Reviewed-by: Iikka Eklund <iikka.eklund@theqtcompany.com>
* CleanupsLars Knoll2015-01-233-11/+11
| | | | | | | | Remove duplicated methods. Remove some mostly unused methods, and simplify some others. Change-Id: I605b249e54417bb32c3dfc8e22f2c8b6b684a1e1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove all remaining usages of ValueRefLars Knoll2015-01-232-3/+3
| | | | | Change-Id: Icd76d3d03fac2e57530e55f8ec15b97109dcdcbc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of most uses of ValueRefLars Knoll2015-01-232-10/+10
| | | | | | | | | | | | Instead pass a const Value & into the functions With our new inheritance structure, we can get rid of ValueRef and instead simply pass a pointer to a Value again. Pointers to Values are safe to use again now, as they are now guaranteed to be in a place where the GC knows about them. Change-Id: I44c606fde764db3993b8128fd6fb781d3a298e53 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Rework QJSValue internalsLars Knoll2015-01-215-258/+341
| | | | | | | | | | | | | Use a flagged pointer to either store a pointer to a QV4::Value (from the persistent storage) or a pointer to a QVariant in QJSValue::d. Like this we don't need to malloc to create a QJSValue for most use cases. Significantly reduces the memory consumption of QJSValue and speeds it up a lot. Change-Id: I10902cc4b6cc3f43d3f816875dc6c4bbb6b4490f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add C++11 move operators, and a simpler internal constructorLars Knoll2015-01-214-18/+31
| | | | | | | | | Move semantics should optimize some copy operations on QJSValues, and the internal constructor will simplify refactoring the QJSValue class to get rid of the extra allocated private. Change-Id: I24863b30523af2432aa81ad6b87fda7fe35749c4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>