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 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | namespace QV4 { |
29 | |
30 | namespace Heap { |
31 | |
32 | struct QmlListWrapper : Object { |
33 | void init(); |
34 | void destroy(); |
35 | QV4QPointer<QObject> object; |
36 | |
37 | QQmlListProperty<QObject> &property() { |
38 | return *reinterpret_cast<QQmlListProperty<QObject>*>(propertyData); |
39 | } |
40 | |
41 | // interface instead of QMetaType to keep class a POD |
42 | const QtPrivate::QMetaTypeInterface *propertyType; |
43 | |
44 | private: |
45 | void *propertyData[sizeof(QQmlListProperty<QObject>)/sizeof(void*)]; |
46 | }; |
47 | |
48 | } |
49 | |
50 | struct Q_QML_EXPORT QmlListWrapper : Object |
51 | { |
52 | V4_OBJECT2(QmlListWrapper, Object) |
53 | V4_NEEDS_DESTROY |
54 | V4_PROTOTYPE(propertyListPrototype) |
55 | Q_MANAGED_TYPE(QmlListProperty) |
56 | |
57 | static ReturnedValue create(ExecutionEngine *engine, QObject *object, int propId, QMetaType propType); |
58 | static ReturnedValue create(ExecutionEngine *engine, const QQmlListProperty<QObject> &prop, QMetaType propType); |
59 | |
60 | QVariant toVariant() const; |
61 | QQmlListReference toListReference() const; |
62 | |
63 | static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty); |
64 | static qint64 virtualGetLength(const Managed *m); |
65 | static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver); |
66 | static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target); |
67 | }; |
68 | |
69 | struct PropertyListPrototype : Object |
70 | { |
71 | V4_PROTOTYPE(arrayPrototype) |
72 | |
73 | void init(); |
74 | |
75 | static ReturnedValue method_pop(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
76 | static ReturnedValue method_push(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
77 | static ReturnedValue method_shift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
78 | static ReturnedValue method_splice(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
79 | static ReturnedValue method_unshift(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
80 | static ReturnedValue method_indexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
81 | static ReturnedValue method_lastIndexOf(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
82 | static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
83 | static ReturnedValue method_get_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
84 | static ReturnedValue method_set_length(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); |
85 | }; |
86 | |
87 | } |
88 | |
89 | QT_END_NAMESPACE |
90 | |
91 | #endif |
92 | |
93 | |