aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-12-09 11:10:40 +0100
committerLars Knoll <lars.knoll@qt.io>2016-12-11 17:00:37 +0000
commitcf4e4899d268b8a39578fc9713fa3c56ceecdf0b (patch)
tree5bbd4eb3ebe2c094e15e580753d5e7a22e554a48 /src
parent4dd13bb4c3b8da79c7ae7f68d930cabff381ead0 (diff)
Clean up the amount of init() methods on FunctionObject
Remove some unused ones and simplify the version taking a QString Change-Id: I682b4a06d4da84c2d6be7e4a9a3e831dbd11c9c4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp47
-rw-r--r--src/qml/jsruntime/qv4functionobject_p.h7
2 files changed, 7 insertions, 47 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index 0c1dc21347..18365e1ce6 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -92,46 +92,9 @@ void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function
void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name, bool createProto)
{
- Object::init();
- function = nullptr;
- this->scope = scope->d();
- Scope s(scope->engine());
- ScopedFunctionObject f(s, this);
- ScopedString n(s, s.engine->newString(name));
- f->init(n, createProto);
-}
-
-void Heap::FunctionObject::init(ExecutionContext *scope, const QString &name, bool createProto)
-{
- Object::init();
- function = nullptr;
- this->scope = scope;
- Scope s(scope->engine);
- ScopedFunctionObject f(s, this);
- ScopedString n(s, s.engine->newString(name));
- f->init(n, createProto);
-}
-
-void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const ReturnedValue name)
-{
- Object::init();
- function = nullptr;
- this->scope = scope->d();
- Scope s(scope);
- ScopedFunctionObject f(s, this);
- ScopedString n(s, name);
- f->init(n, false);
-}
-
-void Heap::FunctionObject::init(ExecutionContext *scope, const ReturnedValue name)
-{
- Object::init();
- function = nullptr;
- this->scope = scope;
- Scope s(scope->engine);
- ScopedFunctionObject f(s, this);
- ScopedString n(s, name);
- f->init(n, false);
+ Scope valueScope(scope);
+ ScopedString s(valueScope, valueScope.engine->newString(name));
+ init(scope, s, createProto);
}
void Heap::FunctionObject::init()
@@ -166,8 +129,8 @@ void FunctionObject::init(String *n, bool createProto)
*propertyData(Heap::FunctionObject::Index_Prototype) = Encode::undefined();
}
- ScopedValue v(s, n);
- defineReadonlyProperty(s.engine->id_name(), v);
+ if (n)
+ defineReadonlyProperty(s.engine->id_name(), *n);
}
ReturnedValue FunctionObject::name() const
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h
index ee11d3c07e..c720632153 100644
--- a/src/qml/jsruntime/qv4functionobject_p.h
+++ b/src/qml/jsruntime/qv4functionobject_p.h
@@ -69,12 +69,9 @@ struct Q_QML_PRIVATE_EXPORT FunctionObject : Object {
Index_ProtoConstructor = 0
};
- void init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto = false);
+ void init(QV4::ExecutionContext *scope, QV4::String *name = 0, bool createProto = false);
void init(QV4::ExecutionContext *scope, QV4::Function *function, bool createProto = false);
- void init(QV4::ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
- void init(ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
- void init(QV4::ExecutionContext *scope, const ReturnedValue name);
- void init(ExecutionContext *scope, const ReturnedValue name);
+ void init(QV4::ExecutionContext *scope, const QString &name, bool createProto = false);
void init();
void destroy();