From 15b355dca205090adf9fe338f02963f945263d98 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 15 Aug 2011 16:20:39 -0300 Subject: Included the unsigned types in TypeEntry::isCppPrimitive() method list of types. Also added a test for a typedef of an unsigned numerical type. --- tests/testnumericaltypedef.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ tests/testnumericaltypedef.h | 1 + typesystem.cpp | 4 +++- 3 files changed, 46 insertions(+), 1 deletion(-) 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 = "\ + \ + \ + \ + \ + \ + \ + "; + 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(); -- cgit v1.2.3