Get rid of memberAccessorGetter
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Jun 2013 10:52:41 +0000 (12:52 +0200)
committerLars Knoll <lars.knoll@digia.com>
Thu, 13 Jun 2013 12:13:12 +0000 (14:13 +0200)
The new defineAccessorProperty is much simpler, so change v4classgen
to generate that.

Change-Id: I5578ef33c2e1735933ec6f10a23e3a69db9b1984
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v4/qv4functionobject.cpp
src/qml/qml/v4/qv4functionobject_p.h
src/qml/qml/v4/v4classgen

index 604b559..b339805 100644 (file)
@@ -543,34 +543,3 @@ void BoundFunction::markObjects(Managed *that)
             m->mark();
     FunctionObject::markObjects(that);
 }
-
-
-Value MemberAccessorGetterSetter::call(Managed *that, ExecutionContext *context, const Value &thisObject, Value *args, int argc)
-{
-    MemberAccessorGetterSetter *getterSetter = static_cast<MemberAccessorGetterSetter *>(that);
-
-    Object *thisO = thisObject.asObject();
-    if (!thisO || thisO->internalType() != getterSetter->managedType)
-        context->throwTypeError();
-
-    QV4::SimpleCallContext ctx;
-    ctx.initSimpleCallContext(context->engine);
-    ctx.strictMode = true;
-    ctx.thisObject = thisObject;
-    ctx.arguments = args;
-    ctx.argumentCount = argc;
-    context->engine->pushContext(&ctx);
-
-    QV4::Value result = QV4::Value::undefinedValue();
-    try {
-        result = getterSetter->getterSetter(&ctx);
-    } catch (QV4::Exception &ex) {
-        ex.partiallyUnwindContext(context);
-        throw;
-    }
-    context->engine->popContext();
-    return result;
-}
-
-
-DEFINE_MANAGED_VTABLE(MemberAccessorGetterSetter);
index 683112c..0c361bf 100644 (file)
@@ -223,26 +223,6 @@ struct BoundFunction: FunctionObject {
     static bool hasInstance(Managed *that, ExecutionContext *ctx, const Value &value);
 };
 
-class Q_QML_EXPORT MemberAccessorGetterSetter : public FunctionObject
-{
-public:
-    typedef Value (* GetterSetterFunction)(QV4::SimpleCallContext *ctx);
-
-    MemberAccessorGetterSetter(ExecutionContext *scope, GetterSetterFunction getterSetter, int managedType)
-        : FunctionObject(scope)
-        , managedType(managedType)
-    {
-        this->vtbl = &static_vtbl;
-        this->getterSetter = getterSetter;
-    }
-
-    static QV4::Value call(Managed *that, ExecutionContext *context, const QV4::Value &thisObject, QV4::Value *args, int argc);
-protected:
-    GetterSetterFunction getterSetter;
-    const int managedType;
-    static const ManagedVTable static_vtbl;
-};
-
 }
 
 QT_END_NAMESPACE
index 614124f..82d6dbf 100755 (executable)
@@ -84,28 +84,15 @@ class Accessor():
         managedType = "type"
         if len(obj) > 0:
             managedType = obj + "internalType()"
-        out.write("    {\n")
-        out.write("        QV4::FunctionObject *wrappedGetter = 0;\n")
-        out.write("        QV4::FunctionObject *wrappedSetter = 0;\n")
-        out.write("\n")
+
+        getter = "0"
         if self.getter:
-            out.write("        wrappedGetter = new (engine->memoryManager) QV4::MemberAccessorGetterSetter(engine->rootContext, &%s::%s, %s);\n" % (parsedClass.name, self.getter.fullMethodName(), managedType))
+            getter = "%s::%s" % (parsedClass.name, self.getter.fullMethodName())
+        setter = "0"
         if self.setter:
-            out.write("        wrappedSetter = new (engine->memoryManager) QV4::MemberAccessorGetterSetter(engine->rootContext, &%s::%s, %s);\n" % (parsedClass.name, self.setter.fullMethodName(), managedType))
-
-        attributes = ["QV4::Attr_Accessor"];
-
-        if self.getter and "attributes" in self.getter.options:
-            attributes = attributes + [self.getter.options["attributes"]]
-        if self.setter and "attributes" in self.setter.options:
-            attributes = attributes + [self.setter.options["attributes"]]
-
-        out.write("        QV4::PropertyAttributes attrs = %s;\n" % "|".join(attributes))
+            setter = "%s::%s" % (parsedClass.name, self.setter.fullMethodName())
 
-        out.write("        QV4::Property *pd = %sinsertMember(engine->newIdentifier(QStringLiteral(\"%s\")), attrs);\n" % (obj, self.name));
-        out.write("        pd->setGetter(wrappedGetter);\n");
-        out.write("        pd->setSetter(wrappedSetter);\n");
-        out.write("    }\n");
+        out.write("    %sdefineAccessorProperty(engine, QStringLiteral(\"%s\"), %s, %s);\n" % (obj, self.name, getter, setter))
 
 def parseOptions(options):
     options = options.split(" ")