OSDN Git Service

get rid of the variantFromValue function in qscriptqobject
authorIvailo Monev <xakepa10@gmail.com>
Sun, 13 Dec 2015 21:37:49 +0000 (23:37 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 13 Dec 2015 21:37:49 +0000 (23:37 +0200)
upstream commits:
0460d63ed03f0de574a06268df2a267d44784cb0 (partitially)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/script/bridge/qscriptqobject.cpp

index d90a75f..3c55da9 100644 (file)
@@ -198,29 +198,6 @@ static inline bool methodNameEquals(const QMetaMethod &method,
         && (otherSignature[nameLength] == '(');
 }
 
-static QVariant variantFromValue(JSC::ExecState *exec, int targetType, JSC::JSValue value)
-{
-    QVariant v(targetType, (void *)0);
-    if (QScriptEnginePrivate::convertValue(exec, value, targetType, v.data()))
-        return v;
-    if (uint(targetType) == QVariant::LastType)
-        return QScriptEnginePrivate::toVariant(exec, value);
-    if (QScriptEnginePrivate::isVariant(value)) {
-        v = QScriptEnginePrivate::variantValue(value);
-        if (v.canConvert(QVariant::Type(targetType))) {
-            v.convert(QVariant::Type(targetType));
-            return v;
-        }
-        QByteArray typeName = v.typeName();
-        if (typeName.endsWith('*')
-            && (QMetaType::type(typeName.left(typeName.size()-1)) == targetType)) {
-            return QVariant(targetType, *reinterpret_cast<void* *>(v.data()));
-        }
-    }
-
-    return QVariant();
-}
-
 static const bool GeneratePropertyFunctions = true;
 
 static unsigned flagsForMetaProperty(const QMetaProperty &prop)
@@ -1113,7 +1090,7 @@ JSC::JSValue QtPropertyFunction::execute(JSC::ExecState *exec,
             // string to enum value
             v = (QString)arg.toString(exec);
         } else {
-            v = variantFromValue(exec, prop.userType(), arg);
+            v = QScriptEnginePrivate::jscValueToVariant(exec, arg, prop.userType());
         }
 
         QScriptable *scriptable = scriptableFromQObject(qobject);