diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-12-20 19:42:14 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:20 -0300 |
commit | c19323bbe798f6e3a5cc4d2714789ede8b025e0d (patch) | |
tree | db3effabf52427c4a43816b7960b2cef14a4009b | |
parent | 470991329c637150eb44a223a9e061a62ea6ce2f (diff) |
AbstractMetaTypes for object types used as values must have the Value usage pattern.
-rw-r--r-- | abstractmetalang.cpp | 16 | ||||
-rw-r--r-- | tests/testabstractmetatype.cpp | 30 | ||||
-rw-r--r-- | tests/testabstractmetatype.h | 1 |
3 files changed, 40 insertions, 7 deletions
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp index 04fec2d8c..fefda5046 100644 --- a/abstractmetalang.cpp +++ b/abstractmetalang.cpp @@ -150,13 +150,15 @@ void AbstractMetaType::decideUsagePattern() } else if (type->isEnum() && !actualIndirections()) { setTypeUsagePattern(AbstractMetaType::EnumPattern); - } else if (type->isObject() - && indirections() == 0 - && isReference()) { - if (((ComplexTypeEntry*) type)->isQObject()) - setTypeUsagePattern(AbstractMetaType::QObjectPattern); - else - setTypeUsagePattern(AbstractMetaType::ObjectPattern); + } else if (type->isObject() && indirections() == 0) { + if (isReference()) { + if (((ComplexTypeEntry*) type)->isQObject()) + setTypeUsagePattern(AbstractMetaType::QObjectPattern); + else + setTypeUsagePattern(AbstractMetaType::ObjectPattern); + } else { + setTypeUsagePattern(AbstractMetaType::ValuePattern); + } } else if (type->isObject() && indirections() == 1) { diff --git a/tests/testabstractmetatype.cpp b/tests/testabstractmetatype.cpp index ed39ebc3b..1e9ce81eb 100644 --- a/tests/testabstractmetatype.cpp +++ b/tests/testabstractmetatype.cpp @@ -171,6 +171,36 @@ void TestAbstractMetaType::testTypedefWithTemplates() QCOMPARE(metaType->cppSignature(), QString("A<B >")); } + +void TestAbstractMetaType::testObjectTypeUsedAsValue() +{ + const char* cppCode ="\ + class A {\ + void method(A);\ + };\ + "; + const char* xmlCode = "<typesystem package='Foo'>\ + <object-type name='A' />\ + </typesystem>"; + TestUtil t(cppCode, xmlCode); + + AbstractMetaClassList classes = t.builder()->classes(); + QCOMPARE(classes.size(), 1); + AbstractMetaClass* classA = classes.findClass("A"); + QVERIFY(classA); + AbstractMetaFunctionList overloads = classA->queryFunctionsByName("method"); + QCOMPARE(overloads.count(), 1); + AbstractMetaFunction* method = overloads.first(); + QVERIFY(method); + AbstractMetaArgumentList args = method->arguments(); + QCOMPARE(args.count(), 1); + AbstractMetaArgument* arg = args.first(); + AbstractMetaType* metaType = arg->type(); + QCOMPARE(metaType->cppSignature(), QString("A")); + QVERIFY(metaType->isValue()); + QVERIFY(metaType->typeEntry()->isObject()); +} + QTEST_APPLESS_MAIN(TestAbstractMetaType) #include "testabstractmetatype.moc" diff --git a/tests/testabstractmetatype.h b/tests/testabstractmetatype.h index e62e05107..f543172cc 100644 --- a/tests/testabstractmetatype.h +++ b/tests/testabstractmetatype.h @@ -36,6 +36,7 @@ private slots: void testTypedefWithTemplates(); void testApiVersionSupported(); void testApiVersionNotSupported(); + void testObjectTypeUsedAsValue(); }; #endif |