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
f95181c7bb
(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>
This commit is contained in:
parent
b20cbf7102
commit
66ec281ba2
@ -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);
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ private:
|
||||
void generateFunctions(const QList<FunctionDef> &list, const char *functype, int type, int ¶msIndex);
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user