Fix QJSValue::toVariant and isVariant
authorLars Knoll <lars.knoll@digia.com>
Mon, 13 May 2013 16:30:16 +0000 (18:30 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Fri, 17 May 2013 21:49:52 +0000 (23:49 +0200)
Change-Id: I7360e37e34756e26f3e8936751c6b65a9d0a2167
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/qml/v8/qjsvalue.cpp
src/qml/qml/v8/qv8variantwrapper_p.h

index 293e32f..8705a41 100644 (file)
@@ -51,6 +51,7 @@
 #include "qv4dateobject_p.h"
 #include "qv4runtime_p.h"
 #include "qv4v8_p.h"
+#include "qv8variantwrapper_p.h"
 
 /*!
   \since 5.0
@@ -317,8 +318,11 @@ bool QJSValue::isCallable() const
 */
 bool QJSValue::isVariant() const
 {
-    // ###
-    return false;
+    QV4::ExecutionEngine *e = d->engine();
+    if (!e)
+        return false;
+
+    return QV8VariantWrapper::isVariant(d->value);
 }
 
 /*!
@@ -458,8 +462,7 @@ quint32 QJSValue::toUInt() const
 */
 QVariant QJSValue::toVariant() const
 {
-    // ###
-    return QVariant();
+    return QV8VariantWrapper::toVariant(d->value);
 }
 
 /*!
index 2615fd1..b1b515e 100644 (file)
@@ -73,7 +73,7 @@ public:
     void destroy();
 
     v8::Handle<v8::Object> newVariant(const QVariant &);
-    bool isVariant(v8::Handle<v8::Value>);
+    static bool isVariant(v8::Handle<v8::Value>);
     static QVariant toVariant(v8::Handle<v8::Object>);
     static QVariant toVariant(QV8ObjectResource *);
     QVariant &variantValue(v8::Handle<v8::Value>);