diff options
| author | Lars Knoll <lars.knoll@digia.com> | 2013-09-18 09:30:45 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-22 01:06:20 +0200 |
| commit | 055f71f87d5d58be2aafd6c0ef2b84d57ed48b63 (patch) | |
| tree | 71f5f12e997bdcca340309cd5da81aacf0b3731f /src/qml/jsruntime/qv4functionobject.cpp | |
| parent | 2d781c4ca42f50643fa37200073a2fb2644b3806 (diff) | |
Introduce a Referenced<T> class to pass Objects into methods
Added some convenience typedefs (StringRef, ObjectRef, ReturnedString,
ScopedString, ...)
Used StringRef in newBuiltinFunction() for testing.
Cleaned up the duplicated code for thrower functions.
Change-Id: I7b7676690cbe70d9eabb0a5afd0d922f0be3aefd
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index aa94f93461..18bf4ed6b5 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -213,8 +213,6 @@ FunctionCtor::FunctionCtor(ExecutionContext *scope) ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData) { FunctionCtor *f = static_cast<FunctionCtor *>(that); - MemoryManager::GCBlocker gcBlocker(f->engine()->memoryManager); - ExecutionContext *ctx = f->engine()->current; QString arguments; QString body; @@ -365,13 +363,6 @@ ReturnedValue FunctionPrototype::method_bind(SimpleCallContext *ctx) return ctx->engine->newBoundFunction(ctx->engine->rootContext, target.getPointer(), boundThis, boundArgs)->asReturnedValue(); } - -static ReturnedValue throwTypeError(SimpleCallContext *ctx) -{ - ctx->throwTypeError(); - return 0; -} - DEFINE_MANAGED_VTABLE(ScriptFunction); ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) @@ -387,7 +378,7 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) if (!scope) return; - MemoryManager::GCBlocker gcBlocker(scope->engine->memoryManager); + ExecutionEngine *v4 = scope->engine; needsActivation = function->needsActivation(); usesArgumentsObject = function->usesArgumentsObject(); @@ -400,9 +391,7 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) varList = function->locals.constData(); if (scope->strictMode) { - Scope s(scope); - Scoped<FunctionObject> thrower(s, scope->engine->newBuiltinFunction(scope, 0, throwTypeError)); - Property pd = Property::fromAccessor(thrower.getPointer(), thrower.getPointer()); + Property pd = Property::fromAccessor(v4->thrower, v4->thrower); *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd; *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd; } @@ -484,7 +473,7 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu if (!scope) return; - MemoryManager::GCBlocker gcBlocker(scope->engine->memoryManager); + ExecutionEngine *v4 = scope->engine; needsActivation = function->needsActivation(); usesArgumentsObject = function->usesArgumentsObject(); @@ -497,9 +486,7 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu varList = function->locals.constData(); if (scope->strictMode) { - Scope s(scope); - Scoped<FunctionObject> thrower(s, scope->engine->newBuiltinFunction(scope, 0, throwTypeError)); - Property pd = Property::fromAccessor(thrower.getPointer(), thrower.getPointer()); + Property pd = Property::fromAccessor(v4->thrower, v4->thrower); *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd; *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd; } @@ -656,9 +643,9 @@ BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObject *target, Va len = 0; defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(len)); - Scope s(scope); - Scoped<FunctionObject> thrower(s, scope->engine->newBuiltinFunction(scope, 0, throwTypeError)); - Property pd = Property::fromAccessor(thrower.getPointer(), thrower.getPointer()); + ExecutionEngine *v4 = scope->engine; + + Property pd = Property::fromAccessor(v4->thrower, v4->thrower); *insertMember(scope->engine->id_arguments, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd; *insertMember(scope->engine->id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable) = pd; } |
