diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-08-02 16:54:59 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-08-02 20:25:55 +0000 |
commit | a88f01364e147d9ea093bf0fdc639b45feef1788 (patch) | |
tree | cf1c49dee57f1c691eeecd633bffd0601256f236 /src/qml/jsruntime/qv4objectiterator_p.h | |
parent | 0d63c22eee293fe59d7691608deaaf3468045eb3 (diff) |
Implement ObjectIterator using the new iteration mechanism
And with that get rid of the old advanceIterator methods.
Change-Id: I969fa89d25df8992a4b08c8c081b91c92ffdfddd
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4objectiterator_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4objectiterator_p.h | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index ca40748b79..d6160b9dd0 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE namespace QV4 { -struct Q_QML_EXPORT ObjectIteratorData +struct Q_QML_EXPORT ObjectIterator { enum Flags { NoFlags = 0, @@ -65,48 +65,27 @@ struct Q_QML_EXPORT ObjectIteratorData }; ExecutionEngine *engine; - Value *object; - Value *current; - SparseArrayNode *arrayNode; - uint arrayIndex; - uint memberIndex; + Object *object; + OwnPropertyKeyIterator *iterator = nullptr; uint flags; -}; -Q_STATIC_ASSERT(std::is_trivial< ObjectIteratorData >::value); - -struct Q_QML_EXPORT ObjectIterator: ObjectIteratorData -{ - ObjectIterator(ExecutionEngine *e, Value *scratch1, Value *scratch2, Object *o, uint flags) - { - engine = e; - object = scratch1; - current = scratch2; - arrayNode = nullptr; - arrayIndex = 0; - memberIndex = 0; - this->flags = flags; - init(o); - } ObjectIterator(Scope &scope, const Object *o, uint flags) { engine = scope.engine; - object = scope.alloc(); - current = scope.alloc(); - arrayNode = nullptr; - arrayIndex = 0; - memberIndex = 0; + object = static_cast<Object *>(scope.alloc()); this->flags = flags; - init(o); + object->setM(o ? o->m() : nullptr); + iterator = object->ownPropertyKeys(); + } + ~ObjectIterator() + { + delete iterator; } void next(Value *name, uint *index, Property *pd, PropertyAttributes *attributes = nullptr); ReturnedValue nextPropertyName(Value *value); ReturnedValue nextPropertyNameAsString(Value *value); ReturnedValue nextPropertyNameAsString(); - -private: - void init(const Object *o); }; namespace Heap { |