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
4#ifndef QQMLTYPEWRAPPER_P_H
5#define QQMLTYPEWRAPPER_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 <private/qv4value_p.h>
22#include <private/qv4functionobject_p.h>
23#include <private/qv4qmetaobjectwrapper_p.h>
24
25QT_BEGIN_NAMESPACE
26
27class QQmlTypeNameCache;
28class QQmlType;
29class QQmlTypePrivate;
30struct QQmlImportRef;
31
32namespace QV4 {
33
34namespace Heap {
35
37
43
44 enum Kind : quint8 {
45 Type = 0x0,
46 Namespace = 0x2,
48 };
49
50 void init(TypeNameMode m, QObject *o, const QQmlTypePrivate *type);
51 void init(TypeNameMode m, QObject *o, QQmlTypeNameCache *type, const QQmlImportRef *import);
52
53 void destroy();
54
55 const QMetaObject *metaObject() const { return type().metaObject(); }
56 QMetaType metaType() const { return type().typeId(); }
57
58 QQmlType type() const;
59 TypeNameMode typeNameMode() const { return TypeNameMode(flags & TypeNameModeMask); }
60 Kind kind() const { return Kind(flags & KindMask); }
61
63 const QMetaObject *metaObject, QMetaType metaType)
64 {
65 Q_ASSERT(kind() == Type);
66 if (!t.constructors && metaObject) {
67 t.constructors = QMetaObjectWrapper::createConstructors(metaObject, metaType);
69 }
70 return t.constructors;
71 }
72 void warnIfUncreatable() const;
73
75 const QV4::String *name, QV4::ExecutionEngine *engine) const;
76
78
79 union {
80 struct {
81 const QQmlTypePrivate *typePrivate;
83 } t;
84 struct {
85 QQmlTypeNameCache *typeNamespace;
87 } n;
88 };
89
91};
92
94
96{
97 void init() { Object::init(); }
98 void destroy();
99 QQmlType type() const;
100
101 const QQmlTypePrivate *typePrivate;
103 bool scoped;
104};
105
106}
107
108struct Q_QML_EXPORT QQmlTypeWrapper : FunctionObject
109{
114
115 bool isSingleton() const;
116 const QMetaObject *metaObject() const;
117 QObject *object() const;
118 QObject *singletonObject() const;
119
120 QVariant toVariant() const;
121
122 static void initProto(ExecutionEngine *v4);
123
124 static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &,
126 static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlRefPointer<QQmlTypeNameCache> &, const QQmlImportRef *,
128
129 static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup);
130 static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value);
131 static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
132 static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a);
133
134 static ReturnedValue lookupSingletonProperty(Lookup *l, ExecutionEngine *engine, const Value &base);
135 static ReturnedValue lookupSingletonMethod(Lookup *l, ExecutionEngine *engine, const Value &base);
136 static ReturnedValue lookupEnumValue(Lookup *l, ExecutionEngine *engine, const Value &base);
137 static ReturnedValue lookupEnum(Lookup *l, ExecutionEngine *engine, const Value &base);
138
139protected:
141 static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
142 static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
143 static bool virtualIsEqualTo(Managed *that, Managed *o);
144 static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var);
145
146private:
148 const FunctionObject *, const Value *thisObject, const Value *argv, int argc);
149 static ReturnedValue method_toString(
150 const FunctionObject *b, const Value *thisObject, const Value *, int);
151};
152
154{
155 V4_OBJECT2(QQmlTypeConstructor, QQmlTypeWrapper)
156
158 const FunctionObject *f, const Value *argv, int argc, const Value *)
159 {
162 static_cast<const QQmlTypeWrapper *>(f)->d(), argv, argc);
163 }
164};
165
166struct Q_QML_EXPORT QQmlEnumWrapper : Object
167{
168 V4_OBJECT2(QQmlEnumWrapper, Object)
169 V4_NEEDS_DESTROY
170
171 static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
172};
173
174}
175
176QT_END_NAMESPACE
177
178#endif // QQMLTYPEWRAPPER_P_H
QQmlTypeWrapper QQmlTypeConstructor
Definition qjsvalue.h:23
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