summaryrefslogtreecommitdiffstats
path: root/src/tools/moc
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>2012-02-13 16:26:35 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-02 12:57:29 +0100
commit362bde8e8eef41fc6a338ed8fbe6cbf7e9996019 (patch)
tree96f93a2b19acaba947d13e936f9f6b3cba12d2ff /src/tools/moc
parent2b70a7d25c3e73d02d6d14075790668dcfc16e64 (diff)
Introduce QMetaType::UnknownType.
QMetaType::Void was ambiguous, it was pointing to a valid type (void) and in the same time it was signaling errors in QMetaType. There was no clean way to check if returned type was valid void or some unregistered type. This feature will be used by new QMetaObject revision which will store type ids instead of type names. So it will be easy to distinguish between: void mySlot(); MyUnregisteredType mySlot(); Change-Id: I73ff097f75585a95e12df74d50c6f3141153e771 Reviewed-by: Kent Hansen <kent.hansen@nokia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/tools/moc')
-rw-r--r--src/tools/moc/generator.cpp20
-rw-r--r--src/tools/moc/moc.cpp4
2 files changed, 12 insertions, 12 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 73a0605028..1284518fc5 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -60,7 +60,7 @@ uint nameToBuiltinType(const QByteArray &name)
return 0;
uint tp = QMetaType::type(name.constData());
- return tp < QMetaType::User ? tp : 0;
+ return tp < uint(QMetaType::User) ? tp : QMetaType::UnknownType;
}
/*
@@ -69,7 +69,7 @@ uint nameToBuiltinType(const QByteArray &name)
bool isBuiltinType(const QByteArray &type)
{
int id = QMetaType::type(type.constData());
- if (!id && !type.isEmpty() && type != "void")
+ if (id == QMetaType::UnknownType)
return false;
return (id < QMetaType::User);
}
@@ -632,7 +632,7 @@ void Generator::generateFunctionParameters(const QList<FunctionDef>& list, const
else
fprintf(out, "%4d", type);
} else {
- Q_ASSERT(!typeName.isEmpty());
+ Q_ASSERT(!typeName.isEmpty() || f.isConstructor);
fprintf(out, "0x%.8x | %d", IsUnresolvedType, stridx(typeName));
}
fputc(',', out);
@@ -1097,8 +1097,9 @@ void Generator::generateStaticMetacall()
fprintf(out, " switch (_id) {\n");
for (int methodindex = 0; methodindex < methodList.size(); ++methodindex) {
const FunctionDef &f = methodList.at(methodindex);
+ Q_ASSERT(!f.normalizedType.isEmpty());
fprintf(out, " case %d: ", methodindex);
- if (f.normalizedType.size())
+ if (f.normalizedType != "void")
fprintf(out, "{ %s _r = ", noRef(f.normalizedType).constData());
fprintf(out, "_t->");
if (f.inPrivateClass.size())
@@ -1113,7 +1114,7 @@ void Generator::generateStaticMetacall()
isUsed_a = true;
}
fprintf(out, ");");
- if (f.normalizedType.size()) {
+ if (f.normalizedType != "void") {
fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = _r; } ",
noRef(f.normalizedType).constData());
isUsed_a = true;
@@ -1192,7 +1193,8 @@ void Generator::generateSignal(FunctionDef *def,int index)
constQualifier = "const";
}
- if (def->arguments.isEmpty() && def->normalizedType.isEmpty()) {
+ Q_ASSERT(!def->normalizedType.isEmpty());
+ if (def->arguments.isEmpty() && def->normalizedType == "void") {
fprintf(out, ")%s\n{\n"
" QMetaObject::activate(%s, &staticMetaObject, %d, 0);\n"
"}\n", constQualifier, thisPtr.constData(), index);
@@ -1207,11 +1209,11 @@ void Generator::generateSignal(FunctionDef *def,int index)
fprintf(out, "%s _t%d%s", a.type.name.constData(), offset++, a.rightType.constData());
}
fprintf(out, ")%s\n{\n", constQualifier);
- if (def->type.name.size() && def->normalizedType.size())
+ if (def->type.name.size() && def->normalizedType != "void")
fprintf(out, " %s _t0 = %s();\n", noRef(def->normalizedType).constData(), noRef(def->normalizedType).constData());
fprintf(out, " void *_a[] = { ");
- if (def->normalizedType.isEmpty()) {
+ if (def->normalizedType == "void") {
fprintf(out, "0");
} else {
if (def->returnTypeIsVolatile)
@@ -1227,7 +1229,7 @@ void Generator::generateSignal(FunctionDef *def,int index)
fprintf(out, ", const_cast<void*>(reinterpret_cast<const void*>(&_t%d))", i);
fprintf(out, " };\n");
fprintf(out, " QMetaObject::activate(%s, &staticMetaObject, %d, _a);\n", thisPtr.constData(), index);
- if (def->normalizedType.size())
+ if (def->normalizedType != "void")
fprintf(out, " return _t0;\n");
fprintf(out, "}\n");
}
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 49fc29592d..467f85c599 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -75,9 +75,7 @@ static QByteArray normalizeType(const QByteArray &ba, bool fixScope = false)
}
}
*d = '\0';
- QByteArray result;
- if (strncmp("void", buf, d - buf) != 0)
- result = normalizeTypeInternal(buf, d, fixScope);
+ QByteArray result = normalizeTypeInternal(buf, d, fixScope);
if (buf != stackbuf)
delete [] buf;
return result;