diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-07-03 11:07:15 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-07-03 11:19:03 +0000 |
commit | fc01254cf89543e509e8ebaca93aac7f009247dd (patch) | |
tree | 5da1b88e31797bc7dfa63343d3a9e9c3659c8252 /src/qml/jsruntime/qv4generatorobject.cpp | |
parent | a2372fd2c643615687ea3b8b1ccf53d699b6debd (diff) |
Fix class members that are generators
Properly support member functions that are generators in classes.
Change-Id: I5fc8d5b58a17c61a446b43d6576bb83de5ecd920
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4generatorobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4generatorobject.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4generatorobject.cpp b/src/qml/jsruntime/qv4generatorobject.cpp index bfc27954c4..8c3cd8b863 100644 --- a/src/qml/jsruntime/qv4generatorobject.cpp +++ b/src/qml/jsruntime/qv4generatorobject.cpp @@ -232,3 +232,21 @@ ReturnedValue GeneratorObject::resume(ExecutionEngine *engine, const Value &arg) return Encode::undefined(); return IteratorPrototype::createIterResultObject(engine, result, done); } + +DEFINE_OBJECT_VTABLE(MemberGeneratorFunction); + +Heap::FunctionObject *MemberGeneratorFunction::create(ExecutionContext *context, Function *function) +{ + Scope scope(context); + Scoped<GeneratorFunction> g(scope, context->engine()->memoryManager->allocate<MemberGeneratorFunction>(context, function)); + ScopedObject proto(scope, scope.engine->newObject()); + proto->setPrototypeOf(scope.engine->generatorPrototype()); + g->defineDefaultProperty(scope.engine->id_prototype(), proto, Attr_NotConfigurable|Attr_NotEnumerable); + g->setPrototypeOf(ScopedObject(scope, scope.engine->generatorFunctionCtor()->get(scope.engine->id_prototype()))); + return g->d(); +} + +ReturnedValue MemberGeneratorFunction::virtualCallAsConstructor(const FunctionObject *f, const Value *, int, const Value *) +{ + return f->engine()->throwTypeError(QStringLiteral("Function is not a constructor.")); +} |