From 59d60a65b22acf21f62314dd5ab6a047509bb7e4 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 27 Oct 2010 18:15:16 -0200 Subject: Add helper method TypeEntry::isCppPrimitive. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Returns true is the type is a primitive C++ type. Reviewer: Luciano Wolf Renato Araújo --- typesystem.cpp | 16 ++++++++++++++++ typesystem.h | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/typesystem.cpp b/typesystem.cpp index b407f2e0b..3c09524a3 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -2001,6 +2001,22 @@ QString ContainerTypeEntry::typeName() const } } +static bool strLess(const char* a, const char* b) +{ + return ::strcmp(a, b) < 0; +} + +bool TypeEntry::isCppPrimitive() const +{ + if (m_name.contains(' ')) + return true; + // Keep this sorted!! + static const char* cppTypes[] = { "bool", "char", "double", "float", "int", "long", "short", "wchar_t"}; + const int N = sizeof(cppTypes)/sizeof(char*); + + const char** res = qBinaryFind(&cppTypes[0], &cppTypes[N], m_name.toAscii().constData(), strLess); + return res != &cppTypes[N]; +} /* static void injectCode(ComplexTypeEntry *e, diff --git a/typesystem.h b/typesystem.h index 62d041892..6961cbda5 100644 --- a/typesystem.h +++ b/typesystem.h @@ -952,7 +952,7 @@ public: return m_conversionRule.startsWith(TARGET_CONVERSION_RULE_FLAG); } - + bool isCppPrimitive() const; private: QString m_name; Type m_type; -- cgit v1.2.3