Get rid of subtype usage in Function objects
authorLars Knoll <lars.knoll@theqtcompany.com>
Fri, 9 Jan 2015 12:28:40 +0000 (13:28 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Mon, 12 Jan 2015 10:04:22 +0000 (11:04 +0100)
Change-Id: Ic84ddab292cb69e79dac0f2b8a87b96b096360d8
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4functionobject_p.h
src/qml/jsruntime/qv4qobjectwrapper.cpp
src/qml/jsruntime/qv4runtime.cpp

index 3b0d723..e74acf7 100644 (file)
@@ -206,6 +206,11 @@ bool FunctionObject::isBinding() const
     return d()->internalClass->vtable == QQmlBindingFunction::staticVTable();
 }
 
+bool FunctionObject::isBoundFunction() const
+{
+    return d()->internalClass->vtable == BoundFunction::staticVTable();
+}
+
 DEFINE_OBJECT_VTABLE(FunctionCtor);
 
 Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope)
@@ -623,7 +628,6 @@ Heap::BoundFunction::BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionOb
 {
     this->boundThis = boundThis;
     setVTable(QV4::BoundFunction::staticVTable());
-    subtype = FunctionObject::BoundFunction;
 
     Scope s(scope);
     ScopedObject f(s, this);
index 2ccec8e..e806888 100644 (file)
@@ -45,13 +45,6 @@ namespace QV4 {
 namespace Heap {
 
 struct Q_QML_PRIVATE_EXPORT FunctionObject : Object {
-    // Used with Managed::subType
-    enum FunctionType {
-        RegularFunction = 0,
-        WrappedQtMethod = 1,
-        BoundFunction
-    };
-
     enum {
         Index_Prototype = 0,
         Index_ProtoConstructor = 0
@@ -145,6 +138,7 @@ struct Q_QML_EXPORT FunctionObject: Object {
     bool needsActivation() const { return d()->needsActivation(); }
     bool strictMode() const { return d()->function ? d()->function->isStrict() : false; }
     bool isBinding() const;
+    bool isBoundFunction() const;
 
     static void markObjects(Heap::Base *that, ExecutionEngine *e);
 };
index 149bf24..3f3e499 100644 (file)
@@ -1758,7 +1758,6 @@ Heap::QObjectMethod::QObjectMethod(QV4::ExecutionContext *scope)
     : Heap::FunctionObject(scope)
 {
     setVTable(QV4::QObjectMethod::staticVTable());
-    subtype = WrappedQtMethod;
 }
 
 const QMetaObject *Heap::QObjectMethod::metaObject()
index 7338b8a..61a2fc5 100644 (file)
@@ -318,7 +318,7 @@ QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const ValueRef l
     if (!f)
         return engine->throwTypeError();
 
-    if (f->subtype() == Heap::FunctionObject::BoundFunction)
+    if (f->isBoundFunction())
         f = static_cast<BoundFunction *>(f.getPointer())->target();
 
     ScopedObject v(scope, left->asObject());