Commit Graph

11 Commits

Author SHA1 Message Date
Tarja Sundqvist 6517e8df24 Update commercial SPDX-License-Identifier
Some files in tqtc-qtdeclarative were missing the commercial
SPDX-License-Identifier. Build files, examples, tests, or
documentation are not updated.

Task-number: QTQAINFRA-5900
Change-Id: I2cad9a7a271b0b3f3af3074259614b890b266a91
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 132fe2df41)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-13 16:58:36 +00:00
Ulf Hermann 91c6d45559 QmlCompiler: Allow lists as arguments to methods
Since lists are allowed as property types, you should be able to pass
them as arguments to methods, too. For now we only handle QML-defined
methods, implemented by adding JavaScript functions to your QML
elements. The usual type coercion rules apply if you pass JavaScript
arrays to such methods. That is, it usually works.

We now resolve properties with the "list" flag to their actual types
(QQmlListProperty or QList) already when populating the QQmlJSScope, and
store the list types as members of QQmlJSScope rather than as a special
map in QQmlJSTypeResolver. This allows us to do the same to lists passed
as arguments and simplifies some of the type analysis.

Fixes: QTBUG-107171
Change-Id: Idf71ccdc1d59f472c17084a36b5d7879c4d959c0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-10 15:00:11 +01:00
Marc Mutz 534241f723 Port to new Q_UNREACHABLE_RETURN()
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>
2022-10-20 23:59:33 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
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>
2022-06-11 08:05:15 +02:00
Sona Kurazyan 2c9c1590e6 Replace uses of deprecated _qs with _s/QStringLiteral
Task-number: QTBUG-101408
Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-29 09:47:43 +02:00
Ulf Hermann 388ccd7b6f QmlCompiler: Allow retrieval of descriptive name from invalid types
Apparently we do that somewhere. It should not just crash.

Pick-to: 6.2 6.3
Task-number: QTBUG-102147
Change-Id: Id612e0543d8794aa4f334a899b117142b7a8cd38
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-07 00:18:12 +02:00
Ulf Hermann fdb45a0e2e QmlCompiler: Clean up exports
We need to export all the classes used by qmlsc, and we need to use the
private export macro for private symbols.

Change-Id: I91d59611e864621dc2c49b9383596e706529bd42
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-30 08:08:11 +02:00
Maximilian Goldstein e1c8f26397 qmlcompiler: Store filename for QML scopes
Previously the filename was only available for C++ types that have been
exposed via qmltypes. Now every scope has a valid filename to reference.

This is important in order to give more useful hints to the user and
will also prove useful for debugging.

Change-Id: I6142b58278f388814514fffd86cbc241eb969bb2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-25 10:49:31 +01:00
Ulf Hermann f3d66dc1d3 QQmlJSRegisterContent: Make conversions explicit
Introduce a new kind to QQmlJSRegisterContent: "conversion". This is
what we store when we merge multiple types together, or convert a
selection of types into a new one. This way we can record what the
original types were, and later figure out whether we can losslessly
convert them already at the point where we store them.

For now, only merges are implemented.

Change-Id: If4ad0b1f075199e6aa1532959cf9591ba6755709
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-15 23:47:54 +01:00
Ulf Hermann 30e6bb35e4 qmlcompiler: Add a content variant for module prefixes
The code generator needs to see the modulePrefix as a separate step in
order to generate sensible code. The savedPrefix we had before was not
exposed to the code generator. As an added benefit we can also check
that we don't refer to singletons as properties of objects this way.

Task-number: QTBUG-95822
Change-Id: Ia8992dba340bf0552e7647f0d66b441f1ac1b8c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-19 21:44:36 +02:00
Maximilian Goldstein 3308e56b2d qmlcompiler: Port type inference code from qmlcachegenplus
Move the type inference code so qmllint can benefit from the improved type analysis.

Change-Id: I00b2fad8334ec19fb33a45b3ceec9d6c49d12e93
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-06-30 10:08:03 +02:00