aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-10-27 18:15:16 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:12 -0300
commit59d60a65b22acf21f62314dd5ab6a047509bb7e4 (patch)
treea8cefdbad2b2803982162266deeee313b046659c
parente5ecbe66d2f1ccfe8c80d58e3e66f4344f3e5505 (diff)
Add helper method TypeEntry::isCppPrimitive.
Returns true is the type is a primitive C++ type. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
-rw-r--r--typesystem.cpp16
-rw-r--r--typesystem.h2
2 files changed, 17 insertions, 1 deletions
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;