aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Allow type conversions in storeNameSloppy()Ulf Hermann2021-09-071-2/+13
| | | | | | | | | | | That's part of the sloppiness. We have no way of retrieving the lookup metatype here. Task-number: QTBUG-96144 Change-Id: Ibd1c0d8e9bb66bfe66e59fd1368f3f8ac663d01c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit fb37577559fe524f010625302cf236609918d445) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Check setter == setLookup when retrieving lookup metatypeUlf Hermann2021-09-071-1/+2
| | | | | | | | | | | We want the same init/apply mechanics to also work with setObjectLookup, and for that we need lookupResultMetaType to do the same thing there. Task-number: QTBUG-96144 Change-Id: I410101b7f13e60c0c2ed156a8cf5813c490d7bf0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit eff007aef95bfb71618ad3a7bd00481e5197c0f3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Allow AOT functions to signal an undefined result via the contextUlf Hermann2021-06-161-0/+7
| | | | | | | | | | | | undefined as value returned from bindings has the special meaning of resetting the binding. As AOT-compiled functions return the actual type of the binding rather than a QV4::Value, we cannot always encode undefined. Therefore, add a flag that tells us whether the result was supposed to be undefined. Change-Id: Iac2298869dde80f6d889240dd8200b2ad83e5dc5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 31ab6b81060abb0db0a68c88c61ea93c7d6bdc60)
* Fix AOT-lookup of values in value typesUlf Hermann2021-06-141-2/+2
| | | | | | | | | | | | We cannot use the lookup metatype before we initialize it, and the calling code cannot know the result metatype before the lookup is initialized, either. Change-Id: I3c691b41dbdb416aa1822c0ea7c4b887398f7908 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 3d4ceaf5b83d74d0c2f87caa45547237b3e315fb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Handle half-deleted scope objects in AOT lookupsUlf Hermann2021-06-141-4/+9
| | | | | | | | | | | Apparently we can still call bindings and functions on those. In contrast to the QML engine, we throw a type error here, rather than silently returning undefined. Change-Id: I7d7daf1582d891f6acadb705b50dc36e23f8425c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> (cherry picked from commit 29fccccb402be67f06852005ffcf20250897b13a) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Handle objects without QQmlData and objects being deleted in AOT lookupsUlf Hermann2021-06-121-16/+81
| | | | | | | | | | | Otherwise we trigger asserts in various places. We also need to generate exceptions matching those the interpreter generates, and we need to decline capturing of nullptr objects. Change-Id: I65744fa3e440939db28d7b16a044f6968500a67b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 603ea30924ea925db2830efa2b2c5cef500ee528) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
* Add QML_EXTRA_VERSION for adding extra QML versionsFabian Kosmale2021-06-021-4/+9
| | | | | | | | Currently internal, as the only user might be qtcharts. Change-Id: I40fc5295de6375c082d82ebeeb73bf4cd6dc7e4a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Resolve chicken/egg problem when initializing AOT lookupsUlf Hermann2021-05-181-2/+6
| | | | | | | | | | As long as the lookup isn't initialized, we cannot get its result type. If the AOT code relies on the result type to be retrieved from the lookup, allow an invalid type to be passed to the initialization function. Change-Id: I36a1dbe316010dc466a28bae65c3ed267588fc29 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Accept any QQmlListProperty in place of another as AOT lookup resultUlf Hermann2021-05-181-1/+4
| | | | | | | | We often use QQmlListProperty<QObject> as generic type for any list property. This is somewhat dangerous, but unavoidable for now. Change-Id: I9eba2829eaa84aaffe193365f46f406c30fdbf69 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Accept QObject* base classes as types for results of AOT lookupsUlf Hermann2021-05-181-1/+26
| | | | | | | | The AOT compiled code may be unable to express the true type. Change-Id: Id6a0b0c107aa5f05f6024817a1fdea5179ddf5ca Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Require intended types for setting up AOT lookupsUlf Hermann2021-05-181-38/+66
| | | | | | | | | | | | The object to be used for the lookup can be different from what the caller expects. We need to verify that the caller talks about the same type as the object. If it doesn't, throw an exception. For the same reason, also throw an exception rather than asserting if the property caches don't match. Change-Id: I3b45691bfe2204820d878a624814d412d1358c24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Be more lenient about property caches when doing AOT lookupsUlf Hermann2021-05-171-4/+12
| | | | | | | | | If we know that a property is final, we don't have to consider overrides. Therefore, we can accept a derived class as subject of the lookup. It doesn't have to be the exact same class. Change-Id: I831c64b661730d78d12cec5c98e39282fc8742d8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Provide an AOT variant of StoreNameSloppyUlf Hermann2021-05-031-0/+13
| | | | | | | Leverage the property cache for efficiency. Change-Id: I99910d6851aa5c3d58b15094fbc092c157c74368 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove caching of recursive AOT context lookupsUlf Hermann2021-04-301-25/+24
| | | | | | | | | Such lookups are usually caused by repeaters or similar constructs where many objects look up something in their parent context. As all those objects have different contexts, we would constantly invalidate the cache. Change-Id: I06c7d337d859e5e6a81f6e9a8693b155b2af7498 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Redesign the AOT lookupsUlf Hermann2021-04-301-205/+449
| | | | | | | | | | | | | | | Each kind of lookup should come with a function that tries to execute the lookup, taking a minimal number of parameters, and another one that initializes the lookup, taking whatever is needed for that. No initialization should be done in the execution step and vice versa. Rather, the execution step should be repeated if an initialization had to be done first. This way, the happy path can be very fast if the lookups have been initialized before. Change-Id: Ic435b3dd4906d00144138cb05161a99a0a9c64ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Drop further sanity checks from AOT lookupsUlf Hermann2021-04-231-14/+13
| | | | | | | The caller has to make sure the types match. We only check for QVariant. Change-Id: I17d08cab650f9f4d467fa61e2f285f045b73ba0c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Provide optimized AOT lookups for value type propertiesUlf Hermann2021-04-231-0/+30
| | | | | Change-Id: I4acfce1571bfb2527d2ede43229957b89230022e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Further optimize various AOT lookupsUlf Hermann2021-04-231-29/+55
| | | | | | | | | | We can shortcut some of the lookups if we know what we're looking for. Also, as the lookups are populated from the same code that calls them later, we can drop the sanity checks. The calling code should know what it does. Change-Id: Iae3a5b0e997aa5a90bea7933e7ce1f2415f5299b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Provide optimized variant of QmlContextPropertyLookup for AOTUlf Hermann2021-04-221-0/+15
| | | | | Change-Id: Ie06b029850b74e98d6d6e38b480cedef4e481691 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize property capture for known property cachesUlf Hermann2021-04-191-17/+12
| | | | | | | | If we already know the property cache and data we don't have to look them up again in captureProperty(). Such lookups can be expensive. Change-Id: I94553260311912c5acee3105295f124721203e01 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Don't pre-resolve the QQmlContext for AOT functionsUlf Hermann2021-04-191-4/+8
| | | | | | | | We only ever need it to retrieve the QQmlEngine. However, resolving the context can involve an allocation. Change-Id: I064fd528fa7ab9bd37043c5dd1c62d17ea9380e3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Do not throw an exception in the optimized AOT lookup pathUlf Hermann2021-03-311-5/+1
| | | | | | | | | | | | The method already returns a bool status which tells the caller "something is wrong". If something is wrong, the caller will try a different method to retrieve the value, and that will generate the exception again. We should not shortcut the procedure as generating the exception requires the instruction pointer to be set, which is additional overhead on the caller's side. Change-Id: Ia2d3a90c897b14660a18a5740498a0e5016dc49a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optimize some common lookups for AOT compiled codeUlf Hermann2021-03-291-0/+67
| | | | | | | | Getting a property of an object and getting an object by ID should not require any type transformations. Change-Id: I7ba06cf7c09cdf4ce7b0093b670fd7879ecf799a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow a bare lookup capture, without executing the lookupUlf Hermann2021-03-291-0/+51
| | | | | | | | This is useful when we know how to read the property directly. Change-Id: Ibc314a8e8bf9e51b3a15d934f6a1f17a53ea168a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Expose lookups to AOT compiled functionsUlf Hermann2021-03-231-0/+104
| | | | | | | | This is based on QJSValue for now, but can be extended to operate on QMetaType/void* later. Change-Id: Ic63d4c9081090998afcca63ff3253963ff5096a2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add some documentation for deferred propertiesFabian Kosmale2021-03-171-0/+13
| | | | | | | Change-Id: Ie29baf584629193234ab07db63ed97ee656634f5 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* QQmlPrivate: Check for frame before setting instruction pointerUlf Hermann2021-02-261-1/+2
| | | | | | | | | | | In certain corner cases there may be no stack frame available. As the setting of the IP is only used for generating better error messages, we don't have to care about that too much. Pick-to: 6.1 Change-Id: If249b96a97a2189ef0b2e83f7a057a001a4307cd Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move implementation of functions declared in qqml.h into qqml.cppUlf Hermann2021-01-291-0/+76
| | | | | | | | It makes no sense to have them qqmlengine.cpp. Change-Id: I138807c7650ec7aef4c6e8833e8bac8a6f179d1c Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Allow AOT compiled functions to set the instruction pointerUlf Hermann2021-01-261-0/+5
| | | | | | | | This way we get correct line numbers in error messages. Change-Id: Ieb642523f74adf73955e78cdfb8cb2faee40b321 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move qmlRegisterUncreatableMetaObject to qqml.cppUlf Hermann2021-01-251-0/+33
| | | | | | | | | There is no reason to keep it in qqmlengine.cpp as it is declared in qqml.h. Change-Id: I0a0261b943c4a3b4333d7161becbd68ad4f1b21e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Pass a more comprehensive context to AOT-compiled functionsUlf Hermann2021-01-111-0/+7
| | | | | | | | | | We need the compilation unit, and a way to retrieve JavaScript metatypes from it. Also, prepare for cases where we only have a QJSEngine, not a QQmlEngine, and pass the scope object as part of the AOT context. Change-Id: Ica81e92c99f3c9b6baffd04db1e0e91603fd2ac7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtQml: Integrate sequences with registration macrosUlf Hermann2020-11-111-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | You get to write QML_SEQUENTIAL_CONTAINER(value_type) now, and qmltyperegistrar will generate a sensible registration call from that. A registration might look like this: struct MyStringListForeign { Q_GADGET QML_ANONYMOUS QML_SEQUENTIAL_CONTAINER(QString) QML_FOREIGN(MyStringList) QML_ADDED_IN_VERSION(3, 1) }; It's unfortunate that we need to use a metaobject to transfer all of this information, but there is no other sensible way. Transform the containers defined in qv4sequenceobject.cpp to use the new style, and move them out of the builtins, into QtQml. Recognize that only one of them was ever tested, and add tests for the rest. Task-number: QTBUG-82443 Change-Id: I3a30f9e27266bb575eea26c5daf5dad1ec461cc5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Doc:: Fix documentation warnings for Qt QMLTopi Reinio2020-11-051-2/+2
| | | | | | Task-number: QTBUG-88156 Change-Id: Ic6127c6128b4c7736cb4b5ab8ce51629388b59ca Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QML: Allow singleton types to be extendedUlf Hermann2020-11-021-0/+2
| | | | | | | | | It seems we never stated that singletons can not be extended in our documentation. Therefore this is technically a bug fix and doesn't need separate documentation. Change-Id: I7877289bd5a52ecf709f80ba1975137981ec65f0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Allow namespaces as extensions to typesUlf Hermann2020-11-021-2/+2
| | | | | | | | | | | | | | | | | This way we can access the enums of namespaces as properties of the primary type. This is achieved by: 1. Making enums of extended types available in the base type 2. Allowing the extension to be specified as plain metaObject rather than as type name. 3. Refraining from creating the extension if the create function does not exist. The goal of this is to declare the Qt namespace in a civilized way, but will also help with cleaning up the QtQuick value types and their enums. Change-Id: I13399741d30ce38d1bff753cfa1b11e72ccfbf6a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow optional imports in qmldir filesUlf Hermann2020-10-081-4/+4
| | | | | | | | | | This is useful for modules that select their imports at runtime using qmlRegisterModuleImport(). We can list all possible variants as optional imports so that tools can see what types might be available. Task-number: QTBUG-87130 Change-Id: I8a37bdde79aef3619fd1f05e5ea6781d521afa88 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use factory functions and ctors for creating value typesUlf Hermann2020-10-021-0/+2
| | | | | | | | | | As you can extend value types with QML_EXTENDED we may as well allow a factory function in the extended type. Furthermore, if the original type allows construction from QJSValue, we may just use that. In turn, we can get rid of the value type providers now. Change-Id: I9124ea47537eab6c33d7451080ab2fff942eaa7b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Rewrite qv4sequenceobject based on QMetaSequenceUlf Hermann2020-10-021-0/+6
| | | | | | | | | | This avoids the template explosion and makes the mechanism extendable. You can now register additional anonymous sequential containers. Fixes: QTBUG-71574 Task-number: QTBUG-82443 Change-Id: I5b9ed9af1533a3b7df8fc5bb37bbb73b8304e592 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Restrict qmlRegisterTypesAndRevisions to major version givenUlf Hermann2020-07-161-0/+4
| | | | | | | | | | | We should not register any revisions larger than the given major version as that allows importing an incomplete module, as the version-less import. Typically the offending version is pulled in via some QML_FOREIGN and only the types derived from that foreign class are available in the higher major version. Change-Id: I186fb010d704bea514cefff9f66eb58186df5c91 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add userdata callback to qml registrationMaximilian Goldstein2020-07-101-0/+3
| | | | | | | This is needed in order to remove PySide2's qml type limit. Change-Id: I331d9e31574a744eb9085222d58ea8a8789e0e31 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Discern between "auto" and versioned imports in qmldirsUlf Hermann2020-06-241-10/+82
| | | | | | | | | | | | | You can now import the latest version, a specific version, or, "auto" which is the same version as the parent module. [ChangeLog][QtQml] You can now procedurally add module imports to modules, using qmlRegisterModuleImport(). However, actual import statements in qmldir files should be preferred wherever possible. Fixes: QTBUG-84899 Change-Id: I3b32dd8b07a19d31b6538b9a6bb436840862f345 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Un-pimpl QQmlModuleImportUlf Hermann2020-06-101-1/+1
| | | | | | | There is no point in having that pimpl'd. Change-Id: I9e3f6671ca178ea3f58fd0488dbb291a38656685 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add methods to programatically insert qmldir import statementsUlf Hermann2020-06-091-0/+31
| | | | | | | We need this for controls2 to select the style at runtime. Change-Id: I23b6ab962a647b519d5af019eade27f89e1e4e00 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add a default message to QML_UNCREATABLEMaximilian Goldstein2020-05-061-3/+8
| | | | | | | | | [ChangeLog][QML][Feature] Add a default message to QML_UNCREATABLE when proving an empty string as a reason Fixes: QTBUG-83842 Change-Id: Ifd2044fa6c56c3a382d451ec47d5f92a1ac16b81 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Clean up type registration structsUlf Hermann2020-03-121-12/+7
| | | | | | | | | | | | * reset all structVersions to 0, removing checks for higher versions * add structVerions where they are missing * consistently check for compatibility in qqmlmetatype.cpp * remove unused members * rename RegisterSingletonFunctor Fixes: QTBUG-82241 Change-Id: I74f1876b3298dbb60ff7cfab8c13e8ad4f9f8cdc Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Optionally return type IDs from qmlRegisterTypeAndRevisions()Ulf Hermann2020-03-111-4/+9
| | | | | | | | This allows us to save the type IDs and later unregister the types in qmltyperegistrar-generated code. Change-Id: Id1bc73e2832c6d76e513ee3ee267b8d52e3851da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adapt to the the new QMetaType changeOlivier Goffart2020-03-091-4/+2
| | | | | | Fixes: QTBUG-82453 Change-Id: I7e5682945a07c3af183becd3947a69568f139d16 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-02-171-0/+37
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/imports/qtqml/plugin.cpp src/qml/qml/qqml.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmlmetatype_p.h src/qml/qml/qqmltypeloader.cpp src/qml/types/qqmlbind.cpp src/quick/items/qquickitemsmodule.cpp tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
| * Provide a macro for qmlRegisterTypeNotAvailableUlf Hermann2020-02-121-0/+37
| | | | | | | | | | | | | | | | | | | | | | That is, register QQmlTypeNotAvailable as foreign type under the name given as parameter. Also, statically register QQuickAnimatedImage as unavailable in case of !quick_animatedimage and register it for the right version. Task-number: QTBUG-68796 Change-Id: I2ea292d2aeda66d8ce43b3bccbd3d21663330bd6 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Remove custom operator<(QTypeRevision, QTypeRevision)Ulf Hermann2020-02-131-11/+0
| | | | | | | | | | | | | | | | We have global comparison operators now. Change-Id: I5e7461c8442591f139642379f8889445dfaa8431 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>