aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi/qjsvalue.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Doc: Fix minor typosSze Howe Koh2020-08-301-1/+1
| | | | | | Pick-to: 5.15 Change-Id: I4c51c40697e410d56b6a2d2446ed9f8ae218576d Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
* Fix QtQml after QMetaType/QVariant changes in Qt CoreLars Knoll2020-08-281-0/+65
| | | | | Change-Id: I2a983cf8188e88d80d3b7726208d821427eb8f3c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove deprecated function QJSValue::engineFabian Kosmale2020-08-261-19/+0
| | | | | | | | | [ChangeLog][QJSValue] The deprecated function QJSValue::engine() has been removed. Change-Id: I2be35379e0a9e51f5371a2c98b955282955b7147 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Adapt to qtbase changesFabian Kosmale2020-08-231-1/+1
| | | | | | | | | | | The internal QVariant constructor taking a QMetaTypeId has been removed. Thus, construct QMetaTypes where necessary from the id, or avoid a QMetaType -> ID -> QMetaType roundtrip where we already have a metatype. Also fix a few missing includse that were previously transitively included. Change-Id: I56ce92281d616108a4ff80fe5052b919d1282357 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Store a QV4::ReturnedValue in QJSValueUlf Hermann2020-03-181-310/+148
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Being careful, we can now save primitive values inline. We use the heap pointer of QV4::Value as either QString* or QV4::Value* for complex types. We cannot store persistent managed QV4::Value without the double indirection as those need to be allocated in a special place. The generic QVariant case is not supported anymore. The only place where it was actually needed were the stream operators for QJSValue. Those were fundamentally broken: * A managed QJSValue saved and loaded from a stream was converted to a QVariant-type QJSValue * QVariant-type QJSValues were not callable, could not be objects or arrays, or any of the special types. * Cyclic references were forcibly broken when saving to a data stream. In general the support for saving and loading of managed types to/from a data stream was so abysmally bad that we don't lose much by dropping it. [ChangeLog][QML][Important Behavior Changes] When saving a QJSValue to a QDataStream only primitive values or strings will be retained. Support for objects and arrays was incomplete and unreliable already before. It cannot work correctly as we don't necessarily have a JavaScript heap when loading a QJSValue from a stream. Therefore, we don't have a proper place to keep any managed values. Using QVariant to keep them instead is a bad idea because QVariant cannot represent everything a QJSValue can contain. Fixes: QTBUG-75174 Change-Id: I75697670639bca8d4b1668763d7020c4cf871bda Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSValue: Make call* const (Qt 6 TODO)Fabian Kosmale2020-03-131-3/+3
| | | | | Change-Id: I3a6c83ffc203bf27121f460ba23d31a39d1493ee Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace QVariant::type with QVariant::userTypeOlivier Goffart2020-01-171-6/+6
| | | | | | | | | | | as type is going to be deprecated. This change was done automatically with the help of clazy. In addition, ColumnRoleMetadata was changed to take an int instead of a QVariant::Type Change-Id: Ibc02d7b52e7d931a56c19fdebc4788b5e6df2a39 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port from implicit to explicit atomic operationsMarc Mutz2019-07-021-3/+3
| | | | | | | | | | | | The old code used the implicit conversions from QAtomicPointer<T> to T*, and QAtomicInteger<T> to T, and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixes some users of these APIs before we deprecate them. Change-Id: I892d705c22280f1c6fdc62c1777248b44e9c4329 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make JavaScript execution interruptibleUlf Hermann2019-04-301-0/+6
| | | | | | | | | | | Add an atomic isInterrupted flag to BaseEngine and check that in addition to the hasException flag on checkException(). Add some more exception checks to cover all possible infinite loops. Also, remove the writeBarrierActive member from QV4::EngineBase. It isn't used. Fixes: QTBUG-49080 Change-Id: I86b3114e3e61aff3e5eb9b020749a908ed801c2b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-04-101-1/+1
|\ | | | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlmetatype.cpp src/qml/types/qqmlmodelsmodule.cpp Change-Id: Idc63689ba98d83a455283674f4b5cf3014473605
| * Doc: Use the \nullptr macro instead of 0Venugopal Shivashankar2019-03-291-1/+1
| | | | | | | | | | | | | | | | This enables overriding the macro so that it translates to 'None' in the Qt for Python context. Change-Id: Ied1ddcb0f9e6e2299d9042e4cc4c2bb6d11a491b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | Remove unused includes of qv8engine_p.hUlf Hermann2019-04-091-1/+0
| | | | | | | | | | Change-Id: Ic135a863581d29a3afb9c6c7f070d2630b3913b4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | V4: Clean up the runtime functions declarationsErik Verbruggen2019-02-051-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | The declarations and usage of runtime functions have seen a number of changes: - we don't use the array of method pointers anymore because we don't use cross-platform AOT JITting - the check if a method can throw a JS exception was invalid, and was not used anymore - value-pointer vs. const-value-ref was inconsistent This patch cleans that up. By fixing the exception checking, we can now use it in the baseline JIT to automatically insert those checks. To make that work correctly, all runtime methods are in a struct, which gets annotated to indicate if that method throws. (The old way of checking which type of engine was used is fragile: some non-throwing methods do not take an engine parameter at all, and those got flagged as throwing). By using a struct, we can also get rid of a bunch of interesting macros. The flags in the struct (as mentioned above) can later be extended to capture more information, e.g. if a method will change the context. Change-Id: I1e0b9ba62a0bf538eb728b4378e2678136e29a64 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Documentation: Start using the \nullptr macroFriedemann Kleint2019-01-211-3/+3
| | | | | | Task-number: PYSIDE-903 Change-Id: I0c4640eb20157673eabb131e8834e79cbbf95d5c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Doc: Fix spelling of qjsvalue_cast()Ulf Hermann2018-11-201-1/+1
| | | | | Change-Id: Ic853e8c958b250d87a953942ea944f5d52d456a2 Reviewed-by: Rainer Keller <Rainer.Keller@qt.io>
* Clarify documentation about throwError and the specific error typesSimon Hausmann2018-10-311-6/+16
| | | | | | | | | | | | | Elaborate a bit on some specific types, suggest the use of the overload and omit some values that either exist only to complete the enum for API standard purposes (NoError) or exist only for porting purposes but are not relevant in use (EvalError). Change-Id: I4f9cf7a4605305642fc20570a90a16f2c29d8b98 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Richard Weickelt <richard@weickelt.de>
* Add convenience functions for creating and inspecting error objectsAllan Sandfeld Jensen2018-10-301-1/+52
| | | | | | | | | Serves to simplify porting from QtScript by replacing QScriptContext::Error and QScriptContext::throwError(). Change-Id: I4bfe404c358c50aaf3b5469a4304fec97552bf24 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-2/+2
| | | | | | | | | | | | Get rid of Primitive and move the corresponding methods directly into Value. Mark many methods in Value as constexpr and turn Value into a POD type again. Keep Primitive as a pure alias to Value for source compatibility of other modules that might be using it. Change-Id: Icb47458947dd3482c8852e95782123ea4346f5ec Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Clean up the property key API in StringOrSymbolLars Knoll2018-07-021-16/+4
| | | | | | | | | | | | | | Get rid of makeIdentifier(), as toPropertyKey() will take care of it. Rename identifier() to propertyKey() and check that the key is valid. Remove String/StringOrSymbol::asArrayIndex(), we don't need it anymore. Change-Id: I3c490fabc1475c9ea288b49b1638b6fa1bc237b7 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-1/+1
| | | | | | | | Change all uses of Identifier to use the new PropertyKey class and get rid of Identifier. Change-Id: Ib7e83b06a3c923235e145b6e083fe980dc240452 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify the get and getIndexed vtable functions of QV4::ObjectLars Knoll2018-07-021-1/+1
| | | | | | | | This finalizes the refactoring of Object's vtable API. Also added the receiver argument to the method as required by the ES7 spec. Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify put and putIndexedLars Knoll2018-07-021-4/+2
| | | | | | | | | | Pass an Identifier through those virtual methods to unify the string and integer based versions. Also add the receiver that's required in ES7 Change-Id: I4e7f01b4c97cc80bcb3c485f6343f28213dc9e6b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify deleteProperty and deleteIndexedProperty vtable methodsLars Knoll2018-06-261-1/+1
| | | | | Change-Id: I25245818c6ff2104642594476cb9684bac824f29 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add Proxy support for prototype handlingLars Knoll2018-06-251-3/+3
| | | | | | | | | | | | | | Cleanup get/setPrototypeOf and fix some smaller incompatibilities in the default implementation for Object. Add the methods to the vtable and reimplement them according to spec for ProxyObjects. Clean up the Object.prototype.get/setPrototypeOf/__proto__ methods and fix a smaller bug in the Reflect API for those methods. Change-Id: I6e438753332ec4db963d6cdcf86f340ff212777a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add virtual interface for hasPropertyLars Knoll2018-06-251-2/+2
| | | | | | | This is required to correctly support Proxy Change-Id: I95ec17e919915290a05ad9501cd649452ab82135 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement a virtual interface for getOwnPropertyLars Knoll2018-06-251-1/+1
| | | | | | | | | | | | This is required to support Proxy properly, and at the same time fixes a couple of test failures. The new interface also replaces the old query and queryIndexed virtual interfaces, as those where doing a subset of what getOwnProperty does. Change-Id: I750e366b475ce971d6d9edf35fa17b7a2b07f771 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix JIT build on INTEGRITY ARM64Kimmo Ollila2018-04-261-4/+4
| | | | | | | | | | | -typedef "Jump" may not be used in an elaborated type specifier -explicit specialization of function must precede its first use -"Value" is ambiguous Change-Id: Ic15c196f1b33211cd3f2f25a54ba478747336fe4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Nikola Velinov <nvelinov@ghs.com>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-9/+9
| | | | | | | | | | | | | From now on we prefer nullptr instead of 0 to clarify cases where we are assigning or testing a pointer rather than a numeric zero. Also, replaced cases where 0 was passed as Qt::KeyboardModifiers with Qt::NoModifier (clang-tidy replaced them with nullptr, which waas wrong, so it was just as well to make the tests more readable rather than to revert those lines). Change-Id: I4735d35e4d9f42db5216862ce091429eadc6e65d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.11Liang Qi2018-02-181-5/+81
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp Change-Id: I7feb9772fc35066f56b7c073482b53ca8c86c70b
| * Document how to work with arrays using QJSValueMitch Curtis2018-02-081-5/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Mention (in the detailed description) that Array is indeed supported. - Provide examples for getting and setting individual array elements, and how to read the length of the array. - Properly document the property() and setProperty() overloads that take an index. - Link to the overloads where it makes sense. These changes make the intended workflow for using arrays much more obvious. Change-Id: I4657a7b1e2b4c2977120ee8e345ee9ae7d2bbc2d Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
* | doc: Fix qdoc warnings for templates and staticsMartin Smith2018-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | Several \fn commands needed template parameters added, and several static functions that were not accessible were documented but should not have been documented. The template texts were added and the qdoc comments of the static functions were changed to non-qdoc comments. Change-Id: Icc44e243fbec2023865f47b7c73dc15d241d5b4d Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
* | Merge remote-tracking branch 'origin/dev' into new-backendLars Knoll2017-11-081-0/+7
|\ \ | | | | | | | | | Change-Id: I1a49b4a242ed0764101521d06ec612e96bff0e4c
| * | Doc: add documentation for QJSValueListSamuel Gaist2017-09-301-0/+7
| |/ | | | | | | | | | | | | This patch adds the missing documentation of the QJSValueList typedef. Change-Id: I8eafbc8a4a5d2fa965595085a3dc240997b13292 Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
* | Further cleanup JSCallDataLars Knoll2017-11-071-2/+2
| | | | | | | | | | | | | | Avoid allocations on the JS stack if possible Change-Id: I344cd6dceb6264314f9d22c94db22b22d1d24d14 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Simplify JSCallData constructionLars Knoll2017-11-071-3/+3
| | | | | | | | | | Change-Id: Ic53532edae9a209aa7125af6f00a9d993d74f1a3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Get rid of JSCallData::call()Lars Knoll2017-11-071-8/+8
| | | | | | | | | | Change-Id: I6b99e9a7102b3dcb6a7699f54b6456eba6248699 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Get rid of JSCallData::callAsConstructor()Lars Knoll2017-11-071-3/+3
| | | | | | | | | | Change-Id: I7c7a69791e98ba0ce82b4d23785fc12a510c449e Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Rename JSCall to JSCallDataLars Knoll2017-11-071-3/+3
| | | | | | | | | | | | | | | | As, this is going to change in a simple stack based structure to keep pointers to the data to pass to calls. Change-Id: Ia9aa3f81ee3eeba36affd16aac7b2fe97d59aea9 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | Always set the correct FunctionObject when calling JS functionsLars Knoll2017-09-021-11/+11
| | | | | | | | | | | | | | | | | | Renamed ScopedCallData to JSCall, enforced passing a JS FunctionObject to it, and added call() and callAsConstructor() methods to it. Change-Id: I30db65c9765c2896b5909fe2105c0934c6dad861 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Move ScopedCallData and ScopedStackFrame into a separate fileLars Knoll2017-09-011-3/+3
| | | | | | | | | | Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Don't throw exceptions in Object::delete(indexed) anymoreLars Knoll2017-08-101-4/+1
| | | | | | | | | | Change-Id: I8613ab21eb1435903e2a8514c21fe51f4a305a2f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Change function signatures for call/construct backLars Knoll2017-08-041-9/+9
|/ | | | | | | | Change those back again to return a value. This will be required to avoid creation of Scope objects between JS function calls. Change-Id: I05cb5cf8fd0c13dcefa60d213ccd5983fab57ea3 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* 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>
* 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>
* QJSValue: Adapt to introduction of QMetaType::NullptrChristian Kandeler2016-08-081-4/+7
| | | | | | | | | [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-051-0/+36
| | | | | | | | | | | | | 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-241-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | 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