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);
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
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(" ")