aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi/qjsvalue.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QtQml: Move QMetaObjectWrapper into separate header/impl filesUlf Hermann2024-04-281-0/+1
| | | | | | | | | We want to use it from QQmlTypeWrapper and avoid circular includes. Task-number: QTBUG-124662 Change-Id: I4c78a17eb262a303b7239bbdd853ec02d609c330 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix build with disable-deprecated-up-to configurationJari Helaakoski2024-04-111-0/+2
| | | | | Change-Id: I4b2d0e361a2e4fa14c89e1d374bd4244a4b9e0fd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Deprecate QJSValue::isVariantFabian Kosmale2024-03-211-0/+9
| | | | | | | | | | | It returns rather unexpected results, see updated documentation for details. Amends 8704c640946ac852668638e2980d3e2b78aa27ae Pick-to: 6.7 Change-Id: I439ae8dd218aa36fe63ac01953c34e5dff66470d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSEngine: Correctly detect QVariantFabian Kosmale2024-02-081-1/+7
| | | | | | | | | | | | With the introduction of QQmlVarForeign, a QVariant can now be represented as as either a QV4::VariantObject, or as a QQmlValueTypeWrapper wrapping a QVariant. Fix QJSEngine::isVariant to consider the new case, too. Pick-to: 6.7 Fixes: QTBUG-120008 Change-Id: I6aefa64c315b9ed1c7d1e214486f47556ef780fc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QJSValue: convert more aggressively to QVariantFabian Kosmale2023-12-191-2/+5
| | | | | | | | | | | | | | | | | | | | | | | Normally, we don't want to convert aggressively between JS objects and QVariant, as that is prone to losing information. However, QJSValue::toVariant is documented to attempt lossy conversions. Restore the behavior of Qt < 6.5.3 for it. This is done by replacing the boolean indicating we should wrap JS objects into QJSValue with an enum instead. That enum introduces a third state ("Aggressive"), which is only used for QJSValue::toVariant. All other users of QJSEngine::toVariant behave as before (post 6.5.3). Function objects are still not converted, as we know that this would be a futile attempt, and more importantly, to keep the behavior that existed before Qt 6.5.3. Amends 43077556550c6b17226a7d393ec844b605c9c678 which introduced the regression and afe96c4d633146df477012975824b8ab65034239 which fixed the issue only partially. Pick-to: 6.5 6.6 6.7 Fixes: QTBUG-119963 Change-Id: I07d9901437812579ac5b873a4dff4de60c8f617e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QJSValue: document that isUrl only returns true for JS URL objectsVolker Hilsheimer2023-12-181-1/+4
| | | | | | | | | | | | It does not return true for a QJSValue that carries a QVariant with a QUrl. However, on the C++ side the caller will want the URL value anyway as a QUrl, and in both cases, going through the QVariant works for that. Fixes: QTBUG-119794 Pick-to: 6.7 6.6 6.5 Change-Id: I90fd4a1a27d4dd4758b1060205ce2aeec730eb72 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Allow conversion of symbols to QVariantUlf Hermann2023-06-201-1/+2
| | | | | | | | | | | We produce their descriptiveString or simply a QVariant containing a QJSValue, depending on whether we're supposed to convert objects without equivalent C++ type or not. Pick-to: 6.6 6.5 6.2 Fixes: QTBUG-113854 Change-Id: I22b6038c936d860fdd8aa227f9dfe704e3265a77 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Change value encoding scheme to make space for larger pointersUlf Hermann2023-01-121-37/+64
| | | | | | | | | | | | | | | | | | On android and on some other platforms, the upper bits of a pointer are significant. We need to store them in our JS value encoding. Shift the bits around to make this happen. We now can store pointers of up to 57 bits. That's enough for everything we've seen so far. Fixes: QTBUG-101686 Fixes: QTBUG-91150 Pick-to: 6.5 Change-Id: I72e0fe63b27fca94840f82963e4d3936b3581b28 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* QmlCompiler: Fix wrapping of numbers in QJSPrimitiveValueUlf Hermann2022-12-151-14/+1
| | | | | | | | | | | | | | | | | | We need to explicitly cast to double if we are wrapping a number type that's not natively accepted by the ctors. As a side effect, correctly run conversions from generic QVariant to QJSPrimitiveValue through the engine now. For that we need another clause in metaTypeFromJS(). Since we are calling methods that return list types in the test, we need to add another clause that converts JS arrays to list types. Otherwise we cannot run that test in interpreted mode. Pick-to: 6.5 6.2 6.4 6.4.2 Task-number: QTBUG-109111 Change-Id: I87f7aafd24371d2c1ffe85569e1f2cd3a1979742 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc: add section to QJSValue about converting to JSONMitch Curtis2022-10-261-0/+10
| | | | | | | | | | This is especially useful if you already have serialization code that can perform strict checks on the data, rather than having to rewrite it to work with QJSValue. Pick-to: 6.2 6.4 Change-Id: I5b12aa9806e187586ac1b41995633a46621f76c9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that on() was replaced with a matcher that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* V4: Make ExecutionEngine::toVariant() staticUlf Hermann2022-09-201-2/+4
| | | | | | | | | Wherever we need an engine in there, we also have a managed value to get it from. This relieves us from the requirement to drag an engine around wherever we want to call toVariant(). Change-Id: Ib95d02b5fbf5eaa494214e337c9b700e97e5e0df Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Remove unused includes in qml, first partSemih Yavuz2022-09-141-1/+0
| | | | | | | | | | | | | | | Drop unnecessary includes detected by clangd-iwyu. Add new includes due to the transitive includes. Also, some of the includes were detected as unused even if they were actually in use. In those cases, use angular brackets instead of "" which deceives the tool not to complain. Affected subfolders: Debugger, Compiler, JsApi, JsRuntime, Memory, Parser Task-number: QTBUG-106473 Change-Id: I01d996a2a2ba31cbbc5f60f5454c8f850298f528 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* 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>
* QJSEngine: optimize isInterrupted handlingMarc Mutz2022-06-041-3/+3
| | | | | | | | | | | The isInterrupted flag is just that: a flag, so it doesn't require acquire/release semantics when loading/storing. Use relaxed loads and stores instead. Change-Id: I6d733a6bebcfc7f2b786265fc28f9ba7e25bb1c7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Support native transformation between UrlObject and QVariant/QUrlUlf Hermann2021-04-221-0/+10
| | | | | | | | | | | | | | URL has become a builtin type. We should support it on the same level as QString/String and QDateTime/Date. In order to continue support for comparing URL properties with the JavaScript equality operators, we still pass URLs as variants when using them in JavaScript. However, we now create proper URL objects for QJSValue and QJSManagedValue, and we allow transforming the URL-carrying variant objects back into QUrls. Change-Id: I78cb2d7d51ac720877217d2d4b4d0ab17cdd2a4b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QV4::Engine::toVariant: Use metatype instead of metatype idFabian Kosmale2021-03-251-1/+1
| | | | | | | | | | This way, we can avoid the costly id to metatype lookup in case where we actually need the full metatype. Task-number: QTBUG-88766 Change-Id: Ibe29b323007f00d2f8d1807fb9b64f9a8f87e807 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Clean up JSCallData setupUlf Hermann2021-03-171-8/+8
| | | | | | | | | | | | | | | | | We either have pre-populated arguments and thisObject, then we can just use them and keep them const. Or, we want to allocate and populate the arguments and the thisObject. Then, do allocate them in a separate object, and transform that into JSCallData afterwards if necessary. Furthermore, avoid alloc(0) as that just returns the current stack top. Writing to it will clobber other data. Rather, just use nullptr and crash if it's written to. Also, remove the useless operator-> from JSCallData. That one just confuses the reader. Change-Id: I8310911fcfe005b05a07b78fcb3791d991a0c2ce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace std::variant with tagged union in QJSPrimitiveValueUlf Hermann2021-03-121-1/+1
| | | | | | | | Pick-to: 6.1 Fixes: QTBUG-91717 Change-Id: Id19e08589206253b96c76bc40a799ccd95b0e0bf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QJSValue: Add a toPrimitive() methodUlf Hermann2020-12-191-0/+33
| | | | | | | We need a way to easily get a primitive from a QJSValue. Change-Id: I91a55d92ffa4ba6139b1e3f2e9308800b7047563 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add a QJSManagedValueUlf Hermann2020-12-181-0/+15
| | | | | | | | | | | | | A QJSManagedValue is a view on a QJSValue which always knows the engine the value belongs to. This allows us to implement the JavaScript semantics of the various QJSValue methods in a much more rigorous way. [ChangeLog][QtQml] The new QJSManagedValue should be used instead of QJSValue for manipulating properties and prototypes of JavaScript values, as well as for calling JavaScript functions. Change-Id: I9d445ffcf68dfa72dba9bae0818e83c80665ad66 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow JavaScript primitive type transformations inline in C++Ulf Hermann2020-12-181-0/+27
| | | | | | | | | | We don't want to call into the engine just for adding two numbers. This implements the most common operators on primitive JavaScript values. More are to follow in the future. Change-Id: Id51a5af59a3af9fec78a2d8f293e59e6567e9204 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSValue: Add toVariant() overload with conversion behaviorUlf Hermann2020-12-071-12/+42
| | | | | | | | | | | | The QJSValue to QVariant conversion is traditionally messy. The recent addition of a special case for FunctionObject did not make that better. Rather, we now add a way of specifying that the conversion should be lossless, which avoids all conversions of JS objects and arrays. Amends commit 6b08c24297f39f3c67bc5c16f46198b33af66529. Change-Id: I6d4506b52d3175ed2f2984f8a26d560cf6311ab6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QJSValue: On toVariant() don't try to unwrap function objectsUlf Hermann2020-11-261-2/+4
| | | | | | | | We cannot retrieve anything sensible from those. Therefore, just wrap the QJSValue into a variant. Change-Id: I8acd9fb59a8859c8b2c389efb7934b597a2e479f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* 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>