15void SetIteratorPrototype::init(ExecutionEngine *e)
17 defineDefaultProperty(QStringLiteral(
"next"), method_next, 0);
20 ScopedString val(scope, e->newString(QLatin1String(
"Set Iterator")));
21 defineReadonlyConfigurableProperty(e->symbol_toStringTag(), val);
24ReturnedValue SetIteratorPrototype::method_next(
const FunctionObject *b,
const Value *that,
const Value *,
int)
27 const SetIteratorObject *thisObject = that->as<SetIteratorObject>();
29 return scope.engine->throwTypeError(QLatin1String(
"Not a Set Iterator instance"));
31 Scoped<SetObject> s(scope, thisObject->d()->iteratedSet);
32 uint index = thisObject->d()->setNextIndex;
33 IteratorKind itemKind = thisObject->d()->iterationKind;
36 QV4::Value undefined = Value::undefinedValue();
37 return IteratorPrototype::createIterResultObject(scope.engine, undefined,
true);
40 Value *arguments = scope.constructUndefined(2);
42 while (index < s->d()->esTable->size()) {
43 s->d()->esTable->iterate(index, &arguments[0], &arguments[1]);
44 thisObject->d()->setNextIndex = index + 1;
46 if (itemKind == KeyValueIteratorKind) {
47 ScopedArrayObject resultArray(scope, scope.engine->newArrayObject());
48 resultArray->arrayReserve(2);
49 resultArray->arrayPut(0, arguments[0]);
50 resultArray->arrayPut(1, arguments[0]);
51 resultArray->setArrayLengthUnchecked(2);
53 return IteratorPrototype::createIterResultObject(scope.engine, resultArray,
false);
56 return IteratorPrototype::createIterResultObject(scope.engine, arguments[0],
false);
59 thisObject->d()->iteratedSet.set(scope.engine,
nullptr);
60 QV4::Value undefined = Value::undefinedValue();
61 return IteratorPrototype::createIterResultObject(scope.engine, undefined,
true);