Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qqmlvaluetypewrapper_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 QQMLVALUETYPEWRAPPER_P_H
5#define QQMLVALUETYPEWRAPPER_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 <private/qtqmlglobal_p.h>
20
21#include <private/qv4referenceobject_p.h>
22#include <private/qqmlpropertycache_p.h>
23#include <private/qqmltype_p_p.h>
24#include <private/qqmltypewrapper_p.h>
25#include <private/qv4object_p.h>
26#include <private/qv4qobjectwrapper_p.h>
27#include <private/qv4sequenceobject_p.h>
28#include <private/qv4value_p.h>
29#include <private/qv4referenceobject_p.h>
30
32
33class QQmlValueType;
34
35namespace QV4 {
36
37namespace Heap {
38
39#define QQmlValueTypeWrapperMembers(class, Member)
40
43
44 void init(
45 const void *data, QMetaType metaType, const QMetaObject *metaObject,
46 Object *object, int property, Flags flags)
47 {
48 ReferenceObject::init(object, property, flags);
49 setMetaType(metaType);
50 setMetaObject(metaObject);
51 if (data)
53 }
54
55 QQmlValueTypeWrapper *detached() const;
56
57 void destroy();
58
59 QMetaType metaType() const
60 {
61 Q_ASSERT(m_metaType != nullptr);
62 return QMetaType(m_metaType);
63 }
64
65 void setGadgetPtr(void *gadgetPtr) { m_gadgetPtr = gadgetPtr; }
66 void *gadgetPtr() const { return m_gadgetPtr; }
67
68 const QMetaObject *metaObject() const { return m_metaObject; }
69
70 void setData(const void *data)
71 {
72 const QMetaType type = metaType();
73 void *gadget = gadgetPtr();
74 if (gadget) {
75 type.destruct(gadget);
76 } else {
77 gadget = ::operator new(type.sizeOf());
78 setGadgetPtr(gadget);
79 }
80 type.construct(gadget, data);
81 }
82
83 QVariant toVariant() const;
84
85 void *storagePointer();
86 bool setVariant(const QVariant &variant);
87
88 bool readReference();
89 bool writeBack(int propertyIndex = QV4::ReferenceObject::AllProperties);
90
91private:
92 void setMetaObject(const QMetaObject *metaObject) { m_metaObject = metaObject; }
93 void setMetaType(QMetaType metaType)
94 {
95 Q_ASSERT(metaType.isValid());
96 m_metaType = metaType.iface();
97 }
98
99 void *m_gadgetPtr;
100 const QtPrivate::QMetaTypeInterface *m_metaType;
101 const QMetaObject *m_metaObject;
102};
103
104}
105
106struct Q_QML_EXPORT QQmlValueTypeWrapper : public ReferenceObject
107{
109 V4_PROTOTYPE(valueTypeWrapperPrototype)
111
112public:
113
114 static ReturnedValue create(
115 ExecutionEngine *engine, const void *data, const QMetaObject *metaObject,
116 QMetaType type, Heap::Object *object, int property, Heap::ReferenceObject::Flags flags);
117 static ReturnedValue create(
118 ExecutionEngine *engine, Heap::QQmlValueTypeWrapper *cloneFrom, Heap::Object *object);
119 static ReturnedValue create(
121
122 QVariant toVariant() const;
123 bool toGadget(void *data) const;
124 bool isEqual(const QVariant& value) const;
125 int typeId() const;
126 QMetaType type() const;
127 bool write(QObject *target, int propertyIndex) const;
128 bool readReferenceValue() const { return d()->readReference(); }
129 const QMetaObject *metaObject() const { return d()->metaObject(); }
130
131 QQmlPropertyData dataForPropertyKey(PropertyKey id) const;
132
133 static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
134 static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
135 static bool virtualIsEqualTo(Managed *m, Managed *other);
136 static bool virtualHasProperty(const Managed *m, PropertyKey id);
137 static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
138 static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
139 static ReturnedValue method_toString(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc);
140 static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup);
141 static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value);
142 static ReturnedValue lookupGetter(Lookup *lookup, ExecutionEngine *engine, const Value &object);
143 static bool lookupSetter(QV4::Lookup *l, QV4::ExecutionEngine *engine,
144 QV4::Value &object, const QV4::Value &value);
145
146 static void initProto(ExecutionEngine *v4);
147 static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a);
148};
149
150}
151
153
154#endif // QV8VALUETYPEWRAPPER_P_H
155
156
static bool isEqual(const aiUVTransform &a, const aiUVTransform &b)
\inmodule QtCore
Definition qmetatype.h:320
const QtPrivate::QMetaTypeInterface * iface() const
Definition qmetatype.h:750
bool isValid() const
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qvariant.h:64
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
quint64 ReturnedValue
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
Flags
GLboolean GLboolean GLboolean b
const GLfloat * m
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLenum type
GLenum target
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLfloat GLfloat p
[1]
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
static QVariant toVariant(const QV4::Value &value, QMetaType typeHint, bool createJSValueForObjectsAndSymbols, V4ObjectSet *visitedObjects)
#define V4_NEEDS_DESTROY
#define DECLARE_HEAP_OBJECT(name, base)
#define DECLARE_MARKOBJECTS(class)
#define V4_PROTOTYPE(p)
#define V4_OBJECT2(DataClass, superClass)
const char property[13]
Definition qwizard.cpp:101
gzip write("uncompressed data")
mimeData setData("text/csv", csvData)
obj metaObject() -> className()
QVariant variant
[1]
QSharedPointer< T > other(t)
[5]
view create()
QJSEngine engine
[0]
\inmodule QtCore
const QMetaObject * metaObject() const
static constexpr const int AllProperties