aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--abstractmetalang.cpp4
-rw-r--r--typesystem.cpp22
-rw-r--r--typesystem.h2
3 files changed, 24 insertions, 4 deletions
diff --git a/abstractmetalang.cpp b/abstractmetalang.cpp
index 13942f769..db6e1b3e6 100644
--- a/abstractmetalang.cpp
+++ b/abstractmetalang.cpp
@@ -305,7 +305,7 @@ QStringList AbstractMetaFunction::introspectionCompatibleSignatures(const QStrin
{
AbstractMetaArgumentList arguments = this->arguments();
if (arguments.size() == resolvedArguments.size()) {
- return (QStringList() << QMetaObject::normalizedSignature((name() + "(" + resolvedArguments.join(",") + ")").toUtf8().constData()));
+ return (QStringList() << TypeDatabase::normalizedSignature((name() + "(" + resolvedArguments.join(",") + ")").toUtf8().constData()));
} else {
QStringList returned;
@@ -669,7 +669,7 @@ QString AbstractMetaFunction::minimalSignature() const
if (isConstant())
minimalSignature += "const";
- minimalSignature = QMetaObject::normalizedSignature(minimalSignature.toLocal8Bit().constData());
+ minimalSignature = TypeDatabase::normalizedSignature(minimalSignature.toLocal8Bit().constData());
m_cachedMinimalSignature = minimalSignature;
return minimalSignature;
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");
diff --git a/typesystem.h b/typesystem.h
index 2c9be3e31..28a3cb85f 100644
--- a/typesystem.h
+++ b/typesystem.h
@@ -1754,6 +1754,8 @@ public:
*/
static TypeDatabase *instance(bool newInstance = false);
+ static QString normalizedSignature(const char* signature);
+
QStringList requiredTargetImports()
{
return m_requiredTargetImports;