summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2012-08-13 09:47:43 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-14 08:29:21 +0200
commitb0c4e816e6da2c09593cf8de2f563093947ebdaf (patch)
tree50659e7b5e8689af5d4a6cf4dd55ff75e54ce36b /src/script/api
parentd1cf1cc364463c196dfc99f04328755a67476569 (diff)
downloadqtscript-b0c4e816e6da2c09593cf8de2f563093947ebdaf.tar.gz
Add default conversion for types long and ulong
Such conversion is not guaranteed to be lossless on all platforms, but it's still reasonable to support these types by default. JSC::JSValue already had constructors for them. The type matching / overload resolution in the QObject binding already handled long and ulong, but the value conversion itself was missing, for some reason. Task-number: QTBUG-2124 Change-Id: I14ff29a8e949403234b7659c0aca8b48bcdbda0e Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/qscriptengine.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index d8eaf3f..5dc4e2d 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -3046,6 +3046,10 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const
return JSC::jsNumber(exec, *reinterpret_cast<const int*>(ptr));
case QMetaType::UInt:
return JSC::jsNumber(exec, *reinterpret_cast<const uint*>(ptr));
+ case QMetaType::Long:
+ return JSC::jsNumber(exec, *reinterpret_cast<const long*>(ptr));
+ case QMetaType::ULong:
+ return JSC::jsNumber(exec, *reinterpret_cast<const ulong*>(ptr));
case QMetaType::LongLong:
return JSC::jsNumber(exec, qsreal(*reinterpret_cast<const qlonglong*>(ptr)));
case QMetaType::ULongLong:
@@ -3153,6 +3157,12 @@ bool QScriptEnginePrivate::convertValue(JSC::ExecState *exec, JSC::JSValue value
case QMetaType::UInt:
*reinterpret_cast<uint*>(ptr) = toUInt32(exec, value);
return true;
+ case QMetaType::Long:
+ *reinterpret_cast<long*>(ptr) = long(toInteger(exec, value));
+ return true;
+ case QMetaType::ULong:
+ *reinterpret_cast<ulong*>(ptr) = ulong(toInteger(exec, value));
+ return true;
case QMetaType::LongLong:
*reinterpret_cast<qlonglong*>(ptr) = qlonglong(toInteger(exec, value));
return true;
@@ -3330,6 +3340,12 @@ bool QScriptEnginePrivate::convertNumber(qsreal value, int type, void *ptr)
case QMetaType::UInt:
*reinterpret_cast<uint*>(ptr) = QScript::ToUInt32(value);
return true;
+ case QMetaType::Long:
+ *reinterpret_cast<long*>(ptr) = long(QScript::ToInteger(value));
+ return true;
+ case QMetaType::ULong:
+ *reinterpret_cast<ulong*>(ptr) = ulong(QScript::ToInteger(value));
+ return true;
case QMetaType::LongLong:
*reinterpret_cast<qlonglong*>(ptr) = qlonglong(QScript::ToInteger(value));
return true;
@@ -3378,6 +3394,12 @@ bool QScriptEnginePrivate::convertString(const QString &value, int type, void *p
case QMetaType::UInt:
*reinterpret_cast<uint*>(ptr) = QScript::ToUInt32(value);
return true;
+ case QMetaType::Long:
+ *reinterpret_cast<long*>(ptr) = long(QScript::ToInteger(value));
+ return true;
+ case QMetaType::ULong:
+ *reinterpret_cast<ulong*>(ptr) = ulong(QScript::ToInteger(value));
+ return true;
case QMetaType::LongLong:
*reinterpret_cast<qlonglong*>(ptr) = qlonglong(QScript::ToInteger(value));
return true;