summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptengine.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-03-04 09:47:36 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-03-04 09:47:36 (GMT)
commita99fe8624a25f8a09fe9b3234306a4d8b3a3f38e (patch)
tree574351218cdd58a3bae7995ff7b1c5e92698b119 /src/script/api/qscriptengine.cpp
parentc7fec28e7b2f7192c6589c37f3db3e0b4ee85460 (diff)
downloadQt-a99fe8624a25f8a09fe9b3234306a4d8b3a3f38e.zip
Qt-a99fe8624a25f8a09fe9b3234306a4d8b3a3f38e.tar.gz
Qt-a99fe8624a25f8a09fe9b3234306a4d8b3a3f38e.tar.bz2
QScript: Test against QMetaType::QVariant instead of against the string
now that QVariant is known to QMetaType, we can test for the metatype id instead of doing string comparison Reviewed-by: Kent Hansen
Diffstat (limited to 'src/script/api/qscriptengine.cpp')
-rw-r--r--src/script/api/qscriptengine.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 9cd5c63..47c5262 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -2901,6 +2901,9 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const
result = eng->newQObject(*reinterpret_cast<QObject* const *>(ptr));
break;
#endif
+ case QMetaType::QVariant:
+ result = jscValueFromVariant(exec, *reinterpret_cast<const QVariant*>(ptr));
+ break;
default:
if (type == qMetaTypeId<QScriptValue>()) {
result = eng->scriptValueToJSCValue(*reinterpret_cast<const QScriptValue*>(ptr));
@@ -2922,8 +2925,6 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const
else {
QByteArray typeName = QMetaType::typeName(type);
- if (typeName == "QVariant")
- result = jscValueFromVariant(exec, *reinterpret_cast<const QVariant*>(ptr));
if (typeName.endsWith('*') && !*reinterpret_cast<void* const *>(ptr))
return JSC::jsNull();
else
@@ -3046,6 +3047,9 @@ bool QScriptEnginePrivate::convertValue(JSC::ExecState *exec, JSC::JSValue value
*reinterpret_cast<QVariantMap *>(ptr) = variantMapFromObject(exec, value);
return true;
} break;
+ case QMetaType::QVariant:
+ *reinterpret_cast<QVariant*>(ptr) = toVariant(exec, value);
+ return true;
default:
;
}
@@ -3096,9 +3100,6 @@ bool QScriptEnginePrivate::convertValue(JSC::ExecState *exec, JSC::JSValue value
return false;
*reinterpret_cast<QScriptValue*>(ptr) = eng->scriptValueFromJSCValue(value);
return true;
- } else if (name == "QVariant") {
- *reinterpret_cast<QVariant*>(ptr) = toVariant(exec, value);
- return true;
}
// lazy registration of some common list types