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 QV8TYPEWRAPPER_P_H
5#define QV8TYPEWRAPPER_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/qv4object_p.h>
23
24QT_BEGIN_NAMESPACE
25
26class QQmlTypeNameCache;
27class QQmlType;
28class QQmlTypePrivate;
29struct QQmlImportRef;
30
31namespace QV4 {
32
33namespace Heap {
34
35struct QQmlTypeWrapper : Object {
36 enum TypeNameMode {
37 IncludeEnums,
38 ExcludeEnums
39 };
40
41 void init();
42 void destroy();
43 TypeNameMode mode;
44 QV4QPointer<QObject> object;
45
46 QQmlType type() const;
47
48 const QQmlTypePrivate *typePrivate;
49 QQmlTypeNameCache *typeNamespace;
50 const QQmlImportRef *importNamespace;
51};
52
53struct QQmlScopedEnumWrapper : Object {
54 void init() { Object::init(); }
55 void destroy();
56 int scopeEnumIndex;
57 const QQmlTypePrivate *typePrivate;
58 QQmlType type() const;
59};
60
61}
62
63struct Q_QML_EXPORT QQmlTypeWrapper : Object
64{
65 V4_OBJECT2(QQmlTypeWrapper, Object)
66 V4_NEEDS_DESTROY
67
68 bool isSingleton() const;
69 const QMetaObject *metaObject() const;
70 QObject *object() const;
71 QObject *singletonObject() const;
72
73 QVariant toVariant() const;
74
75 static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlType &,
76 Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums);
77 static ReturnedValue create(ExecutionEngine *, QObject *, const QQmlRefPointer<QQmlTypeNameCache> &, const QQmlImportRef *,
78 Heap::QQmlTypeWrapper::TypeNameMode = Heap::QQmlTypeWrapper::IncludeEnums);
79
80 static ReturnedValue virtualResolveLookupGetter(const Object *object, ExecutionEngine *engine, Lookup *lookup);
81 static bool virtualResolveLookupSetter(Object *object, ExecutionEngine *engine, Lookup *lookup, const Value &value);
82 static OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
83 static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a);
84
85 static ReturnedValue lookupSingletonProperty(Lookup *l, ExecutionEngine *engine, const Value &base);
86 static ReturnedValue lookupSingletonMethod(Lookup *l, ExecutionEngine *engine, const Value &base);
87 static ReturnedValue lookupEnumValue(Lookup *l, ExecutionEngine *engine, const Value &base);
88 static ReturnedValue lookupScopedEnum(Lookup *l, ExecutionEngine *engine, const Value &base);
89
90protected:
91 static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
92 static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver);
93 static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p);
94 static bool virtualIsEqualTo(Managed *that, Managed *o);
95 static ReturnedValue virtualInstanceOf(const Object *typeObject, const Value &var);
96};
97
98struct Q_QML_EXPORT QQmlScopedEnumWrapper : Object
99{
100 V4_OBJECT2(QQmlScopedEnumWrapper, Object)
101 V4_NEEDS_DESTROY
102
103 static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty);
104};
105
106}
107
108QT_END_NAMESPACE
109
110#endif // QV8TYPEWRAPPER_P_H
111
112

source code of qtdeclarative/src/qml/qml/qqmltypewrapper_p.h