aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4typedarray.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-09 21:57:43 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-10 06:37:42 +0000
commit0b157e9ab3b2b6282e567e656b5f6b8c713a9ac3 (patch)
tree31f3972c7ee2cedd3fad7e71855023dea8c088b4 /src/qml/jsruntime/qv4typedarray.cpp
parentccd9bd94147dbacbaae3dba4c6fb9425877faaee (diff)
Implement OwnPropertyKeys for TypedArray
Change-Id: I85d6cfa4b4652863cfafad4810176d99dccdabc9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4typedarray.cpp')
-rw-r--r--src/qml/jsruntime/qv4typedarray.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp
index a07443077e..a4d32ec06b 100644
--- a/src/qml/jsruntime/qv4typedarray.cpp
+++ b/src/qml/jsruntime/qv4typedarray.cpp
@@ -576,6 +576,38 @@ bool TypedArray::virtualDefineOwnProperty(Managed *m, PropertyKey id, const Prop
return true;
}
+struct TypedArrayOwnPropertyKeyIterator : ObjectOwnPropertyKeyIterator
+{
+ ~TypedArrayOwnPropertyKeyIterator() override = default;
+ PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override;
+
+};
+
+PropertyKey TypedArrayOwnPropertyKeyIterator::next(const Object *o, Property *pd, PropertyAttributes *attrs)
+{
+ const TypedArray *a = static_cast<const TypedArray *>(o);
+ if (arrayIndex < a->length()) {
+ if (attrs)
+ *attrs = Attr_NotConfigurable;
+ PropertyKey id = PropertyKey::fromArrayIndex(arrayIndex);
+ if (pd) {
+ bool hasProperty = false;
+ pd->value = TypedArray::virtualGet(a, id, a, &hasProperty);
+ }
+ ++arrayIndex;
+ return id;
+ }
+
+ arrayIndex = UINT_MAX;
+ return ObjectOwnPropertyKeyIterator::next(o, pd, attrs);
+}
+
+OwnPropertyKeyIterator *TypedArray::virtualOwnPropertyKeys(const Object *m, Value *target)
+{
+ *target = *m;
+ return new TypedArrayOwnPropertyKeyIterator();
+}
+
void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor)
{
Scope scope(engine);