aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v8/qv8engine.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QtDeclarative fixes and workarounds for NaClwip/naclMorten Johan Sørvig2016-05-131-0/+3
| | | | | | | | | | | Make QtDeclarative run on Native Client. Some of these should be looked at more closely at a later point in time, but will do as workarounds from now. Change-Id: Ifddcb45b190c3a80c6137772a05ababb5466ea22 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Add extension API to QJSEngineMitch Curtis2015-09-251-1/+4
| | | | | | | | | | | | | | | | | | | | | | 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>
* Speed up QQmlEngine constructorLars Knoll2015-09-251-28/+34
| | | | | | | | | | | | | | | | Freezing the global object using a script is pretty slow, esp. given that the script needs to be compiled as well. Rather do it programmatically. The old code actually had a bug that would only cause the global object to be frozen, not it's children. The new code fixes this, but doesn't completely freeze the objects. Instead it makes all the existing properties of the global object and it's children readonly, but still allows extending existing objects with new properties. Change-Id: I0d7331cdc89a0ac717b8ed3b1a490b2a3742de02 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Cleanup retrieval of scope and context objectsLars Knoll2015-06-181-5/+0
| | | | | Change-Id: I9c6174181f950bc4f829727dc6acdfe82fa4e894 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Move exceptionValue and globalObject from the Engine onto the JS stackLars Knoll2015-04-241-9/+7
| | | | | | | | | 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-241-1/+1
| | | | | | | | 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>
* Update copyright headersJani Heikkinen2015-02-121-7/+7
| | | | | | | | | 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>
* Get rid of most uses of ValueRefLars Knoll2015-01-231-1/+1
| | | | | | | | | | | | 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-211-7/+5
| | | | | | | | | | | | | 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>
* Refactor persistent valuesLars Knoll2015-01-161-3/+6
| | | | | | | | | | Use a page wise allocation mechanism for persistent values. This significantly reduces memory consumption of persistent values and also improves their performance a lot. Change-Id: I8499d2ca5bdd871e029f643ae605a94544558bb5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make sure we always have an engine when assigning to a PersistentLars Knoll2015-01-131-1/+1
| | | | | | | This prepares things for a rewrite of the internals of Persistent. Change-Id: Ib93ec5911984d1bfce87ffdc3f86bc75f6ecafe9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move the variant conversion methods from qv8engine to qv4::ExecutionEngineLars Knoll2015-01-091-673/+0
| | | | | Change-Id: Ibd529ae5cc3ba06f46152e9daa9119a4e7a2561c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make the remaining variant conversion methods staticLars Knoll2015-01-091-25/+25
| | | | | | | And make most private as well Change-Id: If215aba4985a5150aa5a901f2e50e31bf0afa709 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove most v8engine references in xhrLars Knoll2015-01-081-2/+2
| | | | | Change-Id: Ibbb38d57782f8566502852a2cb3cfd4a28f9dfc3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove v8engine dependency from qqmllocaleLars Knoll2015-01-081-1/+1
| | | | | Change-Id: Ib6f51915c5a049592c2958624017eb2f8ad962d8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of QV8Engine::toStringLars Knoll2015-01-081-5/+0
| | | | | Change-Id: Ib51fa09ae251c1b7b8878ecdf920016f8fcc0067 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use QV4::ScopedObject typedef instead of actual typeOleg Shparber2015-01-031-1/+1
| | | | | Change-Id: I0b68c534ea513a7c230b12114f6b42b069f9864b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use QV4::ScopedArrayObject typedef instead of actual typeOleg Shparber2015-01-031-3/+3
| | | | | Change-Id: I975536745ac6c264aca074f84d223fbec7682d3d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use QV4::ScopedFunctionObject typedef instead of actual typeOleg Shparber2015-01-021-1/+1
| | | | | Change-Id: I6b4effaa5bef992b4ae9402eea7fe655bc7b18f0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove v8engine dependency in fromVariant conversionsLars Knoll2015-01-021-32/+30
| | | | | Change-Id: I3427129dc7a0e68c8fa0b61f353835e2bee179a0 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove v8engine dependency in toVariant conversionsLars Knoll2015-01-021-21/+21
| | | | | Change-Id: I0f2f77c9cc268a0c5ca3ffe0cd66fc98bb1964b3 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Enable gadget wrapping for custom value typesSimon Hausmann2015-01-021-3/+15
| | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] Custom C++ value types annotated with Q_GADGET are now fully accessible in the QML and QJSEngine JavaScript environment. QJSEngine::toScriptValue can be used for injection and fromScriptValue to extraction. The QML "built-in" gadget wrappers for QPoint and the gui types are not exposed this way, toScriptValue(point) will still return an opaque QVariant wrapper. We could expose the core types right away, but then we would be lacking an API to enable use of the Gui types that are registered in QtQuick. It would be better to make the core types in qtbase gadgets and thus enable them without the need for hooks and init functions to be called by the user. Task-number: QTBUG-29769 Change-Id: I8179cd599bdc1209ff61cfdbdda419cb400296bb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Don't store a v8engine pointer in qqmllistwrapperLars Knoll2015-01-011-1/+1
| | | | | Change-Id: I21b055deb74aafff8b2ee1cdce776e06f154dcaa Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Further value type wrapper cleanupsSimon Hausmann2014-12-231-2/+2
| | | | | | | Removed the QV8Engine * member in QQmlValueTypeWrapper. Change-Id: I37cc131a3ff0279240b227c11a6b74bfc7bf4960 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Fix value type wrapper class nameSimon Hausmann2014-12-231-3/+3
| | | | | | | | It's supposed to be QQmlFoo instead of QmlFoo. While all this code is being touched, we might as well fix the name. Change-Id: Ia8be0c6ec46e114f7559c1e7a07a9d368932999e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Initial work on gadget supportSimon Hausmann2014-12-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | Changed built-in QtQml value types to use gadgets. This is in preparation for supporting external gadgets. This replaces the mostly direct inheritance of the concrete value types with gadgets and "dynamic" inheritance through QQmlValueType being generic. Over time as some of the value types may become gadgets, we can remove the ones here. It's important that these "separate" gadgets have the same memory layout as the actual types (QPointF, etc.). Also while QQmlValueType remains practically a singleton, it's not required anymore to be one. Consequently the JS wrappers for value types keep their own instance of QQmlValueType. This allows eliminating the qobject_cast in various places that dealt with the singleton nature. This comes at a cost, making the JS wrappers slightly heavier. However that is meant to be a temporary situation and finally the value type wrapper should merely store the meta-object in addition to the data and the type. Change-Id: I15071ded0a1e54203f29ec1ecf7a9ab646d1168e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Use pointers to Heap object to avoid recursionLars Knoll2014-12-201-3/+3
| | | | | Change-Id: If491b35ba43758bd4792166f7213cd5a11d227d9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove most of the places where getPointer() is usedLars Knoll2014-12-201-2/+2
| | | | | | | This is no longer required, and simply uglifies the code Change-Id: Iba91a1d7735ebe23a43437f137a488423b6eb743 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix build: include <qdatastream.h> before using QDataStreamThiago Macieira2014-12-191-0/+1
| | | | | Change-Id: I623b9089f3d42bd2fe2a4c9e9119953dc3bfa1dc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Return Heap::ExecutionContext for currentContext()Lars Knoll2014-12-191-2/+2
| | | | | Change-Id: I155ab996e24d7f36761d2ea62a04774e16469b34 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Better encapsulate access to the global objectLars Knoll2014-12-111-7/+7
| | | | | Change-Id: I8a76112d821cb3fc172ba0d16ee8410d39b4422a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make QV4::RegExpObject header independent from masm headersOleg Shparber2014-11-211-2/+2
| | | | | | | | | | | Also remove pointless uint32_t for uint values and replace a few inconsistent uint16_t uses with quint16. MSVC was using uintN_t defined in masm headers instead of cstdint, so this change eliminates such situation. Change-Id: Ibd7dd50fc047dcdc78e057299883311a24dd3960 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Changed InternalClass to store Identifier* instead of String*Simon Hausmann2014-11-211-1/+1
| | | | | | | | | All members are identifiers anyway, so this gets rid of a ### and also simplifies some of the call sites by removing the need for a scoped string. Change-Id: Ic6b550cdb97afa5a4b0fa7e9b13e7768ed3f6bd8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Ported ExecutionEngine::newString and newIdentifier to Heap::StringSimon Hausmann2014-11-121-1/+1
| | | | | | | | | | Avoid the use of Returned<String> for newString and changed the identifier table to use Heap::String. This required moving some code back into Heap::String, but that's code that doesn't call back into the GC, so allocations and therefore future object moves aren't possible. Change-Id: I1dca3e9c12a9c56f09419af8cc8cba39fe04f720 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move data of more Qml related objects into Heap namespace.Lars Knoll2014-11-101-1/+1
| | | | | Change-Id: Ifb3a7093351474d6feb2f64498b531c36fdf669b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup: Remove duplicated codeSimon Hausmann2014-11-031-16/+1
| | | | | | | | arrayFromStringList is identical to ExecutionEngine's newArrayObject overload that takes a QStringList Change-Id: I17fed4703d0d6647d6ca44a0069834ce0da8d22c Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix compiler warnings in qv8engine.cpp.Friedemann Kleint2014-09-191-1/+5
| | | | | | | | qml\v8\qv8engine.cpp(91) : warning C4805: '|' : unsafe mix of type 'bool' and type 'int' in operation Task-number: QTBUG-40431 Change-Id: Ibdc96907aaab132956c87dd6aec2eab2f3bf0e9f Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix mapping of JS objects/arrays to C++Simon Hausmann2014-09-171-175/+124
| | | | | | | | | | | | | | | [ChangeLog][QtQml][Important Behavior Changes] When a JavaScript object/array is passed to C++ through a QVariant, the engine no longer immediately converts the object recursively into a QVariantMap or QVariantList but instead stores a QJSValue in the QVariant. This prevents a loss of data when the JS object contains non-primitive types such as function objects for example. Code that expects the variant type to be exactly QVariant::Map or QVariant::List may need to be adapted. Registered conversion functions however ensure that code that merely calls toMap() or toList() continues to work. Task-number: QTBUG-40431 Change-Id: I1dbc1d5f8e78ad28bb62db3681b9a0b34557e7f5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix roundtrip conversion between JS var and QVariantLars Knoll2014-09-111-1/+7
| | | | | | | | | | | | | | Always convert null to a QVariant(VoidStar) as documented in QJSValue. Make sure the reverse conversion will lead back to a null JS value. Adjusted two test cases that expected an invalid QVariant when setting the property to null, and added test cases for the correct conversion. Task-number: QTBUG-40880 Change-Id: I6eb01f0067f2c89779c53fd2cd0a1193047ed2cc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* Remove unused methodLars Knoll2014-07-221-5/+0
| | | | | Change-Id: I3830de8c4f01cc7340ab37673024ceea93585a9e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of all uses of ObjectRefLars Knoll2014-07-221-3/+2
| | | | | Change-Id: I705e2362dcda542f56826dadec6b0a6f15848788 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove the less often used Ref classesLars Knoll2014-07-221-2/+1
| | | | | Change-Id: I9ee531c903317a0f324671d98af1f967b684915c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Get rid of StringRefLars Knoll2014-07-221-3/+3
| | | | | | | | Remove the Ref classes, as they won't be required anymore once Managed and Managed::Data are separated. Change-Id: Ic6bec2d5b4ecf2595ce129dbb45bbf6a385138a5 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert ExecutionContext to new storage schemeLars Knoll2014-07-221-2/+2
| | | | | Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert qml locale object to new data layoutLars Knoll2014-07-221-1/+1
| | | | | Change-Id: I1c02498102d89be1127fb6bbf0b38e21c48bed8b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move VariantObject over to new storage layoutLars Knoll2014-07-221-5/+5
| | | | | Change-Id: I96a4ce5d3a3e4fdd29ba0aac1bd3361588457580 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move object data into internal structureLars Knoll2014-07-221-1/+1
| | | | | Change-Id: I1fcccd535ed356e736468337bd450270cd290044 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Move Managed data into it's own subclassLars Knoll2014-07-221-8/+8
| | | | | | | | | This prepares for moving over to a d pointer scheme, where Managed subclasses don't hold any data directly. This is required to be able to move over to a modern GC. Change-Id: I3f59633ac07a7da461bd2d4f0f9f3a8e3b0baf02 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix crash in conversion from QVariantMap to QJSValueSimon Hausmann2014-03-281-1/+5
| | | | | | | | | | When the key is an array index, use arraySet instead of trying to insert an array index as internal class member. Task-number: QTBUG-37854 Change-Id: I23f01cc9d6be98b57d3f13ac7ee847298e9632a3 Reviewed-by: Matt Broadstone <mbroadst@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>