From b0c4e816e6da2c09593cf8de2f563093947ebdaf Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 13 Aug 2012 09:47:43 +0200 Subject: 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 --- src/script/api/qscriptengine.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/script/api') 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(ptr)); case QMetaType::UInt: return JSC::jsNumber(exec, *reinterpret_cast(ptr)); + case QMetaType::Long: + return JSC::jsNumber(exec, *reinterpret_cast(ptr)); + case QMetaType::ULong: + return JSC::jsNumber(exec, *reinterpret_cast(ptr)); case QMetaType::LongLong: return JSC::jsNumber(exec, qsreal(*reinterpret_cast(ptr))); case QMetaType::ULongLong: @@ -3153,6 +3157,12 @@ bool QScriptEnginePrivate::convertValue(JSC::ExecState *exec, JSC::JSValue value case QMetaType::UInt: *reinterpret_cast(ptr) = toUInt32(exec, value); return true; + case QMetaType::Long: + *reinterpret_cast(ptr) = long(toInteger(exec, value)); + return true; + case QMetaType::ULong: + *reinterpret_cast(ptr) = ulong(toInteger(exec, value)); + return true; case QMetaType::LongLong: *reinterpret_cast(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(ptr) = QScript::ToUInt32(value); return true; + case QMetaType::Long: + *reinterpret_cast(ptr) = long(QScript::ToInteger(value)); + return true; + case QMetaType::ULong: + *reinterpret_cast(ptr) = ulong(QScript::ToInteger(value)); + return true; case QMetaType::LongLong: *reinterpret_cast(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(ptr) = QScript::ToUInt32(value); return true; + case QMetaType::Long: + *reinterpret_cast(ptr) = long(QScript::ToInteger(value)); + return true; + case QMetaType::ULong: + *reinterpret_cast(ptr) = ulong(QScript::ToInteger(value)); + return true; case QMetaType::LongLong: *reinterpret_cast(ptr) = qlonglong(QScript::ToInteger(value)); return true; -- cgit v1.2.1