diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-08 23:07:31 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-09 15:52:10 +0000 |
commit | bcc9aa7daf197e8f2befe215902443d608e07b6a (patch) | |
tree | 89d077b637c683e5b8add795e0b8ba2089dc4a3d /src/qml/jsruntime/qv4objectproto.cpp | |
parent | 166fc4d84729fee683a9ea6b2c27cf51dc5f1c9d (diff) |
Include symbols in getOwnPropertyKeys
And fix getOwnPropertySymbols and getOwnPropertyDescriptors.
Change-Id: Ie0e4c3d308ffe8a904e9a6ab9242b2cda59d779f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4objectproto.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 926d246373..a4f960a3b6 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -188,7 +188,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyDescriptors(const FunctionOb ScopedObject descriptors(scope, scope.engine->newObject()); - ObjectIterator it(scope, o, ObjectIterator::NoFlags); + ObjectIterator it(scope, o, ObjectIterator::WithSymbols); ScopedProperty pd(scope); PropertyAttributes attrs; ScopedPropertyKey key(scope); @@ -227,15 +227,19 @@ ReturnedValue ObjectPrototype::method_getOwnPropertySymbols(const FunctionObject ScopedObject O(scope, argv[0].toObject(scope.engine)); if (!O) return Encode::undefined(); - Heap::InternalClass *ic = O->d()->internalClass; - ScopedValue n(scope); + ScopedArrayObject array(scope, scope.engine->newArrayObject()); - for (uint i = 0; i < ic->size; ++i) { - PropertyKey id = ic->nameMap.at(i); - n = id.asStringOrSymbol(); - if (!n || !n->isSymbol()) - continue; - array->push_back(n); + if (O) { + ObjectIterator it(scope, O, ObjectIterator::WithSymbols); + ScopedValue name(scope); + while (1) { + name = it.nextPropertyNameAsString(); + if (name->isNull()) + break; + if (!name->isSymbol()) + continue; + array->push_back(name); + } } return array->asReturnedValue(); } @@ -916,6 +920,8 @@ Heap::ArrayObject *ObjectPrototype::getOwnPropertyNames(ExecutionEngine *v4, con name = it.nextPropertyNameAsString(); if (name->isNull()) break; + if (name->isSymbol()) + continue; array->push_back(name); } } |