From 66ec281ba2b992d9300e5a7f2bf0bb8d1d22ff2d Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Fri, 16 Mar 2012 15:05:48 +0100 Subject: Ensure that moc doesn't resolve the qreal meta-type id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: João Abecasis --- src/tools/moc/generator.cpp | 50 ++++++++++++++++++++++++--------------------- src/tools/moc/generator.h | 1 + 2 files changed, 28 insertions(+), 23 deletions(-) (limited to 'src/tools/moc') 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& 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& 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 &list, const char *functype, int type, int ¶msIndex); void generateFunctionRevisions(const QList& list, const char *functype); void generateFunctionParameters(const QList &list, const char *functype); + void generateTypeInfo(const QByteArray &typeName, bool allowEmptyName = false); void registerEnumStrings(); void generateEnums(int index); void registerPropertyStrings(); -- cgit v1.2.3