diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-17 22:06:45 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-06-25 07:36:22 +0000 |
commit | 3e1bb90da4c44455c8c307e01876cc2127bdb15c (patch) | |
tree | 6b9278e2612fe71ce84273857babf8494b8d91bc /src/qml/qml/qqmltypewrapper.cpp | |
parent | f5a7953df3cb61edc6cc30175ea4f7f1c97deae6 (diff) |
Implement a virtual interface for getOwnProperty
This is required to support Proxy properly, and at the
same time fixes a couple of test failures.
The new interface also replaces the old query and
queryIndexed virtual interfaces, as those where doing
a subset of what getOwnProperty does.
Change-Id: I750e366b475ce971d6d9edf35fa17b7a2b07f771
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypewrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmltypewrapper.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 7270cffb00..144d077c44 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -350,15 +350,18 @@ bool QQmlTypeWrapper::put(Managed *m, StringOrSymbol *n, const Value &value) return false; } -PropertyAttributes QQmlTypeWrapper::query(const Managed *m, StringOrSymbol *name) +PropertyAttributes QQmlTypeWrapper::getOwnProperty(Managed *m, Identifier id, Property *p) { - if (name->isSymbol()) - return Object::query(m, name); - String *n = static_cast<String *>(name); - // ### Implement more efficiently. - bool hasProperty = false; - static_cast<Object *>(const_cast<Managed*>(m))->get(n, &hasProperty); - return hasProperty ? Attr_Data : Attr_Invalid; + if (id.isString()) { + Scope scope(m); + ScopedString n(scope, id.asHeapObject()); + // ### Implement more efficiently. + bool hasProperty = false; + static_cast<Object *>(m)->get(n, &hasProperty); + return hasProperty ? Attr_Data : Attr_Invalid; + } + + return QV4::Object::getOwnProperty(m, id, p); } bool QQmlTypeWrapper::isEqualTo(Managed *a, Managed *b) |