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 QQMLPROXYMETAOBJECT_P_H |
5 | #define QQMLPROXYMETAOBJECT_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 <private/qtqmlglobal_p.h> |
19 | #include <private/qmetaobjectbuilder_p.h> |
20 | |
21 | #include <QtCore/QMetaObject> |
22 | #include <QtCore/QObject> |
23 | |
24 | #include <private/qobject_p.h> |
25 | |
26 | QT_BEGIN_NAMESPACE |
27 | |
28 | class Q_QML_PRIVATE_EXPORT QQmlProxyMetaObject : public QDynamicMetaObjectData |
29 | { |
30 | public: |
31 | struct ProxyData { |
32 | typedef QObject *(*CreateFunc)(QObject *); |
33 | QMetaObject *metaObject; |
34 | CreateFunc createFunc; |
35 | int propertyOffset; |
36 | int methodOffset; |
37 | }; |
38 | |
39 | QQmlProxyMetaObject(QObject *, QList<ProxyData> *); |
40 | ~QQmlProxyMetaObject(); |
41 | |
42 | static constexpr int extensionObjectId(int id) noexcept |
43 | { |
44 | Q_ASSERT(id >= 0); |
45 | Q_ASSERT(id <= MaxExtensionCount); // MaxExtensionCount is a valid index |
46 | return ExtensionObjectId | id; |
47 | } |
48 | |
49 | protected: |
50 | int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override; |
51 | QMetaObject *toDynamicMetaObject(QObject *) override; |
52 | |
53 | private: |
54 | QObject *getProxy(int index); |
55 | |
56 | QList<ProxyData> *metaObjects; |
57 | QObject **proxies; |
58 | |
59 | QDynamicMetaObjectData *parent; |
60 | QMetaObject *metaObject; |
61 | QObject *object; |
62 | |
63 | // ExtensionObjectId acts as a flag for whether we should interpret a |
64 | // QMetaObject::CustomCall as a call to fetch the extension object (see |
65 | // QQmlProxyMetaObject::metaCall()). MaxExtensionCount is a limit on how |
66 | // many extensions we can query via such mechanism |
67 | enum : int { |
68 | MaxExtensionCount = 127, // magic number so that low bits are all '1' |
69 | ExtensionObjectId = ~MaxExtensionCount, |
70 | }; |
71 | }; |
72 | |
73 | QT_END_NAMESPACE |
74 | |
75 | #endif // QQMLPROXYMETAOBJECT_P_H |
76 | |
77 | |