From e60ac3f16ac3acb3a94a75566e07d302d87b8d09 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 9 Sep 2020 09:41:56 +0200 Subject: Rename QQmlSequence to QV4Sequence This feature is available without QML, in pure JavaScript. Change-Id: Iec8a52ed10ed3eeaec24d3955c8c132bf2bd9677 Reviewed-by: Fabian Kosmale --- src/qml/jsruntime/qv4managed.cpp | 4 +- src/qml/jsruntime/qv4managed_p.h | 4 +- src/qml/jsruntime/qv4sequenceobject.cpp | 136 ++++++++++++++++---------------- 3 files changed, 72 insertions(+), 72 deletions(-) (limited to 'src/qml/jsruntime') diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index f090afe649..4f9636ea27 100644 --- a/src/qml/jsruntime/qv4managed.cpp +++ b/src/qml/jsruntime/qv4managed.cpp @@ -137,8 +137,8 @@ QString Managed::className() const s = "__RegExp"; break; - case Type_QmlSequence: - s = "QmlSequence"; + case Type_V4Sequence: + s = "V4Sequence"; break; } return QString::fromLatin1(s); diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 96c47a9c41..6db03181f9 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -156,7 +156,7 @@ public: Type_ForInIterator, Type_RegExp, - Type_QmlSequence + Type_V4Sequence }; Q_MANAGED_TYPE(Invalid) @@ -164,7 +164,7 @@ public: const VTable *vtable() const { return d()->internalClass->vtable; } inline ExecutionEngine *engine() const { return internalClass()->engine; } - bool isListType() const { return d()->internalClass->vtable->type == Type_QmlSequence; } + bool isListType() const { return d()->internalClass->vtable->type == Type_V4Sequence; } bool isArrayLike() const { return isArrayObject() || isListType(); } bool isArrayObject() const { return d()->internalClass->vtable->type == Type_ArrayObject; } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index b78d6495e8..0031d65761 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -78,15 +78,15 @@ static void generateWarning(QV4::ExecutionEngine *v4, const QString& description // F(elementType, elementTypeName, sequenceType, defaultValue) #if QT_CONFIG(qml_itemmodel) -#define FOREACH_QML_SEQUENCE_TYPE_FOR_ITEMMODEL(F) \ +#define FOREACH_QV4_SEQUENCE_TYPE_FOR_ITEMMODEL(F) \ F(QModelIndex, QModelIndex, QModelIndexList, QModelIndex()) \ F(QModelIndex, QModelIndexStdVector, std::vector, QModelIndex()) \ F(QItemSelectionRange, QItemSelectionRange, QItemSelection, QItemSelectionRange()) #else -#define FOREACH_QML_SEQUENCE_TYPE_FOR_ITEMMODEL(F) +#define FOREACH_QV4_SEQUENCE_TYPE_FOR_ITEMMODEL(F) #endif -#define FOREACH_QML_SEQUENCE_TYPE(F) \ +#define FOREACH_QV4_SEQUENCE_TYPE(F) \ F(int, IntStdVector, std::vector, 0) \ F(qreal, RealStdVector, std::vector, 0.0) \ F(bool, BoolStdVector, std::vector, false) \ @@ -97,7 +97,7 @@ static void generateWarning(QV4::ExecutionEngine *v4, const QString& description F(QString, StringStdVector, std::vector, QString()) \ F(QUrl, Url, QList, QUrl()) \ F(QUrl, UrlStdVector, std::vector, QUrl()) \ - FOREACH_QML_SEQUENCE_TYPE_FOR_ITEMMODEL(F) + FOREACH_QV4_SEQUENCE_TYPE_FOR_ITEMMODEL(F) static QV4::ReturnedValue convertElementToValue(QV4::ExecutionEngine *engine, const QString &element) { @@ -228,12 +228,12 @@ template <> bool convertValueToElement(const Value &value) namespace QV4 { -template struct QQmlSequence; +template struct QV4Sequence; namespace Heap { template -struct QQmlSequence : Object { +struct QV4Sequence : Object { void init(const Container &container); void init(QObject *object, int propertyIndex, bool readOnly); void destroy() { @@ -252,10 +252,10 @@ struct QQmlSequence : Object { } template -struct QQmlSequence : public QV4::Object +struct QV4Sequence : public QV4::Object { - V4_OBJECT2(QQmlSequence, QV4::Object) - Q_MANAGED_TYPE(QmlSequence) + V4_OBJECT2(QV4Sequence, QV4::Object) + Q_MANAGED_TYPE(V4Sequence) V4_PROTOTYPE(sequencePrototype) V4_NEEDS_DESTROY public: @@ -357,7 +357,7 @@ public: ~OwnPropertyKeyIterator() override = default; PropertyKey next(const Object *o, Property *pd = nullptr, PropertyAttributes *attrs = nullptr) override { - const QQmlSequence *s = static_cast(o); + const QV4Sequence *s = static_cast(o); if (s->d()->isReference) { if (!s->d()->object) @@ -415,7 +415,7 @@ public: { if (!other) return false; - QQmlSequence *otherSequence = other->as >(); + QV4Sequence *otherSequence = other->as >(); if (!otherSequence) return false; if (d()->isReference && otherSequence->d()->isReference) { @@ -487,7 +487,7 @@ public: static QV4::ReturnedValue method_get_length(const FunctionObject *b, const Value *thisObject, const Value *, int) { QV4::Scope scope(b); - QV4::Scoped> This(scope, thisObject->as >()); + QV4::Scoped> This(scope, thisObject->as >()); if (!This) THROW_TYPE_ERROR(); @@ -502,7 +502,7 @@ public: static QV4::ReturnedValue method_set_length(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc) { QV4::Scope scope(f); - QV4::Scoped> This(scope, thisObject->as >()); + QV4::Scoped> This(scope, thisObject->as >()); if (!This) THROW_TYPE_ERROR(); @@ -589,34 +589,34 @@ public: { if (!id.isArrayIndex()) return Object::virtualGet(that, id, receiver, hasProperty); - return static_cast *>(that)->containerGetIndexed(id.asArrayIndex(), hasProperty); + return static_cast *>(that)->containerGetIndexed(id.asArrayIndex(), hasProperty); } static bool virtualPut(Managed *that, PropertyKey id, const QV4::Value &value, Value *receiver) { if (id.isArrayIndex()) - return static_cast *>(that)->containerPutIndexed(id.asArrayIndex(), value); + return static_cast *>(that)->containerPutIndexed(id.asArrayIndex(), value); return Object::virtualPut(that, id, value, receiver); } static QV4::PropertyAttributes queryIndexed(const QV4::Managed *that, uint index) - { return static_cast *>(that)->containerQueryIndexed(index); } + { return static_cast *>(that)->containerQueryIndexed(index); } static bool virtualDeleteProperty(QV4::Managed *that, PropertyKey id) { if (id.isArrayIndex()) { uint index = id.asArrayIndex(); - return static_cast *>(that)->containerDeleteIndexedProperty(index); + return static_cast *>(that)->containerDeleteIndexedProperty(index); } return Object::virtualDeleteProperty(that, id); } static bool virtualIsEqualTo(Managed *that, Managed *other) - { return static_cast *>(that)->containerIsEqualTo(other); } + { return static_cast *>(that)->containerIsEqualTo(other); } static QV4::OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target) - { return static_cast *>(m)->containerOwnPropertyKeys(m, target);} + { return static_cast *>(m)->containerOwnPropertyKeys(m, target);} }; template -void Heap::QQmlSequence::init(const Container &container) +void Heap::QV4Sequence::init(const Container &container) { Object::init(); this->container = new Container(container); @@ -626,13 +626,13 @@ void Heap::QQmlSequence::init(const Container &container) object.init(); QV4::Scope scope(internalClass->engine); - QV4::Scoped > o(scope, this); + QV4::Scoped > o(scope, this); o->setArrayType(Heap::ArrayData::Custom); o->init(); } template -void Heap::QQmlSequence::init(QObject *object, int propertyIndex, bool readOnly) +void Heap::QV4Sequence::init(QObject *object, int propertyIndex, bool readOnly) { Object::init(); this->container = new Container; @@ -641,7 +641,7 @@ void Heap::QQmlSequence::init(QObject *object, int propertyIndex, boo this->isReadOnly = readOnly; this->object.init(object); QV4::Scope scope(internalClass->engine); - QV4::Scoped > o(scope, this); + QV4::Scoped > o(scope, this); o->setArrayType(Heap::ArrayData::Custom); o->loadReference(); o->init(); @@ -651,45 +651,45 @@ void Heap::QQmlSequence::init(QObject *object, int propertyIndex, boo namespace QV4 { -typedef QQmlSequence > QQmlIntStdVectorList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlIntStdVectorList); -typedef QQmlSequence > QQmlRealStdVectorList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlRealStdVectorList); -typedef QQmlSequence > QQmlBoolStdVectorList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlBoolStdVectorList); -typedef QQmlSequence QQmlQStringList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlQStringList); -typedef QQmlSequence > QQmlStringStdVectorList; -typedef QQmlSequence > QQmlIntList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlIntList); -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlStringStdVectorList); -typedef QQmlSequence > QQmlUrlList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlUrlList); -typedef QQmlSequence > QQmlUrlStdVectorList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlUrlStdVectorList); +typedef QV4Sequence > QV4IntStdVectorList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4IntStdVectorList); +typedef QV4Sequence > QV4RealStdVectorList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4RealStdVectorList); +typedef QV4Sequence > QV4BoolStdVectorList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4BoolStdVectorList); +typedef QV4Sequence QV4QStringList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4QStringList); +typedef QV4Sequence > QV4StringStdVectorList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4StringStdVectorList); +typedef QV4Sequence > QV4IntList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4IntList); +typedef QV4Sequence > QV4UrlList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4UrlList); +typedef QV4Sequence > QV4UrlStdVectorList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4UrlStdVectorList); #if QT_CONFIG(qml_itemmodel) -typedef QQmlSequence QQmlQModelIndexList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlQModelIndexList); -typedef QQmlSequence > QQmlQModelIndexStdVectorList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlQModelIndexStdVectorList); -typedef QQmlSequence QQmlQItemSelectionRangeList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlQItemSelectionRangeList); +typedef QV4Sequence QV4QModelIndexList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4QModelIndexList); +typedef QV4Sequence > QV4QModelIndexStdVectorList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4QModelIndexStdVectorList); +typedef QV4Sequence QV4QItemSelectionRangeList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4QItemSelectionRangeList); #endif -typedef QQmlSequence > QQmlBoolList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlBoolList); -typedef QQmlSequence > QQmlRealList; -DEFINE_OBJECT_TEMPLATE_VTABLE(QQmlRealList); +typedef QV4Sequence > QV4BoolList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4BoolList); +typedef QV4Sequence > QV4RealList; +DEFINE_OBJECT_TEMPLATE_VTABLE(QV4RealList); } -#define REGISTER_QML_SEQUENCE_METATYPE(unused, unused2, SequenceType, unused3) qRegisterMetaType(#SequenceType); +#define REGISTER_QV4_SEQUENCE_METATYPE(unused, unused2, SequenceType, unused3) qRegisterMetaType(#SequenceType); void SequencePrototype::init() { - FOREACH_QML_SEQUENCE_TYPE(REGISTER_QML_SEQUENCE_METATYPE) + FOREACH_QV4_SEQUENCE_TYPE(REGISTER_QV4_SEQUENCE_METATYPE) defineDefaultProperty(QStringLiteral("sort"), method_sort, 1); defineDefaultProperty(engine()->id_valueOf(), method_valueOf, 0); } -#undef REGISTER_QML_SEQUENCE_METATYPE +#undef REGISTER_QV4_SEQUENCE_METATYPE ReturnedValue SequencePrototype::method_valueOf(const FunctionObject *f, const Value *thisObject, const Value *, int) { @@ -707,12 +707,12 @@ ReturnedValue SequencePrototype::method_sort(const FunctionObject *b, const Valu return o.asReturnedValue(); #define CALL_SORT(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue) \ - if (QQml##SequenceElementTypeName##List *s = o->as()) { \ + if (QV4##SequenceElementTypeName##List *s = o->as()) { \ if (!s->sort(b, thisObject, argv, argc)) \ THROW_TYPE_ERROR(); \ } else - FOREACH_QML_SEQUENCE_TYPE(CALL_SORT) + FOREACH_QV4_SEQUENCE_TYPE(CALL_SORT) #undef CALL_SORT {} @@ -726,13 +726,13 @@ ReturnedValue SequencePrototype::method_sort(const FunctionObject *b, const Valu bool SequencePrototype::isSequenceType(int sequenceTypeId) { - FOREACH_QML_SEQUENCE_TYPE(IS_SEQUENCE) { /* else */ return false; } + FOREACH_QV4_SEQUENCE_TYPE(IS_SEQUENCE) { /* else */ return false; } } #undef IS_SEQUENCE #define NEW_REFERENCE_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \ if (sequenceType == qMetaTypeId()) { \ - QV4::ScopedObject obj(scope, engine->memoryManager->allocate(object, propertyIndex, readOnly)); \ + QV4::ScopedObject obj(scope, engine->memoryManager->allocate(object, propertyIndex, readOnly)); \ return obj.asReturnedValue(); \ } else @@ -744,13 +744,13 @@ ReturnedValue SequencePrototype::newSequence(QV4::ExecutionEngine *engine, int s // (as well as object ptr + property index for updated-read and write-back) // and so access/mutate avoids variant conversion. *succeeded = true; - FOREACH_QML_SEQUENCE_TYPE(NEW_REFERENCE_SEQUENCE) { /* else */ *succeeded = false; return QV4::Encode::undefined(); } + FOREACH_QV4_SEQUENCE_TYPE(NEW_REFERENCE_SEQUENCE) { /* else */ *succeeded = false; return QV4::Encode::undefined(); } } #undef NEW_REFERENCE_SEQUENCE #define NEW_COPY_SEQUENCE(ElementType, ElementTypeName, SequenceType, unused) \ if (sequenceType == qMetaTypeId()) { \ - QV4::ScopedObject obj(scope, engine->memoryManager->allocate(v.value())); \ + QV4::ScopedObject obj(scope, engine->memoryManager->allocate(v.value())); \ return obj.asReturnedValue(); \ } else @@ -763,25 +763,25 @@ ReturnedValue SequencePrototype::fromVariant(QV4::ExecutionEngine *engine, const // QObject property. int sequenceType = v.userType(); *succeeded = true; - FOREACH_QML_SEQUENCE_TYPE(NEW_COPY_SEQUENCE) { /* else */ *succeeded = false; return QV4::Encode::undefined(); } + FOREACH_QV4_SEQUENCE_TYPE(NEW_COPY_SEQUENCE) { /* else */ *succeeded = false; return QV4::Encode::undefined(); } } #undef NEW_COPY_SEQUENCE #define SEQUENCE_TO_VARIANT(ElementType, ElementTypeName, SequenceType, unused) \ - if (QQml##ElementTypeName##List *list = object->as()) \ + if (QV4##ElementTypeName##List *list = object->as()) \ return list->toVariant(); \ else QVariant SequencePrototype::toVariant(Object *object) { Q_ASSERT(object->isListType()); - FOREACH_QML_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ return QVariant(); } + FOREACH_QV4_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ return QVariant(); } } #undef SEQUENCE_TO_VARIANT #define SEQUENCE_TO_VARIANT(ElementType, ElementTypeName, SequenceType, unused) \ if (typeHint == qMetaTypeId()) { \ - return QQml##ElementTypeName##List::toVariant(a); \ + return QV4##ElementTypeName##List::toVariant(a); \ } else QVariant SequencePrototype::toVariant(const QV4::Value &array, int typeHint, bool *succeeded) @@ -795,32 +795,32 @@ QVariant SequencePrototype::toVariant(const QV4::Value &array, int typeHint, boo QV4::Scope scope(array.as()->engine()); QV4::ScopedArrayObject a(scope, array); - FOREACH_QML_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ *succeeded = false; return QVariant(); } + FOREACH_QV4_SEQUENCE_TYPE(SEQUENCE_TO_VARIANT) { /* else */ *succeeded = false; return QVariant(); } } #undef SEQUENCE_TO_VARIANT #define SEQUENCE_GET_RAWCONTAINERPTR(ElementType, ElementTypeName, SequenceType, unused) \ - if (const QQml##ElementTypeName##List *list = [&]() -> const QQml##ElementTypeName##List* \ - { if (typeHint == qMetaTypeId()) return object->as(); return nullptr;}()) \ + if (const QV4##ElementTypeName##List *list = [&]() -> const QV4##ElementTypeName##List* \ + { if (typeHint == qMetaTypeId()) return object->as(); return nullptr;}()) \ return list->getRawContainerPtr(); \ else void* SequencePrototype::getRawContainerPtr(const Object *object, int typeHint) { - FOREACH_QML_SEQUENCE_TYPE(SEQUENCE_GET_RAWCONTAINERPTR) { /* else */ return nullptr; } + FOREACH_QV4_SEQUENCE_TYPE(SEQUENCE_GET_RAWCONTAINERPTR) { /* else */ return nullptr; } } #undef SEQUENCE_GET_RAWCONTAINERPTR #define MAP_META_TYPE(ElementType, ElementTypeName, SequenceType, unused) \ - if (object->as()) { \ + if (object->as()) { \ return qMetaTypeId(); \ } else int SequencePrototype::metaTypeForSequence(const QV4::Object *object) { - FOREACH_QML_SEQUENCE_TYPE(MAP_META_TYPE) + FOREACH_QV4_SEQUENCE_TYPE(MAP_META_TYPE) /*else*/ { return -1; } -- cgit v1.2.3