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
qqmllistwrapper_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// Qt-Security score:significant
4
5#ifndef QQMLLISTWRAPPER_P_H
6#define QQMLLISTWRAPPER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qglobal.h>
20#include <QtCore/qpointer.h>
21
22#include <QtQml/qqmllist.h>
23
24#include <private/qv4value_p.h>
25#include <private/qv4object_p.h>
26
28
30
31class QQmlProperty;
32
33namespace QV4 {
34
35namespace Heap {
36
38{
39 void init(QMetaType propertyType);
40 void init(QObject *object, int propertyId, QMetaType propertyType);
41 void init(QObject *object, const QQmlListProperty<QObject> &list, QMetaType propertyType);
42 void destroy();
43
44 QObject *object() const { return m_object.data(); }
45 QMetaType propertyType() const { return QMetaType(m_propertyType); }
46 QMetaType elementType() const { return QQmlMetaType::listValueType(propertyType()); }
47
49 {
50 return reinterpret_cast<const QQmlListProperty<QObject>*>(m_propertyData);
51 }
52
54 {
55 return reinterpret_cast<QQmlListProperty<QObject>*>(m_propertyData);
56 }
57
58 // True if this wraps a QObject-owned list whose owner has since been
59 // destroyed, leaving property() dangling. A detached, owner-less list
60 // has both null, and thus returns false
61 bool hasDeadOwner() const { return !object() && property()->object; }
62
63private:
64 void *m_propertyData[sizeof(QQmlListProperty<QObject>)/sizeof(void*)];
65
66 QV4QPointer<QObject> m_object;
67
68 // interface instead of QMetaType to keep class a POD
69 const QtPrivate::QMetaTypeInterface *m_propertyType;
70};
71
72}
73
74struct Q_QML_EXPORT QmlListWrapper : Object
75{
80
82 static ReturnedValue create(ExecutionEngine *engine, const QQmlListProperty<QObject> &prop, QMetaType propType);
83 static ReturnedValue create(ExecutionEngine *engine, QMetaType propType);
84 static ReturnedValue createOwned(ExecutionEngine *engine, const QQmlProperty &prop);
85
86 QVariant toVariant() const;
88
89 static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
90 static qint64 virtualGetLength(const Managed *m);
91 static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
92 static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
93};
94
96{
97 V4_PROTOTYPE(arrayPrototype)
98
99 void init();
100
101 static ReturnedValue method_pop(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
102 static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
103 static ReturnedValue method_shift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
104 static ReturnedValue method_splice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
105 static ReturnedValue method_unshift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
106 static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
107 static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
108 static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
109 static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
110 static ReturnedValue method_set_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
111};
112
113}
114
115QT_END_NAMESPACE
116
117#endif
Combined button and popup list for selecting options.
Definition qjsvalue.h:24
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcQIORing)
static void appendWrapped(QQmlListProperty< QObject > *p, QObject *o)
static QObject * atWrapped(QQmlListProperty< QObject > *p, qsizetype i)
static void clearWrapped(QQmlListProperty< QObject > *p)
DEFINE_OBJECT_VTABLE(QmlListWrapper)
static void removeLastWrapped(QQmlListProperty< QObject > *p)
static qsizetype countWrapped(QQmlListProperty< QObject > *p)
static void replaceWrapped(QQmlListProperty< QObject > *p, qsizetype i, QObject *o)
ReturnedValue firstOrLastIndexOf(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc, Iterate iterate)
static void setArrayData(Heap::QmlListWrapper *d)
void init(QObject *object, int propertyId, QMetaType propertyType)
QMetaType elementType() const
QQmlListProperty< QObject > * property()
const QQmlListProperty< QObject > * property() const
void init(QMetaType propertyType)
QMetaType propertyType() const
void init(QObject *object, const QQmlListProperty< QObject > &list, QMetaType propertyType)
static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_splice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_set_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_pop(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_unshift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_shift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static qint64 virtualGetLength(const Managed *m)
static OwnPropertyKeyIterator * virtualOwnPropertyKeys(const Object *m, Value *target)
static ReturnedValue create(ExecutionEngine *engine, const QQmlListProperty< QObject > &prop, QMetaType propType)
QQmlListReference toListReference() const
static ReturnedValue create(ExecutionEngine *engine, QMetaType propType)
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
static ReturnedValue createOwned(ExecutionEngine *engine, const QQmlProperty &prop)
QVariant toVariant() const
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
~QmlListWrapperOwnPropertyKeyIterator() override=default