aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypemodule.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Port from container::count() and length() to size() - V5Marc Mutz2022-10-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | 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>
* 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>
* QQmlTypeNameCache: Unify querying for typesUlf Hermann2021-12-031-16/+1
| | | | | | | | | | | | | | | Template all of the code and make sure the different query variants do the same work. There is no reason not to query the namespaced imports if we are passed a different string type as parameter. If we want to skip the namespaced imports, that is a separate parameter. This needs to be picked to 6.2 as precondition for fixing AOTCompiledContext::initLoadAttachedLookup. We need to pass a QQmlImport::RecursionRestriction when querying by QHashedStringRef. Pick-to: 6.2 Change-Id: I98aecc7775036728668cc93f550aa73fdefafe9a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmlmetatypemodule: Fix maximumMinorVersion() returning bad valuesMaximilian Goldstein2020-10-271-1/+3
| | | | | | | | maximumMinorVersion() needs to ignore unspecified values as they are not versions in themselves. Change-Id: I7c91cf4b8320fd6636eb1be10b069cf885797ee1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Discern between "auto" and versioned imports in qmldirsUlf Hermann2020-06-241-18/+0
| | | | | | | | | | | | | 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>
* Lock the mutex when accessing QQmlTypeModule::m_importsUlf Hermann2020-06-101-0/+3
| | | | | | | The type modules are passed around in various places. Change-Id: I59b2fec80a3ae25799116533635545229d3841da Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Un-pimpl QQmlModuleImportUlf Hermann2020-06-101-62/+20
| | | | | | | There is no point in having that pimpl'd. Change-Id: I9e3f6671ca178ea3f58fd0488dbb291a38656685 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlTypeModule: Clean up remove loopUlf Hermann2020-06-101-11/+1
| | | | | Change-Id: I0f7808e84ca295560eca9bca99db9b44737210d2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add methods to programatically insert qmldir import statementsUlf Hermann2020-06-091-0/+15
| | | | | | | We need this for controls2 to select the style at runtime. Change-Id: I23b6ab962a647b519d5af019eade27f89e1e4e00 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Use QTypeRevision for all versions and revisionsUlf Hermann2020-02-031-12/+12
| | | | | | | | | | | | | | In many places we carry major and minor versions or revisions that are loosely coupled to minor versions. As the Qt minor version resets now, we need to handle these things more systematically. In particular, we need to add a "major" part to revisions. QTypeRevision can express the current major/minor pairs more efficiently and can also be used to add a major version to revisions. This change does not change the semantics, yet, but only replaces the types. Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Allow overriding type registrationsUlf Hermann2020-01-151-2/+6
| | | | | | | | | | | | | | Previously if the same revision of the same type was registered multiple times, the first registration would dominate. Now, the last one does. [ChangeLog] If you register the same revision of the same type multiple times, the last registration is the one QML will use. This allows you to override qmlRegisterSingleton*() calls, for example in order to register a singleton instance for a type tagged with QML_SINGLETON. Task-number: QTBUG-79331 Change-Id: I32a2acabc89af6faa89d8ccb6380a473bc8b8ddd Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port towards load/storeRelaxed atomicsGiuseppe D'Angelo2019-06-251-8/+8
| | | | | | | | | | Plain load() / store() have been deprecated, so port away to their straight replacements. Task-number: QTBUG-76611 Change-Id: I79935b889cf7b2ba7698f70cc5e33994b034aa09 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Tighten the interface of QQmlTypeModuleUlf Hermann2019-02-071-20/+43
| | | | | | | | | | | | | | | | | | | | No other classes really need direct access to QQmlTypeModulePrivate. Adding or removing types, as well as lookup of types needs to be protected by a mutex, as that can happen from multiple threads. However, we don't need to acquire the global type registration mutex in order to change the internals of some QQmlTypeModule. Rather, each type module gets its own mutex. The minimum and maximum versions as well as the "locked" property can be handled with atomic integers as they only ever move in one direction. The module and majorVersion properties are constant over the life time of the object. Therefore they don't need any locking. Task-number: QTBUG-73271 Change-Id: I23fe7dcaf521ccecaaaf19c1fb0436e109c42f03 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add a mutable iterator to QStringHashUlf Hermann2019-02-071-4/+2
| | | | | | | And use that in QQmlTypeModule to get rid of a const_cast. Change-Id: Ifbb39293b6f0e159355dd7780febba0eed149025 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QML: Split qqmlmetatype{_p.h|.cpp} into multiple filesUlf Hermann2019-02-061-0/+153
Having all those classes in one big file promotes spaghetti code and makes the code unreadable. Change-Id: I3b6df93b9cfe1d97228771049b3054e78b868ea3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>