aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-18 10:02:04 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-22 01:06:20 +0200
commit8b3623ee7b707e1b26ad48bdbf7816b95d9e0e24 (patch)
treeca8c955546b9a70c60a4befc7eeccc944bc16d58 /src/qml/jsruntime
parent055f71f87d5d58be2aafd6c0ef2b84d57ed48b63 (diff)
Start using StringRef for parameter passing
Change-Id: If2c41daeda2862cd1162c5da8163a9d62fe4111d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
-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
6 files changed, 21 insertions, 19 deletions
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; }