diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-18 16:36:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-22 01:06:20 +0200 |
commit | df5edd28bc4258b89d9d5ffdddf837f339a17aad (patch) | |
tree | 2a5939d5e3c49928aadf43337832d3ef5a58df08 /src/qml/jsruntime | |
parent | 700ba1bcb39e082049c96fafdfaccfe5d83cd77e (diff) |
convert Managed::put() API to be GC safe
Change-Id: I09198ce372fa545372db389fac26828d21ad5731
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4arrayobject.cpp | 28 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4include.cpp | 28 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup.cpp | 100 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup_p.h | 38 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4managed.cpp | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4managed_p.h | 12 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 42 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexp.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexp_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 16 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4serialize.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 4 |
20 files changed, 182 insertions, 157 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 61ceee95f5..ff4f4aa40e 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -247,12 +247,12 @@ ReturnedValue ArrayPrototype::method_join(SimpleCallContext *ctx) ReturnedValue ArrayPrototype::method_pop(SimpleCallContext *ctx) { Scope scope(ctx); - Object *instance = ctx->thisObject.toObject(ctx); - uint len = getLength(ctx, instance); + ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + uint len = getLength(ctx, instance.getPointer()); if (!len) { if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, Value::fromInt32(0)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromInt32(0))); return Value::undefinedValue().asReturnedValue(); } @@ -262,25 +262,27 @@ ReturnedValue ArrayPrototype::method_pop(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len - 1); else - instance->put(ctx->engine->id_length, Value::fromDouble(len - 1)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len - 1))); return result.asReturnedValue(); } ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) { - Object *instance = ctx->thisObject.toObject(ctx); - uint len = getLength(ctx, instance); + Scope scope(ctx); + ScopedObject instance(scope, ctx->thisObject.toObject(ctx)); + uint len = getLength(ctx, instance.getPointer()); if (len + ctx->argumentCount < len) { // ughh... double l = len; for (int i = 0; i < ctx->argumentCount; ++i) { Value idx = Value::fromDouble(l + i); - instance->put(idx.toString(ctx), ctx->arguments[i]); + ScopedString s(scope, idx.toString(ctx)); + instance->put(s, ctx->arguments[i]); } double newLen = l + ctx->argumentCount; if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, Value::fromDouble(newLen)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(newLen))); else ctx->throwRangeError(Value::fromString(ctx, QStringLiteral("Array.prototype.push: Overflow"))); return Value::fromDouble(newLen).asReturnedValue(); @@ -311,7 +313,7 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len); else - instance->put(ctx->engine->id_length, Value::fromDouble(len)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len))); if (len < INT_MAX) return Value::fromInt32(len).asReturnedValue(); @@ -353,7 +355,7 @@ ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx) if (!len) { if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, Value::fromInt32(0)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromInt32(0))); return Value::undefinedValue().asReturnedValue(); } @@ -395,7 +397,7 @@ ReturnedValue ArrayPrototype::method_shift(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len - 1); else - instance->put(ctx->engine->id_length, Value::fromDouble(len - 1)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len - 1))); return result.asReturnedValue(); } @@ -507,7 +509,7 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx) instance->putIndexed(start + i, ctx->arguments[i + 2]); ctx->strictMode = true; - instance->put(ctx->engine->id_length, Value::fromDouble(len - deleteCount + itemCount)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(len - deleteCount + itemCount))); return newArray.asReturnedValue(); } @@ -558,7 +560,7 @@ ReturnedValue ArrayPrototype::method_unshift(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(newLen); else - instance->put(ctx->engine->id_length, Value::fromDouble(newLen)); + instance->put(ctx->engine->id_length, ScopedValue(scope, Value::fromDouble(newLen))); if (newLen < INT_MAX) return Value::fromInt32(newLen).asReturnedValue(); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 1da2499ec5..73a059c4e8 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -367,7 +367,7 @@ void ExecutionContext::mark() } } -void ExecutionContext::setProperty(String *name, const Value& value) +void ExecutionContext::setProperty(String *name, const ValueRef value) { Scope scope(this); ScopedString n(scope, name); @@ -375,11 +375,11 @@ void ExecutionContext::setProperty(String *name, const Value& value) if (ctx->type == Type_WithContext) { Object *w = static_cast<WithContext *>(ctx)->withObject; if (w->__hasProperty__(n)) { - w->put(name, value); + w->put(n, value); return; } } else if (ctx->type == Type_CatchContext && static_cast<CatchContext *>(ctx)->exceptionVarName->isEqualTo(name)) { - static_cast<CatchContext *>(ctx)->exceptionValue = value; + static_cast<CatchContext *>(ctx)->exceptionValue = *value; return; } else { Object *activation = 0; @@ -387,12 +387,12 @@ void ExecutionContext::setProperty(String *name, const Value& value) CallContext *c = static_cast<CallContext *>(ctx); for (unsigned int i = 0; i < c->function->varCount; ++i) if (c->function->varList[i]->isEqualTo(name)) { - c->locals[i] = value; + c->locals[i] = *value; return; } for (int i = (int)c->function->formalParameterCount - 1; i >= 0; --i) if (c->function->formalParameterList[i]->isEqualTo(name)) { - c->arguments[i] = value; + c->arguments[i] = *value; return; } activation = c->activation; @@ -401,7 +401,7 @@ void ExecutionContext::setProperty(String *name, const Value& value) } if (activation && (ctx->type == Type_QmlContext || activation->__hasProperty__(n))) { - activation->put(name, value); + activation->put(n, value); return; } } @@ -410,7 +410,7 @@ void ExecutionContext::setProperty(String *name, const Value& value) Scoped<String> n(scope, name); throwReferenceError(n); } - engine->globalObject->put(name, value); + engine->globalObject->put(n, value); } ReturnedValue ExecutionContext::getProperty(String *name) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index fe15a53fd2..3e230f97c2 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -142,7 +142,7 @@ struct Q_QML_EXPORT ExecutionContext void Q_NORETURN throwURIError(Value msg); void Q_NORETURN throwUnimplemented(const QString &message); - void setProperty(String *name, const Value &value); + void setProperty(String *name, const ValueRef value); ReturnedValue getProperty(String *name); ReturnedValue getPropertyNoThrow(String *name); ReturnedValue getPropertyAndBase(String *name, Object **base); diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 4d9573b990..681ae5990d 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -87,13 +87,14 @@ QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status stat QV4::Scope scope(v4); // XXX It seems inefficient to create this object from scratch each time. - QV4::Scoped<QV4::Object> o(scope, v4->newObject()); - o->put(v4->newString("OK"), QV4::Value::fromInt32(Ok)); - o->put(v4->newString("LOADING"), QV4::Value::fromInt32(Loading)); - o->put(v4->newString("NETWORK_ERROR"), QV4::Value::fromInt32(NetworkError)); - o->put(v4->newString("EXCEPTION"), QV4::Value::fromInt32(Exception)); - - o->put(v4->newString("status"), QV4::Value::fromInt32(status)); + QV4::ScopedObject o(scope, v4->newObject()); + QV4::ScopedString s(scope); + QV4::ScopedValue v(scope); + o->put((s = v4->newString("OK")), (v = QV4::Value::fromInt32(Ok))); + o->put((s = v4->newString("LOADING")), (v = QV4::Value::fromInt32(Loading))); + o->put((s = v4->newString("NETWORK_ERROR")), (v = QV4::Value::fromInt32(NetworkError))); + o->put((s = v4->newString("EXCEPTION")), (v = QV4::Value::fromInt32(Exception))); + o->put((s = v4->newString("status")), (v = QV4::Value::fromInt32(status))); return o.asReturnedValue(); } @@ -141,6 +142,7 @@ void QV4Include::finished() } } + QV4::Scope scope(v4); if (m_reply->error() == QNetworkReply::NoError) { QByteArray data = m_reply->readAll(); @@ -150,20 +152,20 @@ void QV4Include::finished() QV4::Script script(v4, m_qmlglobal.value().asObject(), code, m_url.toString()); QV4::ExecutionContext *ctx = v4->current; - QV4::Scope scope(v4); QV4::Scoped<QV4::Object> o(scope, m_resultObject.value()); + QV4::ScopedString status(scope, v4->newString("status")); try { script.parse(); script.run(); - o->put(v4->newString("status"), QV4::Value::fromInt32(Ok)); + o->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Ok))); } catch (QV4::Exception &e) { e.accept(ctx); - o->put(v4->newString("status"), QV4::Value::fromInt32(Exception)); + o->put(status, QV4::ScopedValue(scope, QV4::Value::fromInt32(Exception))); QV4::ScopedValue ex(scope, e.value()); - o->put(v4->newString("exception"), ex); + o->put(QV4::ScopedString(scope, v4->newString("exception")), ex); } } else { - m_resultObject.value().asObject()->put(v4->newString("status"), QV4::Value::fromInt32(NetworkError)); + m_resultObject.value().asObject()->put(QV4::ScopedString(scope, v4->newString("status")), QV4::ScopedValue(scope, QV4::Value::fromInt32(NetworkError))); } callback(m_callbackFunction.value(), m_resultObject.value()); @@ -225,7 +227,7 @@ QV4::ReturnedValue QV4Include::method_include(QV4::SimpleCallContext *ctx) e.accept(ctx); result = resultValue(v4, Exception); QV4::ScopedValue ex(scope, e.value()); - result->asObject()->put(v4->newString("exception"), ex); + result->asObject()->put(QV4::ScopedString(scope, v4->newString("exception")), ex); } } else { result = resultValue(v4, NetworkError); diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 6dec2d1ec6..e3e159233b 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -716,7 +716,8 @@ QString Stringify::Str(const QString &key, Value value) if (replacerFunction) { Scoped<Object> holder(scope, ctx->engine->newObject()); - holder->put(ctx, QString(), value); + ScopedValue v(scope, value); + holder->put(ctx, QString(), v); ScopedCallData callData(scope, 2); callData->args[0] = Value::fromString(ctx, key); callData->args[1] = value; @@ -985,8 +986,12 @@ QV4::ReturnedValue JsonObject::fromJsonObject(ExecutionEngine *engine, const QJs { Scope scope(engine); Scoped<Object> o(scope, engine->newObject()); - for (QJsonObject::const_iterator it = object.begin(); it != object.end(); ++it) - o->put(engine->newString(it.key()), Value::fromReturnedValue(fromJsonValue(engine, it.value()))); + ScopedString s(scope); + ScopedValue v(scope); + for (QJsonObject::const_iterator it = object.begin(); it != object.end(); ++it) { + v = Value::fromReturnedValue(fromJsonValue(engine, it.value())); + o->put((s = engine->newString(it.key())), v); + } return o.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index da078729e4..50e56edcbd 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -87,14 +87,14 @@ Property *Lookup::lookup(Object *obj, PropertyAttributes *attrs) } -ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const QV4::Value &object) +ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const ValueRef object) { - if (Object *o = object.asObject()) + if (Object *o = object->asObject()) return o->getLookup(l); ExecutionEngine *engine = l->name->engine(); Object *proto; - switch (object.type()) { + switch (object->type()) { case Value::Undefined_Type: case Value::Null_Type: engine->current->throwTypeError(); @@ -102,7 +102,7 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const QV4::Value &object) proto = engine->booleanClass->prototype; break; case Value::Managed_Type: - Q_ASSERT(object.isString()); + Q_ASSERT(object->isString()); proto = engine->stringClass->prototype; if (l->name == engine->id_length) { // special case, as the property is on the object itself @@ -118,7 +118,7 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const QV4::Value &object) PropertyAttributes attrs; Property *p = l->lookup(proto, &attrs); if (p) { - l->type = object.type(); + l->type = object->type(); l->proto = proto; if (attrs.isData()) { if (l->level == 0) @@ -131,16 +131,16 @@ ReturnedValue Lookup::getterGeneric(QV4::Lookup *l, const QV4::Value &object) l->getter = Lookup::primitiveGetterAccessor0; else if (l->level == 1) l->getter = Lookup::primitiveGetterAccessor1; - return proto->getValue(object, p, attrs); + return proto->getValue(*object, p, attrs); } } return Value::undefinedValue().asReturnedValue(); } -ReturnedValue Lookup::getter0(Lookup *l, const Value &object) +ReturnedValue Lookup::getter0(Lookup *l, const ValueRef object) { - if (Object *o = object.asObject()) { + if (Object *o = object->asObject()) { if (l->classList[0] == o->internalClass) return o->memberData[l->index].value.asReturnedValue(); } @@ -148,9 +148,9 @@ ReturnedValue Lookup::getter0(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::getter1(Lookup *l, const Value &object) +ReturnedValue Lookup::getter1(Lookup *l, const ValueRef object) { - if (Object *o = object.asObject()) { + if (Object *o = object->asObject()) { if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype()->internalClass) return o->prototype()->memberData[l->index].value.asReturnedValue(); @@ -159,9 +159,9 @@ ReturnedValue Lookup::getter1(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::getter2(Lookup *l, const Value &object) +ReturnedValue Lookup::getter2(Lookup *l, const ValueRef object) { - if (Object *o = object.asObject()) { + if (Object *o = object->asObject()) { if (l->classList[0] == o->internalClass) { o = o->prototype(); if (l->classList[1] == o->internalClass) { @@ -175,9 +175,9 @@ ReturnedValue Lookup::getter2(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::getterAccessor0(Lookup *l, const Value &object) +ReturnedValue Lookup::getterAccessor0(Lookup *l, const ValueRef object) { - if (Object *o = object.asObject()) { + if (Object *o = object->asObject()) { if (l->classList[0] == o->internalClass) { Scope scope(o->engine()); FunctionObject *getter = o->memberData[l->index].getter(); @@ -185,7 +185,7 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, const Value &object) return Value::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = object; + callData->thisObject = *object; return getter->call(callData); } } @@ -193,9 +193,9 @@ ReturnedValue Lookup::getterAccessor0(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::getterAccessor1(Lookup *l, const Value &object) +ReturnedValue Lookup::getterAccessor1(Lookup *l, const ValueRef object) { - if (Object *o = object.asObject()) { + if (Object *o = object->asObject()) { if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype()->internalClass) { Scope scope(o->engine()); @@ -204,7 +204,7 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, const Value &object) return Value::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = object; + callData->thisObject = *object; return getter->call(callData); } } @@ -212,9 +212,9 @@ ReturnedValue Lookup::getterAccessor1(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::getterAccessor2(Lookup *l, const Value &object) +ReturnedValue Lookup::getterAccessor2(Lookup *l, const ValueRef object) { - if (Object *o = object.asObject()) { + if (Object *o = object->asObject()) { if (l->classList[0] == o->internalClass) { o = o->prototype(); if (l->classList[1] == o->internalClass) { @@ -226,7 +226,7 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, const Value &object) return Value::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = object; + callData->thisObject = *object; return getter->call(callData); } } @@ -237,9 +237,9 @@ ReturnedValue Lookup::getterAccessor2(Lookup *l, const Value &object) } -ReturnedValue Lookup::primitiveGetter0(Lookup *l, const Value &object) +ReturnedValue Lookup::primitiveGetter0(Lookup *l, const ValueRef object) { - if (object.type() == l->type) { + if (object->type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass) return o->memberData[l->index].value.asReturnedValue(); @@ -248,9 +248,9 @@ ReturnedValue Lookup::primitiveGetter0(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::primitiveGetter1(Lookup *l, const Value &object) +ReturnedValue Lookup::primitiveGetter1(Lookup *l, const ValueRef object) { - if (object.type() == l->type) { + if (object->type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype()->internalClass) @@ -260,9 +260,9 @@ ReturnedValue Lookup::primitiveGetter1(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, const Value &object) +ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, const ValueRef object) { - if (object.type() == l->type) { + if (object->type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass) { Scope scope(o->engine()); @@ -272,7 +272,7 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, const Value &object) return Value::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = object; + callData->thisObject = *object; return getter->call(callData); } } @@ -280,9 +280,9 @@ ReturnedValue Lookup::primitiveGetterAccessor0(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, const Value &object) +ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, const ValueRef object) { - if (object.type() == l->type) { + if (object->type() == l->type) { Object *o = l->proto; if (l->classList[0] == o->internalClass && l->classList[1] == o->prototype()->internalClass) { @@ -293,7 +293,7 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, const Value &object) return Value::undefinedValue().asReturnedValue(); ScopedCallData callData(scope, 0); - callData->thisObject = object; + callData->thisObject = *object; return getter->call(callData); } } @@ -301,9 +301,9 @@ ReturnedValue Lookup::primitiveGetterAccessor1(Lookup *l, const Value &object) return getterGeneric(l, object); } -ReturnedValue Lookup::stringLengthGetter(Lookup *l, const Value &object) +ReturnedValue Lookup::stringLengthGetter(Lookup *l, const ValueRef object) { - if (String *s = object.asString()) + if (String *s = object->asString()) return Value::fromUInt32(s->length()).asReturnedValue(); l->getter = getterGeneric; @@ -435,22 +435,24 @@ ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionContext *ctx) return globalGetterGeneric(l, ctx); } -void Lookup::setterGeneric(Lookup *l, const Value &object, const Value &value) +void Lookup::setterGeneric(Lookup *l, const ValueRef object, const ValueRef value) { - Object *o = object.asObject(); + Scope scope(l->name->engine()); + ScopedObject o(scope, object); if (!o) { - o = __qmljs_convert_to_object(l->name->engine()->current, ValueRef::fromRawValue(&object))->getPointer(); - o->put(l->name, value); + o = __qmljs_convert_to_object(scope.engine->current, object); + ScopedString s(scope, l->name); + o->put(s, value); return; } o->setLookup(l, value); } -void Lookup::setter0(Lookup *l, const Value &object, const Value &value) +void Lookup::setter0(Lookup *l, const ValueRef object, const ValueRef value) { - Object *o = object.asObject(); + Object *o = object->asObject(); if (o && o->internalClass == l->classList[0]) { - o->memberData[l->index].value = value; + o->memberData[l->index].value = *value; return; } @@ -458,12 +460,12 @@ void Lookup::setter0(Lookup *l, const Value &object, const Value &value) setterGeneric(l, object, value); } -void Lookup::setterInsert0(Lookup *l, const Value &object, const Value &value) +void Lookup::setterInsert0(Lookup *l, const ValueRef object, const ValueRef value) { - Object *o = object.asObject(); + Object *o = object->asObject(); if (o && o->internalClass == l->classList[0]) { if (!o->prototype()) { - o->memberData[l->index].value = value; + o->memberData[l->index].value = *value; o->internalClass = l->classList[3]; return; } @@ -473,13 +475,13 @@ void Lookup::setterInsert0(Lookup *l, const Value &object, const Value &value) setterGeneric(l, object, value); } -void Lookup::setterInsert1(Lookup *l, const Value &object, const Value &value) +void Lookup::setterInsert1(Lookup *l, const ValueRef object, const ValueRef value) { - Object *o = object.asObject(); + Object *o = object->asObject(); if (o && o->internalClass == l->classList[0]) { Object *p = o->prototype(); if (p && p->internalClass == l->classList[1]) { - o->memberData[l->index].value = value; + o->memberData[l->index].value = *value; o->internalClass = l->classList[3]; return; } @@ -489,16 +491,16 @@ void Lookup::setterInsert1(Lookup *l, const Value &object, const Value &value) setterGeneric(l, object, value); } -void Lookup::setterInsert2(Lookup *l, const Value &object, const Value &value) +void Lookup::setterInsert2(Lookup *l, const ValueRef object, const ValueRef value) { - Object *o = object.asObject(); + Object *o = object->asObject(); if (o && o->internalClass == l->classList[0]) { Object *p = o->prototype(); if (p && p->internalClass == l->classList[1]) { p = p->prototype(); if (p && p->internalClass == l->classList[2]) { o->ensureMemberIndex(l->index); - o->memberData[l->index].value = value; + o->memberData[l->index].value = *value; o->internalClass = l->classList[3]; return; } diff --git a/src/qml/jsruntime/qv4lookup_p.h b/src/qml/jsruntime/qv4lookup_p.h index b79e91028f..9966d36604 100644 --- a/src/qml/jsruntime/qv4lookup_p.h +++ b/src/qml/jsruntime/qv4lookup_p.h @@ -55,9 +55,9 @@ namespace QV4 { struct Lookup { enum { Size = 4 }; union { - ReturnedValue (*getter)(Lookup *l, const Value &object); + ReturnedValue (*getter)(Lookup *l, const ValueRef object); ReturnedValue (*globalGetter)(Lookup *l, ExecutionContext *ctx); - void (*setter)(Lookup *l, const Value &object, const Value &v); + void (*setter)(Lookup *l, const ValueRef object, const ValueRef v); }; union { InternalClass *classList[Size]; @@ -72,19 +72,19 @@ struct Lookup { uint index; String *name; - static ReturnedValue getterGeneric(Lookup *l, const Value &object); - static ReturnedValue getter0(Lookup *l, const Value &object); - static ReturnedValue getter1(Lookup *l, const Value &object); - static ReturnedValue getter2(Lookup *l, const Value &object); - static ReturnedValue getterAccessor0(Lookup *l, const Value &object); - static ReturnedValue getterAccessor1(Lookup *l, const Value &object); - static ReturnedValue getterAccessor2(Lookup *l, const Value &object); + static ReturnedValue getterGeneric(Lookup *l, const ValueRef object); + static ReturnedValue getter0(Lookup *l, const ValueRef object); + static ReturnedValue getter1(Lookup *l, const ValueRef object); + static ReturnedValue getter2(Lookup *l, const ValueRef object); + static ReturnedValue getterAccessor0(Lookup *l, const ValueRef object); + static ReturnedValue getterAccessor1(Lookup *l, const ValueRef object); + static ReturnedValue getterAccessor2(Lookup *l, const ValueRef object); - static ReturnedValue primitiveGetter0(Lookup *l, const Value &object); - static ReturnedValue primitiveGetter1(Lookup *l, const Value &object); - static ReturnedValue primitiveGetterAccessor0(Lookup *l, const Value &object); - static ReturnedValue primitiveGetterAccessor1(Lookup *l, const Value &object); - static ReturnedValue stringLengthGetter(Lookup *l, const Value &object); + static ReturnedValue primitiveGetter0(Lookup *l, const ValueRef object); + static ReturnedValue primitiveGetter1(Lookup *l, const ValueRef object); + static ReturnedValue primitiveGetterAccessor0(Lookup *l, const ValueRef object); + static ReturnedValue primitiveGetterAccessor1(Lookup *l, const ValueRef object); + static ReturnedValue stringLengthGetter(Lookup *l, const ValueRef object); static ReturnedValue globalGetterGeneric(Lookup *l, ExecutionContext *ctx); static ReturnedValue globalGetter0(Lookup *l, ExecutionContext *ctx); @@ -94,11 +94,11 @@ struct Lookup { static ReturnedValue globalGetterAccessor1(Lookup *l, ExecutionContext *ctx); static ReturnedValue globalGetterAccessor2(Lookup *l, ExecutionContext *ctx); - static void setterGeneric(Lookup *l, const Value &object, const Value &value); - static void setter0(Lookup *l, const Value &object, const Value &value); - static void setterInsert0(Lookup *l, const Value &object, const Value &value); - static void setterInsert1(Lookup *l, const Value &object, const Value &value); - static void setterInsert2(Lookup *l, const Value &object, const Value &value); + static void setterGeneric(Lookup *l, const ValueRef object, const ValueRef value); + static void setter0(Lookup *l, const ValueRef object, const ValueRef value); + static void setterInsert0(Lookup *l, const ValueRef object, const ValueRef value); + static void setterInsert1(Lookup *l, const ValueRef object, const ValueRef value); + static void setterInsert2(Lookup *l, const ValueRef object, const ValueRef value); Property *lookup(Object *obj, PropertyAttributes *attrs); diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index 776819a75f..c469293f5e 100644 --- a/src/qml/jsruntime/qv4managed.cpp +++ b/src/qml/jsruntime/qv4managed.cpp @@ -192,7 +192,7 @@ ReturnedValue Managed::getLookup(Managed *m, Lookup *) return 0; } -void Managed::setLookup(Managed *m, Lookup *, const Value &) +void Managed::setLookup(Managed *m, Lookup *, const ValueRef) { m->engine()->current->throwTypeError(); } @@ -211,3 +211,13 @@ ReturnedValue Managed::getIndexed(uint index, bool *hasProperty) { return vtbl->getIndexed(this, index, hasProperty); } + +void Managed::put(const StringRef name, const ValueRef value) +{ + vtbl->put(this, name, value); +} + +void Managed::setLookup(Lookup *l, const ValueRef v) +{ + vtbl->setLookup(this, l, v); +} diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 71b3573922..00ad52a9ef 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -99,14 +99,14 @@ struct ManagedVTable bool (*hasInstance)(Managed *, const Value &value); ReturnedValue (*get)(Managed *, const StringRef name, bool *hasProperty); ReturnedValue (*getIndexed)(Managed *, uint index, bool *hasProperty); - void (*put)(Managed *, String *name, const Value &value); + void (*put)(Managed *, const StringRef name, const ValueRef value); void (*putIndexed)(Managed *, uint index, const Value &value); PropertyAttributes (*query)(const Managed *, String *name); PropertyAttributes (*queryIndexed)(const Managed *, uint index); bool (*deleteProperty)(Managed *m, String *name); bool (*deleteIndexedProperty)(Managed *m, uint index); ReturnedValue (*getLookup)(Managed *m, Lookup *l); - void (*setLookup)(Managed *m, Lookup *l, const Value &v); + void (*setLookup)(Managed *m, Lookup *l, const ValueRef v); bool (*isEqualTo)(Managed *m, Managed *other); Property *(*advanceIterator)(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes); const char *className; @@ -265,8 +265,7 @@ public: ReturnedValue call(CallData *d); ReturnedValue get(const StringRef name, bool *hasProperty = 0); ReturnedValue getIndexed(uint index, bool *hasProperty = 0); - void put(String *name, const Value &value) - { vtbl->put(this, name, value); } + void put(const StringRef name, const ValueRef value); void putIndexed(uint index, const Value &value) { vtbl->putIndexed(this, index, value); } PropertyAttributes query(String *name) const @@ -280,8 +279,7 @@ public: { return vtbl->deleteIndexedProperty(this, index); } ReturnedValue getLookup(Lookup *l) { return vtbl->getLookup(this, l); } - void setLookup(Lookup *l, const Value &v) - { vtbl->setLookup(this, l, v); } + void setLookup(Lookup *l, const ValueRef v); bool isEqualTo(Managed *other) { return vtbl->isEqualTo(this, other); } @@ -293,7 +291,7 @@ public: static ReturnedValue construct(Managed *m, CallData *d); static ReturnedValue call(Managed *m, CallData *); static ReturnedValue getLookup(Managed *m, Lookup *); - static void setLookup(Managed *m, Lookup *l, const Value &v); + static void setLookup(Managed *m, Lookup *l, const ValueRef v); static bool isEqualTo(Managed *m, Managed *other); uint internalType() const { diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 168933f8e5..44c248dd1a 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -122,9 +122,11 @@ void Object::destroy(Managed *that) static_cast<Object *>(that)->~Object(); } -void Object::put(ExecutionContext *ctx, const QString &name, const Value &value) +void Object::put(ExecutionContext *ctx, const QString &name, const ValueRef value) { - put(ctx->engine->newString(name), value); + Scope scope(ctx); + ScopedString n(scope, ctx->engine->newString(name)); + put(n, value); } ReturnedValue Object::getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs) @@ -173,7 +175,7 @@ void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const V ScopedString n(scope, name); ScopedValue v(scope, get(n)); ScopedValue result(scope, op(v, rhs)); - put(name, result); + put(n, result); } void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, const ValueRef index, const ValueRef rhs) @@ -198,7 +200,7 @@ void Object::inplaceBinOp(ExecutionContext *ctx, BinOpContext op, String *name, ScopedString n(scope, name); ScopedValue v(scope, get(n)); ScopedValue result(scope, op(ctx, v, rhs)); - put(name, result); + put(n, result); } void Object::inplaceBinOp(ExecutionContext *ctx, BinOpContext op, const ValueRef index, const ValueRef rhs) @@ -465,11 +467,9 @@ ReturnedValue Object::getIndexed(Managed *m, uint index, bool *hasProperty) return static_cast<Object *>(m)->internalGetIndexed(index, hasProperty); } -void Object::put(Managed *m, String *name, const Value &value) +void Object::put(Managed *m, const StringRef name, const ValueRef value) { - Scope scope(m->engine()); - ScopedString s(scope, name); - static_cast<Object *>(m)->internalPut(s, value); + static_cast<Object *>(m)->internalPut(name, value); } void Object::putIndexed(Managed *m, uint index, const Value &value) @@ -545,9 +545,10 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l) return Value::undefinedValue().asReturnedValue(); } -void Object::setLookup(Managed *m, Lookup *l, const Value &value) +void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) { - Object *o = static_cast<Object *>(m); + Scope scope(m->engine()); + ScopedObject o(scope, static_cast<Object *>(m)); InternalClass *c = o->internalClass; uint idx = c->find(l->name); @@ -556,17 +557,18 @@ void Object::setLookup(Managed *m, Lookup *l, const Value &value) l->classList[0] = o->internalClass; l->index = idx; l->setter = Lookup::setter0; - o->memberData[idx].value = value; + o->memberData[idx].value = *value; return; } if (idx != UINT_MAX) { - o->putValue(o->memberData + idx, o->internalClass->propertyData[idx], value); + o->putValue(o->memberData + idx, o->internalClass->propertyData[idx], *value); return; } } - o->put(l->name, value); + ScopedString s(scope, l->name); + o->put(s, value); if (o->internalClass == c) return; @@ -717,11 +719,11 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) // Section 8.12.5 -void Object::internalPut(const StringRef name, const Value &value) +void Object::internalPut(const StringRef name, const ValueRef value) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) - return putIndexed(idx, value); + return putIndexed(idx, *value); name->makeIdentifier(); @@ -743,14 +745,14 @@ void Object::internalPut(const StringRef name, const Value &value) goto reject; else if (isArrayObject() && name->isEqualTo(engine()->id_length)) { bool ok; - uint l = value.asArrayLength(&ok); + uint l = value->asArrayLength(&ok); if (!ok) - engine()->current->throwRangeError(value); + engine()->current->throwRangeError(*value); ok = setArrayLength(l); if (!ok) goto reject; } else { - pd->value = value; + pd->value = *value; } return; } else if (!prototype()) { @@ -778,7 +780,7 @@ void Object::internalPut(const StringRef name, const Value &value) Scope scope(engine()); ScopedCallData callData(scope, 1); - callData->args[0] = value; + callData->args[0] = *value; callData->thisObject = Value::fromObject(this); pd->setter()->call(callData); return; @@ -786,7 +788,7 @@ void Object::internalPut(const StringRef name, const Value &value) { Property *p = insertMember(name, Attr_Data); - p->value = value; + p->value = *value; return; } diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index b17146c64a..dd75187cc2 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -148,7 +148,7 @@ struct Q_QML_EXPORT Object: Managed { // // helpers // - void put(ExecutionContext *ctx, const QString &name, const Value &value); + void put(ExecutionContext *ctx, const QString &name, const ValueRef value); static ReturnedValue getValue(const Value &thisObject, const Property *p, PropertyAttributes attrs); ReturnedValue getValue(const Property *p, PropertyAttributes attrs) const { @@ -292,7 +292,7 @@ public: { return vtbl->get(this, name, hasProperty); } inline ReturnedValue getIndexed(uint idx, bool *hasProperty = 0) { return vtbl->getIndexed(this, idx, hasProperty); } - inline void put(String *name, const Value &v) + inline void put(const StringRef name, const ValueRef v) { vtbl->put(this, name, v); } inline void putIndexed(uint idx, const Value &v) { vtbl->putIndexed(this, idx, v); } @@ -312,21 +312,21 @@ protected: static void markObjects(Managed *that); static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, String *name, const Value &value); + static void put(Managed *m, const StringRef name, const ValueRef value); static void putIndexed(Managed *m, uint index, const Value &value); static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); static bool deleteProperty(Managed *m, String *name); static bool deleteIndexedProperty(Managed *m, uint index); static ReturnedValue getLookup(Managed *m, Lookup *l); - static void setLookup(Managed *m, Lookup *l, const Value &v); + static void setLookup(Managed *m, Lookup *l, const ValueRef v); static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes); private: ReturnedValue internalGet(const StringRef name, bool *hasProperty); ReturnedValue internalGetIndexed(uint index, bool *hasProperty); - void internalPut(const StringRef name, const Value &value); + void internalPut(const StringRef name, const ValueRef value); void internalPutIndexed(uint index, const Value &value); bool internalDeleteProperty(String *name); bool internalDeleteIndexedProperty(uint index); diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index c8488924a9..226de86a38 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -332,8 +332,8 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD QV4::ScopedString connect(scope, ctx->engine->newIdentifier(QStringLiteral("connect"))); QV4::ScopedString disconnect(scope, ctx->engine->newIdentifier(QStringLiteral("disconnect"))); - handler->put(connect.getPointer(), QV4::Value::fromReturnedValue(ctx->engine->functionClass->prototype->get(connect))); - handler->put(disconnect.getPointer(), QV4::Value::fromReturnedValue(ctx->engine->functionClass->prototype->get(disconnect))); + handler->put(connect, QV4::ScopedValue(scope, ctx->engine->functionClass->prototype->get(connect))); + handler->put(disconnect, QV4::ScopedValue(scope, ctx->engine->functionClass->prototype->get(disconnect))); return QV4::Value::fromObject(handler).asReturnedValue(); } else { @@ -605,7 +605,7 @@ QV4::ReturnedValue QObjectWrapper::get(Managed *m, const StringRef name, bool *h return that->getQmlProperty(v4->current, qmlContext, name.getPointer(), IgnoreRevision, hasProperty, /*includeImports*/ true); } -void QObjectWrapper::put(Managed *m, String *name, const Value &value) +void QObjectWrapper::put(Managed *m, const StringRef name, const ValueRef value) { QObjectWrapper *that = static_cast<QObjectWrapper*>(m); ExecutionEngine *v4 = m->engine(); @@ -614,7 +614,7 @@ void QObjectWrapper::put(Managed *m, String *name, const Value &value) return; QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4); - if (!setQmlProperty(v4->current, qmlContext, that->m_object, name, QV4::QObjectWrapper::IgnoreRevision, value)) { + if (!setQmlProperty(v4->current, qmlContext, that->m_object, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, *value)) { QString error = QLatin1String("Cannot assign to non-existent property \"") + name->toQString() + QLatin1Char('\"'); v4->current->throwError(error); diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h index 3e4abc30b9..e8c2d91da6 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper_p.h +++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h @@ -106,7 +106,7 @@ private: String *m_toString; static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); - static void put(Managed *m, String *name, const Value &value); + static void put(Managed *m, const StringRef name, const ValueRef value); static PropertyAttributes query(const Managed *, String *name); static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes); static void markObjects(Managed *that); diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index 0a10002766..076bd72adf 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -146,7 +146,7 @@ ReturnedValue RegExp::getIndexed(Managed *m, uint index, bool *hasProperty) return Value::undefinedValue().asReturnedValue(); } -void RegExp::put(Managed *m, String *name, const Value &value) +void RegExp::put(Managed *m, const StringRef name, const ValueRef value) { } diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index cae0665469..2600cac425 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -113,7 +113,7 @@ protected: static void markObjects(Managed *that); static ReturnedValue get(Managed *, const StringRef, bool *); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, String *name, const Value &value); + static void put(Managed *m, const StringRef name, const ValueRef value); static void putIndexed(Managed *m, uint index, const Value &value); static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index f297762ec7..9ecb1bf103 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -645,8 +645,10 @@ Returned<String> *__qmljs_convert_to_string(ExecutionContext *ctx, const ValueRe void __qmljs_set_property(ExecutionContext *ctx, const ValueRef object, String *name, const ValueRef value) { - Object *o = object->toObject(ctx); - o->put(name, *value); + Scope scope(ctx); + ScopedObject o(scope, object->toObject(ctx)); + ScopedString n(scope, name); + o->put(n, value); } ReturnedValue __qmljs_get_element(ExecutionContext *ctx, const ValueRef object, const ValueRef index) @@ -692,7 +694,7 @@ ReturnedValue __qmljs_get_element(ExecutionContext *ctx, const ValueRef object, void __qmljs_set_element(ExecutionContext *ctx, const ValueRef object, const ValueRef index, const ValueRef value) { Scope scope(ctx); - Object *o = object->toObject(ctx); + ScopedObject o(scope, object->toObject(ctx)); uint idx = index->asArrayIndex(); if (idx < UINT_MAX) { @@ -719,7 +721,7 @@ void __qmljs_set_element(ExecutionContext *ctx, const ValueRef object, const Val } ScopedCallData callData(scope, 1); - callData->thisObject = Value::fromObject(o); + callData->thisObject = o; callData->args[0] = *value; setter->call(callData); return; @@ -729,8 +731,8 @@ void __qmljs_set_element(ExecutionContext *ctx, const ValueRef object, const Val return; } - String *name = index->toString(ctx); - o->put(name, *value); + ScopedString name(scope, index->toString(ctx)); + o->put(name, value); } ReturnedValue __qmljs_foreach_iterator_object(ExecutionContext *ctx, const ValueRef in) @@ -756,7 +758,7 @@ ReturnedValue __qmljs_foreach_next_property_name(const ValueRef foreach_iterator void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const ValueRef value) { - ctx->setProperty(name, *value); + ctx->setProperty(name, value); } ReturnedValue __qmljs_get_property(ExecutionContext *ctx, const ValueRef object, String *n) diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index 48f2272e7d..cabe326d13 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -333,11 +333,13 @@ ReturnedValue Serialize::deserialize(const char *&data, QV8Engine *engine) quint32 size = headersize(header); Scoped<Object> o(scope, v4->newObject()); ScopedValue name(scope); + ScopedString n(scope); ScopedValue value(scope); for (quint32 ii = 0; ii < size; ++ii) { name = deserialize(data, engine); value = deserialize(data, engine); - o->put(name->asString(), value); + n = name.asReturnedValue(); + o->put(n, value); } return o.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 0323f3c1d3..73e55a09dc 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -173,7 +173,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) return engine->stringClass->prototype->getValue(Value::fromString(that), pd, attrs); } -void String::put(Managed *m, String *name, const Value &value) +void String::put(Managed *m, const StringRef name, const ValueRef value) { Scope scope(m->engine()); String *that = static_cast<String *>(m); diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index 36eb5103eb..4289725cf9 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -129,7 +129,7 @@ protected: static void destroy(Managed *); static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, String *name, const Value &value); + static void put(Managed *m, const StringRef name, const ValueRef value); static void putIndexed(Managed *m, uint index, const Value &value); static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 22e746311c..26f662d005 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -379,7 +379,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context) return exec->call(callData); ScopedString lastIndex(scope, context->engine->newString(QStringLiteral("lastIndex"))); - rx->put(lastIndex.getPointer(), Value::fromInt32(0)); + rx->put(lastIndex, ScopedValue(scope, Value::fromInt32(0))); Scoped<ArrayObject> a(scope, context->engine->newArrayObject()); double previousLastIndex = 0; @@ -396,7 +396,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context) double thisIndex = index->toInteger(); if (previousLastIndex == thisIndex) { previousLastIndex = thisIndex + 1; - rx->put(lastIndex.getPointer(), Value::fromDouble(previousLastIndex)); + rx->put(lastIndex, ScopedValue(scope, Value::fromDouble(previousLastIndex))); } else { previousLastIndex = thisIndex; } |