aboutsummaryrefslogtreecommitdiffstats
path: root/ApiExtractor/tests/testtemplates.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-02-28 16:44:21 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-03-02 12:49:30 +0000
commit8d77d61eef45ccb3200f54e24c057da255edfc63 (patch)
tree20bcb5e0cff198e2bbcb3bbe7b3231f31276937e /ApiExtractor/tests/testtemplates.cpp
parent8ea1045330964d71211ac8e9580858b2b4aac5c7 (diff)
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<T> &) 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<T>) 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 <alexandru.croitor@qt.io>
Diffstat (limited to 'ApiExtractor/tests/testtemplates.cpp')
-rw-r--r--ApiExtractor/tests/testtemplates.cpp33
1 files changed, 33 insertions, 0 deletions
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<int > &"));
}
+void TestTemplates::testTemplateParameterFixup()
+{
+ const char cppCode[] = "\n\
+ template<typename T>\n\
+ struct List {\n\
+ struct Iterator {};\n\
+ void append(List l);\n\
+ void erase(List::Iterator it);\n\
+ };\n";
+
+ const char xmlCode[] = "\n\
+ <typesystem package='Package'>\n\
+ <container-type name='List' type='list'/>\n\
+ <value-type name='List::Iterator'/>\n\
+ </typesystem>\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<T >"
+ const AbstractMetaFunction *append = list->findFunction(QStringLiteral("append"));
+ QVERIFY(append);
+ QCOMPARE(append->arguments().size(), 1);
+ QCOMPARE(append->arguments().at(0)->type()->cppSignature(), QLatin1String("List<T >"));
+ // 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\