aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlvaluetypewrapper.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename QQmlQPointer to QV4QPointerUlf Hermann2020-09-211-2/+2
| | | | | | | You can wrap QObject pointers in plain JavaScript. Change-Id: I246a72a7d5d7b2562e722bf9eafc7880b772a806 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Avoid various warnings about deprected QMetaType methodsUlf Hermann2020-09-161-5/+5
| | | | | Change-Id: I8f4b2703fdd08ff341904219cec33c321e0511c7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Adapt to qtbase changesFabian Kosmale2020-08-231-2/+2
| | | | | | | | | | | 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>
* Weak compare for value types in QMLFawzi Mohamed2020-08-201-1/+47
| | | | | | | | | | | | QPoint, QPointF, QRect, QRectF,... are basically equivalent in QML JS where int and double are stored as double, but QVariant now has a stricter equality comparison, which breaks code. Make QQmlValueTypeWrapper::isEqual perform the weaker comparison. This fixes a regression in tst_qqmlvaluetypes and tst_qqmlvaluetypeproviders which blocked CI. Change-Id: I0fe1cab17092190ff6cf2a01310943d72d932073 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix tst_qqmlvaluetypes::toStringConversionFawzi Mohamed2020-08-061-8/+2
| | | | | | | Fixes crash observed in I50bd32557c55dddcb197f163609fd7d5a1b2301b Change-Id: I93f580dbdf5f6d4fe0ad87f4a8a4080421872e4a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix QQmlValueTypeWrapper::method_toString()Ulf Hermann2020-07-091-3/+4
| | | | | | | | | | | QMetaType::convert() is notoriously hard to use. You cannot keep the QString on the stack as QString because its dtor will unconditionally be called when the scope is left, no matter if the conversion succeeded. Therefore, keep an array of quint8 on the stack and manually call the dtor if the conversion succeeds. Change-Id: If7970ff6adb4cc2a822a065f9f07130065ce9502 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-241-4/+4
|\ | | | | | | Change-Id: I9f0d5adf1ba7d3246b1107a20d145e7aac2c7a77
| * QQmlValueTypeWrapper: Avoid compile warningsUlf Hermann2020-03-231-4/+4
| | | | | | | | | | | | | | | | The type names are expected to be UTF-8 and we don't need to keep temporary meta types. Change-Id: I676d04d8733ef0ea3e159038d4973753350572bf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Encapsulate QQmlContextDataUlf Hermann2020-03-231-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This class is not a private detail of QQmlContext. And it is incredibly hard to see who owns what in there. Let's add some civilization ... We enforce refcounting for QQmlContextData across the code base, with two exceptions: 1. QQmlContextPrivate may or may not own its QQmlContextData. 2. We may request a QQmlContextData owned by its parent QQmlContextData. For these two cases we keep flags in QQmlContextData and when the respective field (m_parent or m_publicContext) is reset, we release() once. Furthermore, QQmlContextData and QQmlGuardedContextData are moved to their own files, in order to de-spaghettify qqmlcontext_p.h and qqmlcontext.cpp. When the QQmlEngine is deleted, any QQmlComponents drop their object creators now, in order to release any context data held by those. Before, the context data would be deleted, but the object creators would retain the dangling pointer. [ChangeLog][QML][Important Behavior Changes] QQmlContext::baseUrl() does what the documentation says now: It prefers explicitly set baseUrls over compilation unit URLs. Only if no baseUrl is set, the CU's URL is returned. It used to prefer the CU's URL. Change-Id: Ieeb5dcb07b45d891526191321386d5443b8f5738 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Check that value type exists before creating wrapperFabian Kosmale2020-03-121-2/+12
| | | | | | Fixes: QTBUG-82843 Change-Id: I1ea4a52b33e7d318525e63346eab46ecf7a8fec0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Replace QVariant::type with QVariant::userTypeOlivier Goffart2020-01-171-1/+1
| | | | | | | | | | | 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>
* Refactor QQmlValueTypeWrapper and assert on some null pointersUlf Hermann2019-09-101-43/+43
| | | | | Change-Id: I8314f2a675211fba08b71e74eacc38076c82b1ed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused includes of qv8engine_p.hUlf Hermann2019-04-091-1/+1
| | | | | Change-Id: Ic135a863581d29a3afb9c6c7f070d2630b3913b4 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-03-211-37/+114
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmltypecompiler.cpp src/qml/compiler/qv4bytecodehandler.cpp src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4compiler.cpp src/qml/compiler/qv4instr_moth.cpp src/qml/compiler/qv4instr_moth_p.h src/qml/jit/qv4baselinejit.cpp src/qml/jit/qv4baselinejit_p.h src/qml/jsruntime/qv4function.cpp src/qml/jsruntime/qv4vme_moth.cpp Change-Id: I8fb4d6f19677bcec0a4593b250f2eda5ae85e3d2
| * Enable lookups in QMLSimon Hausmann2019-03-191-37/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main feature that needs to be implemented in order to enable lookups in QML files is to respect that the QObject wrapper has its own storage layer (meta-object properties). Lookups need to be able to index those when the base is a QObject. This is done by caching the property data and guarding the validity by comparing property cache pointers. The same lookup logic is also implemented for value type wrappers. OVerall there's more that can be done with lookups in meta-objects, for constant properties for example. For "global" lookups we have a safeguard in place that generates a LoadName instruction for property access that should end up in the qml context wrapper. So no changes are needed here at first, but the lookup in the QML context can be optimized in the future. The way of storing the property cache in the lookup itself trades ugliness on destruction against the creation of less internal classes. Another option would be to store the property cache in the internal class and let QObjectWrapper always transition via the property cache. Task-number: QTBUG-69898 Change-Id: I9c378c071acc6d7d4a34a2a76616f9594119d515 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Reduce size of QQmlValueTypeJędrzej Nowacki2018-10-091-6/+6
|/ | | | | | | | | QMetaType exposes the type id it holds, so QQmlValueType do not have to keep a duplicate. Change-Id: I4491744b9f7c1e447cd21466f9d71b4007fdfa06 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make Object::getOwnProperty() constLars Knoll2018-09-231-1/+1
| | | | | | | | Object::getOwnProperty never modifies the object, so make it a const member function. Change-Id: I175bb45d61a66a1d9f577c087129562d44d62e17 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* Cleanups in Value/PrimitiveLars Knoll2018-09-171-1/+1
| | | | | | | | | | | | 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>
* Fix ownKey iteration over Proxy objectsLars Knoll2018-09-091-1/+2
| | | | | Change-Id: I045a4844c06df9232cc8b04485ab0a39bb990e3f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Implement ObjectIterator using the new iteration mechanismLars Knoll2018-08-021-28/+0
| | | | | | | And with that get rid of the old advanceIterator methods. Change-Id: I969fa89d25df8992a4b08c8c081b91c92ffdfddd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce a new mechanism to iterate over object propertiesLars Knoll2018-08-021-0/+40
| | | | | | | | | | | | | | | | | 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>
* Move the C++ and JS stack frame definitions into it's own fileLars Knoll2018-07-031-1/+1
| | | | | Change-Id: I86e89e07197aec6071809c2d32bd5c98cb7ac6f6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Prefix vtable methods with virtualLars Knoll2018-07-031-10/+10
| | | | | | | | | Turns out that the overloading of vtable methods and regular ones is problematic in some cases. So let's rather make it explicit which methods are part of the vtable, and which aren't. Change-Id: Ifee32a26104d30f3c82bca8b5a9cdea2d4f4f526 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Identifier by PropertyKeyLars Knoll2018-07-021-3/+3
| | | | | | | | 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>
* Cleanups in the Identifier APILars Knoll2018-07-021-3/+3
| | | | | | | | | | Rename from/asHeapObject to from/asStringOrSymbol and fix the signature. Add a isStringOrSymbol() method and redefine isValid() to also include array indices. Change-Id: Ic8272bfbe84d15421e2ebe86ddda7fdaa8db4f3e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Unify the get and getIndexed vtable functions of QV4::ObjectLars Knoll2018-07-021-6/+7
| | | | | | | | 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-5/+6
| | | | | | | | | | 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>
* Implement a virtual interface for getOwnPropertyLars Knoll2018-06-251-9/+9
| | | | | | | | | | | | 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>
* Change Objects vtable methods to take a StringOrSymbolLars Knoll2018-05-021-4/+17
| | | | | | | This is needed for symbol support. Change-Id: I83db21f232168710d18999fd97d912016e86d630 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-04-181-2/+6
|\ | | | | | | Change-Id: I4a9c7802c180757e70fa4dd16df3287104a088bc
| * Fix calling Qt.binding() on bound functionsLars Knoll2018-04-161-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling Qt.binding() on a bound function object is a valid use case and used to work until Qt 5.8. The problem was that we optimized the code in QQmlBinding and QQmlJavascriptExpression to directly work on a QV4::Function, so this wouldn't work anymore. To fix this make sure recursive calls to Function.bind() are unrolled (so that the BoundFunction's target is never a bound function itself), then add the bound function as an optional member to the QQmlBinding and use it's bound arguments if present. Task-number: QTBUG-61927 Change-Id: I472214ddd82fc2a1212efd9b769861fc43d2ddaf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Disambiguate different allocation functions in the memory managerLars Knoll2018-04-121-2/+2
|/ | | | | | | | | | | Some compilers (in this case MingW 5.3) don't manage to properly disambiguate the template overloads, and try to instantiate the wrong template function. Solve this by renaming the one of the template functions. Change-Id: I3574e617fe96c4bd52920a0127a1dfe39cc3d302 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* use nullptr consistently (clang-tidy)Shawn Rutledge2018-02-261-16/+16
| | | | | | | | | | | | | 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.10' into 5.11Liang Qi2018-02-121-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/imports/shapes/qquickshape.cpp src/imports/shapes/qquickshape_p_p.h src/qml/compiler/qqmlpropertycachecreator_p.h src/qml/jsruntime/qv4value_p.h src/quick/items/qquickloader_p.h tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp tools/qmlprofiler/qmlprofilerapplication.cpp Change-Id: Iafc66ae84bf78630ed72a986acb678e9d19e3a69
| * Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2018-02-021-0/+2
| |\ | | | | | | | | | Change-Id: I41ca9120a470a905c2f5c168c1de4cf970fa0fff
| | * Fix memory leak with value typesSimon Hausmann2018-02-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 3b14e2ffdd8eb4b7f7f4508768b75f2acc399370 replaced the QQmlRefPointer<QQmlPropertyCache> with a raw QQmlPropertyCache pointer and added a V4_NEEDS_DESTROY tag. However unfortunately the destroy() method in the heap class does not decrease the reference count. Change-Id: I90a8c56cd638592b67aae7041fbb57c879c4146c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Convert more builtin functions to use the new calling conventionLars Knoll2018-01-121-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | Convert most of the methods used QML objects to the new calling convention. Converted IndexedBuiltinFunction to do the same. Change-Id: I41b26042c2f56f24988485b06e8ccd214e2573c0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Merge remote-tracking branch 'origin/dev' into HEADLars Knoll2017-10-221-2/+2
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qv4codegen.cpp src/qml/compiler/qv4compileddata.cpp src/qml/compiler/qv4compileddata_p.h src/qml/compiler/qv4isel_moth_p.h src/qml/compiler/qv4ssa.cpp src/qml/jit/qv4assembler_p.h src/qml/jit/qv4isel_masm_p.h src/qml/jit/qv4regalloc.cpp src/qml/jsruntime/qv4engine.cpp src/qml/jsruntime/qv4qmlcontext_p.h src/qml/jsruntime/qv4regexp.cpp src/qml/jsruntime/qv4regexp_p.h src/qml/jsruntime/qv4regexpobject.cpp src/qml/jsruntime/qv4runtime.cpp src/qml/jsruntime/qv4vme_moth.cpp src/qml/qml/v8/qqmlbuiltinfunctions.cpp tests/auto/qml/qml.pro tests/auto/qml/qmlplugindump/tst_qmlplugindump.cpp tools/qmlcachegen/qmlcachegen.cpp Change-Id: I1577e195c736f3414089036b957a01cb91a3ca23
| * | | Replace Q_NULLPTR with nullptrKevin Funk2017-09-271-2/+2
| |/ / | | | | | | | | | | | | Change-Id: I0c01862dbb475494c84e39c695cb563df8cbcfa8 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Move line number information into a side tableLars Knoll2017-08-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Don't emit any Line instructions anymore, and instead store the info in a side table in the compiled data, where it can be looked up on demand. Change-Id: Idcaf3bf4ee4129fd62f9e717bf1277dc6a34fe19 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | | Remove Scope::result and convert calling convention for builtinsLars Knoll2017-08-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | Allow for faster calling of builtins, and completely avoid scope creation in many cases. Change-Id: I0f1681e19e9908db10def85a74e134a87fc2e44c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Don't store the current line number in the ExecutionContextLars Knoll2017-08-041-2/+2
|/ / | | | | | | | | | | | | | | | | Instead modify our StackFrame struct to hold the QV4::Function and have a linked list of those for the frames. Change-Id: I8676e16bc51a5ba6cf25a5b3423576d44e8a926a Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
* | QML: emit messages when breaking bindingsOlivier JG2017-05-171-4/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new logging category that can be used to debug issues with unexpected binding breakages caused by assignment to previously bound properties. If enabled, outputs a message when a binding is broken with detailed location and property/value information. [ChangeLog][QtQml] The QML engine can now emit informational messages (in the "qt.qml.binding.removal" logging category) whenever a binding is lost due to an imperative assignment. This can be used to debug issues due to broken bindings. Change-Id: Ie31e5a198450b6f998c1266acfc97e8f33a92e3d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-02-281-1/+3
|\| | | | | | | Change-Id: I92b13a9c1727644d63e125c1e6f1fdac72720ad7
| * Add Q_ALLOCA_VAR, Q_ALLOCA_DECLARE and Q_ALLOCA_ASSIGN macrosKimmo Ollila2017-02-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | Define Q_ALLOCA_VAR macro to be used instead of #ifdeffing the occurrences of alloca() in case it's not supported. Q_ALLOCA_DECLARE and Q_ALLOCA_ASSIGN macros separate memory allocation from the declaration and RAII. Change-Id: Idc7551642c48a968a44bcade14d84800a3a1270e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Object: Allow put and putIndexed to return success or failureRobin Burchell2017-02-091-6/+8
|/ | | | | | | | | Some parts of the ES6 (and even ES5!) spec specifically require handling of a property write failure. This will be introduced in followup changes, as it's going to be rather more involved than this. Change-Id: Ie482493fcf4780df0e23619650a856421d20bd55 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Convert more builtin functions to the new calling conventionLars Knoll2017-01-251-6/+6
| | | | | Change-Id: I053215261e1186aff25f29e0967219ef667f7678 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.8' into devLiang Qi2016-12-141-3/+4
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp src/qml/qml/qqmlimport.cpp src/quick/items/context2d/qquickcontext2dtexture_p.h tools/qmleasing/splineeditor.h Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
| * Avoid passing a FunctionObject to QQmlBinding::create()Lars Knoll2016-12-091-1/+2
| | | | | | | | | | | | | | | | Like this we can remove the QQmlBinding::create() overload that takes a FunctionObject. Change-Id: Ib6c37395ded325e68cf0fbf3afd08fb6dd6efa3b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Don't store a source location in the QQmlBindingFunction anymoreLars Knoll2016-12-091-1/+1
| | | | | | | | | | | | | | | | It's not needed anymore as we now store this in the binding directly. Change-Id: I518c83207f219b690f31200e4d17251075bbd322 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>