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
qqmltypewrapper_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// Qt-Security score:significant
4
5#ifndef QQMLTYPEWRAPPER_P_H
6#define QQMLTYPEWRAPPER_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 <QtCore/qglobal.h>
20#include <QtCore/qpointer.h>
21
22#include <private/qv4value_p.h>
23#include <private/qv4functionobject_p.h>
24#include <private/qv4qmetaobjectwrapper_p.h>
25
26QT_BEGIN_NAMESPACE
27
28class QQmlTypeNameCache;
29class QQmlType;
30class QQmlTypePrivate;
31struct QQmlImportRef;
32
33namespace QV4 {
34
35namespace Heap {
36
38
44
45 enum Kind : quint8 {
46 Type = 0x0,
47 Namespace = 0x2,
49 };
50
51 void init(TypeNameMode m, QObject *o, const QQmlTypePrivate *type);
52 void init(TypeNameMode m, QObject *o, QQmlTypeNameCache *type, const QQmlImportRef *import);
53
54 void destroy();
55
56 const QMetaObject *metaObject() const { return type().metaObject(); }
57 QMetaType metaType() const { return type().typeId(); }
58
59 QQmlType type() const;
60 TypeNameMode typeNameMode() const { return TypeNameMode(flags & TypeNameModeMask); }
61 Kind kind() const { return Kind(flags & KindMask); }
62
64 const QMetaObject *metaObject, QMetaType metaType)
65 {
66 Q_ASSERT(kind() == Type);
67 if (!t.constructors && metaObject) {
68 t.constructors = QMetaObjectWrapper::createConstructors(metaObject, metaType);
70 }
71 return t.constructors;
72 }
73 void warnIfUncreatable() const;
74
76 const QV4::String *name, QV4::ExecutionEngine *engine) const;
77
79
80 union {
81 struct {
82 const QQmlTypePrivate *typePrivate;
84 } t;
85 struct {
86 QQmlTypeNameCache *typeNamespace;
88 } n;
89 };
90
92};
93
95
97{
98 void init() { Object::init(); }
99 void destroy();
100 QQmlType type() const;
101
102 const QQmlTypePrivate *typePrivate;
104 bool scoped;
105};
106
107}
108
109struct Q_QML_EXPORT QQmlTypeWrapper : FunctionObject
110{
115
116 bool isSingleton() const;
117 const QMetaObject *metaObject() const;
118 QObject *object() const;
119 QObject *singletonObject() const;
120
121 QVariant toVariant() const;
122
123 static void initProto(ExecutionEngine *v4);
124
125 static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &,
127 static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlRefPointer<QQmlTypeNameCache> &, const QQmlImportRef *,
129
130 static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup);
131 static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value);
132 static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
133 static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a);
134
135 static ReturnedValue lookupSingletonProperty(Lookup *l, ExecutionEngine *engine, const Value &base);
136 static ReturnedValue lookupSingletonMethod(Lookup *l, ExecutionEngine *engine, const Value &base);
137 static ReturnedValue lookupEnumValue(Lookup *l, ExecutionEngine *engine, const Value &base);
138 static ReturnedValue lookupEnum(Lookup *l, ExecutionEngine *engine, const Value &base);
139
140protected:
142 static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
143 static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
144 static bool virtualIsEqualTo(Managed *that, Managed *o);
145 static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var);
146
147private:
149 const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
150 static ReturnedValue method_toString(
151 const FunctionObject *b, const Value *thisObject, const Value *, int);
152};
153
155{
156 V4_OBJECT2(QQmlTypeConstructor, QQmlTypeWrapper)
157
159 const FunctionObject *f, const Value *argv, int argc, const Value *)
160 {
163 static_cast<const QQmlTypeWrapper *>(f)->d(), argv, argc);
164 }
165};
166
167struct Q_QML_EXPORT QQmlEnumWrapper : Object
168{
169 V4_OBJECT2(QQmlEnumWrapper, Object)
170 V4_NEEDS_DESTROY
171
172 static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
173};
174
175}
176
177QT_END_NAMESPACE
178
179#endif // QQMLTYPEWRAPPER_P_H
Combined button and popup list for selecting options.
QQmlTypeWrapper QQmlTypeConstructor
Definition qjsvalue.h:24
static ReturnedValue createEnumWrapper(ExecutionEngine *v4, Scope &scope, QQmlType type, int enumIndex, bool scoped)
static int enumForSingleton(QQmlTypeLoader *typeLoader, String *name, const QQmlType &type, bool *ok)
DEFINE_OBJECT_VTABLE(QQmlTypeWrapper)
static ReturnedValue instanceOfQObject(const QV4::QQmlTypeWrapper *typeWrapper, QObject *wrapperObject)
DEFINE_OBJECT_VTABLE(QQmlTypeConstructor)
void warnWithLocation(const Heap::QQmlTypeWrapper *wrapper, Callback &&callback)
const QQmlTypePrivate * typePrivate
void init(TypeNameMode m, QObject *o, QQmlTypeNameCache *type, const QQmlImportRef *import)
const QQmlPropertyData * constructors
QQmlTypeNameCache * typeNamespace
QQmlTypeNameCache::Result queryNamespace(const QV4::String *name, QV4::ExecutionEngine *engine) const
const QMetaObject * metaObject() const
const QQmlTypePrivate * typePrivate
void init(TypeNameMode m, QObject *o, const QQmlTypePrivate *type)
const QQmlImportRef * importNamespace
QV4QPointer< QObject > object
TypeNameMode typeNameMode() const
const QQmlPropertyData * ensureConstructorsCache(const QMetaObject *metaObject, QMetaType metaType)
static ReturnedValue lookupSingletonMethod(Lookup *l, ExecutionEngine *engine, const Value &base)
QObject * object() const
static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlRefPointer< QQmlTypeNameCache > &, const QQmlImportRef *, Heap::QQmlTypeWrapper::TypeNameMode=Heap::QQmlTypeWrapper::IncludeEnums)
static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &, Heap::QQmlTypeWrapper::TypeNameMode=Heap::QQmlTypeWrapper::IncludeEnums)
static OwnPropertyKeyIterator * virtualOwnPropertyKeys(const Object *m, Value *target)
V4_NEEDS_DESTROY bool isSingleton() const
QObject * singletonObject() const
const QMetaObject * metaObject() const
static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a)
static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value)
static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var)
static ReturnedValue lookupEnum(Lookup *l, ExecutionEngine *engine, const Value &base)
static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
static ReturnedValue lookupEnumValue(Lookup *l, ExecutionEngine *engine, const Value &base)
static void initProto(ExecutionEngine *v4)
static ReturnedValue lookupSingletonProperty(Lookup *l, ExecutionEngine *engine, const Value &base)
static bool virtualIsEqualTo(Managed *that, Managed *o)
static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup)
QVariant toVariant() const