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
4#ifndef QQMLLISTWRAPPER_P_H
5#define QQMLLISTWRAPPER_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/qpointer.h>
20
21#include <QtQml/qqmllist.h>
22
23#include <private/qv4value_p.h>
24#include <private/qv4object_p.h>
25
27
29
30namespace QV4 {
31
32namespace Heap {
33
35{
36 void init(QMetaType propertyType);
37 void init(QObject *object, int propertyId, QMetaType propertyType);
38 void init(QObject *object, const QQmlListProperty<QObject> &list, QMetaType propertyType);
39 void destroy();
40
41 QObject *object() const { return m_object.data(); }
42 QMetaType propertyType() const { return QMetaType(m_propertyType); }
43 QMetaType elementType() const { return QQmlMetaType::listValueType(propertyType()); }
44
46 {
47 return reinterpret_cast<const QQmlListProperty<QObject>*>(m_propertyData);
48 }
49
51 {
52 return reinterpret_cast<QQmlListProperty<QObject>*>(m_propertyData);
53 }
54
55private:
56 void *m_propertyData[sizeof(QQmlListProperty<QObject>)/sizeof(void*)];
57
58 QV4QPointer<QObject> m_object;
59
60 // interface instead of QMetaType to keep class a POD
61 const QtPrivate::QMetaTypeInterface *m_propertyType;
62};
63
64}
65
66struct Q_QML_EXPORT QmlListWrapper : Object
67{
72
74 static ReturnedValue create(ExecutionEngine *engine, const QQmlListProperty<QObject> &prop, QMetaType propType);
75 static ReturnedValue create(ExecutionEngine *engine, QMetaType propType);
76
77 QVariant toVariant() const;
79
80 static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
81 static qint64 virtualGetLength(const Managed *m);
82 static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
83 static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
84};
85
87{
88 V4_PROTOTYPE(arrayPrototype)
89
90 void init();
91
92 static ReturnedValue method_pop(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
93 static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
94 static ReturnedValue method_shift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
95 static ReturnedValue method_splice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
96 static ReturnedValue method_unshift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
97 static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
98 static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
99 static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
100 static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
101 static ReturnedValue method_set_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
102};
103
104}
105
106QT_END_NAMESPACE
107
108#endif
Definition qjsvalue.h:23
QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcEventDispatcher)
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)
QV4::ScopedObject object
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)
QVariant toVariant() const
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
~QmlListWrapperOwnPropertyKeyIterator() override=default