Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4sequenceobject_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QV4SEQUENCEWRAPPER_P_H
5#define QV4SEQUENCEWRAPPER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qglobal.h>
19#include <QtCore/qvariant.h>
20#include <QtQml/qqml.h>
21
22#include <private/qv4referenceobject_p.h>
23#include <private/qv4value_p.h>
24#include <private/qv4object_p.h>
25
26QT_BEGIN_NAMESPACE
27
28namespace QV4 {
29
30struct Sequence;
51
52namespace Heap {
53
55{
56 void init(QMetaType listType, QMetaSequence metaSequence, const void *container);
57 void init(QMetaType listType, QMetaSequence metaSequence, const void *container,
58 Object *object, int propertyIndex, Heap::ReferenceObject::Flags flags);
59
60 Sequence *detached() const;
61 void destroy();
62
63 bool hasData() const { return m_container != nullptr; }
64 void *storagePointer();
65 const void *storagePointer() const { return m_container; }
66
67 bool isReadOnly() const { return m_object && !canWriteBack(); }
68
69 bool setVariant(const QVariant &variant);
70 QVariant toVariant() const;
71
72 QMetaType listType() const { return QMetaType(m_listType); }
73 QMetaType valueMetaType() const { return QMetaType(m_metaSequence->valueMetaType); }
74 QMetaSequence metaSequence() const { return QMetaSequence(m_metaSequence); }
75
76private:
77 void initTypes(QMetaType listType, QMetaSequence metaSequence);
78
79 void *m_container;
80 const QtPrivate::QMetaTypeInterface *m_listType;
81 const QtMetaContainerPrivate::QMetaSequenceInterface *m_metaSequence;
82};
83
84}
85
118
119}
120
121#define QT_DECLARE_SEQUENTIAL_CONTAINER(LOCAL, FOREIGN, VALUE)
122 struct LOCAL
123 {
124 Q_GADGET
125 QML_ANONYMOUS
126 QML_SEQUENTIAL_CONTAINER(VALUE)
127 QML_FOREIGN(FOREIGN)
128 QML_ADDED_IN_VERSION(2, 0)
129 }
130
131// We use the original QT_COORD_TYPE name because that will match up with relevant other
132// types in plugins.qmltypes (if you use either float or double, that is; otherwise you're
133// on your own).
134#ifdef QT_COORD_TYPE
135QT_DECLARE_SEQUENTIAL_CONTAINER(QStdRealVectorForeign, std::vector<qreal>, QT_COORD_TYPE);
136QT_DECLARE_SEQUENTIAL_CONTAINER(QRealListForeign, QList<qreal>, QT_COORD_TYPE);
137#else
138QT_DECLARE_SEQUENTIAL_CONTAINER(QRealStdVectorForeign, std::vector<qreal>, double);
139QT_DECLARE_SEQUENTIAL_CONTAINER(QRealListForeign, QList<qreal>, double);
140#endif
141
142QT_DECLARE_SEQUENTIAL_CONTAINER(QDoubleStdVectorForeign, std::vector<double>, double);
143QT_DECLARE_SEQUENTIAL_CONTAINER(QFloatStdVectorForeign, std::vector<float>, float);
144QT_DECLARE_SEQUENTIAL_CONTAINER(QIntStdVectorForeign, std::vector<int>, int);
145QT_DECLARE_SEQUENTIAL_CONTAINER(QBoolStdVectorForeign, std::vector<bool>, bool);
146QT_DECLARE_SEQUENTIAL_CONTAINER(QStringStdVectorForeign, std::vector<QString>, QString);
147QT_DECLARE_SEQUENTIAL_CONTAINER(QUrlStdVectorForeign, std::vector<QUrl>, QUrl);
148
149#undef QT_DECLARE_SEQUENTIAL_CONTAINER
150
151QT_END_NAMESPACE
152
153#endif // QV4SEQUENCEWRAPPER_P_H
Combined button and popup list for selecting options.
Definition qjsvalue.h:23
static void generateWarning(QV4::ExecutionEngine *v4, const QString &description)
static QV4::ReturnedValue method_set_length(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc)
static QV4::ReturnedValue method_get_length(const FunctionObject *b, const Value *thisObject, const Value *, int)
static ReturnedValue doGetIndexed(const Sequence *s, qsizetype index)
void convertAndDo(const QVariant &item, const QMetaType v, Action action)
bool convertToIterable(QMetaType metaType, void *data, QV4::Object *sequence)
SequenceOwnPropertyKeyIterator * containerOwnPropertyKeys(const Object *m, Value *target)
#define QT_DECLARE_SEQUENTIAL_CONTAINER(LOCAL, FOREIGN, VALUE)
Sequence * detached() const
void init(QMetaType listType, QMetaSequence metaSequence, const void *container)
QVariant toVariant() const
void init(QMetaType listType, QMetaSequence metaSequence, const void *container, Object *object, int propertyIndex, Heap::ReferenceObject::Flags flags)
QMetaType valueMetaType() const
const void * storagePointer() const
QMetaType listType() const
bool setVariant(const QVariant &variant)
QMetaSequence metaSequence() const
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
~SequenceOwnPropertyKeyIterator() override=default