summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-06-05 11:05:24 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-06-05 12:03:40 (GMT)
commit4acabb3abd0ff109b9abeedb6832f5b1c3e0cc4e (patch)
tree76b183192356a216f9084a938d7f3a87a1f4e262 /src/tools
parentf101435831bb06f342bb0e2241e3011073341617 (diff)
downloadQt-4acabb3abd0ff109b9abeedb6832f5b1c3e0cc4e.zip
Qt-4acabb3abd0ff109b9abeedb6832f5b1c3e0cc4e.tar.gz
Qt-4acabb3abd0ff109b9abeedb6832f5b1c3e0cc4e.tar.bz2
handle qreal properties correctly in the meta-object system
When cross-compiling, it's possible that the size of qreal for moc itself (host platform) is different from the size of qreal on the target platform. Thus, we should not encode the metatype-id of qreal at moc time. Instead, use QMetaType::QReal in the generated code so that the the property flags are only derived at compile time. We also need to support the pesky QT_COORD_TYPE. In this case, qreal can be _any_ type (not just float or double), so we encode the property type as 0 and have a special check in QMetaProperty::type() that resolves the correct type at runtime. Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/generator.cpp20
-rw-r--r--src/tools/moc/outputrevision.h2
2 files changed, 16 insertions, 6 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index e94bb77..e4ad068 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -109,6 +109,14 @@ bool isVariantType(const char* type)
return qvariant_nameToType(type) != 0;
}
+/*!
+ Returns true if the type is qreal.
+*/
+static bool isQRealType(const char *type)
+{
+ return strcmp(type, "qreal") == 0;
+}
+
Generator::Generator(ClassDef *classDef, const QList<QByteArray> &metaTypes, FILE *outfile)
: out(outfile), cdef(classDef), metaTypes(metaTypes)
{
@@ -545,7 +553,7 @@ void Generator::generateProperties()
uint flags = Invalid;
if (!isVariantType(p.type)) {
flags |= EnumOrFlag;
- } else {
+ } else if (!isQRealType(p.type)) {
flags |= qvariant_nameToType(p.type) << 24;
}
if (!p.read.isEmpty())
@@ -589,10 +597,12 @@ void Generator::generateProperties()
if (p.notifyId != -1)
flags |= Notify;
- fprintf(out, " %4d, %4d, 0x%.8x,\n",
- strreg(p.name),
- strreg(p.type),
- flags);
+ fprintf(out, " %4d, %4d, ",
+ strreg(p.name),
+ strreg(p.type));
+ if (!(flags >> 24) && isQRealType(p.type))
+ fprintf(out, "(QMetaType::QReal << 24) | ");
+ fprintf(out, "0x%.8x,\n", flags);
}
if(cdef->notifyableProperties) {
diff --git a/src/tools/moc/outputrevision.h b/src/tools/moc/outputrevision.h
index 1e1d640..f577f6c 100644
--- a/src/tools/moc/outputrevision.h
+++ b/src/tools/moc/outputrevision.h
@@ -43,6 +43,6 @@
#define OUTPUTREVISION_H
// if the output revision changes, you MUST change it in qobjectdefs.h too
-enum { mocOutputRevision = 61 }; // moc format output revision
+enum { mocOutputRevision = 62 }; // moc format output revision
#endif // OUTPUTREVISION_H