diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-27 11:40:04 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:20:33 +0000 |
commit | a6eb09fa2015a6cff1c8344e5784235d6292098f (patch) | |
tree | e91188032ed251f22a0c07eb72baddccba45fee0 | |
parent | 8761cbd4f7aada5a976831ff404b004f537a660b (diff) |
Cleanup IteratorPrototype::createIterResult API
Change-Id: I42fe22c65f0551287f4acdc5a76889f07cca042c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r-- | src/qml/jsruntime/qv4arrayiterator.cpp | 10 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4iterator.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4iterator_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringiterator.cpp | 6 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4arrayiterator.cpp b/src/qml/jsruntime/qv4arrayiterator.cpp index 13c036f9a9..fb8c3295bd 100644 --- a/src/qml/jsruntime/qv4arrayiterator.cpp +++ b/src/qml/jsruntime/qv4arrayiterator.cpp @@ -66,7 +66,7 @@ ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const ScopedObject a(scope, thisObject->d()->iteratedObject); if (!a) { QV4::Value undefined = Primitive::undefinedValue(); - return IteratorPrototype::createIterResultObject(scope.engine, undefined, ScopedValue(scope, Primitive::fromBoolean(true)))->asReturnedValue(); + return IteratorPrototype::createIterResultObject(scope.engine, undefined, true); } quint32 index = thisObject->d()->nextIndex; @@ -78,19 +78,19 @@ ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const if (index >= len) { thisObject->d()->iteratedObject.set(scope.engine, nullptr); QV4::Value undefined = Primitive::undefinedValue(); - return IteratorPrototype::createIterResultObject(scope.engine, undefined, ScopedValue(scope, Primitive::fromBoolean(true)))->asReturnedValue(); + return IteratorPrototype::createIterResultObject(scope.engine, undefined, true); } thisObject->d()->nextIndex = index + 1; if (itemKind == KeyIteratorKind) { - return IteratorPrototype::createIterResultObject(scope.engine, Primitive::fromInt32(index), ScopedValue(scope, Primitive::fromBoolean(false)))->asReturnedValue(); + return IteratorPrototype::createIterResultObject(scope.engine, Primitive::fromInt32(index), false); } ReturnedValue elementValue = a->getIndexed(index); CHECK_EXCEPTION(); if (itemKind == ValueIteratorKind) { - return IteratorPrototype::createIterResultObject(scope.engine, Value::fromReturnedValue(elementValue), ScopedValue(scope, Primitive::fromBoolean(false)))->asReturnedValue(); + return IteratorPrototype::createIterResultObject(scope.engine, Value::fromReturnedValue(elementValue), false); } else { Q_ASSERT(itemKind == KeyValueIteratorKind); @@ -100,7 +100,7 @@ ReturnedValue ArrayIteratorPrototype::method_next(const FunctionObject *b, const resultArray->arrayPut(1, Value::fromReturnedValue(elementValue)); resultArray->setArrayLengthUnchecked(2); - return IteratorPrototype::createIterResultObject(scope.engine, resultArray, ScopedValue(scope, Primitive::fromBoolean(false)))->asReturnedValue(); + return IteratorPrototype::createIterResultObject(scope.engine, resultArray, false); } } diff --git a/src/qml/jsruntime/qv4iterator.cpp b/src/qml/jsruntime/qv4iterator.cpp index a97d2c60f2..3e2c2582f6 100644 --- a/src/qml/jsruntime/qv4iterator.cpp +++ b/src/qml/jsruntime/qv4iterator.cpp @@ -53,11 +53,11 @@ ReturnedValue IteratorPrototype::method_iterator(const FunctionObject *, const V } -Heap::Object *IteratorPrototype::createIterResultObject(ExecutionEngine *engine, const Value &value, const Value &done) +ReturnedValue IteratorPrototype::createIterResultObject(ExecutionEngine *engine, const Value &value, bool done) { Scope scope(engine); ScopedObject obj(scope, engine->newObject()); obj->set(ScopedString(scope, engine->newString(QStringLiteral("value"))), value, Object::DoNotThrow); - obj->set(ScopedString(scope, engine->newString(QStringLiteral("done"))), done, Object::DoNotThrow); - return obj->d(); + obj->set(ScopedString(scope, engine->newString(QStringLiteral("done"))), Primitive::fromBoolean(done), Object::DoNotThrow); + return obj->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4iterator_p.h b/src/qml/jsruntime/qv4iterator_p.h index 16027e64a0..d4617166ad 100644 --- a/src/qml/jsruntime/qv4iterator_p.h +++ b/src/qml/jsruntime/qv4iterator_p.h @@ -65,7 +65,7 @@ struct IteratorPrototype : Object static ReturnedValue method_iterator(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); - static Heap::Object *createIterResultObject(ExecutionEngine *engine, const Value &value, const Value &done); + static ReturnedValue createIterResultObject(ExecutionEngine *engine, const Value &value, bool done); }; } diff --git a/src/qml/jsruntime/qv4stringiterator.cpp b/src/qml/jsruntime/qv4stringiterator.cpp index abdd0ee051..810ed333e4 100644 --- a/src/qml/jsruntime/qv4stringiterator.cpp +++ b/src/qml/jsruntime/qv4stringiterator.cpp @@ -65,7 +65,7 @@ ReturnedValue StringIteratorPrototype::method_next(const FunctionObject *b, cons ScopedString s(scope, thisObject->d()->iteratedString); if (!s) { QV4::Value undefined = Primitive::undefinedValue(); - return IteratorPrototype::createIterResultObject(scope.engine, undefined, ScopedValue(scope, true); + return IteratorPrototype::createIterResultObject(scope.engine, undefined, true); } quint32 index = thisObject->d()->nextIndex; @@ -76,7 +76,7 @@ ReturnedValue StringIteratorPrototype::method_next(const FunctionObject *b, cons if (index >= len) { thisObject->d()->iteratedString.set(scope.engine, nullptr); QV4::Value undefined = Primitive::undefinedValue(); - return IteratorPrototype::createIterResultObject(scope.engine, undefined, ScopedValue(scope, true); + return IteratorPrototype::createIterResultObject(scope.engine, undefined, true); } QChar ch = str.at(index); @@ -90,6 +90,6 @@ ReturnedValue StringIteratorPrototype::method_next(const FunctionObject *b, cons thisObject->d()->nextIndex += num; ScopedString resultString(scope, scope.engine->newString(s->toQString().mid(index, num))); - return IteratorPrototype::createIterResultObject(scope.engine, resultString, ScopedValue(scope, false); + return IteratorPrototype::createIterResultObject(scope.engine, resultString, false); } |