diff options
author | Lars Knoll <lars.knoll@digia.com> | 2014-04-29 10:48:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-07-22 13:49:00 +0200 |
commit | c4dee17a32ea4e5737ef20f942442bcadad77829 (patch) | |
tree | 910de6d6491787f9e566d16cc1cb5ff8ff05701a /src | |
parent | 36dd5d597bf126223e3728806cbcf4682301b18f (diff) |
Convert FunctionObject to new storage scheme
Change-Id: Ida213b4684c4d7c4c64e75999cbc87987d9894c8
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 32 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 71 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 2 |
3 files changed, 57 insertions, 48 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index ba73615cc2..36bc22b1e3 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -77,16 +77,16 @@ DEFINE_OBJECT_VTABLE(FunctionObject); FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto) : Object(scope->engine->functionClass) { - data.scope = scope; - data.function = 0; + d()->scope = scope; + d()->function = 0; init(name, createProto); } FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto) : Object(scope->engine->functionClass) { - data.scope = scope; - data.function = 0; + d()->scope = scope; + d()->function = 0; Scope s(scope); ScopedValue protectThis(s, this); @@ -97,8 +97,8 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name) : Object(scope->engine->functionClass) { - data.scope = scope; - data.function = 0; + d()->scope = scope; + d()->function = 0; Scope s(scope); ScopedValue protectThis(s, this); @@ -109,8 +109,8 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name FunctionObject::FunctionObject(InternalClass *ic) : Object(ic) { - data.scope = ic->engine->rootContext; - data.function = 0; + d()->scope = ic->engine->rootContext; + d()->function = 0; managedData()->needsActivation = false; managedData()->strictMode = false; @@ -439,8 +439,8 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu Scope s(scope); ScopedValue protectThis(s, this); - data.function = function; - data.function->compilationUnit->ref(); + d()->function = function; + d()->function->compilationUnit->ref(); Q_ASSERT(function); Q_ASSERT(function->code); @@ -558,7 +558,7 @@ DEFINE_OBJECT_VTABLE(BuiltinFunction); BuiltinFunction::BuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)) : FunctionObject(scope, name) { - data.code = code; + d()->code = code; setVTable(staticVTable()); } @@ -583,7 +583,7 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData) ctx.callData = callData; Q_ASSERT(v4->currentContext() == &ctx); - return f->data.code(&ctx); + return f->d()->code(&ctx); } ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) @@ -602,7 +602,7 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) ctx.callData = callData; Q_ASSERT(v4->currentContext() == &ctx); - return f->data.code(&ctx, f->data.index); + return f->d()->code(&ctx, f->d()->index); } DEFINE_OBJECT_VTABLE(IndexedBuiltinFunction); @@ -612,9 +612,9 @@ DEFINE_OBJECT_VTABLE(BoundFunction); BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const Members &boundArgs) : FunctionObject(scope, QStringLiteral("__bound function__")) { - data.target = target; - data.boundThis = boundThis; - data.boundArgs = boundArgs; + d()->target = target; + d()->boundThis = boundThis; + d()->boundArgs = boundArgs; setVTable(staticVTable()); setSubtype(FunctionObject::BoundFunction); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index f5f8c31c1d..ac61c86213 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -94,7 +94,17 @@ struct InternalClass; struct Lookup; struct Q_QML_EXPORT FunctionObject: Object { - V4_OBJECT + struct Data : Object::Data { + ExecutionContext *scope; + Function *function; + + }; + struct { + ExecutionContext *scope; + Function *function; + + } __data; + V4_OBJECT_NEW Q_MANAGED_TYPE(FunctionObject) enum { IsFunctionObject = true @@ -111,16 +121,9 @@ struct Q_QML_EXPORT FunctionObject: Object { Index_ProtoConstructor = 0 }; - struct Data { - ExecutionContext *scope; - Function *function; - - }; - Data data; - - ExecutionContext *scope() { return data.scope; } - Function *function() { return data.function; } + ExecutionContext *scope() { return d()->scope; } + Function *function() { return d()->function; } ReturnedValue name(); unsigned int formalParameterCount() { return function() ? function()->compiledFunction->nFormals : 0; } @@ -167,7 +170,7 @@ DEFINE_REF(FunctionObject, Object); struct FunctionCtor: FunctionObject { - V4_OBJECT + V4_OBJECT_NEW FunctionCtor(ExecutionContext *scope); static ReturnedValue construct(Managed *that, CallData *callData); @@ -186,11 +189,13 @@ struct FunctionPrototype: FunctionObject }; struct BuiltinFunction: FunctionObject { - V4_OBJECT - struct Data { + struct Data : FunctionObject::Data { ReturnedValue (*code)(CallContext *); }; - Data data; + struct { + ReturnedValue (*code)(CallContext *); + } __data; + V4_OBJECT_NEW BuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(CallContext *)); @@ -200,19 +205,21 @@ struct BuiltinFunction: FunctionObject { struct IndexedBuiltinFunction: FunctionObject { - V4_OBJECT - - struct Data { - ReturnedValue (*code)(CallContext *ctx, uint index); + struct Data : FunctionObject::Data { + ReturnedValue (*code)(CallContext *, uint index); uint index; }; - Data data; + struct { + ReturnedValue (*code)(CallContext *, uint index); + uint index; + } __data; + V4_OBJECT_NEW IndexedBuiltinFunction(ExecutionContext *scope, uint index, ReturnedValue (*code)(CallContext *ctx, uint index)) : FunctionObject(scope) { - data.code = code; - data.index = index; + d()->code = code; + d()->index = index; setVTable(staticVTable()); } @@ -226,7 +233,7 @@ struct IndexedBuiltinFunction: FunctionObject struct SimpleScriptFunction: FunctionObject { - V4_OBJECT + V4_OBJECT_NEW SimpleScriptFunction(ExecutionContext *scope, Function *function, bool createProto); static ReturnedValue construct(Managed *, CallData *callData); @@ -236,7 +243,7 @@ struct SimpleScriptFunction: FunctionObject { }; struct ScriptFunction: SimpleScriptFunction { - V4_OBJECT + V4_OBJECT_NEW ScriptFunction(ExecutionContext *scope, Function *function); static ReturnedValue construct(Managed *, CallData *callData); @@ -245,23 +252,25 @@ struct ScriptFunction: SimpleScriptFunction { struct BoundFunction: FunctionObject { - V4_OBJECT - - struct Data { + struct Data : FunctionObject::Data { FunctionObject *target; Value boundThis; Members boundArgs; }; - Data data; + struct { + FunctionObject *target; + Value boundThis; + Members boundArgs; + } __data; + V4_OBJECT_NEW - FunctionObject *target() { return data.target; } - Value boundThis() const { return data.boundThis; } - Members boundArgs() const { return data.boundArgs; } + FunctionObject *target() { return d()->target; } + Value boundThis() const { return d()->boundThis; } + Members boundArgs() const { return d()->boundArgs; } BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const Members &boundArgs); ~BoundFunction() {} - static ReturnedValue construct(Managed *, CallData *d); static ReturnedValue call(Managed *that, CallData *dd); diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 8a28f834fa..3ef6cfb34f 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -69,7 +69,7 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec Q_ASSERT(scope->inUse()); setVTable(staticVTable()); - data.function = f; + d()->function = f; if (function()) function()->compilationUnit->ref(); managedData()->needsActivation = function() ? function()->needsActivation() : false; |