diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-18 11:00:38 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-22 01:06:20 +0200 |
commit | 50624234f2c0b6d3b0985edb8ff0b6aad5cad761 (patch) | |
tree | 2852c8917788d870100278d1cdc0129b94c5b599 /src/qml/jsruntime/qv4runtime.cpp | |
parent | 8b3623ee7b707e1b26ad48bdbf7816b95d9e0e24 (diff) |
Add a Safe<T> class and start using it
The class denotes objects that are stored safely
in areas controlled by the GC. These we can convert
fast to a StringRef etc.
Change-Id: I6b154eccaefddc42d4fafca55b7ee9e77179830c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index f440ade430..c01f172eb3 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -619,14 +619,14 @@ Returned<String> *__qmljs_convert_to_string(ExecutionContext *ctx, const ValueRe case Value::Empty_Type: Q_ASSERT(!"empty Value encountered"); case Value::Undefined_Type: - return ctx->engine->id_undefined->asReturned<String>(); + return ctx->engine->id_undefined; case Value::Null_Type: - return ctx->engine->id_null->asReturned<String>(); + return ctx->engine->id_null; case Value::Boolean_Type: if (value->booleanValue()) - return ctx->engine->id_true->asReturned<String>(); + return ctx->engine->id_true; else - return ctx->engine->id_false->asReturned<String>(); + return ctx->engine->id_false; case Value::Managed_Type: if (value->isString()) return value->stringValue()->asReturned<String>(); @@ -1151,11 +1151,12 @@ void __qmljs_builtin_declare_var(ExecutionContext *ctx, bool deletable, String * void __qmljs_builtin_define_property(ExecutionContext *ctx, const ValueRef object, String *name, ValueRef val) { - Object *o = object->asObject(); + Scope scope(ctx); + ScopedObject o(scope, object->asObject()); assert(o); uint idx = name->asArrayIndex(); - Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx) : o->insertMember(name, Attr_Data); + Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx) : o->insertMember(ScopedString(scope, name), Attr_Data); pd->value = val ? *val : Value::undefinedValue(); } @@ -1187,11 +1188,12 @@ ReturnedValue __qmljs_builtin_define_array(ExecutionContext *ctx, Value *values, void __qmljs_builtin_define_getter_setter(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef getter, const ValueRef setter) { - Object *o = object->asObject(); - assert(o); + Scope scope(ctx); + ScopedObject o(scope, object->asObject()); + Q_ASSERT(!!o); uint idx = name->asArrayIndex(); - Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx, Attr_Accessor) : o->insertMember(name, Attr_Accessor); + Property *pd = (idx != UINT_MAX) ? o->arrayInsert(idx, Attr_Accessor) : o->insertMember(ScopedString(scope, name), Attr_Accessor); pd->setGetter(getter ? getter->asFunctionObject() : 0); pd->setSetter(setter ? setter->asFunctionObject() : 0); } |