aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4object.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-18 09:30:45 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 01:06:20 +0200
commit055f71f87d5d58be2aafd6c0ef2b84d57ed48b63 (patch)
tree71f5f12e997bdcca340309cd5da81aacf0b3731f /src/qml/jsruntime/qv4object.cpp
parent2d781c4ca42f50643fa37200073a2fb2644b3806 (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/qv4object.cpp')
-rw-r--r--src/qml/jsruntime/qv4object.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index d55c3ad41f..fadc8f286a 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -236,7 +236,7 @@ void Object::defineDefaultProperty(ExecutionContext *context, const QString &nam
Q_UNUSED(argumentCount);
Scope scope(context);
Scoped<String> s(scope, context->engine->newIdentifier(name));
- Scoped<FunctionObject> function(scope, context->engine->newBuiltinFunction(context, s.getPointer(), code));
+ Scoped<FunctionObject> function(scope, context->engine->newBuiltinFunction(context, s, code));
function->defineReadonlyProperty(context->engine->id_length, Value::fromInt32(argumentCount));
defineDefaultProperty(s.getPointer(), function.asValue());
}
@@ -246,7 +246,7 @@ void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name,
Q_UNUSED(argumentCount);
Scope scope(engine);
Scoped<String> s(scope, engine->newIdentifier(name));
- Scoped<FunctionObject> function(scope, engine->newBuiltinFunction(engine->rootContext, s.getPointer(), code));
+ Scoped<FunctionObject> function(scope, engine->newBuiltinFunction(engine->rootContext, s, code));
function->defineReadonlyProperty(engine->id_length, Value::fromInt32(argumentCount));
defineDefaultProperty(s.getPointer(), function.asValue());
}
@@ -263,10 +263,13 @@ void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(Simple
{
ExecutionEngine *v4 = engine();
Property *p = insertMember(name, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
+
+ Scope scope(v4);
+ ScopedString s(scope, name);
if (getter)
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, name, getter)->getPointer());
+ p->setGetter(v4->newBuiltinFunction(v4->rootContext, s, getter)->getPointer());
if (setter)
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, name, setter)->getPointer());
+ p->setSetter(v4->newBuiltinFunction(v4->rootContext, s, setter)->getPointer());
}
void Object::defineReadonlyProperty(ExecutionEngine *engine, const QString &name, Value value)