summaryrefslogtreecommitdiffstats
path: root/src/tools/moc
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-03-16 15:05:48 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-18 21:05:59 +0100
commit66ec281ba2b992d9300e5a7f2bf0bb8d1d22ff2d (patch)
tree6c407d77ee8666283497144a18e91f717bbf9efc /src/tools/moc
parentb20cbf7102c62c8c769ed1d1b0c4949e603a7a4c (diff)
Ensure that moc doesn't resolve the qreal meta-type id
When cross-compiling, the qreal type can be different on the target than on the host (e.g. double on host, and float on target). moc is a host binary, so it shouldn't try to resolve the type id of qreal, but instead always output "QMetaType::QReal" (which is just an alias for QMetaType::Double or QMetaType::Float, depending on the target). This was a regression introduced in commit f95181c7bb340744a0ce172e8c5a8fcdc2543297 (new meta-object format); the special-casing for qreal should have been kept. Moved the code that generates the type info into its own function so the logic is shared by generateFunctions() and generateProperties(). Change-Id: I2b76cf063a08ba95a7e6033549452355f67283ac Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
Diffstat (limited to 'src/tools/moc')
-rw-r--r--src/tools/moc/generator.cpp50
-rw-r--r--src/tools/moc/generator.h1
2 files changed, 28 insertions, 23 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index afd4cfe601..71df7e7579 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -624,17 +624,7 @@ void Generator::generateFunctionParameters(const QList<FunctionDef>& list, const
if (j > -1)
fputc(' ', out);
const QByteArray &typeName = (j < 0) ? f.normalizedType : f.arguments.at(j).normalizedType;
- if (isBuiltinType(typeName)) {
- int type = nameToBuiltinType(typeName);
- const char *valueString = metaTypeEnumValueString(type);
- if (valueString)
- fprintf(out, "QMetaType::%s", valueString);
- else
- fprintf(out, "%4d", type);
- } else {
- Q_ASSERT(!typeName.isEmpty() || f.isConstructor);
- fprintf(out, "0x%.8x | %d", IsUnresolvedType, stridx(typeName));
- }
+ generateTypeInfo(typeName, /*allowEmptyName=*/f.isConstructor);
fputc(',', out);
}
@@ -648,6 +638,31 @@ void Generator::generateFunctionParameters(const QList<FunctionDef>& list, const
}
}
+void Generator::generateTypeInfo(const QByteArray &typeName, bool allowEmptyName)
+{
+ Q_UNUSED(allowEmptyName);
+ if (isBuiltinType(typeName)) {
+ int type;
+ const char *valueString;
+ if (typeName == "qreal") {
+ type = QMetaType::UnknownType;
+ valueString = "QReal";
+ } else {
+ type = nameToBuiltinType(typeName);
+ valueString = metaTypeEnumValueString(type);
+ }
+ if (valueString) {
+ fprintf(out, "QMetaType::%s", valueString);
+ } else {
+ Q_ASSERT(type != QMetaType::UnknownType);
+ fprintf(out, "%4d", type);
+ }
+ } else {
+ Q_ASSERT(!typeName.isEmpty() || allowEmptyName);
+ fprintf(out, "0x%.8x | %d", IsUnresolvedType, stridx(typeName));
+ }
+}
+
void Generator::registerPropertyStrings()
{
for (int i = 0; i < cdef->propertyList.count(); ++i) {
@@ -721,18 +736,7 @@ void Generator::generateProperties()
flags |= Final;
fprintf(out, " %4d, ", stridx(p.name));
-
- if (isBuiltinType(p.type)) {
- int type = nameToBuiltinType(p.type);
- const char *valueString = metaTypeEnumValueString(type);
- if (valueString)
- fprintf(out, "QMetaType::%s", valueString);
- else
- fprintf(out, "%4d", type);
- } else {
- fprintf(out, "0x%.8x | %d", IsUnresolvedType, stridx(p.type));
- }
-
+ generateTypeInfo(p.type);
fprintf(out, ", 0x%.8x,\n", flags);
}
diff --git a/src/tools/moc/generator.h b/src/tools/moc/generator.h
index c85d24fd15..8ebc00b100 100644
--- a/src/tools/moc/generator.h
+++ b/src/tools/moc/generator.h
@@ -61,6 +61,7 @@ private:
void generateFunctions(const QList<FunctionDef> &list, const char *functype, int type, int &paramsIndex);
void generateFunctionRevisions(const QList<FunctionDef>& list, const char *functype);
void generateFunctionParameters(const QList<FunctionDef> &list, const char *functype);
+ void generateTypeInfo(const QByteArray &typeName, bool allowEmptyName = false);
void registerEnumStrings();
void generateEnums(int index);
void registerPropertyStrings();