Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
27
28namespace QV4 {
29
30struct Sequence;
31struct Q_QML_EXPORT SequencePrototype : public QV4::Object
32{
33 V4_PROTOTYPE(arrayPrototype)
34 void init();
35
36 static ReturnedValue method_valueOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
37 static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
38
39 static ReturnedValue newSequence(
40 QV4::ExecutionEngine *engine, QMetaType type, QMetaSequence metaSequence, const void *data,
41 Heap::Object *object, int propertyIndex, Heap::ReferenceObject::Flags flags);
42 static ReturnedValue fromVariant(QV4::ExecutionEngine *engine, const QVariant &vd);
43 static ReturnedValue fromData(
44 QV4::ExecutionEngine *engine, QMetaType type, QMetaSequence metaSequence, const void *data);
45
46 static QMetaType metaTypeForSequence(const Sequence *object);
47 static QVariant toVariant(const Sequence *object);
48 static QVariant toVariant(const Value &array, QMetaType typeHint);
49 static void *getRawContainerPtr(const Sequence *object, QMetaType typeHint);
50};
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:
78
79 void *m_container;
80 const QtPrivate::QMetaTypeInterface *m_listType;
82};
83
84}
85
86struct Q_QML_EXPORT Sequence : public QV4::ReferenceObject
87{
89 Q_MANAGED_TYPE(V4Sequence)
90 V4_PROTOTYPE(sequencePrototype)
92public:
93 static QV4::ReturnedValue virtualGet(
94 const QV4::Managed *that, PropertyKey id, const Value *receiver, bool *hasProperty);
95 static qint64 virtualGetLength(const Managed *m);
96 static bool virtualPut(Managed *that, PropertyKey id, const QV4::Value &value, Value *receiver);
97 static bool virtualDeleteProperty(QV4::Managed *that, PropertyKey id);
98 static bool virtualIsEqualTo(Managed *that, Managed *other);
99 static QV4::OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
100 static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a);
101
102 qsizetype size() const;
103 QVariant at(qsizetype index) const;
104 void append(const QVariant &item);
105 void append(qsizetype num, const QVariant &item);
106 void replace(qsizetype index, const QVariant &item);
107 void removeLast(qsizetype num);
108
109 QV4::ReturnedValue containerGetIndexed(qsizetype index, bool *hasProperty) const;
110 bool containerPutIndexed(qsizetype index, const QV4::Value &value);
111 bool containerDeleteIndexedProperty(qsizetype index);
112 bool containerIsEqualTo(Managed *other);
113 bool sort(const FunctionObject *f, const Value *, const Value *argv, int argc);
114 void *getRawContainerPtr() const;
115 bool loadReference() const;
116 bool storeReference();
117};
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
152
153#endif // QV4SEQUENCEWRAPPER_P_H
\inmodule QtCore
\inmodule QtCore
Definition qmetatype.h:341
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
\inmodule QtCore
Definition qvariant.h:65
const QtPrivate::QMetaTypeInterface * valueMetaType
list append(new Employee("Blackpool", "Stephen"))
Combined button and popup list for selecting options.
quint64 ReturnedValue
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
const GLfloat * m
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat f
GLenum type
GLenum target
GLbitfield flags
GLenum array
GLuint num
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, JSToQVariantConversionBehavior conversionBehavior, V4ObjectSet *visitedObjects)
#define V4_NEEDS_DESTROY
#define Q_MANAGED_TYPE(type)
#define QT_DECLARE_SEQUENTIAL_CONTAINER(LOCAL, FOREIGN, VALUE)
#define V4_PROTOTYPE(p)
#define V4_OBJECT2(DataClass, superClass)
QVariant variant
[1]
QSharedPointer< T > other(t)
[5]
QGraphicsItem * item
QAction * at
QJSEngine engine
[0]
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