diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-07-20 14:52:21 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-09-05 11:10:28 +0000 |
commit | 2bfd1de3495b18c0ecc251260442a9a46009861e (patch) | |
tree | 73e8392e8f3059fac87bd80d59bccb4d6b74898c /sources/shiboken2/ApiExtractor/tests/testtemplates.cpp | |
parent | 194df4ac3203546193dc7fb03267ede5d112009f (diff) |
shiboken: Add a typedef typesystem entry
The intention is be able to specify
typedef std::optional<int> OptionalInt
in the typesystem file and generate code for it (without having
a typedef in C++).
Task-number: PYSIDE-725
Change-Id: I5847a3c3f68556ac1d0ea3635f65a29caa6cb208
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/ApiExtractor/tests/testtemplates.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/tests/testtemplates.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp b/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp index d32e24379..b1b171bae 100644 --- a/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp +++ b/sources/shiboken2/ApiExtractor/tests/testtemplates.cpp @@ -474,6 +474,7 @@ public: << "typedef Optional<int> IntOptional;\n"; QString xml; QTextStream(&xml) << xmlPrefix << xmlOptionalDecl << xmlOptionalIntDecl + << "<typedef-type name='XmlIntOptional' source='Optional<int>'/>" << xmlPostFix; QTest::newRow("global-namespace") << cpp << xml; @@ -486,6 +487,7 @@ public: QTextStream(&xml) << xmlPrefix << "<namespace-type name='Std'>\n" << xmlOptionalDecl << "</namespace-type>\n" << xmlOptionalIntDecl + << "<typedef-type name='XmlIntOptional' source='Std::Optional<int>'/>" << xmlPostFix; QTest::newRow("namespace-Std") << cpp << xml; @@ -498,6 +500,7 @@ public: QTextStream(&xml) << xmlPrefix << "<object-type name='Outer'>\n" << xmlOptionalDecl << "</object-type>\n" << xmlOptionalIntDecl + << "<typedef-type name='XmlIntOptional' source='Outer::Optional<int>'/>" << xmlPostFix; QTest::newRow("nested-class") << cpp << xml; @@ -523,17 +526,35 @@ void TestTemplates::testTemplateTypeDefs() QVERIFY(optionalInt); QCOMPARE(optionalInt->templateBaseClass(), optional); + // Find the class typedef'ed in the typesystem XML + const AbstractMetaClass *xmlOptionalInt = + AbstractMetaClass::findClass(classes, QLatin1String("XmlIntOptional")); + QVERIFY(xmlOptionalInt); + QCOMPARE(xmlOptionalInt->templateBaseClass(), optional); + // Check whether the value() method now has an 'int' return const AbstractMetaFunction *valueMethod = optionalInt->findFunction(QLatin1String("value")); QVERIFY(valueMethod); QCOMPARE(valueMethod->type()->cppSignature(), QLatin1String("int")); + // ditto for typesystem XML + const AbstractMetaFunction *xmlValueMethod = + xmlOptionalInt->findFunction(QLatin1String("value")); + QVERIFY(xmlValueMethod); + QCOMPARE(xmlValueMethod->type()->cppSignature(), QLatin1String("int")); + // Check whether the m_value field is of type 'int' const AbstractMetaField *valueField = optionalInt->findField(QLatin1String("m_value")); QVERIFY(valueField); QCOMPARE(valueField->type()->cppSignature(), QLatin1String("int")); + + // ditto for typesystem XML + const AbstractMetaField *xmlValueField = + xmlOptionalInt->findField(QLatin1String("m_value")); + QVERIFY(xmlValueField); + QCOMPARE(xmlValueField->type()->cppSignature(), QLatin1String("int")); } QTEST_APPLESS_MAIN(TestTemplates) |