aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-17 22:06:45 +0200
committerLars Knoll <lars.knoll@qt.io>2018-06-25 07:36:22 +0000
commit3e1bb90da4c44455c8c307e01876cc2127bdb15c (patch)
tree6b9278e2612fe71ce84273857babf8494b8d91bc /src/qml/qml
parentf5a7953df3cb61edc6cc30175ea4f7f1c97deae6 (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')
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp19
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp18
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper_p.h2
4 files changed, 22 insertions, 19 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)
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index 30bbc8d179..b17d0e0868 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -114,7 +114,7 @@ struct Q_QML_EXPORT QQmlTypeWrapper : Object
static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
static bool put(Managed *m, StringOrSymbol *name, const Value &value);
- static PropertyAttributes query(const Managed *, StringOrSymbol *name);
+ static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p);
static bool isEqualTo(Managed *that, Managed *o);
static ReturnedValue instanceOf(const Object *typeObject, const Value &var);
};
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 7e0cf64bed..aa716b8a73 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -241,17 +241,17 @@ bool QQmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other)
return false;
}
-PropertyAttributes QQmlValueTypeWrapper::query(const Managed *m, StringOrSymbol *name)
+PropertyAttributes QQmlValueTypeWrapper::getOwnProperty(Managed *m, Identifier id, Property *p)
{
- if (name->isSymbol())
- return Object::query(m, name);
-
- String *n = static_cast<String *>(name);
- Q_ASSERT(m->as<const QQmlValueTypeWrapper>());
- const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
+ if (id.isString()) {
+ Scope scope(m);
+ ScopedString n(scope, id.asHeapObject());
+ const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m);
+ QQmlPropertyData *result = r->d()->propertyCache()->property(n.getPointer(), nullptr, nullptr);
+ return result ? Attr_Data : Attr_Invalid;
+ }
- QQmlPropertyData *result = r->d()->propertyCache()->property(n, nullptr, nullptr);
- return result ? Attr_Data : Attr_Invalid;
+ return QV4::Object::getOwnProperty(m, id, p);
}
void QQmlValueTypeWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes)
diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h
index 5a684bfb4d..12d7114d2f 100644
--- a/src/qml/qml/qqmlvaluetypewrapper_p.h
+++ b/src/qml/qml/qqmlvaluetypewrapper_p.h
@@ -109,7 +109,7 @@ public:
static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty);
static bool put(Managed *m, StringOrSymbol *name, const Value &value);
static bool isEqualTo(Managed *m, Managed *other);
- static PropertyAttributes query(const Managed *, StringOrSymbol *name);
+ static PropertyAttributes getOwnProperty(Managed *m, Identifier id, Property *p);
static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes);
static ReturnedValue method_toString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);