diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-04-07 13:28:59 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-05-02 14:18:27 +0000 |
commit | d1af494793961a31747b689cf307b65d99367486 (patch) | |
tree | 1e89898065334e841ded62499331274cb9d0b230 /src/qml/qml | |
parent | 3c090c80c58d99f1bd29493ef747a4f6fa915a71 (diff) |
Change Objects vtable methods to take a StringOrSymbol
This is needed for symbol support.
Change-Id: I83db21f232168710d18999fd97d912016e86d630
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmllistwrapper.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/qqmllistwrapper_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmltypewrapper.cpp | 25 | ||||
-rw-r--r-- | src/qml/qml/qqmltypewrapper_p.h | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 21 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper_p.h | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 15 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 2 |
9 files changed, 65 insertions, 27 deletions
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 62ad9988d5..5e30f09eec 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -102,9 +102,14 @@ QVariant QmlListWrapper::toVariant() const } -ReturnedValue QmlListWrapper::get(const Managed *m, String *name, bool *hasProperty) +ReturnedValue QmlListWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty) { Q_ASSERT(m->as<QmlListWrapper>()); + + if (n->isSymbol()) + return Object::get(m, n, hasProperty); + String *name = static_cast<String *>(n); + const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m); QV4::ExecutionEngine *v4 = w->engine(); @@ -140,7 +145,7 @@ ReturnedValue QmlListWrapper::getIndexed(const Managed *m, uint index, bool *has return Primitive::undefinedValue().asReturnedValue(); } -bool QmlListWrapper::put(Managed *m, String *name, const Value &value) +bool QmlListWrapper::put(Managed *m, StringOrSymbol *name, const Value &value) { // doesn't do anything. Should we throw? Q_UNUSED(m); diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index e02831c8d1..4b53d91933 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -93,9 +93,9 @@ struct Q_QML_EXPORT QmlListWrapper : Object QVariant toVariant() const; - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); + static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty); static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty); - static bool put(Managed *m, String *name, const Value &value); + static bool put(Managed *m, StringOrSymbol *name, const Value &value); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); }; diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 8ddfa860d1..26f035705c 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -162,10 +162,14 @@ static ReturnedValue throwLowercaseEnumError(QV4::ExecutionEngine *v4, String *n return v4->throwTypeError(message); } -ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProperty) +ReturnedValue QQmlTypeWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty) { Q_ASSERT(m->as<QQmlTypeWrapper>()); + if (n->isSymbol()) + return Object::get(m, n, hasProperty); + String *name = static_cast<String *>(n); + QV4::ExecutionEngine *v4 = static_cast<const QQmlTypeWrapper *>(m)->engine(); QV4::Scope scope(v4); @@ -295,8 +299,12 @@ ReturnedValue QQmlTypeWrapper::get(const Managed *m, String *name, bool *hasProp } -bool QQmlTypeWrapper::put(Managed *m, String *name, const Value &value) +bool QQmlTypeWrapper::put(Managed *m, StringOrSymbol *n, const Value &value) { + if (n->isSymbol()) + return Object::put(m, n, value); + String *name = static_cast<String *>(n); + Q_ASSERT(m->as<QQmlTypeWrapper>()); QQmlTypeWrapper *w = static_cast<QQmlTypeWrapper *>(m); QV4::ExecutionEngine *v4 = w->engine(); @@ -337,11 +345,14 @@ bool QQmlTypeWrapper::put(Managed *m, String *name, const Value &value) return false; } -PropertyAttributes QQmlTypeWrapper::query(const Managed *m, String *name) +PropertyAttributes QQmlTypeWrapper::query(const Managed *m, StringOrSymbol *name) { + 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(name, &hasProperty); + static_cast<Object *>(const_cast<Managed*>(m))->get(n, &hasProperty); return hasProperty ? Attr_Data : Attr_Invalid; } @@ -409,9 +420,13 @@ QQmlType Heap::QQmlScopedEnumWrapper::type() const return QQmlType(typePrivate); } -ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, String *name, bool *hasProperty) +ReturnedValue QQmlScopedEnumWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty) { Q_ASSERT(m->as<QQmlScopedEnumWrapper>()); + if (n->isSymbol()) + return Object::get(m, n, hasProperty); + String *name = static_cast<String *>(n); + const QQmlScopedEnumWrapper *resource = static_cast<const QQmlScopedEnumWrapper *>(m); QV4::ExecutionEngine *v4 = resource->engine(); QV4::Scope scope(v4); diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h index dbaf83790f..30bbc8d179 100644 --- a/src/qml/qml/qqmltypewrapper_p.h +++ b/src/qml/qml/qqmltypewrapper_p.h @@ -112,9 +112,9 @@ struct Q_QML_EXPORT QQmlTypeWrapper : Object Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums); - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); - static bool put(Managed *m, String *name, const Value &value); - static PropertyAttributes query(const Managed *, String *name); + 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 bool isEqualTo(Managed *that, Managed *o); static ReturnedValue instanceOf(const Object *typeObject, const Value &var); }; @@ -124,7 +124,7 @@ struct Q_QML_EXPORT QQmlScopedEnumWrapper : Object V4_OBJECT2(QQmlScopedEnumWrapper, Object) V4_NEEDS_DESTROY - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); + static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty); }; } diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index c4c4b0b776..7e0cf64bed 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -241,12 +241,16 @@ bool QQmlValueTypeWrapper::isEqualTo(Managed *m, Managed *other) return false; } -PropertyAttributes QQmlValueTypeWrapper::query(const Managed *m, String *name) +PropertyAttributes QQmlValueTypeWrapper::query(const Managed *m, StringOrSymbol *name) { + 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); - QQmlPropertyData *result = r->d()->propertyCache()->property(name, nullptr, nullptr); + QQmlPropertyData *result = r->d()->propertyCache()->property(n, nullptr, nullptr); return result ? Attr_Data : Attr_Invalid; } @@ -355,9 +359,14 @@ ReturnedValue QQmlValueTypeWrapper::method_toString(const FunctionObject *b, con return Encode(b->engine()->newString(result)); } -ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *hasProperty) +ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty) { Q_ASSERT(m->as<QQmlValueTypeWrapper>()); + + if (n->isSymbol()) + return Object::get(m, n, hasProperty); + String *name = static_cast<String *>(n); + const QQmlValueTypeWrapper *r = static_cast<const QQmlValueTypeWrapper *>(m); QV4::ExecutionEngine *v4 = r->engine(); @@ -413,8 +422,12 @@ ReturnedValue QQmlValueTypeWrapper::get(const Managed *m, String *name, bool *ha #undef VALUE_TYPE_ACCESSOR } -bool QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) +bool QQmlValueTypeWrapper::put(Managed *m, StringOrSymbol *n, const Value &value) { + if (n->isSymbol()) + return Object::put(m, n, value); + String *name = static_cast<String *>(n); + Q_ASSERT(m->as<QQmlValueTypeWrapper>()); ExecutionEngine *v4 = static_cast<QQmlValueTypeWrapper *>(m)->engine(); Scope scope(v4); diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index f99d207d68..5a684bfb4d 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -106,10 +106,10 @@ public: int typeId() const; bool write(QObject *target, int propertyIndex) const; - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); - static bool put(Managed *m, String *name, const Value &value); + 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 *, String *name); + static PropertyAttributes query(const Managed *, StringOrSymbol *name); 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); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 9d3388c2f2..41531c1df3 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -228,7 +228,7 @@ public: static ReturnedValue create(ExecutionEngine *, NodeImpl *, const QList<NodeImpl *> &); // JS API - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); + static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty); static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty); }; @@ -250,7 +250,7 @@ public: V4_NEEDS_DESTROY // JS API - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); + static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty); static ReturnedValue getIndexed(const Managed *m, uint index, bool *hasProperty); // C++ API @@ -904,9 +904,14 @@ ReturnedValue NamedNodeMap::getIndexed(const Managed *m, uint index, bool *hasPr return Encode::undefined(); } -ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasProperty) +ReturnedValue NamedNodeMap::get(const Managed *m, StringOrSymbol *n, bool *hasProperty) { Q_ASSERT(m->as<NamedNodeMap>()); + + if (n->isSymbol()) + return Object::get(m, n, hasProperty); + String *name = static_cast<String *>(n); + const NamedNodeMap *r = static_cast<const NamedNodeMap *>(m); QV4::ExecutionEngine *v4 = r->engine(); @@ -949,7 +954,7 @@ ReturnedValue NodeList::getIndexed(const Managed *m, uint index, bool *hasProper return Encode::undefined(); } -ReturnedValue NodeList::get(const Managed *m, String *name, bool *hasProperty) +ReturnedValue NodeList::get(const Managed *m, StringOrSymbol *name, bool *hasProperty) { Q_ASSERT(m->as<NodeList>()); const NodeList *r = static_cast<const NodeList *>(m); @@ -957,7 +962,7 @@ ReturnedValue NodeList::get(const Managed *m, String *name, bool *hasProperty) name->makeIdentifier(); - if (name->equals(v4->id_length())) + if (name->identifier() == v4->id_length()->identifier()) return Primitive::fromInt32(r->d()->d->children.count()).asReturnedValue(); return Object::get(m, name, hasProperty); } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 0af0f79945..608582253b 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -197,7 +197,7 @@ ReturnedValue QtObject::findAndAdd(const QString *name, bool &foundProperty) con return Encode::undefined(); } -ReturnedValue QtObject::get(const Managed *m, String *name, bool *hasProperty) +ReturnedValue QtObject::get(const Managed *m, StringOrSymbol *name, bool *hasProperty) { bool hasProp = false; if (hasProperty == nullptr) { diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index e1f82df390..60a2a6b87d 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -93,7 +93,7 @@ struct QtObject : Object { V4_OBJECT2(QtObject, Object) - static ReturnedValue get(const Managed *m, String *name, bool *hasProperty); + static ReturnedValue get(const Managed *m, StringOrSymbol *name, bool *hasProperty); static void advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint *index, Property *p, PropertyAttributes *attributes); static ReturnedValue method_isQtObject(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); |