diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2024-04-16 10:32:26 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-04-25 18:55:23 +0200 |
commit | 2fc45188c9344ee54205ffc34401c05cdc678c07 (patch) | |
tree | a00f54c4efb4853857e834e2e37490cd8a4fcc44 /tests | |
parent | 2bc9c4760898737bcd95a7c679ebee9620d04c45 (diff) |
QML: Introduce aliases for builtin types
This way we can express the relationship between qsizetype, qlonglong
and int, as well as the equivalents for long, ulong, char, qreal.
We consider aliases as equivalent to primitive types in
qmltyperegistrar. Therefore, you can only do this with types that don't
have a QMetaObject of their own. However, considering the use case, this
is not a big restriction.
When generating qmltypes, we propagate the aliases. When reading back
the qmltypes, we insert the resulting QQmlJSScope under all its separate
names. This makes all the aliases discernible, but actually equal types.
Since we now record the original type names in the qmltypes, this
changes a few test artifacts for qmltyperegistrar and qmllint.
Task-number: QTBUG-122582
Task-number: QTBUG-124294
Change-Id: I571684e3020b9bc30f8819bdc39389646fd1ff54
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qml/qmllint/lintplugin.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp | 28 |
3 files changed, 16 insertions, 16 deletions
diff --git a/tests/auto/qml/qmllint/lintplugin.cpp b/tests/auto/qml/qmllint/lintplugin.cpp index 58b174cb6b..65795c103c 100644 --- a/tests/auto/qml/qmllint/lintplugin.cpp +++ b/tests/auto/qml/qmllint/lintplugin.cpp @@ -23,7 +23,7 @@ public: void run(const QQmlSA::Element &element) override { auto property = element.property(u"radius"_s); - if (!property.isValid() || element.property(u"radius"_s).typeName() != u"double") { + if (!property.isValid() || element.property(u"radius"_s).typeName() != u"qreal") { emitWarning(u"Failed to verify radius property", plugin, element.sourceLocation()); return; } diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index f94b3e149e..57cb7228d8 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -1026,7 +1026,7 @@ expression: \${expr} \${expr} \\\${expr} \\\${expr}`)", { Message { QStringLiteral("Ready") } } } }; QTest::newRow("nullBinding") << QStringLiteral("nullBinding.qml") << Result{ { Message{ QStringLiteral( - "Cannot assign literal of type null to double") } } }; + "Cannot assign literal of type null to qreal") } } }; QTest::newRow("missingRequiredAlias") << QStringLiteral("missingRequiredAlias.qml") << Result { { Message { diff --git a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp index a6377935be..822caea0d0 100644 --- a/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp +++ b/tests/auto/qml/qmltyperegistrar/tst_qmltyperegistrar.cpp @@ -739,47 +739,47 @@ void tst_qmltyperegistrar::typedEnum() exportMetaObjectRevisions: [256] Enum { name: "UChar" - type: "quint8" + type: "uchar" values: ["V0"] } Enum { name: "Int8_T" - type: "qint8" + type: "int8_t" values: ["V1"] } Enum { name: "UInt8_T" - type: "quint8" + type: "uint8_t" values: ["V2"] } Enum { name: "Int16_T" - type: "short" + type: "int16_t" values: ["V3"] } Enum { name: "UInt16_T" - type: "ushort" + type: "uint16_t" values: ["V4"] } Enum { name: "Int32_T" - type: "int" + type: "int32_t" values: ["V5"] } Enum { name: "UInt32_T" - type: "uint" + type: "uint32_t" values: ["V6"] } Enum { name: "S" - type: "short" + type: "qint16" values: ["A", "B", "C"] } Enum { name: "T" - type: "ushort" + type: "quint16" values: ["D", "E", "F"] } Enum { @@ -805,7 +805,7 @@ void tst_qmltyperegistrar::listSignal() prototype: "QObject" Signal { name: "objectListHappened" - Parameter { type: "QObjectList" } + Parameter { type: "QList<QObject*>" } } })")); } @@ -993,10 +993,10 @@ void tst_qmltyperegistrar::longNumberTypes() exports: ["QmlTypeRegistrarTest/LongNumberTypes 1.0"] isCreatable: true exportMetaObjectRevisions: [256] - Property { name: "a"; type: "qlonglong"; index: 0 } - Property { name: "b"; type: "qlonglong"; index: 1 } - Property { name: "c"; type: "qulonglong"; index: 2 } - Property { name: "d"; type: "qulonglong"; index: 3 } + Property { name: "a"; type: "qint64"; index: 0 } + Property { name: "b"; type: "int64_t"; index: 1 } + Property { name: "c"; type: "quint64"; index: 2 } + Property { name: "d"; type: "uint64_t"; index: 3 } })")); } |