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
qv4qmetaobjectwrapper_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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 QV4QMETAOBJECTWRAPPER_P_H
6#define QV4QMETAOBJECTWRAPPER_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 <private/qv4functionobject_p.h>
20#include <private/qv4value_p.h>
21
22#include <QtCore/qmetaobject.h>
23
24QT_BEGIN_NAMESPACE
25
26class QQmlPropertyData;
27
28namespace QV4 {
29namespace Heap {
30
32{
33 void init(const QMetaObject *metaObject);
34 void destroy();
35
36 const QMetaObject *metaObject() const { return m_metaObject; }
38 {
39 const QMetaType type = m_metaObject->metaType();
40 if (type.flags() & QMetaType::IsGadget)
41 return type;
42
43 // QObject* is our best guess because we can't get from a metatype to
44 // the metatype of its pointer.
45 return QMetaType::fromType<QObject *>();
46 }
47
49 const QMetaObject *metaObject, QMetaType metaType)
50 {
51 Q_ASSERT(metaObject);
52 if (!m_constructors)
53 m_constructors = createConstructors(metaObject, metaType);
54 return m_constructors;
55 }
56
57
59 const QMetaObject *metaObject, QMetaType metaType)
60 {
61 Q_ASSERT(metaObject);
62 const int count = metaObject->constructorCount();
63 if (count == 0)
64 return nullptr;
65
66 QQmlPropertyData *constructors = new QQmlPropertyData[count];
67
68 for (int i = 0; i < count; ++i) {
69 QMetaMethod method = metaObject->constructor(i);
70 QQmlPropertyData &d = constructors[i];
71 d.load(method);
72 d.setPropType(metaType);
73 d.setCoreIndex(i);
74 }
75
76 return constructors;
77 }
78
79private:
80 const QMetaObject *m_metaObject;
81 const QQmlPropertyData *m_constructors;
82};
83
84} // namespace Heap
85
86struct Q_QML_EXPORT QMetaObjectWrapper : public FunctionObject
87{
90
92 const QMetaObject *metaObject() const { return d()->metaObject(); }
93
94 template<typename HeapObject>
96 {
97 const QMetaObject *mo = d->metaObject();
98 return constructInternal(
100 }
101
102protected:
104 const FunctionObject *, const Value *argv, int argc, const Value *);
105 static bool virtualIsEqualTo(Managed *a, Managed *b);
106
107private:
109
112 const Value *argv, int argc);
113};
114
115} // namespace QV4
116
117QT_END_NAMESPACE
118
119#endif // QV4QMETAOBJECTWRAPPER_P_H
Definition qjsvalue.h:23
const QMetaObject * metaObject() const
void init(const QMetaObject *metaObject)
static const QQmlPropertyData * createConstructors(const QMetaObject *metaObject, QMetaType metaType)
const QQmlPropertyData * ensureConstructorsCache(const QMetaObject *metaObject, QMetaType metaType)