aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-18 15:34:13 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 01:06:20 +0200
commit700ba1bcb39e082049c96fafdfaccfe5d83cd77e (patch)
treed21da27b94a927377ba2c6efd7c3af731d890b19 /src
parent1aa618970a9bed46123d0648500e957688d725ec (diff)
Use a StringRef for Managed::get()
also store "toString" and "valueOf" as identifiers in the engine and fix two places where we compared strings the wrong way. Change-Id: I70612221e72d43ed0e3c496e4209681bf254cded Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsapi/qjsvalue.cpp4
-rw-r--r--src/qml/jsapi/qjsvalueiterator.cpp10
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp17
-rw-r--r--src/qml/jsruntime/qv4booleanobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4context.cpp37
-rw-r--r--src/qml/jsruntime/qv4dateobject.cpp7
-rw-r--r--src/qml/jsruntime/qv4engine.cpp4
-rw-r--r--src/qml/jsruntime/qv4engine_p.h2
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp7
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4jsonobject.cpp10
-rw-r--r--src/qml/jsruntime/qv4managed.cpp2
-rw-r--r--src/qml/jsruntime/qv4managed_p.h4
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4object.cpp23
-rw-r--r--src/qml/jsruntime/qv4object_p.h7
-rw-r--r--src/qml/jsruntime/qv4objectproto.cpp10
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp33
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h2
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp4
-rw-r--r--src/qml/jsruntime/qv4regexp_p.h2
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp8
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp33
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4serialize.cpp4
-rw-r--r--src/qml/jsruntime/qv4string.cpp7
-rw-r--r--src/qml/jsruntime/qv4string_p.h2
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp23
-rw-r--r--src/qml/jsruntime/qv4variantobject.cpp4
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp8
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h2
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp3
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp4
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h2
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp10
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp8
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp17
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp2
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp7
-rw-r--r--src/quick/util/qquickglobal.cpp26
42 files changed, 210 insertions, 161 deletions
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 87c45e4779..987dd8b29f 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -801,11 +801,11 @@ QJSValue QJSValue::property(const QString& name) const
return QJSValue();
QV4::Scope scope(engine);
- Object *o = d->value.asObject();
+ ScopedObject o(scope, d->value);
if (!o)
return QJSValue();
- String *s = engine->newString(name);
+ ScopedString s(scope, engine->newString(name));
uint idx = s->asArrayIndex();
if (idx < UINT_MAX)
return property(idx);
diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp
index 2b074c3cb2..b4156dcd1d 100644
--- a/src/qml/jsapi/qjsvalueiterator.cpp
+++ b/src/qml/jsapi/qjsvalueiterator.cpp
@@ -179,12 +179,14 @@ QJSValue QJSValueIterator::value() const
QV4::ExecutionContext *ctx = engine->current;
try {
QV4::ScopedValue v(scope);
- if (d_ptr->currentName)
- v = o->get(d_ptr->currentName);
- else if (d_ptr->currentIndex != UINT_MAX)
+ if (d_ptr->currentName) {
+ QV4::ScopedString n(scope, d_ptr->currentName);
+ v = o->get(n);
+ } else if (d_ptr->currentIndex != UINT_MAX) {
v = o->getIndexed(d_ptr->currentIndex);
- else
+ } else {
return QJSValue();
+ }
return new QJSValuePrivate(engine, v);
} catch (QV4::Exception &e) {
e.accept(ctx);
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index c066c3b533..61ceee95f5 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -97,7 +97,7 @@ void ArrayPrototype::init(ExecutionEngine *engine, const Value &ctor)
ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this));
ctor.objectValue()->defineDefaultProperty(QStringLiteral("isArray"), method_isArray, 1);
defineDefaultProperty(QStringLiteral("constructor"), ctor);
- defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
defineDefaultProperty(QStringLiteral("join"), method_join, 1);
@@ -137,11 +137,11 @@ ReturnedValue ArrayPrototype::method_isArray(SimpleCallContext *ctx)
ReturnedValue ArrayPrototype::method_toString(SimpleCallContext *ctx)
{
- QV4::Scope scope(ctx);
- QV4::Object *o = ctx->thisObject.toObject(ctx);
- ScopedValue v(scope, o->get(ctx->engine->newString("join")));
- FunctionObject *f = v->asFunctionObject();
- if (f) {
+ Scope scope(ctx);
+ ScopedObject o(scope, ctx->thisObject, ScopedObject::Convert);
+ ScopedString s(scope, ctx->engine->newString("join"));
+ ScopedFunctionObject f(scope, o->get(s));
+ if (!!f) {
ScopedCallData d(scope, 0);
d->thisObject = ctx->thisObject;
return f->call(d);
@@ -223,7 +223,8 @@ ReturnedValue ArrayPrototype::method_join(SimpleCallContext *ctx)
//
// crazy!
//
- ScopedValue r6(scope, self->get(ctx->engine->newString(QStringLiteral("0"))));
+ ScopedString name(scope, ctx->engine->newString(QStringLiteral("0")));
+ ScopedValue r6(scope, self->get(name));
if (!r6->isNullOrUndefined())
R = r6->toString(ctx)->toQString();
@@ -231,7 +232,7 @@ ReturnedValue ArrayPrototype::method_join(SimpleCallContext *ctx)
for (quint32 k = 1; k < r2; ++k) {
R += r4;
- String *name = Value::fromDouble(k).toString(ctx);
+ name = Value::fromDouble(k).toString(ctx);
r12 = self->get(name);
if (!r12->isNullOrUndefined())
diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp
index 28589e4104..d85f4294ce 100644
--- a/src/qml/jsruntime/qv4booleanobject.cpp
+++ b/src/qml/jsruntime/qv4booleanobject.cpp
@@ -68,8 +68,8 @@ void BooleanPrototype::init(ExecutionEngine *engine, const Value &ctor)
ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1));
ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(this));
defineDefaultProperty(QStringLiteral("constructor"), ctor);
- defineDefaultProperty(QStringLiteral("toString"), method_toString);
- defineDefaultProperty(QStringLiteral("valueOf"), method_valueOf);
+ defineDefaultProperty(engine->id_toString, method_toString);
+ defineDefaultProperty(engine->id_valueOf, method_valueOf);
}
ReturnedValue BooleanPrototype::method_toString(SimpleCallContext *ctx)
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 449ec21b05..1da2499ec5 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -417,7 +417,8 @@ ReturnedValue ExecutionContext::getProperty(String *name)
{
Scope scope(this);
ScopedValue v(scope);
- name->makeIdentifier();
+ ScopedString n(scope, name);
+ n->makeIdentifier();
if (name->isEqualTo(engine->id_this))
return thisObject.asReturnedValue();
@@ -429,7 +430,7 @@ ReturnedValue ExecutionContext::getProperty(String *name)
Object *w = static_cast<WithContext *>(ctx)->withObject;
hasWith = true;
bool hasProperty = false;
- v = w->get(name, &hasProperty);
+ v = w->get(n, &hasProperty);
if (hasProperty) {
return v.asReturnedValue();
}
@@ -456,7 +457,7 @@ ReturnedValue ExecutionContext::getProperty(String *name)
}
if (c->activation) {
bool hasProperty = false;
- v = c->activation->get(name, &hasProperty);
+ v = c->activation->get(n, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
@@ -468,23 +469,23 @@ ReturnedValue ExecutionContext::getProperty(String *name)
else if (ctx->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
- v = g->global->get(name, &hasProperty);
+ v = g->global->get(n, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
}
- Scoped<String> n(scope, name);
throwReferenceError(n);
- return Value::undefinedValue().asReturnedValue();
+ return 0;
}
ReturnedValue ExecutionContext::getPropertyNoThrow(String *name)
{
Scope scope(this);
ScopedValue v(scope);
- name->makeIdentifier();
+ ScopedString n(scope, name);
+ n->makeIdentifier();
- if (name->isEqualTo(engine->id_this))
+ if (n->isEqualTo(engine->id_this))
return thisObject.asReturnedValue();
bool hasWith = false;
@@ -494,7 +495,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(String *name)
Object *w = static_cast<WithContext *>(ctx)->withObject;
hasWith = true;
bool hasProperty = false;
- v = w->get(name, &hasProperty);
+ v = w->get(n, &hasProperty);
if (hasProperty) {
return v.asReturnedValue();
}
@@ -521,7 +522,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(String *name)
}
if (c->activation) {
bool hasProperty = false;
- v = c->activation->get(name, &hasProperty);
+ v = c->activation->get(n, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
@@ -533,7 +534,7 @@ ReturnedValue ExecutionContext::getPropertyNoThrow(String *name)
else if (ctx->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
- v = g->global->get(name, &hasProperty);
+ v = g->global->get(n, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
@@ -545,10 +546,11 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base)
{
Scope scope(this);
ScopedValue v(scope);
+ ScopedString n(scope, name);
*base = 0;
- name->makeIdentifier();
+ n->makeIdentifier();
- if (name->isEqualTo(engine->id_this))
+ if (n->isEqualTo(engine->id_this))
return thisObject.asReturnedValue();
bool hasWith = false;
@@ -558,7 +560,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base)
Object *w = static_cast<WithContext *>(ctx)->withObject;
hasWith = true;
bool hasProperty = false;
- v = w->get(name, &hasProperty);
+ v = w->get(n, &hasProperty);
if (hasProperty) {
*base = w;
return v.asReturnedValue();
@@ -586,7 +588,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base)
}
if (c->activation) {
bool hasProperty = false;
- v = c->activation->get(name, &hasProperty);
+ v = c->activation->get(n, &hasProperty);
if (hasProperty) {
if (ctx->type == Type_QmlContext)
*base = c->activation;
@@ -601,14 +603,13 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base)
else if (ctx->type == Type_GlobalContext) {
GlobalContext *g = static_cast<GlobalContext *>(ctx);
bool hasProperty = false;
- v = g->global->get(name, &hasProperty);
+ v = g->global->get(n, &hasProperty);
if (hasProperty)
return v.asReturnedValue();
}
}
- Scoped<String> n(scope, name);
throwReferenceError(n);
- return Value::undefinedValue().asReturnedValue();
+ return 0;
}
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp
index 0a8aca4a01..72dc5433e5 100644
--- a/src/qml/jsruntime/qv4dateobject.cpp
+++ b/src/qml/jsruntime/qv4dateobject.cpp
@@ -712,13 +712,13 @@ void DatePrototype::init(ExecutionEngine *engine, const Value &ctor)
ctor.objectValue()->defineDefaultProperty(QStringLiteral("now"), method_now, 0);
defineDefaultProperty(QStringLiteral("constructor"), ctor);
- defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(QStringLiteral("toDateString"), method_toDateString, 0);
defineDefaultProperty(QStringLiteral("toTimeString"), method_toTimeString, 0);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("toLocaleDateString"), method_toLocaleDateString, 0);
defineDefaultProperty(QStringLiteral("toLocaleTimeString"), method_toLocaleTimeString, 0);
- defineDefaultProperty(QStringLiteral("valueOf"), method_valueOf, 0);
+ defineDefaultProperty(engine->id_valueOf, method_valueOf, 0);
defineDefaultProperty(QStringLiteral("getTime"), method_getTime, 0);
defineDefaultProperty(QStringLiteral("getYear"), method_getYear, 0);
defineDefaultProperty(QStringLiteral("getFullYear"), method_getFullYear, 0);
@@ -1305,7 +1305,8 @@ ReturnedValue DatePrototype::method_toJSON(SimpleCallContext *ctx)
if (tv->isNumber() && !std::isfinite(tv->toNumber()))
return Encode::null();
- ScopedValue v(scope, O->objectValue()->get(ctx->engine->newString(QStringLiteral("toISOString"))));
+ ScopedString s(scope, ctx->engine->newString(QStringLiteral("toISOString")));
+ ScopedValue v(scope, O->objectValue()->get(s));
FunctionObject *toIso = v->asFunctionObject();
if (!toIso)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 4039e2135c..7e68f41883 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -154,6 +154,8 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
id_name = newIdentifier(QStringLiteral("name"));
id_index = newIdentifier(QStringLiteral("index"));
id_input = newIdentifier(QStringLiteral("input"));
+ id_toString = newIdentifier(QStringLiteral("toString"));
+ id_valueOf = newIdentifier(QStringLiteral("valueOf"));
ObjectPrototype *objectPrototype = new (memoryManager) ObjectPrototype(emptyClass);
objectClass = emptyClass->changePrototype(objectPrototype);
@@ -714,6 +716,8 @@ void ExecutionEngine::markObjects()
id_name->mark();
id_index->mark();
id_input->mark();
+ id_toString->mark();
+ id_valueOf->mark();
objectCtor.mark();
stringCtor.mark();
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 0bc5f81d23..470bebf4c6 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -226,6 +226,8 @@ struct Q_QML_EXPORT ExecutionEngine
SafeString id_name;
SafeString id_index;
SafeString id_input;
+ SafeString id_toString;
+ SafeString id_valueOf;
QSet<CompiledData::CompilationUnit*> compilationUnits;
QMap<quintptr, QV4::Function*> allFunctions;
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index 0face7cf8c..700e17c664 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -322,7 +322,7 @@ void ErrorPrototype::init(ExecutionEngine *engine, const Value &ctor, Object *ob
ctor.objectValue()->defineReadonlyProperty(engine->id_prototype, Value::fromObject(obj));
ctor.objectValue()->defineReadonlyProperty(engine->id_length, Value::fromInt32(1));
obj->defineDefaultProperty(QStringLiteral("constructor"), ctor);
- obj->defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ obj->defineDefaultProperty(engine->id_toString, method_toString, 0);
obj->defineDefaultProperty(QStringLiteral("message"), Value::fromString(engine, QString()));
}
@@ -334,14 +334,15 @@ ReturnedValue ErrorPrototype::method_toString(SimpleCallContext *ctx)
if (!o)
ctx->throwTypeError();
- ScopedValue name(scope, o->get(ctx->engine->newString(QString::fromLatin1("name"))));
+ ScopedValue name(scope, o->get(ctx->engine->id_name));
QString qname;
if (name->isUndefined())
qname = QString::fromLatin1("Error");
else
qname = name->toQString();
- ScopedValue message(scope, o->get(ctx->engine->newString(QString::fromLatin1("message"))));
+ ScopedString s(scope, ctx->engine->newString(QString::fromLatin1("message")));
+ ScopedValue message(scope, o->get(s));
QString qmessage;
if (!message->isUndefined())
qmessage = message->toQString();
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 851bc49c6b..59d6fdb40a 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -274,7 +274,7 @@ void FunctionPrototype::init(ExecutionEngine *engine, const Value &ctor)
defineReadonlyProperty(engine->id_length, Value::fromInt32(0));
defineDefaultProperty(QStringLiteral("constructor"), ctor);
- defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(QStringLiteral("apply"), method_apply, 2);
defineDefaultProperty(QStringLiteral("call"), method_call, 1);
defineDefaultProperty(QStringLiteral("bind"), method_bind, 1);
diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp
index d67daff07f..6dec2d1ec6 100644
--- a/src/qml/jsruntime/qv4jsonobject.cpp
+++ b/src/qml/jsruntime/qv4jsonobject.cpp
@@ -702,10 +702,10 @@ static QString quote(const QString &str)
QString Stringify::Str(const QString &key, Value value)
{
Scope scope(ctx);
- QString result;
if (Object *o = value.asObject()) {
- Scoped<FunctionObject> toJSON(scope, o->get(ctx->engine->newString(QStringLiteral("toJSON"))));
+ ScopedString s(scope, ctx->engine->newString(QStringLiteral("toJSON")));
+ Scoped<FunctionObject> toJSON(scope, o->get(s));
if (!!toJSON) {
ScopedCallData callData(scope, 1);
callData->thisObject = value;
@@ -798,12 +798,14 @@ QString Stringify::JO(Object *o)
partial += member;
}
} else {
+ ScopedString s(scope);
for (int i = 0; i < propertyList.size(); ++i) {
bool exists;
- ScopedValue v(scope, o->get(propertyList.at(i), &exists));
+ s = propertyList.at(i);
+ ScopedValue v(scope, o->get(s, &exists));
if (!exists)
continue;
- QString member = makeMember(propertyList.at(i)->toQString(), v);
+ QString member = makeMember(s->toQString(), v);
if (!member.isEmpty())
partial += member;
}
diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp
index 4404f909b6..776819a75f 100644
--- a/src/qml/jsruntime/qv4managed.cpp
+++ b/src/qml/jsruntime/qv4managed.cpp
@@ -202,7 +202,7 @@ bool Managed::isEqualTo(Managed *, Managed *)
return false;
}
-ReturnedValue Managed::get(String *name, bool *hasProperty)
+ReturnedValue Managed::get(const StringRef name, bool *hasProperty)
{
return vtbl->get(this, name, hasProperty);
}
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 4c1675ef88..71b3573922 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -97,7 +97,7 @@ struct ManagedVTable
void (*destroy)(Managed *);
void (*collectDeletables)(Managed *, GCDeletable **deletable);
bool (*hasInstance)(Managed *, const Value &value);
- ReturnedValue (*get)(Managed *, String *name, bool *hasProperty);
+ ReturnedValue (*get)(Managed *, const StringRef name, bool *hasProperty);
ReturnedValue (*getIndexed)(Managed *, uint index, bool *hasProperty);
void (*put)(Managed *, String *name, const Value &value);
void (*putIndexed)(Managed *, uint index, const Value &value);
@@ -263,7 +263,7 @@ public:
}
ReturnedValue construct(CallData *d);
ReturnedValue call(CallData *d);
- ReturnedValue get(String *name, bool *hasProperty = 0);
+ 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); }
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index eb64b92aa2..75824d7ee5 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -88,9 +88,9 @@ void NumberPrototype::init(ExecutionEngine *engine, const Value &ctor)
#endif
defineDefaultProperty(QStringLiteral("constructor"), ctor);
- defineDefaultProperty(QStringLiteral("toString"), method_toString);
+ defineDefaultProperty(engine->id_toString, method_toString);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString);
- defineDefaultProperty(QStringLiteral("valueOf"), method_valueOf);
+ defineDefaultProperty(engine->id_valueOf, method_valueOf);
defineDefaultProperty(QStringLiteral("toFixed"), method_toFixed, 1);
defineDefaultProperty(QStringLiteral("toExponential"), method_toExponential);
defineDefaultProperty(QStringLiteral("toPrecision"), method_toPrecision);
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 68469f1f2d..168933f8e5 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -170,7 +170,8 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const Value &value
void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const ValueRef rhs)
{
Scope scope(ctx);
- ScopedValue v(scope, get(name));
+ ScopedString n(scope, name);
+ ScopedValue v(scope, get(n));
ScopedValue result(scope, op(v, rhs));
put(name, result);
}
@@ -194,7 +195,8 @@ void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, const ValueRef index,
void Object::inplaceBinOp(ExecutionContext *ctx, BinOpContext op, String *name, const ValueRef rhs)
{
Scope scope(ctx);
- ScopedValue v(scope, get(name));
+ ScopedString n(scope, name);
+ ScopedValue v(scope, get(n));
ScopedValue result(scope, op(ctx, v, rhs));
put(name, result);
}
@@ -239,6 +241,15 @@ void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(Si
defineDefaultProperty(s, function.asValue());
}
+void Object::defineDefaultProperty(const StringRef name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount)
+{
+ ExecutionEngine *e = engine();
+ Scope scope(e);
+ Scoped<FunctionObject> function(scope, e->newBuiltinFunction(e->rootContext, name, code));
+ function->defineReadonlyProperty(e->id_length, Value::fromInt32(argumentCount));
+ defineDefaultProperty(name, function.asValue());
+}
+
void Object::defineAccessorProperty(const QString &name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *))
{
ExecutionEngine *e = engine();
@@ -444,7 +455,7 @@ bool Object::__hasProperty__(uint index) const
return false;
}
-ReturnedValue Object::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue Object::get(Managed *m, const StringRef name, bool *hasProperty)
{
return static_cast<Object *>(m)->internalGet(name, hasProperty);
}
@@ -643,7 +654,7 @@ Property *Object::advanceIterator(Managed *m, ObjectIterator *it, String **name,
}
// Section 8.12.3
-ReturnedValue Object::internalGet(String *name, bool *hasProperty)
+ReturnedValue Object::internalGet(const StringRef name, bool *hasProperty)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
@@ -653,7 +664,7 @@ ReturnedValue Object::internalGet(String *name, bool *hasProperty)
Object *o = this;
while (o) {
- uint idx = o->internalClass->find(name);
+ uint idx = o->internalClass->find(name.getPointer());
if (idx < UINT_MAX) {
if (hasProperty)
*hasProperty = true;
@@ -665,7 +676,7 @@ ReturnedValue Object::internalGet(String *name, bool *hasProperty)
if (hasProperty)
*hasProperty = false;
- return Value::undefinedValue().asReturnedValue();
+ return Encode::undefined();
}
ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty)
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 17e0b6dcf5..b17146c64a 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -166,6 +166,7 @@ struct Q_QML_EXPORT Object: Managed {
void defineDefaultProperty(const StringRef name, Value value);
void defineDefaultProperty(const QString &name, Value value);
void defineDefaultProperty(const QString &name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount = 0);
+ void defineDefaultProperty(const StringRef name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount = 0);
void defineAccessorProperty(const QString &name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *));
void defineAccessorProperty(const StringRef name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *));
/* Fixed: Writable: false, Enumerable: false, Configurable: false */
@@ -287,7 +288,7 @@ public:
}
void ensureMemberIndex(uint idx);
- inline ReturnedValue get(String *name, bool *hasProperty = 0)
+ inline ReturnedValue get(const StringRef name, bool *hasProperty = 0)
{ return vtbl->get(this, name, hasProperty); }
inline ReturnedValue getIndexed(uint idx, bool *hasProperty = 0)
{ return vtbl->getIndexed(this, idx, hasProperty); }
@@ -309,7 +310,7 @@ public:
protected:
static void destroy(Managed *that);
static void markObjects(Managed *that);
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ 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 putIndexed(Managed *m, uint index, const Value &value);
@@ -323,7 +324,7 @@ protected:
private:
- ReturnedValue internalGet(String *name, bool *hasProperty);
+ ReturnedValue internalGet(const StringRef name, bool *hasProperty);
ReturnedValue internalGetIndexed(uint index, bool *hasProperty);
void internalPut(const StringRef name, const Value &value);
void internalPutIndexed(uint index, const Value &value);
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp
index 9cbf14990b..f7085e30b1 100644
--- a/src/qml/jsruntime/qv4objectproto.cpp
+++ b/src/qml/jsruntime/qv4objectproto.cpp
@@ -122,9 +122,9 @@ void ObjectPrototype::init(ExecutionEngine *v4, const Value &ctor)
ctor.objectValue()->defineDefaultProperty(QStringLiteral("keys"), method_keys, 1);
defineDefaultProperty(QStringLiteral("constructor"), ctor);
- defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ defineDefaultProperty(v4->id_toString, method_toString, 0);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
- defineDefaultProperty(QStringLiteral("valueOf"), method_valueOf, 0);
+ defineDefaultProperty(v4->id_valueOf, method_valueOf, 0);
defineDefaultProperty(QStringLiteral("hasOwnProperty"), method_hasOwnProperty, 1);
defineDefaultProperty(QStringLiteral("isPrototypeOf"), method_isPrototypeOf, 1);
defineDefaultProperty(QStringLiteral("propertyIsEnumerable"), method_propertyIsEnumerable, 1);
@@ -399,12 +399,12 @@ ReturnedValue ObjectPrototype::method_toString(SimpleCallContext *ctx)
ReturnedValue ObjectPrototype::method_toLocaleString(SimpleCallContext *ctx)
{
Scope scope(ctx);
- Object *o = ctx->thisObject.toObject(ctx);
- Scoped<FunctionObject> f(scope, o->get(ctx->engine->newString(QStringLiteral("toString"))));
+ ScopedObject o(scope, ctx->thisObject.toObject(ctx));
+ Scoped<FunctionObject> f(scope, o->get(ctx->engine->id_toString));
if (!f)
ctx->throwTypeError();
ScopedCallData callData(scope, 0);
- callData->thisObject = Value::fromObject(o);
+ callData->thisObject = o;
return f->call(callData);
}
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 9eb20f4bcb..c8488924a9 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -235,7 +235,7 @@ QObjectWrapper::QObjectWrapper(ExecutionEngine *engine, QObject *object)
vtbl = &static_vtbl;
m_destroy = engine->newIdentifier(QStringLiteral("destroy"));
- m_toString = engine->newIdentifier(QStringLiteral("toString"));
+ m_toString = engine->id_toString;
}
void QObjectWrapper::initializeBindings(ExecutionEngine *engine)
@@ -257,7 +257,7 @@ QQmlPropertyData *QObjectWrapper::findProperty(ExecutionEngine *engine, QQmlCont
return result;
}
-ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlContext, String *name, QObjectWrapper::RevisionMode revisionMode,
+ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlContext, String *n, QObjectWrapper::RevisionMode revisionMode,
bool *hasProperty, bool includeImports)
{
if (QQmlData::wasDeleted(m_object)) {
@@ -267,6 +267,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD
}
QV4:Scope scope(ctx);
+ QV4::ScopedString name(scope, n);
if (name->isEqualTo(m_destroy) || name->isEqualTo(m_toString)) {
int index = name->isEqualTo(m_destroy) ? QV4::QObjectMethod::DestroyMethod : QV4::QObjectMethod::ToStringMethod;
@@ -277,13 +278,13 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD
}
QQmlPropertyData local;
- QQmlPropertyData *result = findProperty(ctx->engine, qmlContext, name, revisionMode, &local);
+ QQmlPropertyData *result = findProperty(ctx->engine, qmlContext, name.getPointer(), revisionMode, &local);
if (!result) {
if (includeImports && name->startsWithUpper()) {
// Check for attached properties
if (qmlContext && qmlContext->imports) {
- QQmlTypeNameCache::Result r = qmlContext->imports->query(name);
+ QQmlTypeNameCache::Result r = qmlContext->imports->query(name.getPointer());
if (hasProperty)
*hasProperty = true;
@@ -329,10 +330,10 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD
} else if (result->isSignalHandler()) {
QV4::QmlSignalHandler *handler = new (ctx->engine->memoryManager) QV4::QmlSignalHandler(ctx->engine, m_object, result->coreIndex);
- QV4::String *connect = ctx->engine->newIdentifier(QStringLiteral("connect"));
- QV4::String *disconnect = ctx->engine->newIdentifier(QStringLiteral("disconnect"));
- handler->put(connect, QV4::Value::fromReturnedValue(ctx->engine->functionClass->prototype->get(connect)));
- handler->put(disconnect, QV4::Value::fromReturnedValue(ctx->engine->functionClass->prototype->get(disconnect)));
+ 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)));
return QV4::Value::fromObject(handler).asReturnedValue();
} else {
@@ -596,12 +597,12 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QQmlData *ddata, Q
return Value::fromObject(new (engine->memoryManager) QV4::QObjectWrapper(engine, object)).asReturnedValue();
}
-QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty)
+QV4::ReturnedValue QObjectWrapper::get(Managed *m, const StringRef name, bool *hasProperty)
{
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
ExecutionEngine *v4 = m->engine();
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
- return that->getQmlProperty(v4->current, qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true);
+ return that->getQmlProperty(v4->current, qmlContext, name.getPointer(), IgnoreRevision, hasProperty, /*includeImports*/ true);
}
void QObjectWrapper::put(Managed *m, String *name, const Value &value)
@@ -638,6 +639,8 @@ Property *QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, String
*name = 0;
*index = UINT_MAX;
+ QV4::Scope scope(m->engine());
+
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
if (!that->m_object)
@@ -646,20 +649,22 @@ Property *QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, String
const QMetaObject *mo = that->m_object->metaObject();
const int propertyCount = mo->propertyCount();
if (it->arrayIndex < propertyCount) {
- *name = that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name()));
+ ScopedString n(scope, that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name())));
+ *name = n.getPointer();
++it->arrayIndex;
if (attributes)
*attributes = QV4::Attr_Data;
- it->tmpDynamicProperty.value = QV4::Value::fromReturnedValue(that->get(*name));
+ it->tmpDynamicProperty.value = QV4::Value::fromReturnedValue(that->get(n));
return &it->tmpDynamicProperty;
}
const int methodCount = mo->methodCount();
if (it->arrayIndex < propertyCount + methodCount) {
- *name = that->engine()->newString(QString::fromUtf8(mo->method(it->arrayIndex - propertyCount).name()));
+ ScopedString n(scope, that->engine()->newString(QString::fromUtf8(mo->method(it->arrayIndex - propertyCount).name())));
+ *name = n.getPointer();
++it->arrayIndex;
if (attributes)
*attributes = QV4::Attr_Data;
- it->tmpDynamicProperty.value = QV4::Value::fromReturnedValue(that->get(*name));
+ it->tmpDynamicProperty.value = QV4::Value::fromReturnedValue(that->get(n));
return &it->tmpDynamicProperty;
}
return QV4::Object::advanceIterator(m, it, name, index, attributes);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 95986a4b0d..3e4abc30b9 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -105,7 +105,7 @@ private:
String *m_destroy;
String *m_toString;
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static PropertyAttributes query(const Managed *, String *name);
static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes);
diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp
index 5a9a8d9d1d..0a10002766 100644
--- a/src/qml/jsruntime/qv4regexp.cpp
+++ b/src/qml/jsruntime/qv4regexp.cpp
@@ -40,8 +40,8 @@
****************************************************************************/
#include "qv4regexp_p.h"
-
#include "qv4engine_p.h"
+#include "qv4scopedvalue_p.h"
using namespace QV4;
@@ -136,7 +136,7 @@ void RegExp::markObjects(Managed *that)
{
}
-ReturnedValue RegExp::get(Managed *, String *, bool *)
+ReturnedValue RegExp::get(Managed *, const StringRef, bool *)
{
return Value::undefinedValue().asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h
index f91faf5044..cae0665469 100644
--- a/src/qml/jsruntime/qv4regexp_p.h
+++ b/src/qml/jsruntime/qv4regexp_p.h
@@ -111,7 +111,7 @@ public:
protected:
static void destroy(Managed *that);
static void markObjects(Managed *that);
- static ReturnedValue get(Managed *, String *, bool *);
+ 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 putIndexed(Managed *m, uint index, const Value &value);
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index 76d3216fde..efe3c1fe71 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -207,8 +207,10 @@ QString RegExpObject::toString() const
QString RegExpObject::source() const
{
- Value s = Value::fromReturnedValue(const_cast<RegExpObject *>(this)->get(internalClass->engine->newIdentifier(QStringLiteral("source"))));
- return s.stringValue()->toQString();
+ Scope scope(engine());
+ ScopedString source(scope, scope.engine->newIdentifier(QStringLiteral("source")));
+ ScopedValue s(scope, const_cast<RegExpObject *>(this)->get(source));
+ return s->toQString();
}
uint RegExpObject::flags() const
@@ -292,7 +294,7 @@ void RegExpPrototype::init(ExecutionEngine *engine, const Value &ctor)
defineDefaultProperty(QStringLiteral("constructor"), ctor);
defineDefaultProperty(QStringLiteral("exec"), method_exec, 1);
defineDefaultProperty(QStringLiteral("test"), method_test, 1);
- defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(QStringLiteral("compile"), method_compile, 2);
}
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 644db82823..f297762ec7 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -561,8 +561,8 @@ ReturnedValue __qmljs_object_default_value(Object *object, int typeHint)
}
ExecutionEngine *engine = object->internalClass->engine;
- String *meth1 = engine->newString("toString");
- String *meth2 = engine->newString("valueOf");
+ SafeString *meth1 = &engine->id_toString;
+ SafeString *meth2 = &engine->id_valueOf;
if (typeHint == NUMBER_HINT)
qSwap(meth1, meth2);
@@ -572,14 +572,14 @@ ReturnedValue __qmljs_object_default_value(Object *object, int typeHint)
ScopedCallData callData(scope, 0);
callData->thisObject = Value::fromObject(object);
- ScopedValue conv(scope, object->get(meth1));
+ ScopedValue conv(scope, object->get(*meth1));
if (FunctionObject *o = conv->asFunctionObject()) {
Value r = Value::fromReturnedValue(o->call(callData));
if (r.isPrimitive())
return r.asReturnedValue();
}
- conv = object->get(meth2);
+ conv = object->get(*meth2);
if (FunctionObject *o = conv->asFunctionObject()) {
Value r = Value::fromReturnedValue(o->call(callData));
if (r.isPrimitive())
@@ -685,7 +685,7 @@ ReturnedValue __qmljs_get_element(ExecutionContext *ctx, const ValueRef object,
return o->getIndexed(idx);
}
- String *name = index->toString(ctx);
+ ScopedString name(scope, index->toString(ctx));
return o->get(name);
}
@@ -759,9 +759,10 @@ void __qmljs_set_activation_property(ExecutionContext *ctx, String *name, const
ctx->setProperty(name, *value);
}
-ReturnedValue __qmljs_get_property(ExecutionContext *ctx, const ValueRef object, String *name)
+ReturnedValue __qmljs_get_property(ExecutionContext *ctx, const ValueRef object, String *n)
{
Scope scope(ctx);
+ ScopedString name(scope, n);
Scoped<Object> o(scope, object);
if (o)
@@ -967,9 +968,10 @@ ReturnedValue __qmljs_call_activation_property(ExecutionContext *context, String
return o->call(callData);
}
-ReturnedValue __qmljs_call_property(ExecutionContext *context, String *name, CallDataRef callData)
+ReturnedValue __qmljs_call_property(ExecutionContext *context, String *n, CallDataRef callData)
{
Scope scope(context);
+ ScopedString name(scope, n);
Scoped<Object> baseObject(scope, callData->thisObject);
if (!baseObject) {
Q_ASSERT(!callData->thisObject.isEmpty());
@@ -1009,7 +1011,8 @@ ReturnedValue __qmljs_call_element(ExecutionContext *context, const ValueRef ind
Object *baseObject = callData->thisObject.toObject(context);
callData->thisObject = Value::fromObject(baseObject);
- Scoped<Object> o(scope, baseObject->get(index->toString(context)));
+ ScopedString s(scope, index->toString(context));
+ Scoped<Object> o(scope, baseObject->get(s));
if (!o)
context->throwTypeError();
@@ -1060,10 +1063,11 @@ ReturnedValue __qmljs_construct_value(ExecutionContext *context, const ValueRef
return f->construct(callData);
}
-ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueRef base, String *name, CallDataRef callData)
+ReturnedValue __qmljs_construct_property(ExecutionContext *context, const ValueRef base, String *n, CallDataRef callData)
{
Scope scope(context);
- Object *thisObject = base->toObject(context);
+ ScopedObject thisObject(scope, base->toObject(context));
+ ScopedString name(scope, n);
Scoped<Object> f(scope, thisObject->get(name));
if (!f)
@@ -1112,10 +1116,11 @@ QV4::ReturnedValue __qmljs_builtin_typeof_name(ExecutionContext *context, String
return __qmljs_builtin_typeof(context, prop);
}
-QV4::ReturnedValue __qmljs_builtin_typeof_member(ExecutionContext *context, const ValueRef base, String *name)
+QV4::ReturnedValue __qmljs_builtin_typeof_member(ExecutionContext *context, const ValueRef base, String *n)
{
Scope scope(context);
- Object *obj = base->toObject(context);
+ ScopedObject obj(scope, base->toObject(context));
+ ScopedString name(scope, n);
ScopedValue prop(scope, obj->get(name));
return __qmljs_builtin_typeof(context, prop);
}
@@ -1123,8 +1128,8 @@ QV4::ReturnedValue __qmljs_builtin_typeof_member(ExecutionContext *context, cons
QV4::ReturnedValue __qmljs_builtin_typeof_element(ExecutionContext *context, const ValueRef base, const ValueRef index)
{
Scope scope(context);
- String *name = index->toString(context);
- Object *obj = base->toObject(context);
+ ScopedString name(scope, index->toString(context));
+ ScopedObject obj(scope, base->toObject(context));
ScopedValue prop(scope, obj->get(name));
return __qmljs_builtin_typeof(context, prop);
}
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index d1f9363a7b..9b414b544d 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -535,7 +535,7 @@ SequencePrototype::SequencePrototype(InternalClass *ic)
void SequencePrototype::init()
{
defineDefaultProperty(QStringLiteral("sort"), method_sort, 1);
- defineDefaultProperty(QStringLiteral("valueOf"), method_valueOf, 0);
+ defineDefaultProperty(engine()->id_valueOf, method_valueOf, 0);
}
QV4::ReturnedValue SequencePrototype::method_sort(QV4::SimpleCallContext *ctx)
diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp
index f74e8d2451..48f2272e7d 100644
--- a/src/qml/jsruntime/qv4serialize.cpp
+++ b/src/qml/jsruntime/qv4serialize.cpp
@@ -269,13 +269,15 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, QV8Engine *engi
QV4::ScopedValue val(scope);
QV4::ScopedValue s(scope);
+ QV4::ScopedString str(scope);
for (quint32 ii = 0; ii < length; ++ii) {
s = properties->getIndexed(ii);
serialize(data, s, engine);
QV4::ExecutionContext *ctx = v4->current;
try {
- val = o->get(s->asString());
+ str = s->asString();
+ val = o->get(str);
} catch (QV4::Exception &e) {
e.accept(ctx);
}
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 806c37b283..0323f3c1d3 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -129,20 +129,19 @@ void String::destroy(Managed *that)
static_cast<String*>(that)->~String();
}
-ReturnedValue String::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue String::get(Managed *m, const StringRef name, bool *hasProperty)
{
Scope scope(m->engine());
- ScopedString n(scope, name);
String *that = static_cast<String *>(m);
ExecutionEngine *v4 = m->engine();
- if (name == v4->id_length) {
+ if (name->isEqualTo(v4->id_length)) {
if (hasProperty)
*hasProperty = true;
return Value::fromInt32(that->_text.length()).asReturnedValue();
}
PropertyAttributes attrs;
- Property *pd = v4->stringClass->prototype->__getPropertyDescriptor__(n, &attrs);
+ Property *pd = v4->stringClass->prototype->__getPropertyDescriptor__(name, &attrs);
if (!pd || attrs.isGeneric()) {
if (hasProperty)
*hasProperty = false;
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index 840e940802..36eb5103eb 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -127,7 +127,7 @@ struct Q_QML_EXPORT String : public Managed {
protected:
static void destroy(Managed *);
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ 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 putIndexed(Managed *m, uint index, const Value &value);
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 274e5b4bce..22e746311c 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -187,8 +187,8 @@ void StringPrototype::init(ExecutionEngine *engine, const Value &ctor)
ctor.objectValue()->defineDefaultProperty(QStringLiteral("fromCharCode"), method_fromCharCode, 1);
defineDefaultProperty(QStringLiteral("constructor"), ctor);
- defineDefaultProperty(QStringLiteral("toString"), method_toString);
- defineDefaultProperty(QStringLiteral("valueOf"), method_toString); // valueOf and toString are identical
+ defineDefaultProperty(engine->id_toString, method_toString);
+ defineDefaultProperty(engine->id_valueOf, method_toString); // valueOf and toString are identical
defineDefaultProperty(QStringLiteral("charAt"), method_charAt, 1);
defineDefaultProperty(QStringLiteral("charCodeAt"), method_charCodeAt, 1);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
@@ -352,10 +352,10 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context)
context->throwTypeError();
Scope scope(context);
- String *s = context->thisObject.toString(context);
+ ScopedString s(scope, context->thisObject.toString(context));
- Value regexp = context->argumentCount ? context->arguments[0] : Value::undefinedValue();
- RegExpObject *rx = regexp.as<RegExpObject>();
+ ScopedValue regexp(scope, context->argumentCount ? context->arguments[0] : Value::undefinedValue());
+ Scoped<RegExpObject> rx(scope, regexp);
if (!rx) {
ScopedCallData callData(scope, 1);
callData->args[0] = regexp;
@@ -369,16 +369,17 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context)
bool global = rx->global;
// ### use the standard builtin function, not the one that might be redefined in the proto
- Scoped<FunctionObject> exec(scope, context->engine->regExpClass->prototype->get(context->engine->newString(QStringLiteral("exec")), 0));
+ ScopedString execString(scope, context->engine->newString(QStringLiteral("exec")));
+ Scoped<FunctionObject> exec(scope, context->engine->regExpClass->prototype->get(execString));
ScopedCallData callData(scope, 1);
- callData->thisObject = Value::fromObject(rx);
- callData->args[0] = Value::fromString(s);
+ callData->thisObject = rx;
+ callData->args[0] = s;
if (!global)
return exec->call(callData);
- String *lastIndex = context->engine->newString(QStringLiteral("lastIndex"));
- rx->put(lastIndex, Value::fromInt32(0));
+ ScopedString lastIndex(scope, context->engine->newString(QStringLiteral("lastIndex")));
+ rx->put(lastIndex.getPointer(), Value::fromInt32(0));
Scoped<ArrayObject> a(scope, context->engine->newArrayObject());
double previousLastIndex = 0;
@@ -395,7 +396,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context)
double thisIndex = index->toInteger();
if (previousLastIndex == thisIndex) {
previousLastIndex = thisIndex + 1;
- rx->put(lastIndex, Value::fromDouble(previousLastIndex));
+ rx->put(lastIndex.getPointer(), Value::fromDouble(previousLastIndex));
} else {
previousLastIndex = thisIndex;
}
diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp
index 19a08a9ce7..97dcee2fde 100644
--- a/src/qml/jsruntime/qv4variantobject.cpp
+++ b/src/qml/jsruntime/qv4variantobject.cpp
@@ -148,8 +148,8 @@ void VariantPrototype::init()
{
defineDefaultProperty(QStringLiteral("preserve"), method_preserve, 0);
defineDefaultProperty(QStringLiteral("destroy"), method_destroy, 0);
- defineDefaultProperty(QStringLiteral("valueOf"), method_valueOf, 0);
- defineDefaultProperty(QStringLiteral("toString"), method_toString, 0);
+ defineDefaultProperty(engine()->id_valueOf, method_valueOf, 0);
+ defineDefaultProperty(engine()->id_toString, method_toString, 0);
}
QV4::ReturnedValue VariantPrototype::method_preserve(SimpleCallContext *ctx)
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 234700c675..40b90037d8 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -124,7 +124,7 @@ void QmlContextWrapper::takeContextOwnership(const Value &qmlglobal)
}
-ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlContextWrapper::get(Managed *m, const StringRef name, bool *hasProperty)
{
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
@@ -207,7 +207,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
while (context) {
// Search context properties
if (context->propertyNames.count()) {
- int propertyIdx = context->propertyNames.value(name);
+ int propertyIdx = context->propertyNames.value(name.getPointer());
if (propertyIdx != -1) {
@@ -243,7 +243,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
if (scopeObject) {
bool hasProp = false;
QV4::ScopedValue result(scope, QV4::QObjectWrapper::getQmlProperty(v4->current, context, scopeObject,
- name, QV4::QObjectWrapper::CheckRevision, &hasProp));
+ name.getPointer(), QV4::QObjectWrapper::CheckRevision, &hasProp));
if (hasProp) {
if (hasProperty)
*hasProperty = true;
@@ -256,7 +256,7 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty
// Search context object
if (context->contextObject) {
bool hasProp = false;
- result = QV4::QObjectWrapper::getQmlProperty(v4->current, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, &hasProp);
+ result = QV4::QObjectWrapper::getQmlProperty(v4->current, context, context->contextObject, name.getPointer(), QV4::QObjectWrapper::CheckRevision, &hasProp);
if (hasProp) {
if (hasProperty)
*hasProperty = true;
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index c5f7f251c1..f0169cc739 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -82,7 +82,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object
void setReadOnly(bool b) { readOnly = b; }
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static void destroy(Managed *that);
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 5c3e61759a..b1184729d0 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -312,7 +312,8 @@ void QQmlJavaScriptExpression::exceptionToError(const QV4::Exception &e, QQmlErr
}
QV4::Scoped<QV4::ErrorObject> errorObj(scope, e.value());
if (!!errorObj && errorObj->asSyntaxError()) {
- QV4::ScopedValue v(scope, errorObj->get(errorObj->engine()->newString("message")));
+ QV4::ScopedString m(scope, errorObj->engine()->newString("message"));
+ QV4::ScopedValue v(scope, errorObj->get(m));
error.setDescription(v->toQStringNoThrow());
} else {
QV4::ScopedValue v(scope, e.value());
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 23aca851a6..517c6c46db 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -98,14 +98,14 @@ QVariant QmlListWrapper::toVariant() const
}
-ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlListWrapper::get(Managed *m, const StringRef name, bool *hasProperty)
{
QV4::ExecutionEngine *v4 = m->engine();
QmlListWrapper *w = m->as<QmlListWrapper>();
if (!w)
v4->current->throwTypeError();
- if (name == v4->id_length && !w->object.isNull()) {
+ if (name->isEqualTo(v4->id_length) && !w->object.isNull()) {
quint32 count = w->property.count ? w->property.count(&w->property) : 0;
return Value::fromUInt32(count).asReturnedValue();
}
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index 0de028a35b..4bc1e95753 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -81,7 +81,7 @@ public:
QVariant toVariant() const;
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ 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 Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes);
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 09ef732e2d..f7e831cb80 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -112,7 +112,7 @@ ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlTypeNameCach
}
-ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlTypeWrapper::get(Managed *m, const StringRef name, bool *hasProperty)
{
QV4::ExecutionEngine *v4 = m->engine();
QV4::Scope scope(v4);
@@ -158,7 +158,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
}
// check for property.
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, qobjectSingleton, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty);
} else if (!siinfo->scriptApi(e).isUndefined()) {
QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine);
// NOTE: if used in a binding, changes will not trigger re-evaluation since non-NOTIFYable.
@@ -182,7 +182,7 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
} else if (w->object) {
QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object);
if (ao)
- return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, hasProperty);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, context, ao, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision, hasProperty);
// Fall through to base implementation
}
@@ -263,8 +263,10 @@ void QmlTypeWrapper::put(Managed *m, String *name, const Value &value)
PropertyAttributes QmlTypeWrapper::query(const Managed *m, String *name)
{
// ### Implement more efficiently.
+ Scope scope(m->engine());
+ ScopedString n(scope, name);
bool hasProperty = false;
- const_cast<Managed*>(m)->get(name, &hasProperty);
+ const_cast<Managed*>(m)->get(n, &hasProperty);
return hasProperty ? Attr_Data : Attr_Invalid;
}
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index acf6845736..770c50cc64 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -82,7 +82,7 @@ public:
static ReturnedValue create(QV8Engine *, QObject *, QQmlTypeNameCache *, const void *, TypeNameMode = IncludeEnums);
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static PropertyAttributes query(const Managed *, String *name);
static void destroy(Managed *that);
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 57c05b3a48..ca6fa1f277 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -136,7 +136,7 @@ void QmlValueTypeWrapper::initProto(ExecutionEngine *v4)
Scope scope(v4);
Scoped<Object> o(scope, v4->newObject());
- o->defineDefaultProperty(QStringLiteral("toString"), method_toString, 1);
+ o->defineDefaultProperty(v4->id_toString, method_toString, 1);
v4->qmlExtensions()->valueTypeWrapperPrototype = o.getPointer();
}
@@ -264,7 +264,7 @@ ReturnedValue QmlValueTypeWrapper::method_toString(SimpleCallContext *ctx)
}
}
-ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue QmlValueTypeWrapper::get(Managed *m, const StringRef name, bool *hasProperty)
{
QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>();
QV4::ExecutionEngine *v4 = m->engine();
@@ -291,7 +291,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProper
{
QQmlData *ddata = QQmlData::get(r->type, false);
if (ddata && ddata->propertyCache)
- result = ddata->propertyCache->property(name, 0, 0);
+ result = ddata->propertyCache->property(name.getPointer(), 0, 0);
else
result = QQmlPropertyCache::property(r->v8->engine(), r->type, name, 0, local);
}
@@ -302,7 +302,7 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProper
if (result->isFunction()) {
// calling a Q_INVOKABLE function of a value type
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4);
- return QV4::QObjectWrapper::getQmlProperty(v4->current, qmlContext, r->type, name, QV4::QObjectWrapper::IgnoreRevision);
+ return QV4::QObjectWrapper::getQmlProperty(v4->current, qmlContext, r->type, name.getPointer(), QV4::QObjectWrapper::IgnoreRevision);
}
#define VALUE_TYPE_LOAD(metatype, cpptype, constructor) \
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index 355000bb39..5e1256f8a1 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -83,7 +83,7 @@ public:
bool isEqual(const QVariant& value);
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static void put(Managed *m, String *name, const Value &value);
static void destroy(Managed *that);
static bool isEqualTo(Managed *m, Managed *other);
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 7aa68ad816..aa2ac897cc 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -209,7 +209,7 @@ public:
static void destroy(Managed *that) {
that->as<NamedNodeMap>()->~NamedNodeMap();
}
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
QList<NodeImpl *> list; // Only used in NamedNodeMap
@@ -240,7 +240,7 @@ public:
static void destroy(Managed *that) {
that->as<NodeList>()->~NodeList();
}
- static ReturnedValue get(Managed *m, String *name, bool *hasProperty);
+ static ReturnedValue get(Managed *m, const StringRef name, bool *hasProperty);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
// C++ API
@@ -890,7 +890,7 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty
return Encode::undefined();
}
-ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue NamedNodeMap::get(Managed *m, const StringRef name, bool *hasProperty)
{
NamedNodeMap *r = m->as<NamedNodeMap>();
QV4::ExecutionEngine *v4 = m->engine();
@@ -944,7 +944,7 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty)
return Encode::undefined();
}
-ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty)
+ReturnedValue NodeList::get(Managed *m, const StringRef name, bool *hasProperty)
{
QV4::ExecutionEngine *v4 = m->engine();
NodeList *r = m->as<NodeList>();
@@ -1507,17 +1507,20 @@ void QQmlXMLHttpRequest::dispatchCallback(const ValueRef me)
if (!o)
ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
- Scoped<Object> thisObj(scope, o->get(v4->newString(QStringLiteral("ThisObject"))));
+ ScopedString s(scope, v4->newString(QStringLiteral("ThisObject")));
+ Scoped<Object> thisObj(scope, o->get(s));
if (!thisObj)
ctx->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ThisObject"));
- Scoped<FunctionObject> callback(scope, thisObj->get(v4->newString(QStringLiteral("onreadystatechange"))));
+ s = v4->newString(QStringLiteral("onreadystatechange"));
+ Scoped<FunctionObject> callback(scope, thisObj->get(s));
if (!callback) {
// not an error, but no onreadystatechange function to call.
return;
}
- Scoped<Object> activationObject(scope, o->get(v4->newString(QStringLiteral("ActivationObject"))));
+ s = v4->newString(QStringLiteral("ActivationObject"));
+ Scoped<Object> activationObject(scope, o->get(s));
if (!activationObject)
v4->current->throwError(QStringLiteral("QQmlXMLHttpRequest: internal error: empty ActivationObject"));
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 2908d1b47b..64f4d5c000 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -3180,7 +3180,7 @@ public:
return QV4::Value::fromObject(object).asReturnedValue();
}
- static QV4::ReturnedValue get(QV4::Managed *m, QV4::String *name, bool *hasProperty)
+ static QV4::ReturnedValue get(QV4::Managed *m, const QV4::StringRef name, bool *hasProperty)
{
QQmlDelegateModelGroupChangeArray *array = m->as<QQmlDelegateModelGroupChangeArray>();
if (!array)
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index f84a6855dd..1dd4e950c6 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -1720,7 +1720,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::SimpleC
QV8Engine *engine = ctx->engine->v8Engine;
if (ctx->argumentCount == 2) {
- QQuickContext2DStyle *pattern = new (v4->memoryManager) QQuickContext2DStyle(v4);
+ QV4::Scoped<QQuickContext2DStyle> pattern(scope, new (v4->memoryManager) QQuickContext2DStyle(v4));
QColor color = engine->toVariant(ctx->arguments[0], qMetaTypeId<QColor>()).value<QColor>();
if (color.isValid()) {
@@ -1734,7 +1734,8 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::SimpleC
QImage patternTexture;
if (QV4::Object *o = ctx->arguments[0].asObject()) {
- QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, o->get(ctx->engine->newString(QStringLiteral("data"))));
+ QV4::ScopedString s(scope, ctx->engine->newString(QStringLiteral("data")));
+ QV4::Scoped<QQuickJSContext2DPixelData> pixelData(scope, o->get(s));
if (!!pixelData) {
patternTexture = pixelData->image;
}
@@ -1763,7 +1764,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createPattern(QV4::SimpleC
}
}
- return QV4::Value::fromObject(pattern).asReturnedValue();
+ return pattern.asReturnedValue();
}
return QV4::Encode::undefined();
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index c08719dec8..cf3d9acfa3 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -325,18 +325,20 @@ public:
}
QV4::ExecutionEngine *v4 = obj->engine();
-
- QV4::Value vbold = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("bold"))));
- QV4::Value vcap = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("capitalization"))));
- QV4::Value vfam = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("family"))));
- QV4::Value vital = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("italic"))));
- QV4::Value vlspac = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("letterSpacing"))));
- QV4::Value vpixsz = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("pixelSize"))));
- QV4::Value vpntsz = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("pointSize"))));
- QV4::Value vstrk = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("strikeout"))));
- QV4::Value vundl = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("underline"))));
- QV4::Value vweight = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("weight"))));
- QV4::Value vwspac = QV4::Value::fromReturnedValue(obj->get(v4->newString(QStringLiteral("wordSpacing"))));
+ QV4::Scope scope(v4);
+ QV4::ScopedString s(scope);
+
+ QV4::Value vbold = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("bold")))));
+ QV4::Value vcap = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("capitalization")))));
+ QV4::Value vfam = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("family")))));
+ QV4::Value vital = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("italic")))));
+ QV4::Value vlspac = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("letterSpacing")))));
+ QV4::Value vpixsz = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("pixelSize")))));
+ QV4::Value vpntsz = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("pointSize")))));
+ QV4::Value vstrk = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("strikeout")))));
+ QV4::Value vundl = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("underline")))));
+ QV4::Value vweight = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("weight")))));
+ QV4::Value vwspac = QV4::Value::fromReturnedValue(obj->get((s = v4->newString(QStringLiteral("wordSpacing")))));
// pull out the values, set ok to true if at least one valid field is given.
if (vbold.isBoolean()) {