diff options
author | Lars Knoll <[email protected]> | 2013-09-17 22:33:48 +0200 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-09-22 01:06:20 +0200 |
commit | 2d781c4ca42f50643fa37200073a2fb2644b3806 (patch) | |
tree | 9554dbea266f6fbb7820db018e39624b6c0f1353 /src/qml/jsruntime/qv4object.cpp | |
parent | 21198a676128a52e892557bc434035bcd1ddfaac (diff) |
Cleanup ExecutionEngine::newBuiltinFunction() usages
And change the return type to be GC safe
Change-Id: I6d7513962370fea4072a3d8c6b2c6f2d1705992e
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime/qv4object.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 4f7e2966f1..d55c3ad41f 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -234,26 +234,29 @@ void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name, void Object::defineDefaultProperty(ExecutionContext *context, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount) { Q_UNUSED(argumentCount); - String *s = context->engine->newIdentifier(name); - FunctionObject* function = context->engine->newBuiltinFunction(context, s, code); + Scope scope(context); + Scoped<String> s(scope, context->engine->newIdentifier(name)); + Scoped<FunctionObject> function(scope, context->engine->newBuiltinFunction(context, s.getPointer(), code)); function->defineReadonlyProperty(context->engine->id_length, Value::fromInt32(argumentCount)); - defineDefaultProperty(s, Value::fromObject(function)); + defineDefaultProperty(s.getPointer(), function.asValue()); } void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount) { Q_UNUSED(argumentCount); - String *s = engine->newIdentifier(name); - FunctionObject* function = engine->newBuiltinFunction(engine->rootContext, s, code); + Scope scope(engine); + Scoped<String> s(scope, engine->newIdentifier(name)); + Scoped<FunctionObject> function(scope, engine->newBuiltinFunction(engine->rootContext, s.getPointer(), code)); function->defineReadonlyProperty(engine->id_length, Value::fromInt32(argumentCount)); - defineDefaultProperty(s, Value::fromObject(function)); + defineDefaultProperty(s.getPointer(), function.asValue()); } void Object::defineAccessorProperty(ExecutionEngine *engine, const QString &name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *)) { - String *s = engine->newString(name); - defineAccessorProperty(s, getter, setter); + Scope scope(engine); + Scoped<String> s(scope, engine->newIdentifier(name)); + defineAccessorProperty(s.getPointer(), getter, setter); } void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *)) @@ -261,9 +264,9 @@ void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(Simple ExecutionEngine *v4 = engine(); Property *p = insertMember(name, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable); if (getter) - p->setGetter(v4->newBuiltinFunction(v4->rootContext, name, getter)); + p->setGetter(v4->newBuiltinFunction(v4->rootContext, name, getter)->getPointer()); if (setter) - p->setSetter(v4->newBuiltinFunction(v4->rootContext, name, setter)); + p->setSetter(v4->newBuiltinFunction(v4->rootContext, name, setter)->getPointer()); } void Object::defineReadonlyProperty(ExecutionEngine *engine, const QString &name, Value value) |