summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-04-08 06:55:57 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-04-08 07:23:00 (GMT)
commit3baf285917e2ea3183866768807f2495010602ab (patch)
tree46b1b25adc1b7e7b988f97fc039c6c048b29d3cd /src/declarative/qml
parent7d82f3875cd26c1cb0ad46ae0a9fddeb87e049d6 (diff)
downloadQt-3baf285917e2ea3183866768807f2495010602ab.zip
Qt-3baf285917e2ea3183866768807f2495010602ab.tar.gz
Qt-3baf285917e2ea3183866768807f2495010602ab.tar.bz2
Improve static assignment to QVariant's in the int and double case
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp19
-rw-r--r--src/declarative/qml/qdeclarativeinstruction.cpp6
-rw-r--r--src/declarative/qml/qdeclarativeinstruction_p.h2
-rw-r--r--src/declarative/qml/qdeclarativestringconverters.cpp4
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp20
5 files changed, 44 insertions, 7 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index e34cd66..d2b2024 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -342,9 +342,22 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
switch(type) {
case -1:
{
- instr.type = QDeclarativeInstruction::StoreVariant;
- instr.storeString.propertyIndex = prop.propertyIndex();
- instr.storeString.value = output->indexForString(string);
+ if (v->value.isNumber()) {
+ double n = v->value.asNumber();
+ if (double(int(n)) == n) {
+ instr.type = QDeclarativeInstruction::StoreVariantInteger;
+ instr.storeInteger.propertyIndex = prop.propertyIndex();
+ instr.storeInteger.value = int(n);
+ } else {
+ instr.type = QDeclarativeInstruction::StoreVariantDouble;
+ instr.storeDouble.propertyIndex = prop.propertyIndex();
+ instr.storeDouble.value = n;
+ }
+ } else {
+ instr.type = QDeclarativeInstruction::StoreVariant;
+ instr.storeString.propertyIndex = prop.propertyIndex();
+ instr.storeString.value = output->indexForString(string);
+ }
}
break;
case QVariant::String:
diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp
index 1f8b8af..d88d06a 100644
--- a/src/declarative/qml/qdeclarativeinstruction.cpp
+++ b/src/declarative/qml/qdeclarativeinstruction.cpp
@@ -130,6 +130,12 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx)
case QDeclarativeInstruction::StoreVariant:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT\t\t" << instr->storeString.propertyIndex << "\t" << instr->storeString.value << "\t\t" << primitives.at(instr->storeString.value);
break;
+ case QDeclarativeInstruction::StoreVariantInteger:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_INTEGER\t\t" << instr->storeInteger.propertyIndex << "\t" << instr->storeInteger.value;
+ break;
+ case QDeclarativeInstruction::StoreVariantDouble:
+ qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_VARIANT_DOUBLE\t\t" << instr->storeDouble.propertyIndex << "\t" << instr->storeDouble.value;
+ break;
case QDeclarativeInstruction::StoreObject:
qWarning().nospace() << idx << "\t\t" << line << "\t" << "STORE_OBJECT\t\t" << instr->storeObject.propertyIndex;
break;
diff --git a/src/declarative/qml/qdeclarativeinstruction_p.h b/src/declarative/qml/qdeclarativeinstruction_p.h
index 1f3c964..e8287c0 100644
--- a/src/declarative/qml/qdeclarativeinstruction_p.h
+++ b/src/declarative/qml/qdeclarativeinstruction_p.h
@@ -114,6 +114,8 @@ public:
StoreRectF, /* storeRect */
StoreVector3D, /* storeVector3D */
StoreVariant, /* storeString */
+ StoreVariantInteger, /* storeInteger */
+ StoreVariantDouble, /* storeDouble */
StoreObject, /* storeObject */
StoreVariantObject, /* storeObject */
StoreInterface, /* storeObject */
diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp
index 5c88b9a..c0f8338 100644
--- a/src/declarative/qml/qdeclarativestringconverters.cpp
+++ b/src/declarative/qml/qdeclarativestringconverters.cpp
@@ -82,10 +82,6 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s)
{
if (s.isEmpty())
return QVariant(s);
- if (s.startsWith(QLatin1Char('\'')) && s.endsWith(QLatin1Char('\''))) {
- QString data = s.mid(1, s.length() - 2);
- return QVariant(data);
- }
bool ok = false;
QRectF r = rectFFromString(s, &ok);
if (ok) return QVariant(r);
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 2d1a549..0addfabd 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -345,6 +345,26 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
}
break;
+ case QDeclarativeInstruction::StoreVariantInteger:
+ {
+ QObject *target = stack.top();
+ QVariant v(instr.storeInteger.value);
+ void *a[] = { &v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
+ case QDeclarativeInstruction::StoreVariantDouble:
+ {
+ QObject *target = stack.top();
+ QVariant v(instr.storeDouble.value);
+ void *a[] = { &v, 0, &status, &flags };
+ QMetaObject::metacall(target, QMetaObject::WriteProperty,
+ instr.storeString.propertyIndex, a);
+ }
+ break;
+
case QDeclarativeInstruction::StoreString:
{
QObject *target = stack.top();