From 8d77d61eef45ccb3200f54e24c057da255edfc63 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 28 Feb 2017 16:44:21 +0100 Subject: Fix and refactor _fixFunctionModelItemTypes() For template classes, the function was supposed to add the template parameters to the arguments and return types that take the class itself, for example: QList(const QList &) -> QList(const QList &) In the old implementation, it checked only on the first part of the type's qualified name, causing void QList::erase(QList::iterator) -> void QList::erase(QList) Rewrite the function to operate with QStringLists so that a full match can be performed. Task-number: PYSIDE-323 Change-Id: I27900916e864d9451cc588c3ade311fbb033665c Reviewed-by: Alexandru Croitor --- ApiExtractor/tests/testtemplates.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'ApiExtractor/tests/testtemplates.cpp') diff --git a/ApiExtractor/tests/testtemplates.cpp b/ApiExtractor/tests/testtemplates.cpp index 01cd08804..73bf6407c 100644 --- a/ApiExtractor/tests/testtemplates.cpp +++ b/ApiExtractor/tests/testtemplates.cpp @@ -192,6 +192,39 @@ void TestTemplates::testTemplateReferenceAsArgument() QCOMPARE(func->arguments().first()->type()->cppSignature(), QLatin1String("List &")); } +void TestTemplates::testTemplateParameterFixup() +{ + const char cppCode[] = "\n\ + template\n\ + struct List {\n\ + struct Iterator {};\n\ + void append(List l);\n\ + void erase(List::Iterator it);\n\ + };\n"; + + const char xmlCode[] = "\n\ + \n\ + \n\ + \n\ + \n"; + + TestUtil t(cppCode, xmlCode, false); + const AbstractMetaClassList templates = t.builder()->templates(); + + QCOMPARE(templates.count(), 1); + const AbstractMetaClass *list = templates.first(); + // Verify that the parameter of "void append(List l)" gets fixed to "List" + const AbstractMetaFunction *append = list->findFunction(QStringLiteral("append")); + QVERIFY(append); + QCOMPARE(append->arguments().size(), 1); + QCOMPARE(append->arguments().at(0)->type()->cppSignature(), QLatin1String("List")); + // Verify that the parameter of "void erase(Iterator)" is not modified + const AbstractMetaFunction *erase = list->findFunction(QStringLiteral("erase")); + QVERIFY(erase); + QCOMPARE(erase->arguments().size(), 1); + QCOMPARE(erase->arguments().at(0)->type()->cppSignature(), QLatin1String("List::Iterator")); +} + void TestTemplates::testInheritanceFromContainterTemplate() { const char cppCode[] = "\n\ -- cgit v1.2.3