From f12e470665c66101baf3a52fca0737b5102d5420 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Wed, 19 Oct 2011 14:27:36 -0300 Subject: Fixes setting of template argument's usage pattern. Comes with an unit test. Reviewed by Hugo Parente Reviewed by Luciano Wolf --- abstractmetabuilder.cpp | 1 + tests/testcontainer.cpp | 42 +++++++++++++++++++++++++++++++++++++++++- tests/testcontainer.h | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp index c3ebe3b07..9d55c49d3 100644 --- a/abstractmetabuilder.cpp +++ b/abstractmetabuilder.cpp @@ -2538,6 +2538,7 @@ bool AbstractMetaBuilder::inheritTemplate(AbstractMetaClass* subclass, temporaryType->setConstant(i.is_constant); temporaryType->setReference(i.is_reference); temporaryType->setIndirections(i.indirections); + temporaryType->decideUsagePattern(); templateTypes << temporaryType; } else { ReportHandler::warning("Ignoring template parameter " + templateParamName + " from " + info.instantiationName() + ", because I don't know what it is."); diff --git a/tests/testcontainer.cpp b/tests/testcontainer.cpp index 563b75c20..3d31f8a61 100644 --- a/tests/testcontainer.cpp +++ b/tests/testcontainer.cpp @@ -38,7 +38,7 @@ void TestContainer::testContainerType() };\ "; const char* xmlCode = "\ - \ + \ \ \ \ @@ -54,6 +54,46 @@ void TestContainer::testContainerType() QCOMPARE(reinterpret_cast(classA->typeEntry()->baseContainerType())->type(), ContainerTypeEntry::ListContainer); } +void TestContainer::testListOfValueType() +{ + const char* cppCode ="\ + namespace std {\ + template\ + class list { \ + T get(int x) { return 0; }\ + };\ + }\ + class ValueType {};\ + class A : public std::list {\ + };\ + "; + const char* xmlCode = "\ + \ + \ + \ + \ + \ + "; + + TestUtil t(cppCode, xmlCode, true); + AbstractMetaClassList classes = t.builder()->classes(); + QCOMPARE(classes.count(), 3); + + AbstractMetaClass* classA = classes.findClass("A"); + QVERIFY(classA); + QCOMPARE(classA->templateBaseClassInstantiations().count(), 1); + const AbstractMetaType* templateInstanceType = classA->templateBaseClassInstantiations().first(); + QVERIFY(templateInstanceType); + + QCOMPARE(templateInstanceType->indirections(), 0); + QVERIFY(!templateInstanceType->typeEntry()->isObject()); + QVERIFY(templateInstanceType->typeEntry()->isValue()); + QVERIFY(!templateInstanceType->isReference()); + QVERIFY(!templateInstanceType->isObject()); + QVERIFY(!templateInstanceType->isValuePointer()); + QVERIFY(templateInstanceType->isValue()); +} + QTEST_APPLESS_MAIN(TestContainer) #include "testcontainer.moc" diff --git a/tests/testcontainer.h b/tests/testcontainer.h index d760c5a68..22e47eeba 100644 --- a/tests/testcontainer.h +++ b/tests/testcontainer.h @@ -30,6 +30,7 @@ class TestContainer : public QObject Q_OBJECT private slots: void testContainerType(); + void testListOfValueType(); }; #endif -- cgit v1.2.3