diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-01 10:33:09 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-04 18:25:15 +0000 |
commit | a3225954d1049d9e4fea3171de00b24318a5ff31 (patch) | |
tree | 78c9db59611f19df439ac61fb2db339eee5da741 /src/qml | |
parent | 656db7a425fec6661ee3b42b89594a3e28637cdd (diff) |
Member functions should not have a prototype property
Change-Id: I19eb4012c8fee51a7e5bf264d11ab5337ac2a88d
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index f4037991b1..04fbe2d1e3 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -507,7 +507,7 @@ ReturnedValue ScriptFunction::virtualCall(const FunctionObject *fo, const Value return result; } -void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function, QV4::String *n) +void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function, QV4::String *n, bool makeConstructor) { FunctionObject::init(); this->scope.set(scope->engine(), scope->d()); @@ -521,7 +521,8 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function ScopedString name(s, n ? n->d() : function->name()); if (name) f->setName(name); - f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor); + if (makeConstructor) + f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor); Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()->propertyKey()) == Index_Length); setProperty(s.engine, Index_Length, Primitive::fromInt32(int(function->compiledFunction->length))); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 5976fd8f78..43f4921875 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -118,7 +118,7 @@ DECLARE_HEAP_OBJECT(ScriptFunction, FunctionObject) { Index_Name, Index_Length }; - void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr); + void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr, bool makeConstructor = true); }; #define MemberFunctionMembers(class, Member) \ @@ -126,6 +126,10 @@ DECLARE_HEAP_OBJECT(ScriptFunction, FunctionObject) { DECLARE_HEAP_OBJECT(MemberFunction, ScriptFunction) { DECLARE_MARKOBJECTS(MemberFunction) + + void init(QV4::ExecutionContext *scope, Function *function, QV4::String *name = nullptr) { + ScriptFunction::init(scope, function, name, false); + } }; struct ConstructorFunction : MemberFunction |