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/qv4objectproto.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/qv4objectproto.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 6282657556..3b07527355 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -103,6 +103,9 @@ ReturnedValue ObjectCtor::call(Managed *m, CallData *callData) void ObjectPrototype::init(ExecutionContext *ctx, const Value &ctor) { + ExecutionEngine *v4 = ctx->engine; + Scope scope(v4); + ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_prototype, Value::fromObject(this)); ctor.objectValue()->defineReadonlyProperty(ctx->engine->id_length, Value::fromInt32(1)); ctor.objectValue()->defineDefaultProperty(ctx, QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1); @@ -129,10 +132,10 @@ void ObjectPrototype::init(ExecutionContext *ctx, const Value &ctor) defineDefaultProperty(ctx, QStringLiteral("__defineGetter__"), method_defineGetter, 2); defineDefaultProperty(ctx, QStringLiteral("__defineSetter__"), method_defineSetter, 2); - ExecutionEngine *v4 = ctx->engine; + Scoped<String> id_proto(scope, v4->id___proto__); Property *p = insertMember(v4->id___proto__, Attr_Accessor|Attr_NotEnumerable); - p->setGetter(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_get_proto)->getPointer()); - p->setSetter(v4->newBuiltinFunction(v4->rootContext, v4->id___proto__, method_set_proto)->getPointer()); + p->setGetter(v4->newBuiltinFunction(v4->rootContext, id_proto, method_get_proto)->getPointer()); + p->setSetter(v4->newBuiltinFunction(v4->rootContext, id_proto, method_set_proto)->getPointer()); } ReturnedValue ObjectPrototype::method_getPrototypeOf(SimpleCallContext *ctx) |