aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi/qjsvalueiterator.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie GĂ©rard2022-06-111-38/+2
| | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Store a QV4::ReturnedValue in QJSValueUlf Hermann2020-03-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Fix ownKey iteration over Proxy objectsLars Knoll2018-09-091-1/+1
| | | | | Change-Id: I045a4844c06df9232cc8b04485ab0a39bb990e3f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement support for ownKeys in Proxy objectsLars Knoll2018-08-041-2/+2
| | | | | Change-Id: I7edee88e4252e6ed0d2666c3f633bb595cb0e831 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce a new mechanism to iterate over object propertiesLars Knoll2018-08-021-74/+58
| | | | | | | | | | | | | | | | | The old advanceIterator schema was extremely ugly and in addition not flexible enough to support the requirements for Proxy.ownKeys and some of the methods in Object Implemented a new scheme through a OwnPropertyKeys method in the Object VTable that creates and returns an iterator object. Ported QJSValueIterator and for-in to use the new mechanism. There's still many places where we use the old ObjectIterator (that relies on advanceIterator). Those will be ported in subsequent commits. Change-Id: I091a9bea9ff6b2b63630cc336814700757a718be 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>
* Rename ForeachIterator to ForInIteratorLars Knoll2018-05-041-5/+5
| | | | | | | | | As it's being used for for(... in ...) loops. Also add a ES6 compatible iterator interface to it, so that we can unify the handling of for-in and for-of. Change-Id: I264f88ed049484945f5ea7e8bdf0227187456ba2 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>
* Updated license headersJani Heikkinen2016-01-191-14/+20
| | | | | | | | | | | 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>
* Simplify QJSValueIterator code and make it GC safeLars Knoll2015-06-171-6/+10
| | | | | Change-Id: Ie6e4c0d9b8a0b10bedfe32aa6344a2fa8a9a3eac Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Get rid of StringValue usage in QJSValueIteratorLars Knoll2015-06-101-13/+10
| | | | | Change-Id: I86badf9944b335041d16423be9a5434d1098cbb0 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>
* CleanupsLars Knoll2015-01-231-1/+1
| | | | | | | | Remove duplicated methods. Remove some mostly unused methods, and simplify some others. Change-Id: I605b249e54417bb32c3dfc8e22f2c8b6b684a1e1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.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-9/+7
| | | | | | | | | | | | | 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-211-1/+1
| | | | | | | | | 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>
* Refactor persistent valuesLars Knoll2015-01-161-8/+11
| | | | | | | | | | 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-3/+3
| | | | | | | This prepares things for a rewrite of the internals of Persistent. Change-Id: Ib93ec5911984d1bfce87ffdc3f86bc75f6ecafe9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Make Property uses GC safeLars Knoll2014-12-201-1/+1
| | | | | Change-Id: I5aa41a07a2d25e5c8a2d64bfa58a55fcd7aaf77e Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix the way we set the property name during iterationLars Knoll2014-12-201-6/+6
| | | | | | | This was broken due to the new inheritance scheme for Managed Change-Id: Ia9df50e7e655c3a812a01a2c78945e648aa444dc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup exception catching codeLars Knoll2014-11-151-2/+1
| | | | | Change-Id: I85afd5758f72e19c280dc196601ee145f0c25f01 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup header file dependenciesLars Knoll2014-11-041-2/+3
| | | | | Change-Id: Ibb4658576a98b53de2eac2474ce4d5b9eb83b6ae 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>
* Get rid of StringRefLars Knoll2014-07-221-3/+9
| | | | | | | | 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 ObjectIterator to new storage schemeLars Knoll2014-07-221-5/+5
| | | | | Change-Id: I35631089e6791349ade08c6ed063f1e8ab1bdaea Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Convert ObjectIterator to new data layoutLars Knoll2014-07-221-5/+5
| | | | | Change-Id: Icda43ec9c1e324afebcf632a5fdcc40d855b193d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix regression in QJSValueIterator::next() since Qt 5.1.1Gunnar Sletta2014-05-141-6/+3
| | | | | | | | Iteration on the form "while (next) { .. }" would skip the last element. Change-Id: I50692a5a75e23e423e82b7a39e1892f505e4c612 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix copying of Property'sLars Knoll2014-03-101-1/+1
| | | | | | | | | | Data properties don't contain valid data in the set field if they are being stored in Objects. Thus we should never access that field unless we are dealing with accessor properties. Change-Id: I19dcbaee7ebd042ae24387f92a93571d75ca578a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove Property * return value from ObjectIteratorLars Knoll2014-01-201-17/+10
| | | | | | | | The added side effect is that the QJSValueIterator is now somewhat faster. Change-Id: I01ba9f2a72a34224f5691130df69a91ab75b72e6 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Encapsulate the current context and fix it's usageLars Knoll2013-12-041-3/+3
| | | | | | | | | | | Encapsulate accesses to the current context, and rework the way we push and pop this context from the context stack. Largely a cleanup, but simplifies the code in the long term Change-Id: I409e378490d0ab027be6a4c01a4031b2ea35c51d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Correctly catch exceptions in the API methodsLars Knoll2013-10-291-12/+11
| | | | | | | | Replace all C++ try/catch statements with engine->hasException checks. Change-Id: I7c04e02664ec6b4d256478c6e18f6b20ae4f7bc1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Cleanup exception handlingSimon Hausmann2013-10-031-1/+0
| | | | | | | | | | The code in the Exception class operates entirely on the engine's data, so move it into ExecutionEngine instead. This eliminates the need for a QV4::Exception class and catches and old code that tries to still do catch (Exception &) instead of catch (...) Change-Id: Ie608bec6af652038aca6c9423c225a4d7eb13b39 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change exception handling APISimon Hausmann2013-10-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the exception handling API in the engine slightly, encapsulating any use of direct throw statements and catch blocks with concrete types. In the future we need to be able to change the way these are implemented, in order to ensure that the correct stack unwinding code is triggered for throw and re-throw. This patch separates the C++ exception object thrown from the V4 exception (that includes value, throwing context pointer) and stores the latter inside the engine. In order for that to compile, ExecutionEngine::StackTrace and StackFrame had to move into the QV4 namespace directly. In addition the syntax for catching exceptions changes from try { ... } catch (QV4::Exception &ex) { ex.accept(context); QV4::ScopedValue exceptionValue(scope, ex.value()); } to try { ... } catch (...) { QV4::ScopedValue exception(scope, context->catchException()); } Context::catchException() checks if there's a "current" exception in the engine, and if not assumes that we caught an unrelated exception and consequently re-throws. partiallyUnwind() is also gone and replaced with rethrowException(), in order to encapsulate the re-throw. Lastly, in the future nesting try/catch blocks isn't going to be possible due to limitations in the common C++ ABI with regards to foreign exceptions. Change-Id: Ic81c75b057a2147e3176d8e0b4d326c14278b47d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix ObjectIterator API to be GC safeLars Knoll2013-10-021-13/+52
| | | | | Change-Id: I3a9c48d53d8dbadcb9b32c00fcef1f89447c4b8c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use a StringRef for Managed::get()Lars Knoll2013-09-221-4/+6
| | | | | | | | | also store "toString" and "valueOf" as identifiers in the engine and fix two places where we compared strings the wrong way. Change-Id: I70612221e72d43ed0e3c496e4209681bf254cded Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use ReturnedValue for Managed::get().Lars Knoll2013-09-181-1/+3
| | | | | Change-Id: Ia8f35d227b69d32e1f6a041283abbbd083aa34ca Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Fix wrong return typeAlex Blasche2013-09-171-1/+1
| | | | | | | | | | | | | | Android g++4.8 errors out with jsapi/qjsvalueiterator.cpp: In member function 'QString QJSValueIterator::name() const': jsapi/qjsvalueiterator.cpp:155:16: error: converting 'false' to pointer type for argument 1 of 'QString::QString(const char*)' [-Werror=conversion-null] return false; Change-Id: I589418e34c7e1ae72f2bf547067ea8e5944119b8 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Move the JS Api into it's own folderLars Knoll2013-08-081-0/+206
Change-Id: I7ef371ff929387097862121b73a7a5863b51ccf1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>