Get rid of Value::fromManaged()
authorLars Knoll <lars.knoll@theqtcompany.com>
Fri, 13 Feb 2015 08:30:11 +0000 (09:30 +0100)
committerLars Knoll <lars.knoll@digia.com>
Fri, 20 Mar 2015 11:16:59 +0000 (11:16 +0000)
Change-Id: Ifb889e4b270dee8350a9c8f7559c671413995e4b
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/jsruntime/qv4managed_p.h
src/qml/jsruntime/qv4property_p.h
src/qml/jsruntime/qv4value_p.h

index ac7d06a..5a4f305 100644 (file)
@@ -257,13 +257,6 @@ inline FunctionObject *managed_cast(Managed *m)
     return m ? m->asFunctionObject() : 0;
 }
 
-inline Value Value::fromManaged(Managed *m)
-{
-    if (!m)
-        return QV4::Primitive::undefinedValue();
-    return *m;
-}
-
 }
 
 
index 94167ca..34d9cda 100644 (file)
@@ -72,8 +72,8 @@ struct Property {
 
     inline Heap::FunctionObject *getter() const { return value.isManaged() ? reinterpret_cast<Heap::FunctionObject *>(value.heapObject()) : 0; }
     inline Heap::FunctionObject *setter() const { return set.isManaged() ? reinterpret_cast<Heap::FunctionObject *>(set.heapObject()) : 0; }
-    inline void setGetter(FunctionObject *g) { value = Primitive::fromManaged(reinterpret_cast<Managed *>(g)); }
-    inline void setSetter(FunctionObject *s) { set = s ? Primitive::fromManaged(reinterpret_cast<Managed *>(s)) : Value::fromHeapObject(0); }
+    inline void setGetter(FunctionObject *g) { value = reinterpret_cast<Managed *>(g); }
+    inline void setSetter(FunctionObject *s) { set = (s ? reinterpret_cast<Managed *>(s) : 0); }
 
     void copy(const Property *other, PropertyAttributes attrs) {
         value = other->value;
@@ -84,8 +84,8 @@ struct Property {
     explicit Property()  { value = Encode::undefined(); set = Value::fromHeapObject(0); }
     explicit Property(Value v) : value(v) { set = Value::fromHeapObject(0); }
     Property(FunctionObject *getter, FunctionObject *setter) {
-        value = Primitive::fromManaged(reinterpret_cast<Managed *>(getter));
-        set = Primitive::fromManaged(reinterpret_cast<Managed *>(setter));
+        value = reinterpret_cast<Managed *>(getter);
+        set = reinterpret_cast<Managed *>(setter);
     }
     Property(Heap::FunctionObject *getter, Heap::FunctionObject *setter) {
         value.m = reinterpret_cast<Heap::Base *>(getter);
index 194b0ec..71ffae4 100644 (file)
@@ -282,8 +282,6 @@ struct Q_QML_PRIVATE_EXPORT Value
         return v;
     }
 
-    static inline Value fromManaged(Managed *m);
-
     int toUInt16() const;
     inline int toInt32() const;
     inline unsigned int toUInt32() const;
@@ -337,7 +335,12 @@ struct Q_QML_PRIVATE_EXPORT Value
     Value &operator =(const ScopedValue &v);
     Value &operator=(ReturnedValue v) { val = v; return *this; }
     Value &operator=(Managed *m) {
-        val = Value::fromManaged(m).val;
+        if (!m) {
+            tag = Undefined_Type;
+            uint_32 = 0;
+        } else {
+            val = reinterpret_cast<Value *>(m)->val;
+        }
         return *this;
     }
     Value &operator=(Heap::Base *o) {