Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlproxymetaobject.cpp
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
5#include "qqmlproperty_p.h"
6
8
9QQmlProxyMetaObject::QQmlProxyMetaObject(QObject *obj, const QList<ProxyData> *mList)
10 : metaObjects(mList), proxies(nullptr), parent(nullptr), object(obj)
11{
12 metaObject = metaObjects->constFirst().metaObject;
13
15 if (op->metaObject)
16 parent = op->metaObject;
17
18 op->metaObject = this;
19}
20
22{
23 if (parent)
24 delete parent;
25 parent = nullptr;
26
27 if (proxies)
28 delete [] proxies;
29 proxies = nullptr;
30}
31
32QObject *QQmlProxyMetaObject::getProxy(int index)
33{
34 if (!proxies) {
35 proxies = new QObject *[metaObjects->size()];
36 ::memset(proxies, 0, sizeof(QObject *) * metaObjects->size());
37 }
38
39 if (!proxies[index]) {
40 const ProxyData &data = metaObjects->at(index);
41 if (!data.createFunc)
42 return nullptr;
43
44 QObject *proxy = data.createFunc(object);
45 const QMetaObject *metaObject = proxy->metaObject();
46 proxies[index] = proxy;
47
48 int localOffset = data.metaObject->methodOffset();
49 int methodOffset = metaObject->methodOffset();
50 int methods = metaObject->methodCount() - methodOffset;
51
52 // ### - Can this be done more optimally?
53 for (int jj = 0; jj < methods; ++jj) {
55 metaObject->method(jj + methodOffset);
56 if (method.methodType() == QMetaMethod::Signal)
57 QQmlPropertyPrivate::connect(proxy, methodOffset + jj, object, localOffset + jj);
58 }
59 }
60
61 return proxies[index];
62}
63
65{
66 Q_ASSERT(object == o);
67
68 switch (c) {
71 if (id < metaObjects->constLast().propertyOffset)
72 break;
73
74 for (int ii = 0; ii < metaObjects->size(); ++ii) {
75 const int globalPropertyOffset = metaObjects->at(ii).propertyOffset;
76 if (id < globalPropertyOffset)
77 continue;
78
79 QObject *proxy = getProxy(ii);
81 const int localProxyOffset = proxy->metaObject()->propertyOffset();
82 const int localProxyId = id - globalPropertyOffset + localProxyOffset;
83 return proxy->qt_metacall(c, localProxyId, a);
84 }
85 break;
86 }
88 if (id < metaObjects->constLast().methodOffset)
89 break;
90
91 QMetaMethod m = object->metaObject()->method(id);
92 if (m.methodType() == QMetaMethod::Signal) {
93 QMetaObject::activate(object, id, a);
94 return -1;
95 }
96
97 for (int ii = 0; ii < metaObjects->size(); ++ii) {
98 const int globalMethodOffset = metaObjects->at(ii).methodOffset;
99 if (id < globalMethodOffset)
100 continue;
101
102 QObject *proxy = getProxy(ii);
104 const int localMethodOffset = proxy->metaObject()->methodOffset();
105 const int localMethodId = id - globalMethodOffset + localMethodOffset;
106 return proxy->qt_metacall(c, localMethodId, a);
107 }
108
109 break;
110 }
112 if ((id & ~MaxExtensionCount) != ExtensionObjectId)
113 break;
114 int index = id & MaxExtensionCount;
115 if (qsizetype(index) >= metaObjects->size())
116 break;
117 a[0] = getProxy(index);
118 return id;
119 }
120 default:
121 break;
122 }
123
124 if (parent)
125 return parent->metaCall(o, c, id, a);
126 else
127 return object->qt_metacall(c, id, a);
128}
129
134
136{
137 if (parent)
138 parent->objectDestroyed(object);
139 else
141}
142
static JNINativeMethod methods[]
\inmodule QtCore
Definition qmetaobject.h:19
QDynamicMetaObjectData * metaObject
Definition qobject.h:90
static QObjectPrivate * get(QObject *o)
Definition qobject_p.h:150
\inmodule QtCore
Definition qobject.h:103
static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=nullptr)
Connect sender signal_index to receiver method_index with the specified type and types.
int metaCall(QObject *o, QMetaObject::Call _c, int _id, void **_a) override
QQmlProxyMetaObject(QObject *, const QList< ProxyData > *)
QMetaObject * toDynamicMetaObject(QObject *) override
void objectDestroyed(QObject *object) override
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
const GLfloat * m
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint index
[2]
GLenum GLuint id
[7]
GLuint object
[3]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLhandleARB obj
[2]
const GLubyte * c
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
ptrdiff_t qsizetype
Definition qtypes.h:165
obj metaObject() -> className()
QObject::connect nullptr
QNetworkProxy proxy
[0]
virtual void objectDestroyed(QObject *)
Definition qobject_p.h:469
virtual int metaCall(QObject *, QMetaObject::Call, int _id, void **)=0
\inmodule QtCore
static void activate(QObject *sender, int signal_index, void **argv)
Definition qobject.cpp:4193