diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-22 22:59:43 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-02 19:29:29 +0000 |
commit | db695c5b1d07275f208446dad178b1131b20bb0a (patch) | |
tree | c2175a065f4918d31249ca1ce46a2811733b8093 /src/qml/qml/qqmllistwrapper.cpp | |
parent | 98263a01373f5b225d64da216537165ae27d7ff1 (diff) |
Unify the get and getIndexed vtable functions of QV4::Object
This finalizes the refactoring of Object's vtable API. Also added
the receiver argument to the method as required by the ES7 spec.
Change-Id: I36f9989211c47458788fe9f7e929862bcfe7b845
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmllistwrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmllistwrapper.cpp | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index c2c8b796c3..5c88d4c2a5 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -102,47 +102,32 @@ QVariant QmlListWrapper::toVariant() const } -ReturnedValue QmlListWrapper::get(const Managed *m, StringOrSymbol *n, bool *hasProperty) +ReturnedValue QmlListWrapper::get(const Managed *m, Identifier id, const Value *receiver, 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(); - if (name->equals(v4->id_length()) && !w->d()->object.isNull()) { + if (id.isArrayIndex()) { + uint index = id.asArrayIndex(); quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0; - return Primitive::fromUInt32(count).asReturnedValue(); - } - - uint idx = name->asArrayIndex(); - if (idx != UINT_MAX) - return getIndexed(m, idx, hasProperty); + if (index < count && w->d()->property().at) { + if (hasProperty) + *hasProperty = true; + return QV4::QObjectWrapper::wrap(v4, w->d()->property().at(&w->d()->property(), index)); + } - return Object::get(m, name, hasProperty); -} - -ReturnedValue QmlListWrapper::getIndexed(const Managed *m, uint index, bool *hasProperty) -{ - Q_UNUSED(hasProperty); - - Q_ASSERT(m->as<QmlListWrapper>()); - const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m); - QV4::ExecutionEngine *v4 = w->engine(); - - quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0; - if (index < count && w->d()->property().at) { if (hasProperty) - *hasProperty = true; - return QV4::QObjectWrapper::wrap(v4, w->d()->property().at(&w->d()->property(), index)); + *hasProperty = false; + return Primitive::undefinedValue().asReturnedValue(); + } else if (id.isString()) { + if (id == v4->id_length()->identifier() && !w->d()->object.isNull()) { + quint32 count = w->d()->property().count ? w->d()->property().count(&w->d()->property()) : 0; + return Primitive::fromUInt32(count).asReturnedValue(); + } } - if (hasProperty) - *hasProperty = false; - return Primitive::undefinedValue().asReturnedValue(); + return Object::get(m, id, receiver, hasProperty); } bool QmlListWrapper::put(Managed *m, Identifier id, const Value &value, Value *receiver) |