aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltc
Commit message (Collapse)AuthorAgeFilesLines
* qmltc: export generated classesSami Shalayel2023-02-025-0/+47
| | | | | | | | | | | | | | | | | | | | | | Add QMLTC_EXPORT_MACRO_NAME and QMLTC_EXPORT_FILE_NAME arguments to qt_add_qml_module() that allows the user to export qmltc-generated code from its library. The qmltc-generated code will include the header-file specified in QMLTC_EXPORT_FILE_NAME and will be exported with the macro specified by QMLTC_EXPORT_MACRO_NAME. Leave both options unspecified to not export the code generated by qmltc. Describe the options in the documentation and write a test to see if the class really has an export macro in the generated code: 1) tst_qmltc_qprocess will test if the macro and the header are correctly inserted in the generated code. 2) tst_qmltc_{no,}diskcache will test if the generated code can still be used from a static library. Fixes: QTBUG-106840 Task-number: QTBUG-96040 Change-Id: I554f03bcdf043e8114e42f51a7289a5c00de4f89 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* CMake: Allow omitting the version of QML modulesUlf Hermann2023-01-271-1/+0
| | | | | | | | | | | | | | | | | Also, drop all the VERSION 1.0 lines from the examples and tests. 1.0 is actually a bad default version since it's before all the Qt versions. [ChangeLog][QML] You can now omit the VERSION argument to qt_add_qml_module(). This will automatically generate the highest possible version. Pick-to: 6.5 Task-number: QTBUG-99146 Change-Id: Ic10ec69b87c224e0e94e1785f65653815d4c778c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmltc: generate code into namespacesSami Shalayel2023-01-066-23/+86
| | | | | | | | | | | | | | | | | | | | | Generate code into namespaces to avoid clashes between qmltc-generated and user code. Code generated by qmltc will by default be put in the URI_OF_MODULE namespace, and will generate subnamespaces to follow the module hierarchy if URI_OF_MODULE contains dots('.'). Also fix the test to use the new namespaces. [ChangeLog][Qml][qmltc] The type compiler will generate C++-code into a namespace by default. The new default namespace is inferred from the module's URI, where dots are interpreted as separating subnamespaces from each other, e.g., a type in module MyCompany.MyModule.Sub will be generated in the namespace MyCompany::MyModule::Sub. Fixes: QTBUG-109274 Change-Id: I3bfe2697b81e90bb63a079dc44c2810fc9925f97 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qmltc: test C++-namespace supportSami Shalayel2023-01-066-0/+91
| | | | | | | | | Add a test to see if qmltc handles c++ types correctly, that are wrapped into namespaces. Fixes: QTBUG-106830 Change-Id: I9ba89d209b84dfb8104073a02588cd824e657658 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: fix handlers for c++-signalsSami Shalayel2022-12-075-0/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow qmltc to generate handlers for c++-defined signals with const parameters by changing the safeguard to avoid type mismatch between slots and signals. First, remove the qOverload in the generated QObject::connect call to be able the connect slots and signals with different types (namely, pass by const references and pass by value should be interchangeable but is not allowed by qOverload). Second, save in QQmlJSMetaParameter when types are passed by pointer. Like this, qqmljsimportvisitor can check if a value type is indeed passed by value or const reference in a C++ signal. The same for reference types that need to be passed by (const and non-const) pointer. Print a message when an type is passed by argument in an incompatible way instead of letting qmltc generate uncompilable code, which makes the compiler print out cryptical messages. Third, add a qqmlcpptypehelpers template that decides if value types should be passed by value or reference, by letting the c++ compiler check if sizeof(T) > 3*sizeof(void*). Fixes: QTBUG-107625 Fixes: QTBUG-107622 Change-Id: I1a00532df591d10f74c1fd00dff5b7fccf40cb22 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qqmljsscope: resolve enums using their aliasesSami Shalayel2022-11-233-0/+23
| | | | | | | | | | | | | | | | | | | | Some enums happen to have an alias, e.g. when an enum is used as a flag, the enum will exist in two versions, once as enum (e.g. Qt::MouseButton) and once as a flag (e.g. Qt::MouseButtons). In this case, normally only the flag is exposed to the qt metatype system and tools like qmltc will have troubles when encountering the enum in signal parameters etc. To solve this problem, QQmlJSScope::resolveEnums() will create a QQmlJSMetaEnum copy for the alias in case the 'self'-scope already does not have an enum called like the alias. For the greater picture: this allows qmltc to compile signal handlers for signals that take enums as argument without asserting, and also is a step forward to compile the quick/text example with qmltc. Task-number: QTBUG-107609 Change-Id: I8fcb48a15a2066fb2d2dc89fc26b8441a1a0f489 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: add singleton supportSami Shalayel2022-11-237-15/+142
| | | | | | | | | | | | Add singleton support to qmltc. Add the QML_SINGLETON annotation to the class, generate a static T* create(QQmlEngine*, QJSEngine*) method for the engine and also add test this new functionality. Fixes: QTBUG-106828 Change-Id: I7b6b39ab0c8a427b3166562c3f04cf4a7eaa20e2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: support inline components from different qml filesSami Shalayel2022-10-316-0/+125
| | | | | | | | | | | | | | | | | | | | | | | | Make qmltc aware that inline components can be shared between files such that it does not complain about not finding them. Typical usage are `MyOtherFile.MyInlineComponent {}` and `ModuleName.MyOtherFile.MyInlineComponent {}` for an an inline component called MyInlineComponent defined in MyOtherFile.qml, maybe also in a module called ModuleName. Make QQmlJSScope::findType() aware that inline components exists (and potentially that they might also appear in namespaced types). They can also be "imported" or reexported from basetypes and/or deeply nested in some children scopes. Also make it public so that qqmljsimportvisitor can use it when processing property types. Added some tests testing both notations (with and without the qualifed module name). Also add a test to see if there is no confusion between the enums and the inline components (due to their very similar notations). Fixes: QTBUG-106592 Change-Id: I8f2d4790729902ffa664fd0eb1b7c3279af8ddca Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Add some sugar for generated reference-type-list propertiesSami Shalayel2022-10-282-0/+51
| | | | | | | | | | | | | | | When compiling a reference type list with qmltc into a QQmlListProperty, also generate helper methods to make the manipulation of those lists by the user easier in c++. For a list myList, generate the methods myListAt(), myListAppend(), ... as shown in the Birthdayparty example. Also add some documentation about the ownership of the arguments, and tests to see if the list can be accessed from C++. Task-number: QTBUG-107570 Change-Id: Iec0041015311639ead39660fdccf147749566592 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Qml: Analyze qsTranslate at compile timeUlf Hermann2022-10-131-2/+2
| | | | | | | | | | We generate translation bindings for all the other translation functions already. We can just as well generate a translation binding for this one, too. Fixes: QTBUG-107536 Change-Id: I851f03c26510b6d450aa78f5d7a1f0142d3a81aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Remove broken alias optimizationSami Shalayel2022-10-117-1/+86
| | | | | | | | | | | | | | | | | | | | Remove the recursive alias resolution mechanism. It tried to resolve aliases recursively but only knew the id's of the current component. This means that an alias pointing to a property defined in another component (e.g. a different qml file) was resolved using the id-to-scope map of the component containing the alias property. This leads to unresolved aliases at best and endless loops when the aliased property was itself an alias pointing to some property also existing in the original component (see QmltcTests/ComponentWithAlias{1..3}.qml for an example). Also added the reproducer in the qmltc tests. Fixes: QTBUG-107533 Fixes: QTBUG-107534 Change-Id: Idbf0cff3e45213bc7fbb4a98a9393c6754b00046 Pick-to: 6.4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: fix code generation for implicit componentsSami Shalayel2022-10-104-0/+57
| | | | | | | | | | | | | | | | | | | | Do not check if a type is implictly wrapped during visitation, as this information is only made available by QQmlJSImportVisitor after(!) the visit. Move this into the postvisit step of qmltc, and write some internal documentation so this error will hopefully not be done again by some qmltc contributor (e.g., me). Now that implicit components are correctly recognized as such, they can be compiled correctly and the c++-code generated by qmltc can again be compiled. Added also a test to see if all childrens of the repeater are correctly instantiated. Pick-to: 6.4 Fixes: QTBUG-107091 Change-Id: I8fce018b83316f8786ae5ca15e5af27c30bb1d37 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-26/+26
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: support basic inline componentsSami Shalayel2022-09-264-0/+464
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds basic inline component support to qmltc. Implementation details: * added tests: ** (for all tests: see if QQmlComponent would do the same thing) ** try simple inline components ** try inline components extending other inline components ** try recursive inline components (inline component A contain a B that itself contains a A) ** make sure ids in inline components are in their own context, and ** make sure alias inside of inline components work ** remove qmltc_qprocess that tests the error message when inline components are encountered ** test that inline components get their own context (by aliasing a property that they should not be able to see) ** test that also empty components work ** other tests inspired from those at tst_qqmllanguage * separate types depending on the inline component they belong in qmltcvisitor and qmltccompiler ** mostly by replacing T with QHash<QString, T>, where the belonging inline component name serves as hash key ** added a list of inline component names in qmltc * generate correct qmltc-code for inline components ** as they sometimes have mimic a document root and sometimes not ** generate their own "typeCount"-method ** fixed naming used in qmltc generated code by using the inline component names from the qqmljsscope. There is one missing feature (using inline components from other files, using QmlFileName.MyInlineComponent) that will be added in a separate commit. Fixes: QTBUG-106882 Change-Id: Iabe1a8b787027367d73d34bcd93c5f7b5480d217 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: stop using QQmlListReference to appendSami Shalayel2022-09-266-0/+155
| | | | | | | | | | | | | | Instead of using a QQmlListReference to append into lists, use directly the underlying QList<T*> for types compiled with qmltc and QQmlListProperty<T> for types not compiled with qmltc (e.g. types defined in c++). Add a test that tests the private c++ backed "data" property of QQuickItem and different kind of lists (QtObjects and HelloWorlds). Also, append multiple objects to QLists in one go. Fixes: QTBUG-104664 Change-Id: Id5ce6307a241c4c8a167feca677ba5e9b492bc07 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: reject top level componentsSami Shalayel2022-09-195-102/+0
| | | | | | | | | | | | | | In qqmljsimportvisitor, print an error message and return false when a top level component is visited. Also, remove all the tests expecting qmltc to accept top level components and add a test to see that the error is correctly emitted for top level components. Fix qmllint tests using top level components. Fixes: QTBUG-106558 Task-number: QTBUG-106547 Change-Id: I101b42fc7499049fcebca18e7aeab57fa6705f81 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-09-072-2/+2
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id89ed14990804a5024183e75382cc539d4293da1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* qmltc: test support for generalized group propertiesSami Shalayel2022-09-016-1/+107
| | | | | | | | | | | | Test support for generalized group properties in qmltc. Also, force group property bindings to be deferred when they belong to a generalized grouped property, while "not-generalized" grouped properties never are deferred. Fixes: QTBUG-105378 Change-Id: Iadc64d7033f9446ccf53e305d8831c7d348f257c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: test alias on properties with attributesSami Shalayel2022-08-317-7/+357
| | | | | | | | | | | | | | | | | | | | | | | Add tests to qmltc to see if it behaves well for aliases to different kinds of properties, and compares if the engine shares the same behavior. Same for the attributes in the QMetaProperties. Changes: * add some more MOC information to aliases ** always add NOTIFY to aliases (like the engine does) ** always set DESIGNABLE to false for aliases (like the engine does) ** always set CONSTANT to false for aliases (like the engine does) ** always set STORED to false for aliases (like the engine does) Test if: * default aliases works when compiled via qmltc * attributes of aliases are set correctly in QMetaProperty and compare it to the attributes of the QMetaProperty obtained from the engine. * aliases can read/written/reset/notified Fixes: QTBUG-105708 Change-Id: I66b9c43c8c8de3dbd2b33d5ce15cd42ffb377ce7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: translation binding supportSami Shalayel2022-08-259-0/+207
| | | | | | | | | | | | | | | | | | | | | | | Implement and test support for translation bindings in qmltc: * qsTr() * QT_TR_NOOP() * qsTrId() * QT_TRID_NOOP() Not compiled by qmltc, but instead interpreted as script bindings: * combinations like qsTr(qsTr()) * qsTranslate() (as in qmlsc) * QT_TRANSLATE_NOOP() (as in qmlsc) Add the *.qm files directly to the resources as qt_add_translations() is not available from qtdeclarative (the cmake function lives in qttools that depends on qtdeclarative). Fixes: QTBUG-104637 Task-Id: QTBUG-105346 Change-Id: Ia9433c2bcef01f3486358d963059d9779c67708c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Support CONSTANT and RESET property attributes in aliasesAndrei Golubev2022-07-293-0/+30
| | | | | | | | | As a drive by, propagate CONSTANT attribute through the .qmltypes file and qmlcompiler library Task-number: QTBUG-91956 Change-Id: I5802fa29ddedcdadae3e505efca0c4fb4d6b2593 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Make explicit component ids accessible during object creationAndrei Golubev2022-07-283-0/+19
| | | | | | | | | | | | | | | | | | | Explicit components could be accessed by id like regular objects. Make this work in qmltc by revisiting the object creation procedure - store explicit components along with pure QML types in QQmltcObjectCreationBase: xxxxxxxx x'x'x'x'x'|yyyyy... ^ ^ ^ pure explicit types from base class types components As a drive by, fix unset required property in one test file and add a bunch of other test files to the initTestCase() check Pick-to: 6.4 Change-Id: Ibdaa430d692c81101853f51dae1da462a57a9980 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Fix alias assignment code generationAndrei Golubev2022-07-275-0/+39
| | | | | | | | | | | | | | | Fix subtle issue where alias assignment would cause qmltc to generate direct property set code (doesn't work for aliases since those do not have "real" properties) Remove now redundant TODO and identical code path when compiling alias assignments on types with composite bases (used to work poorly during prototype times) Pick-to: 6.4 Change-Id: Ifacf5872ff5432a748fb1ec16c300ec844d65e9a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Support RegExpLiteral bindings in qmltcAndrei Golubev2022-07-274-0/+17
| | | | | | | Task-number: QTBUG-91956 Pick-to: 6.4 Change-Id: I02f8c6d1f0d6e4411985ffe3f22fb3c51fb36db6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Fix import namespace code generationAndrei Golubev2022-07-261-0/+2
| | | | | | | | | | Fix subtle issue where an import namespace would become part of the generated C++ class name without modifications (so with '.'). Preserve the namespace for the time being just to make the generated code more verbose (e.g. consider mixing QQ.Text and ZZ.Text in the same file) Change-Id: I3d409988ae136c272aac6a4eab287a7221f88450 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Acknowledge BINDABLE-only propertiesAndrei Golubev2022-07-266-35/+45
| | | | | | | Task-number: QTBUG-91956 Change-Id: I4c34ccd9d6d5cf4c6a6c1b54e67374515e67861a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Use QMetaObject hierarchy as reference for meta index calculationAndrei Golubev2022-07-263-2/+38
| | | | | | | | | qmltc needs to compute a QMetaProperty index ahead of time when creating property bindings. This procedure has to acknowledge that extensions exist Change-Id: I7bf6b6c558ce78e0fec5ee880bc4d39a79fe5640 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Acknowledge group/attached properties have objects in QmlIRAndrei Golubev2022-07-251-0/+1
| | | | | | | | | | | | | Group and attached properties have QmlIR::Objects associated with them. However, qmltc's object index calculation ignores groups/attached types. Fix this, making object index calculation aligned for implicit components Fixes: QTBUG-104780 Pick-to: 6.4 Change-Id: I377d3eab714d0e9618ac2ef84c2738b45ad3b6cc Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmltypecompiler: align runtime function table order to qmlcachegenAndrei Golubev2022-07-221-10/+0
| | | | | | | | | | | | | | | | When we write runtime functions to compilation unit at run time, the order of the functions in the unit (often) differs from the order of functions in the unit produced ahead of time by qmlcachegen and friends. Additionally, the order also differs from what qmltc expects (and qmlcompiler library in general) Fix the order by simplifying the procedure of JS code generation when we create the compilation unit at run time: new logic just goes over the objects in the document linearly, instead of relying on bindings (which are known to be out of order w.r.t. AST) Change-Id: I4070b9d061f03c4c76d03120654ad3f30725493a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Support value type lists in qmltcSami Shalayel2022-07-134-0/+73
| | | | | | | | | Generate list of values in qmltc when possible, by using QList<T> instead of QQmlListProperty<T>, e.g., when T is an int or a QColor.. Fixes: QTBUG-100313 Change-Id: Ifd84cbb550437854fb156a295435240cef446e61 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Make Component.onCompleted compilation less specialAndrei Golubev2022-07-091-0/+2
| | | | | | | | | | Use the existing compilation machinery to handle attached Component signals Task-number: QTBUG-91956 Pick-to: 6.4 Change-Id: I271e3c50b61a8e38d9bb601768d871bf977f365a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-082-0/+6
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I72c89a98c42bbc9234d8495e9e503bec81d11037 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* qmltc: Ensure properties with MEMBER can be read and writtenAndrei Golubev2022-06-305-0/+57
| | | | | | | Pick-to: 6.4 Task-number: QTBUG-91956 Change-Id: I980089ed7e4991de7bf7429722caf7351d9e79b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: Use correct output C++ file names within a moduleAndrei Golubev2022-06-295-1/+23
| | | | | | | | | | | | | | | | | | | | | Due to custom basenames in CMake qmltc can create non-default file names that contain the generated C++. This would cause troubles when locally importing such a custom-marked QML file from the same module. Resolve this by introducing a qrc-based mapping from source file name to C++ header file that the generated code would be put into Use the mapping information inside QmltcVisitor so that imported types are properly set Doing so, with some additional fixes around file paths collection, allows to get rid of the prototype code completely Fixes: QTBUG-104094 Pick-to: 6.4 Change-Id: I6a54774addf303449f35915df501ab3f47470c44 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Introduce a sane resource path to qt_add_qml_moduleUlf Hermann2022-06-232-57/+58
| | | | | | | | | | | | | | | | | | Since "/qt" is reserved, we can use "/qt/qml" as the default path for user QML modules. [ChangeLog][QtQml] The AUTO_RESOURCE_PREFIX option was added to qt_add_qml_module(). It places your QML modules in the otherwise reserved resource directory /qt/qml. This directory is also added to the default QML import path. By using it you don't have to specify custom import paths anymore. Specifying neither AUTO_RESOURCE_PREFIX nor an explicit RESOURCE_PREFIX will generate a warning now because such QML modules are likely invisible in the resource file system. Fixes: QTBUG-95145 Fixes: QTBUG-103452 Change-Id: Ie27dec5cbf34ea06258d55c659d202cdd61e54b2 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-1118-498/+37
| | | | | | | | | | | | 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>
* Remember QML document context in each qmltc-generated objectAndrei Golubev2022-06-096-0/+38
| | | | | | | | | | | | | | | | | There is an apparent problem in certain cases where using outer context to fetch ids is invalid: the outer context is the *outermost* context, meaning that if a type has a derived type in another QML document, the derived type would place its own context as a QQmlData::outerContext As a simpler solution, just remember the document's context in all the objects within this document. This automatically works in derived types since they appear in other documents with separate contexts Pick-to: 6.4 Fixes: QTBUG-103956 Change-Id: I29420ff4962b485502d87b2d2ac2f89b9e0f5736 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmltc: Move from QmlIR::Binding to QQmlJSMetaPropertyBindingAndrei Golubev2022-06-091-0/+2
| | | | | | | | | | | | | | | This symbolizes the last piece of QmlIR dependency that qmltc has. We do still have some implicit dependencies on QmlIR, though, but that should go way once the remaining prototype code's logic is migrated to QmltcVisitor, QQmlJSScope and friends. This, however, is not attempted here as the patch itself is rather large In the process of switching to QQmlJSMetaPropertyBinding, observe and fix issues in QmltcVisitor and surroundings Pick-to: 6.4 Change-Id: I752b68a7f57baf354de16dc0bb466a3f693a4e49 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Rename tst_qmltc_{no}diskcache data folder to QmltcTestsAndrei Golubev2022-06-0386-1/+1
| | | | | | | | | | | Follow the policy of "good" QML modules where the module would reside in a folder named the same way as the module URI Somehow this is still not enough to remove an explicit "-i <own qmldir>" workaround in qmltc compilation command Change-Id: If1725ec03baf3690bb6cb8fc7876b082a155eaa2 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Address extension types in qmltcAndrei Golubev2022-06-029-7/+487
| | | | | | | | | | | | | | | | | | | | | Whenever working with properties (reading, writing, aliasing, etc.) of the type that has extensions, prefer the same-named properties from extension objects over type-owned properties (this is the internal QML mechanism) To achieve that, we need to query the extension object: * for Q_GADGETs use a dummy model of assuming we can cast the object to the extension type and use that * for Q_OBJECTs use a qmlExtendedObject() with additional logic of figuring out which extension should be picked in each specific case Create QQmlProxyMetaObject via a custom dynamic meta object API for qmltc-compiled objects that are derived from base types with extensions Task-number: QTBUG-91956 Change-Id: I5e783768ae2abdb9dddf894de7e79960244352bd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove qmltc compilation command in favor of qt_add_qml_module()Andrei Golubev2022-05-312-5/+7
| | | | | | | | | | | | [ChangeLog][CMake] The qmltc compilation functionality provided by qt6_target_compile_qml_to_cpp() is merged into qt6_add_qml_module() command and is available through ENABLE_TYPE_COMPILER argument. The qt6_target_compile_qml_to_cpp() function does nothing and is left only to highlight that users must migrate away from it. Fixes: QTBUG-100215 Change-Id: Ie7d6b82564dff86176194fce35039ba0d93c0977 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* qmltc: Move alias compilation to qqmltccompilerAndrei Golubev2022-05-031-0/+3
| | | | | | | | | | | Introduce an alias resolution procedure to query the origin property and its owner for a given alias Add alias compilation to the "proper" qmltc code and remove the equivalent one from the prototype Change-Id: I55bc1e3e6206b4cfce259526d1bc2813e8ea7cfb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace uses of deprecated _qs with _s/QStringLiteralSona Kurazyan2022-04-292-60/+64
| | | | | | Task-number: QTBUG-101408 Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmltc: Support setting Gradient property of RectangleAndrei Golubev2022-04-287-0/+80
| | | | | | | Fixes: QTBUG-102560 Pick-to: 6.3 Change-Id: I7c339d2807a723f38e18e06b944362449d89ad7a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Make QQmlEngine resolve closures when executing runtime functionsAndrei Golubev2022-04-271-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | QML can create a function which holds a closure in the cases like: onSignal: function() { ... } If the left-hand side is a signal handler (or similar), we want to execute the *inner* function when a signal is called, not the outer one. However, under certain conditions (e.g. we use `this`), the outer function must also be called beforehand to correctly setup the calling scope for the inner function Thus, make the QQmlEnginePrivate::executeRuntimeFunction() do that: always call an outer function first and then the inner one if present. This creates an overhead when dealing with certain signal handlers but we could optimize it later if needed Note that the case `property var prop: function() { return 42; }` where a property contains a callable function is no longer supported by the executeRuntimeFunction() routine (we always call the inner code now). This is fine since qmltc (the main beneficiary of the routine) does not rely on this functionality when dealing with property bindings Given the change, qmltc can be simplified to only work with absolute function indices, ignoring the nesting problem altogether Change-Id: I61f61587b6fe700cb695b3b7a213d9cfab0eb746 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Blacklist tst_qmltc::listView on AndroidAndreas Buhr2022-04-261-0/+3
| | | | | | | | | | | | | tst_qmltc_diskcache keeps appearing in test failures. It is flaky. And it seems to be a special kind of flakyness: On some days it always fails, on other days it never fails. It does not seem to be random. Pick-to: 6.2 6.3 Task-number: QTBUG-101342 Task-number: QTBUG-101865 Change-Id: Ia6716d38a10f348199d3582be8453d52f331a8b1 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmlcompiler: Support attached property bindingsAndrei Golubev2022-04-227-4/+43
| | | | | | | | | | | | Extend group property binding creation with attached properties case As a drive by, add extra attached property tests for QML and qmltc, covering the case where an attaching type exists in both base and derived types Task-number: QTBUG-102082 Change-Id: I6c0d2b941da72d6dab7fc05a4f7b2a7875423ef0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Replace uses of deprecated _qba with _baSona Kurazyan2022-04-191-1/+3
| | | | | | Task-number: QTBUG-101408 Change-Id: Ie4d6d8f92241a546c9c6507a0fbb27035661d33a Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* tst_qmltc::listView is failing with no apparent reasonPasi Petäjäjärvi2022-03-021-0/+2
| | | | | | | Pick-to: 6.3 Task-number: QTBUG-101342 Change-Id: Ib660394b5956b891b86dd20cab83c80f5274fa43 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* qmltc: Handle (simple) deferred properties correctlyAndrei Golubev2022-02-1710-0/+312
| | | | | | | | | | | | | | | Simple deferred properties occur quite often in QML (throughout Qt Quick, for example), so qmltc should be able to deal with them as with deferred properties Ignore generalized group properties, PropertyChanges and similar types for now. They require more testing and are well out of scope of the tech preview Pick-to: 6.3 Task-number: QTBUG-100053 Change-Id: I0f3588789d188cd6bec81de0b61d3205b665a917 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>