aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4reflect.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-08-15 11:55:29 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-15 18:55:41 +0000
commit7f59171d00d185828b32d5d3e1cc9bcd34e7b003 (patch)
treef9624098ecf03e06fba7b2f66c992ffd6f592d1b /src/qml/jsruntime/qv4reflect.cpp
parent6747b6f3d68ad79c249d18e31eed0f3579848d12 (diff)
Fix Reflect.ownKeys
This function should not only return the names but also keys (symbols). Change-Id: I431e4aa8fa31ac6c16a415f00fb9f98405632562 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4reflect.cpp')
-rw-r--r--src/qml/jsruntime/qv4reflect.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/qml/jsruntime/qv4reflect.cpp b/src/qml/jsruntime/qv4reflect.cpp
index 20ea39d4e5..90c39f7c37 100644
--- a/src/qml/jsruntime/qv4reflect.cpp
+++ b/src/qml/jsruntime/qv4reflect.cpp
@@ -211,12 +211,32 @@ ReturnedValue Reflect::method_isExtensible(const FunctionObject *f, const Value
}
-ReturnedValue Reflect::method_ownKeys(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
+ReturnedValue Reflect::method_ownKeys(const FunctionObject *f, const Value *, const Value *argv, int argc)
{
if (!argc || !argv[0].isObject())
return f->engine()->throwTypeError();
- return ObjectPrototype::method_getOwnPropertyNames(f, thisObject, argv, argc);
+ Scope scope(f);
+ if (!argc)
+ return scope.engine->throwTypeError();
+
+ ScopedObject O(scope, argv[0].toObject(scope.engine));
+ if (!O)
+ return Encode::undefined();
+
+ ScopedArrayObject keys(scope, ObjectPrototype::getOwnPropertyNames(scope.engine, O));
+
+ Heap::InternalClass *ic = O->d()->internalClass;
+ ScopedValue n(scope);
+ for (uint i = 0; i < ic->size; ++i) {
+ PropertyKey id = ic->nameMap.at(i);
+ n = id.asStringOrSymbol();
+ if (!n || !n->isSymbol())
+ continue;
+ keys->push_back(n);
+ }
+ return keys->asReturnedValue();
+
}
ReturnedValue Reflect::method_preventExtensions(const FunctionObject *f, const Value *, const Value *argv, int argc)