From 2bfd1de3495b18c0ecc251260442a9a46009861e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 20 Jul 2018 14:52:21 +0200 Subject: shiboken: Add a typedef typesystem entry The intention is be able to specify typedef std::optional 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 --- .../shiboken2/ApiExtractor/tests/testtemplates.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sources/shiboken2/ApiExtractor/tests/testtemplates.cpp') 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 IntOptional;\n"; QString xml; QTextStream(&xml) << xmlPrefix << xmlOptionalDecl << xmlOptionalIntDecl + << "" << xmlPostFix; QTest::newRow("global-namespace") << cpp << xml; @@ -486,6 +487,7 @@ public: QTextStream(&xml) << xmlPrefix << "\n" << xmlOptionalDecl << "\n" << xmlOptionalIntDecl + << "" << xmlPostFix; QTest::newRow("namespace-Std") << cpp << xml; @@ -498,6 +500,7 @@ public: QTextStream(&xml) << xmlPrefix << "\n" << xmlOptionalDecl << "\n" << xmlOptionalIntDecl + << "" << 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) -- cgit v1.2.3