aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/imports/localstorage/plugin.cpp6
-rw-r--r--src/qml/jsruntime/qv4engine.cpp2
-rw-r--r--src/qml/jsruntime/qv4engine_p.h2
-rw-r--r--src/qml/jsruntime/qv4errorobject.cpp2
-rw-r--r--src/qml/jsruntime/qv4object.cpp28
-rw-r--r--src/qml/jsruntime/qv4object_p.h4
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h2
-rw-r--r--src/qml/qml/qqmlcomponent.cpp6
-rw-r--r--src/qml/qml/qqmlxmlhttprequest.cpp4
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp6
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp6
-rw-r--r--src/qml/util/qqmladaptormodel.cpp8
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp3
-rw-r--r--tests/auto/qml/qv4debugger/tst_qv4debugger.cpp2
14 files changed, 43 insertions, 38 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index c72e61cd99..1c71c529ca 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -448,7 +448,7 @@ QQmlSqlDatabaseData::QQmlSqlDatabaseData(QV8Engine *engine)
Scoped<Object> proto(scope, v4->newObject());
proto->defineDefaultProperty(v4, QStringLiteral("transaction"), qmlsqldatabase_transaction);
proto->defineDefaultProperty(v4, QStringLiteral("readTransaction"), qmlsqldatabase_read_transaction);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("version")), qmlsqldatabase_version, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("version"), qmlsqldatabase_version, 0);
proto->defineDefaultProperty(v4, QStringLiteral("changeVersion"), qmlsqldatabase_changeVersion);
databaseProto = proto;
}
@@ -461,8 +461,8 @@ QQmlSqlDatabaseData::QQmlSqlDatabaseData(QV8Engine *engine)
{
Scoped<Object> proto(scope, v4->newObject());
proto->defineDefaultProperty(v4, QStringLiteral("item"), qmlsqldatabase_rows_item);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("length")), qmlsqldatabase_rows_length, 0);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("forwardOnly")),
+ proto->defineAccessorProperty(v4, QStringLiteral("length"), qmlsqldatabase_rows_length, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("forwardOnly"),
qmlsqldatabase_rows_forwardOnly, qmlsqldatabase_rows_setForwardOnly);
rowsProto = proto;
}
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 70108aa00f..331d9d83f4 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -354,7 +354,7 @@ ExecutionContext *ExecutionEngine::pushGlobalContext()
return current;
}
-Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, StringRef name, ReturnedValue (*code)(SimpleCallContext *))
+Returned<FunctionObject> *ExecutionEngine::newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(SimpleCallContext *))
{
BuiltinFunction *f = new (memoryManager) BuiltinFunction(scope, name.getPointer(), code);
return f->asReturned<FunctionObject>();
diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h
index 5ee5e46eec..1cbf32e622 100644
--- a/src/qml/jsruntime/qv4engine_p.h
+++ b/src/qml/jsruntime/qv4engine_p.h
@@ -262,7 +262,7 @@ struct Q_QML_EXPORT ExecutionEngine
void pushContext(SimpleCallContext *context);
ExecutionContext *popContext();
- Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, StringRef name, ReturnedValue (*code)(SimpleCallContext *));
+ Returned<FunctionObject> *newBuiltinFunction(ExecutionContext *scope, const StringRef name, ReturnedValue (*code)(SimpleCallContext *));
Returned<BoundFunction> *newBoundFunction(ExecutionContext *scope, FunctionObject *target, Value boundThis, const QVector<Value> &boundArgs);
Returned<Object> *newObject();
diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp
index 987d5083fa..1fd539ae2f 100644
--- a/src/qml/jsruntime/qv4errorobject.cpp
+++ b/src/qml/jsruntime/qv4errorobject.cpp
@@ -91,7 +91,7 @@ ErrorObject::ErrorObject(InternalClass *ic, const Value &message, ErrorType t)
defineAccessorProperty(ic->engine, QStringLiteral("stack"), ErrorObject::method_get_stack, 0);
if (!message.isUndefined())
- defineDefaultProperty(ic->engine->newString(QStringLiteral("message")), message);
+ defineDefaultProperty(ic->engine, QStringLiteral("message"), message);
defineDefaultProperty(ic->engine, QStringLiteral("name"), Value::fromString(ic->engine, className()));
stackTrace = ic->engine->stackTrace();
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index fadc8f286a..e157faaf67 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -215,20 +215,24 @@ void Object::inplaceBinOp(ExecutionContext *ctx, BinOpContext op, const ValueRef
inplaceBinOp(ctx, op, name, rhs);
}
-void Object::defineDefaultProperty(String *name, Value value)
+void Object::defineDefaultProperty(const StringRef name, Value value)
{
- Property *pd = insertMember(name, Attr_Data|Attr_NotEnumerable);
+ Property *pd = insertMember(name.getPointer(), Attr_Data|Attr_NotEnumerable);
pd->value = value;
}
void Object::defineDefaultProperty(ExecutionContext *context, const QString &name, Value value)
{
- defineDefaultProperty(context->engine->newIdentifier(name), value);
+ Scope scope(context);
+ ScopedString s(scope, context->engine->newIdentifier(name));
+ defineDefaultProperty(s, value);
}
void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name, Value value)
{
- defineDefaultProperty(engine->newIdentifier(name), value);
+ Scope scope(engine);
+ ScopedString s(scope, engine->newIdentifier(name));
+ defineDefaultProperty(s, value);
}
void Object::defineDefaultProperty(ExecutionContext *context, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount)
@@ -238,7 +242,7 @@ void Object::defineDefaultProperty(ExecutionContext *context, const QString &nam
Scoped<String> s(scope, context->engine->newIdentifier(name));
Scoped<FunctionObject> function(scope, context->engine->newBuiltinFunction(context, s, code));
function->defineReadonlyProperty(context->engine->id_length, Value::fromInt32(argumentCount));
- defineDefaultProperty(s.getPointer(), function.asValue());
+ defineDefaultProperty(s, function.asValue());
}
void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int argumentCount)
@@ -248,7 +252,7 @@ void Object::defineDefaultProperty(ExecutionEngine *engine, const QString &name,
Scoped<String> s(scope, engine->newIdentifier(name));
Scoped<FunctionObject> function(scope, engine->newBuiltinFunction(engine->rootContext, s, code));
function->defineReadonlyProperty(engine->id_length, Value::fromInt32(argumentCount));
- defineDefaultProperty(s.getPointer(), function.asValue());
+ defineDefaultProperty(s, function.asValue());
}
void Object::defineAccessorProperty(ExecutionEngine *engine, const QString &name,
@@ -256,20 +260,18 @@ void Object::defineAccessorProperty(ExecutionEngine *engine, const QString &name
{
Scope scope(engine);
Scoped<String> s(scope, engine->newIdentifier(name));
- defineAccessorProperty(s.getPointer(), getter, setter);
+ defineAccessorProperty(s, getter, setter);
}
-void Object::defineAccessorProperty(String *name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *))
+void Object::defineAccessorProperty(const StringRef name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *))
{
ExecutionEngine *v4 = engine();
- Property *p = insertMember(name, QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
+ Property *p = insertMember(name.getPointer(), QV4::Attr_Accessor|QV4::Attr_NotConfigurable|QV4::Attr_NotEnumerable);
- Scope scope(v4);
- ScopedString s(scope, name);
if (getter)
- p->setGetter(v4->newBuiltinFunction(v4->rootContext, s, getter)->getPointer());
+ p->setGetter(v4->newBuiltinFunction(v4->rootContext, name, getter)->getPointer());
if (setter)
- p->setSetter(v4->newBuiltinFunction(v4->rootContext, s, setter)->getPointer());
+ p->setSetter(v4->newBuiltinFunction(v4->rootContext, name, setter)->getPointer());
}
void Object::defineReadonlyProperty(ExecutionEngine *engine, const QString &name, Value value)
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index 83c7d864ff..c0676667a4 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -163,13 +163,13 @@ struct Q_QML_EXPORT Object: Managed {
void inplaceBinOp(ExecutionContext *ctx, BinOpContext op, const ValueRef index, const ValueRef rhs);
/* The spec default: Writable: true, Enumerable: false, Configurable: true */
- void defineDefaultProperty(String *name, Value value);
+ void defineDefaultProperty(const StringRef name, Value value);
void defineDefaultProperty(ExecutionContext *context, const QString &name, Value value);
void defineDefaultProperty(ExecutionEngine *engine, const QString &name, Value value);
void defineDefaultProperty(ExecutionContext *context, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int count = 0);
void defineDefaultProperty(ExecutionEngine *engine, const QString &name, ReturnedValue (*code)(SimpleCallContext *), int count = 0);
void defineAccessorProperty(ExecutionEngine *engine, const QString &name, ReturnedValue (*getter)(SimpleCallContext *), ReturnedValue (*setter)(SimpleCallContext *));
- void defineAccessorProperty(String *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 */
void defineReadonlyProperty(ExecutionEngine *engine, const QString &name, Value value);
void defineReadonlyProperty(String *name, Value value);
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 066ed88588..68299c2e65 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -443,7 +443,7 @@ struct Referenced {
return static_cast<T*>(ptr->managed());
}
- T *getPointer() {
+ T *getPointer() const {
return static_cast<T *>(ptr->managed());
}
ReturnedValue asReturnedValue() const { return ptr->val; }
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 095da5d906..d3c30fc40d 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1407,10 +1407,10 @@ QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine)
QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine);
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- proto->defineAccessorProperty(v4->newString(QStringLiteral("onStatusChanged")),
+ proto->defineAccessorProperty(v4, QStringLiteral("onStatusChanged"),
QmlIncubatorObject::method_get_statusChanged, QmlIncubatorObject::method_set_statusChanged);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("status")), QmlIncubatorObject::method_get_status, 0);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("object")), QmlIncubatorObject::method_get_object, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("status"), QmlIncubatorObject::method_get_status, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("object"), QmlIncubatorObject::method_get_object, 0);
proto->defineDefaultProperty(v4, QStringLiteral("forceCompletion"), QmlIncubatorObject::method_forceCompletion);
incubationProto = proto;
diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp
index 131fb1c51f..53fb6ad477 100644
--- a/src/qml/qml/qqmlxmlhttprequest.cpp
+++ b/src/qml/qml/qqmlxmlhttprequest.cpp
@@ -1592,7 +1592,9 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject
defineReadonlyProperty(engine, QStringLiteral("DONE"), Value::fromInt32(4));
if (!proto)
setupProto();
- defineDefaultProperty(engine->id_prototype, Value::fromObject(proto));
+ Scope scope(engine);
+ ScopedString s(scope, engine->id_prototype);
+ defineDefaultProperty(s, Value::fromObject(proto));
}
~QQmlXMLHttpRequestCtor()
{}
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index bd10b7e719..f03ec7ee19 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -143,10 +143,10 @@ QV4::QtObject::QtObject(ExecutionEngine *v4, QQmlEngine *qmlEngine)
defineDefaultProperty(v4, QStringLiteral("createComponent"), method_createComponent);
}
- defineAccessorProperty(v4->newString(QStringLiteral("platform")), method_get_platform, 0);
- defineAccessorProperty(v4->newString(QStringLiteral("application")), method_get_application, 0);
+ defineAccessorProperty(v4, QStringLiteral("platform"), method_get_platform, 0);
+ defineAccessorProperty(v4, QStringLiteral("application"), method_get_application, 0);
#ifndef QT_NO_IM
- defineAccessorProperty(v4->newString(QStringLiteral("inputMethod")), method_get_inputMethod, 0);
+ defineAccessorProperty(v4, QStringLiteral("inputMethod"), method_get_inputMethod, 0);
#endif
}
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 8faa1ec088..c4b6141335 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -3239,9 +3239,9 @@ QQmlDelegateModelEngineData::QQmlDelegateModelEngineData(QV8Engine *e)
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- proto->defineAccessorProperty(v4->newString(QStringLiteral("index")), QQmlDelegateModelGroupChange::method_get_index, 0);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("count")), QQmlDelegateModelGroupChange::method_get_count, 0);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("moveId")), QQmlDelegateModelGroupChange::method_get_moveId, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("index"), QQmlDelegateModelGroupChange::method_get_index, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("count"), QQmlDelegateModelGroupChange::method_get_count, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("moveId"), QQmlDelegateModelGroupChange::method_get_moveId, 0);
changeProto = proto;
}
diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp
index 1562ab1029..51d6b3c4da 100644
--- a/src/qml/util/qqmladaptormodel.cpp
+++ b/src/qml/util/qqmladaptormodel.cpp
@@ -215,8 +215,8 @@ public:
QV4::ExecutionEngine *v4 = data->v4;
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- proto->defineAccessorProperty(v4->newString(QStringLiteral("index")), get_index, 0);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("hasModelChildren")), get_hasModelChildren, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("index"), get_index, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("hasModelChildren"), get_hasModelChildren, 0);
typedef QHash<QByteArray, int>::const_iterator iterator;
for (iterator it = roleNames.constBegin(), end = roleNames.constEnd(); it != end; ++it) {
@@ -953,8 +953,8 @@ QQmlAdaptorModelEngineData::QQmlAdaptorModelEngineData(QV8Engine *e)
{
QV4::Scope scope(v4);
QV4::Scoped<QV4::Object> proto(scope, v4->newObject());
- proto->defineAccessorProperty(v4->newString(QStringLiteral("index")), get_index, 0);
- proto->defineAccessorProperty(v4->newString(QStringLiteral("modelData")),
+ proto->defineAccessorProperty(v4, QStringLiteral("index"), get_index, 0);
+ proto->defineAccessorProperty(v4, QStringLiteral("modelData"),
QQmlDMListAccessorData::get_modelData, QQmlDMListAccessorData::set_modelData);
listItemProto = proto;
}
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index 82fbbd0862..ff7ad838f3 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -4179,7 +4179,8 @@ QQuickContext2DEngineData::QQuickContext2DEngineData(QV8Engine *engine)
gradientProto = proto;
proto = v4->newObject();
- proto->defineAccessorProperty(v4->id_length, QQuickJSContext2DPixelData::proto_get_length, 0);
+ QV4::ScopedString s(scope, v4->id_length);
+ proto->defineAccessorProperty(s, QQuickJSContext2DPixelData::proto_get_length, 0);
pixelArrayProto = proto;
}
diff --git a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp
index 7be954d4ef..3acc9c8311 100644
--- a/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp
+++ b/tests/auto/qml/qv4debugger/tst_qv4debugger.cpp
@@ -85,7 +85,7 @@ public:
QV4::Scope scope(v4);
QV4::Scoped<QV4::String> name(scope, v4->newString(functionName));
- QV4::ScopedValue function(scope, v4->newBuiltinFunction(v4->rootContext, name.getPointer(), injectedFunction));
+ QV4::ScopedValue function(scope, v4->newBuiltinFunction(v4->rootContext, name, injectedFunction));
v4->globalObject->put(name.getPointer(), function);
}