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>
This commit is contained in:
Lars Knoll 2016-12-09 11:10:40 +01:00
parent 4dd13bb4c3
commit cf4e4899d2
2 changed files with 7 additions and 47 deletions

View File

@ -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

View File

@ -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();