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
24
QT_BEGIN_NAMESPACE
25
26
class
QQmlPropertyData;
27
28
namespace
QV4
{
29
namespace
Heap
{
30
31
struct
QMetaObjectWrapper
:
FunctionObject
32
{
33
void
init
(
const
QMetaObject *metaObject);
34
void
destroy
();
35
36
const
QMetaObject
*
metaObject
()
const
{
return
m_metaObject; }
37
QMetaType
metaType
()
const
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
48
const
QQmlPropertyData
*
ensureConstructorsCache
(
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
58
static
const
QQmlPropertyData
*
createConstructors
(
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
79
private
:
80
const
QMetaObject *m_metaObject;
81
const
QQmlPropertyData
*m_constructors;
82
};
83
84
}
// namespace Heap
85
86
struct
Q_QML_EXPORT
QMetaObjectWrapper
:
public
FunctionObject
87
{
88
V4_OBJECT2
(
QMetaObjectWrapper
,
FunctionObject
)
89
V4_NEEDS_DESTROY
90
91
static
ReturnedValue
create
(
ExecutionEngine
*
engine
,
const
QMetaObject
*
metaObject
);
92
const
QMetaObject
*
metaObject
()
const
{
return
d
()->
metaObject
(); }
93
94
template
<
typename
HeapObject
>
95
ReturnedValue
static
construct
(
HeapObject
*
d
,
const
Value
*
argv
,
int
argc
)
96
{
97
const
QMetaObject
*
mo
=
d
->
metaObject
();
98
return
constructInternal
(
99
mo
,
d
->
ensureConstructorsCache
(
mo
,
d
->
metaType
()),
d
,
argv
,
argc
);
100
}
101
102
protected
:
103
static
ReturnedValue
virtualCallAsConstructor
(
104
const
FunctionObject
*,
const
Value
*
argv
,
int
argc
,
const
Value
*);
105
static
bool
virtualIsEqualTo
(
Managed
*
a
,
Managed
*
b
);
106
107
private
:
108
void
init
(
ExecutionEngine
*
engine
);
109
110
static
ReturnedValue
constructInternal
(
111
const
QMetaObject
*
mo
,
const
QQmlPropertyData
*
constructors
,
Heap
::
FunctionObject
*
d
,
112
const
Value
*
argv
,
int
argc
);
113
};
114
115
}
// namespace QV4
116
117
QT_END_NAMESPACE
118
119
#
endif
// QV4QMETAOBJECTWRAPPER_P_H
QQmlPropertyData
Definition
qqmlpropertydata_p.h:26
QPlatformGraphicsBufferHelper
\inmodule QtGui
QV4::Heap
Definition
qv4compileddata_p.h:72
QV4
Definition
qjsvalue.h:23
QV4::Heap::QMetaObjectWrapper
Definition
qv4qmetaobjectwrapper_p.h:32
QV4::Heap::QMetaObjectWrapper::metaObject
const QMetaObject * metaObject() const
Definition
qv4qmetaobjectwrapper_p.h:36
QV4::Heap::QMetaObjectWrapper::metaType
QMetaType metaType() const
Definition
qv4qmetaobjectwrapper_p.h:37
QV4::Heap::QMetaObjectWrapper::init
void init(const QMetaObject *metaObject)
Definition
qv4qmetaobjectwrapper.cpp:17
QV4::Heap::QMetaObjectWrapper::destroy
void destroy()
Definition
qv4qmetaobjectwrapper.cpp:23
QV4::Heap::QMetaObjectWrapper::createConstructors
static const QQmlPropertyData * createConstructors(const QMetaObject *metaObject, QMetaType metaType)
Definition
qv4qmetaobjectwrapper_p.h:58
QV4::Heap::QMetaObjectWrapper::ensureConstructorsCache
const QQmlPropertyData * ensureConstructorsCache(const QMetaObject *metaObject, QMetaType metaType)
Definition
qv4qmetaobjectwrapper_p.h:48
QV4::QMetaObjectWrapper
Definition
qv4qmetaobjectwrapper_p.h:87
qtdeclarative
src
qml
jsruntime
qv4qmetaobjectwrapper_p.h
Generated on
for Qt by
1.14.0