summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-06-09 01:16:41 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-06-09 01:16:41 (GMT)
commit991b41aa407b5a8740e6899a3efdc724276dcb95 (patch)
tree09704bd06a87731269f9571abd9943e010923853
parentef4378dd282ed51098d1366792e46e9cfbde727a (diff)
downloadQt-991b41aa407b5a8740e6899a3efdc724276dcb95.zip
Qt-991b41aa407b5a8740e6899a3efdc724276dcb95.tar.gz
Qt-991b41aa407b5a8740e6899a3efdc724276dcb95.tar.bz2
Fix handling of qreal properties.
This is to bring us in line with the fix made to moc's handling of qreal properties.
-rw-r--r--src/declarative/qml/qmlbasicscript.cpp14
-rw-r--r--src/declarative/qml/qmlcompiler.cpp24
-rw-r--r--src/declarative/qml/qmlinstruction.cpp7
-rw-r--r--src/declarative/qml/qmlinstruction_p.h14
-rw-r--r--src/declarative/qml/qmlvme.cpp26
5 files changed, 59 insertions, 26 deletions
diff --git a/src/declarative/qml/qmlbasicscript.cpp b/src/declarative/qml/qmlbasicscript.cpp
index 3d74b37..7bd898c 100644
--- a/src/declarative/qml/qmlbasicscript.cpp
+++ b/src/declarative/qml/qmlbasicscript.cpp
@@ -117,25 +117,25 @@ void QmlBasicScriptNodeCache::clear()
static QVariant toObjectOrVariant(const QVariant &v)
{
- switch(v.type()) {
+ switch(v.userType()) {
case QVariant::String:
case QVariant::UInt:
case QVariant::Int:
- case 135:
+ case QMetaType::Float:
case QVariant::Double:
case QVariant::Color:
case QVariant::Bool:
default:
- return v;
- case QVariant::UserType:
- {
+ {
+ if (v.type() == QVariant::UserType) {
QObject *o = QmlMetaType::toQObject(v);
if (o)
return qVariantFromValue(o);
else
return v;
}
- break;
+ return v;
+ }
}
}
@@ -166,7 +166,7 @@ static QVariant fetch_value(QObject *o, int idx, int type)
return QVariant(val);
}
break;
- case 135:
+ case QMetaType::Float:
{
float val;
void *args[] = { &val, 0 };
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 46695b7..b28d7dd 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -262,7 +262,7 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
instr.storeInteger.value = value;
return true;
}
- int type = prop.type();
+ int type = prop.userType();
switch(type) {
case -1:
{
@@ -300,16 +300,26 @@ bool QmlCompiler::compileStoreInstruction(QmlInstruction &instr,
instr.storeInteger.value = value;
}
break;
- case 135:
- case QVariant::Double:
+ case QMetaType::Float:
{
- instr.type = QmlInstruction::StoreReal;
- instr.storeReal.propertyIndex = prop.propertyIndex();
+ instr.type = QmlInstruction::StoreFloat;
+ instr.storeFloat.propertyIndex = prop.propertyIndex();
bool ok;
float value = string.toFloat(&ok);
if (!ok)
- COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to real number");
- instr.storeReal.value = value;
+ COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to float number");
+ instr.storeFloat.value = value;
+ }
+ break;
+ case QVariant::Double:
+ {
+ instr.type = QmlInstruction::StoreDouble;
+ instr.storeDouble.propertyIndex = prop.propertyIndex();
+ bool ok;
+ double value = string.toDouble(&ok);
+ if (!ok)
+ COMPILE_EXCEPTION2(v, "Cannot convert value" << string << "to double number");
+ instr.storeDouble.value = value;
}
break;
case QVariant::Color:
diff --git a/src/declarative/qml/qmlinstruction.cpp b/src/declarative/qml/qmlinstruction.cpp
index 0aa860d..af1489a 100644
--- a/src/declarative/qml/qmlinstruction.cpp
+++ b/src/declarative/qml/qmlinstruction.cpp
@@ -70,8 +70,11 @@ void QmlCompiledComponent::dump(QmlInstruction *instr, int idx)
case QmlInstruction::StoreMetaObject:
qWarning() << idx << "\t" << line << "\t" << "STORE_META\t\t" << instr->storeMeta.data << "\t" << instr->storeMeta.slotData;
break;
- case QmlInstruction::StoreReal:
- qWarning() << idx << "\t" << line << "\t" << "STORE_REAL\t\t" << instr->storeReal.propertyIndex << "\t" << instr->storeReal.value;
+ case QmlInstruction::StoreFloat:
+ qWarning() << idx << "\t" << line << "\t" << "STORE_FLOAT\t\t" << instr->storeFloat.propertyIndex << "\t" << instr->storeFloat.value;
+ break;
+ case QmlInstruction::StoreDouble:
+ qWarning() << idx << "\t" << line << "\t" << "STORE_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
break;
case QmlInstruction::StoreInteger:
qWarning() << idx << "\t" << line << "\t" << "STORE_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
diff --git a/src/declarative/qml/qmlinstruction_p.h b/src/declarative/qml/qmlinstruction_p.h
index 5c6fa5a..5a1729f 100644
--- a/src/declarative/qml/qmlinstruction_p.h
+++ b/src/declarative/qml/qmlinstruction_p.h
@@ -71,7 +71,8 @@ public:
//
// Precomputed single assignment
//
- // StoreReal - Store a qreal in a core property
+ // StoreFloat - Store a float in a core property
+ // StoreDouble - Store a double in a core property
// StoreInteger - Store a int or uint in a core property
// StoreBool - Store a bool in a core property
// StoreString - Store a QString in a core property
@@ -82,14 +83,15 @@ public:
// StoreVariant - Store a QVariant in a core property
// StoreObject - Pop the object on the top of the object stack and
// store it in a core property
- StoreReal, /* storeReal */
+ StoreFloat, /* storeFloat */
+ StoreDouble, /* storeDouble */
StoreInteger, /* storeInteger */
StoreBool, /* storeBool */
StoreString, /* storeString */
StoreColor, /* storeColor */
StoreDate, /* storeDate */
StoreTime, /* storeTime */
- StoreDateTime, /* storeDateTime */
+ StoreDateTime, /* storeDateTime */
StorePoint, /* storeRealPair */
StorePointF, /* storeRealPair */
StoreSize, /* storeRealPair */
@@ -196,7 +198,11 @@ public:
struct {
int propertyIndex;
float value;
- } storeReal;
+ } storeFloat;
+ struct {
+ int propertyIndex;
+ double value;
+ } storeDouble;
struct {
int propertyIndex;
int value;
diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp
index 3c13b38..f00d282 100644
--- a/src/declarative/qml/qmlvme.cpp
+++ b/src/declarative/qml/qmlvme.cpp
@@ -337,17 +337,31 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
}
break;
- case QmlInstruction::StoreReal:
+ case QmlInstruction::StoreFloat:
{
#ifdef Q_ENABLE_PERFORMANCE_LOG
QFxCompilerTimer<QFxCompiler::InstrStoreReal> cc;
#endif
QObject *target = stack.top();
- qreal r = instr.storeReal.value;
+ float f = instr.storeFloat.value;
void *a[1];
- a[0] = &r;
- QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeReal.propertyIndex, a);
+ a[0] = &f;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeFloat.propertyIndex, a);
+ }
+ break;
+
+case QmlInstruction::StoreDouble:
+ {
+#ifdef Q_ENABLE_PERFORMANCE_LOG
+ QFxCompilerTimer<QFxCompiler::InstrStoreReal> cc;
+#endif
+ QObject *target = stack.top();
+ double d = instr.storeDouble.value;
+ void *a[1];
+ a[0] = &d;
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeDouble.propertyIndex, a);
}
break;
@@ -373,7 +387,7 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in
void *a[1];
a[0] = (void *)&instr.storeInteger.value;
QMetaObject::metacall(target, QMetaObject::WriteProperty,
- instr.storeReal.propertyIndex, a);
+ instr.storeInteger.propertyIndex, a);
}
break;