| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | #include <qv4iterator_p.h> |
| 4 | #include <qv4symbol_p.h> |
| 5 | #include <qv4engine_p.h> |
| 6 | |
| 7 | using namespace QV4; |
| 8 | |
| 9 | void IteratorPrototype::init(ExecutionEngine *engine) |
| 10 | { |
| 11 | defineDefaultProperty(name: engine->symbol_iterator(), code: method_iterator, argumentCount: 0); |
| 12 | } |
| 13 | |
| 14 | ReturnedValue IteratorPrototype::method_iterator(const FunctionObject *, const Value *thisObject, const Value *, int) |
| 15 | { |
| 16 | return thisObject->asReturnedValue(); |
| 17 | } |
| 18 | |
| 19 | |
| 20 | ReturnedValue IteratorPrototype::createIterResultObject(ExecutionEngine *engine, const Value &value, bool done) |
| 21 | { |
| 22 | Scope scope(engine); |
| 23 | ScopedObject obj(scope, engine->newObject()); |
| 24 | obj->set(name: ScopedString(scope, engine->newString(QStringLiteral("value" ))), v: value, shouldThrow: Object::DoNotThrow); |
| 25 | obj->set(name: ScopedString(scope, engine->newString(QStringLiteral("done" ))), v: Value::fromBoolean(b: done), shouldThrow: Object::DoNotThrow); |
| 26 | return obj->asReturnedValue(); |
| 27 | } |
| 28 | |
| 29 | |