aboutsummaryrefslogtreecommitdiffstats
path: root/typesystem.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2009-12-15 19:55:10 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2009-12-16 12:29:57 -0300
commitf2fd366c90dd64a37f48e5ea554b8aebf00b6de5 (patch)
treeff48419993f22c42d9d52e58a1e92569a766aa7c /typesystem.cpp
parentcb253eb807d15586a12f5de86fd716286ed3b15d (diff)
Adds normalizedSignature static method to TypeDatabase.
All the uses of QMetaObject::normalizedSignature were replaced to use TypeDatabase::normalizedSignature; the former always changes the unsigned primitives to the shorter versions (e.g. "unsigned int" becomes "uint") that aren't necessarily used by the parsed library. The new normalizer changes back "uNUMBER" to "unsigned NUMBER" if the former is not present in the TypeDatabase. Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Diffstat (limited to 'typesystem.cpp')
-rw-r--r--typesystem.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/typesystem.cpp b/typesystem.cpp
index 74bb6c384..1a5fbffd7 100644
--- a/typesystem.cpp
+++ b/typesystem.cpp
@@ -1293,7 +1293,7 @@ bool Handler::startElement(const QString &, const QString &n,
}
QString signature = attributes["signature"];
- signature = QMetaObject::normalizedSignature(signature.toLocal8Bit().constData());
+ signature = TypeDatabase::normalizedSignature(signature.toLocal8Bit().constData());
if (signature.isEmpty()) {
m_error = "No signature for the added function";
return false;
@@ -1331,7 +1331,7 @@ bool Handler::startElement(const QString &, const QString &n,
}
QString signature = attributes["signature"];
- signature = QMetaObject::normalizedSignature(signature.toLocal8Bit().constData());
+ signature = TypeDatabase::normalizedSignature(signature.toLocal8Bit().constData());
if (signature.isEmpty()) {
m_error = "No signature for modified function";
return false;
@@ -1670,6 +1670,24 @@ TypeDatabase *TypeDatabase::instance(bool newInstance)
return db;
}
+QString TypeDatabase::normalizedSignature(const char* signature)
+{
+ QString normalized = QMetaObject::normalizedSignature(signature);
+
+ if (!instance() || !QString(signature).contains("unsigned"))
+ return normalized;
+
+ QStringList types;
+ types << "char" << "short" << "int" << "long";
+ foreach (const QString& type, types) {
+ if (instance()->findType(QString("u%1").arg(type)))
+ continue;
+ normalized.replace(QRegExp(QString("\\bu%1\\b").arg(type)), QString("unsigned %1").arg(type));
+ }
+
+ return normalized;
+}
+
TypeDatabase::TypeDatabase() : m_suppressWarnings(true)
{
StringTypeEntry* e = new StringTypeEntry("QXmlStreamStringRef");