diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-02-09 14:50:51 +0100 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2024-02-14 11:44:39 +0100 |
| commit | e303d1282770e1fa1c2439d92f811c09d4e51140 (patch) | |
| tree | c8ef0e83237260a1a47fe9da400563a65b1bef34 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | |
| parent | 1dbdcf070f89b270d3a2c509feec1953fa97da83 (diff) | |
Compiler: Handle method list return types from qmltypes file
When parsing methods details from qmltypes files, the `isList` value
was ignored. It indicates that the return type of the method is a list
of the type specified in the `type` value.
This patch adds QQmlJSMetaReturnType (typedef of QQmlJSMetaParameter) to
hold information about the method's return type. With this, we can now
mark a method's return type as being a list when reading qmltypes files
and we can act accordingly when resolving the method later on.
As a drive-by, only expose the getter and setter of the metaReturnType
in QQmlJSMetaMethod and not their internals directly.
Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-122106
Change-Id: I6ea07c02fbeb6cb07d9fe9184205ff7f3274fd73
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
| -rw-r--r-- | tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp index b5c2a2dc03..668ed3efc8 100644 --- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp +++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp @@ -76,6 +76,7 @@ private slots: void convertPrimitiveToVar(); void convertQJSPrimitiveValueToIntegral(); void convertToOriginalReadAcumulatorForUnaryOperators(); + void cppMethodListReturnType(); void cppValueTypeList(); void dateConstruction(); void dateConversions(); @@ -1375,6 +1376,17 @@ void tst_QmlCppCodegen::convertToOriginalReadAcumulatorForUnaryOperators() QVERIFY(!o.isNull()); } +void tst_QmlCppCodegen::cppMethodListReturnType() +{ + QQmlEngine engine; + QQmlComponent c(&engine, QUrl(u"qrc:/qt/qml/TestTypes/CppMethodListReturnType.qml"_s)); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(!o.isNull()); + + QCOMPARE(o->property("list").toList()[2].toInt(), 2); +} + void tst_QmlCppCodegen::cppValueTypeList() { QQmlEngine engine; |
