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
qqmlproxymetaobject_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 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
27
28class Q_QML_EXPORT QQmlProxyMetaObject : public QDynamicMetaObjectData
29{
30public:
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 *, const 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
49protected:
50 int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override;
51#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
52 const QMetaObject *toDynamicMetaObject(QObject *) const override
53#else
54 QMetaObject *toDynamicMetaObject(QObject *) override
55#endif
56 {
57 return metaObject;
58 }
59 void objectDestroyed(QObject *object) override;
60
61private:
62 QObject *getProxy(int index);
63
64 const QList<ProxyData> *metaObjects;
65 QObject **proxies;
66
67 QDynamicMetaObjectData *parent;
68 QMetaObject *metaObject;
69 QObject *object;
70
71 // ExtensionObjectId acts as a flag for whether we should interpret a
72 // QMetaObject::CustomCall as a call to fetch the extension object (see
73 // QQmlProxyMetaObject::metaCall()). MaxExtensionCount is a limit on how
74 // many extensions we can query via such mechanism
75 enum : int {
76 MaxExtensionCount = 127, // magic number so that low bits are all '1'
77 ExtensionObjectId = ~MaxExtensionCount,
78 };
79};
80
81QT_END_NAMESPACE
82
83#endif // QQMLPROXYMETAOBJECT_P_H