From cf4e4899d268b8a39578fc9713fa3c56ceecdf0b Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 9 Dec 2016 11:10:40 +0100 Subject: 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 --- src/qml/jsruntime/qv4functionobject.cpp | 47 ++++----------------------------- src/qml/jsruntime/qv4functionobject_p.h | 7 ++--- 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(); -- cgit v1.2.3