diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-08-15 16:20:39 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:18 -0300 |
commit | 15b355dca205090adf9fe338f02963f945263d98 (patch) | |
tree | 5442a17d63b101adb908faa9295690d626f6d7a2 | |
parent | 26eeabae2ac5f8b449d34bf472b1e506efdf35cd (diff) |
Included the unsigned types in TypeEntry::isCppPrimitive() method list of types.
Also added a test for a typedef of an unsigned numerical type.
-rw-r--r-- | tests/testnumericaltypedef.cpp | 42 | ||||
-rw-r--r-- | tests/testnumericaltypedef.h | 1 | ||||
-rw-r--r-- | typesystem.cpp | 4 |
3 files changed, 46 insertions, 1 deletions
diff --git a/tests/testnumericaltypedef.cpp b/tests/testnumericaltypedef.cpp index c479b8d69..e48796726 100644 --- a/tests/testnumericaltypedef.cpp +++ b/tests/testnumericaltypedef.cpp @@ -66,6 +66,48 @@ void TestNumericalTypedef::testNumericalTypedef() QVERIFY(realType->typeEntry()->isCppPrimitive()); } +void TestNumericalTypedef::testUnsignedNumericalTypedef() +{ + const char* cppCode ="\ + typedef unsigned short ushort;\ + void funcUnsignedShort(unsigned short);\ + void funcUShort(ushort);\ + "; + const char* xmlCode = "\ + <typesystem package='Foo'> \ + <primitive-type name='short' /> \ + <primitive-type name='unsigned short' /> \ + <primitive-type name='ushort' /> \ + <function signature='funcUnsignedShort(unsigned short)' />\ + <function signature='funcUShort(ushort)' />\ + </typesystem>"; + TestUtil t(cppCode, xmlCode, false); + + QCOMPARE(t.builder()->globalFunctions().size(), 2); + const AbstractMetaFunction* funcUnsignedShort = t.builder()->globalFunctions().first(); + QVERIFY(funcUnsignedShort); + const AbstractMetaFunction* funcUShort = t.builder()->globalFunctions().last(); + QVERIFY(funcUShort); + + if (funcUnsignedShort->name() == "funcUShort") + std::swap(funcUnsignedShort, funcUShort); + + QCOMPARE(funcUnsignedShort->minimalSignature(), QString("funcUnsignedShort(unsigned short)")); + QCOMPARE(funcUShort->minimalSignature(), QString("funcUShort(ushort)")); + + const AbstractMetaType* unsignedShortType = funcUnsignedShort->arguments().first()->type(); + QVERIFY(unsignedShortType); + QCOMPARE(unsignedShortType->cppSignature(), QString("unsigned short")); + QVERIFY(unsignedShortType->isPrimitive()); + QVERIFY(unsignedShortType->typeEntry()->isCppPrimitive()); + + const AbstractMetaType* ushortType = funcUShort->arguments().first()->type(); + QVERIFY(ushortType); + QCOMPARE(ushortType->cppSignature(), QString("ushort")); + QVERIFY(ushortType->isPrimitive()); + QVERIFY(ushortType->typeEntry()->isCppPrimitive()); +} + QTEST_APPLESS_MAIN(TestNumericalTypedef) #include "testnumericaltypedef.moc" diff --git a/tests/testnumericaltypedef.h b/tests/testnumericaltypedef.h index ee11e63e2..a1d1bbe59 100644 --- a/tests/testnumericaltypedef.h +++ b/tests/testnumericaltypedef.h @@ -31,6 +31,7 @@ class TestNumericalTypedef : public QObject Q_OBJECT private slots: void testNumericalTypedef(); + void testUnsignedNumericalTypedef(); }; #endif diff --git a/typesystem.cpp b/typesystem.cpp index 0c1eae7c3..8d52e7aaa 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -2138,7 +2138,9 @@ bool TypeEntry::isCppPrimitive() const if (m_name.contains(' ') || m_type == VoidType) return true; // Keep this sorted!! - static const char* cppTypes[] = { "bool", "char", "double", "float", "int", "long", "long long", "short", "wchar_t"}; + static const char* cppTypes[] = { "bool", "char", "double", "float", "int", "long", "long long", "short", + "unsigned char", "unsigned double", "unsigned float", "unsigned int", + "unsigned long", "unsigned long long", "unsigned short", "wchar_t" }; const int N = sizeof(cppTypes)/sizeof(char*); PrimitiveTypeEntry* aliasedType = ((PrimitiveTypeEntry*)this)->basicAliasedTypeEntry(); |