117 QQmlInterceptorMetaObject(QObject *obj,
const QQmlPropertyCache::ConstPtr &cache);
118 ~QQmlInterceptorMetaObject() override;
120 void registerInterceptor(QQmlPropertyIndex index, QQmlPropertyValueInterceptor *interceptor);
122 static QQmlInterceptorMetaObject *get(QObject *obj);
124#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
125 const QMetaObject *toDynamicMetaObject(QObject *o)
const override;
127 QMetaObject *toDynamicMetaObject(QObject *o) override;
131 QQmlPropertyCache::ConstPtr propertyCache()
const {
return cache; }
137 void setPropertyCache(
const QQmlPropertyCache::ConstPtr &newCache)
140 metaObject = QTaggedPointer<
const QMetaObject, MetaObjectValidity>();
143 bool intercepts(QQmlPropertyIndex propertyIndex)
const
145 for (
auto it = interceptors; it; it = it->m_next) {
146 if (it->m_propertyIndex == propertyIndex)
149 if (
auto parentInterceptor = ((parent.isT1() && parent.flag()) ?
static_cast<QQmlInterceptorMetaObject *>(parent.asT1()) :
nullptr))
150 return parentInterceptor->intercepts(propertyIndex);
154 void invalidate() { metaObject.setTag(MetaObjectInvalid); }
157 enum InterceptionBehavior { Intercept, SkipInterception };
158 static void setInterceptionMode(QObject *object, InterceptionBehavior behavior);
160 QTaggedPointer<QObject> object =
nullptr;
161 QQmlPropertyCache::ConstPtr cache;
164 int metaCall(QObject *o, QMetaObject::Call c,
int id,
void **a) override;
165 bool intercept(QMetaObject::Call c,
int id,
void **a)
171 case QMetaObject::WriteProperty:
172 if (*
reinterpret_cast<
int*>(a[3]) & QQmlPropertyData::BypassInterceptor)
175 case QMetaObject::BindableProperty:
176 if (object.tag() == SkipInterception) {
184 return doIntercept(c, id, a);
187 QBiPointer<QDynamicMetaObjectData,
const QMetaObject> parent;
189 enum MetaObjectValidity { MetaObjectValid, MetaObjectInvalid };
190 QTaggedPointer<
const QMetaObject, MetaObjectValidity> metaObject;
193 bool doIntercept(QMetaObject::Call c,
int id,
void **a);
194 QQmlPropertyValueInterceptor *interceptors =
nullptr;
209inline void QQmlInterceptorMetaObject::setInterceptionMode(
210 QObject *object, QQmlInterceptorMetaObject::InterceptionBehavior behavior)
212 QQmlInterceptorMetaObject *interceptorMetaObject = get(object);
213 while (interceptorMetaObject) {
214 interceptorMetaObject->object.setTag(behavior);
215 auto parent = interceptorMetaObject->parent;
216 interceptorMetaObject = ((parent.isT1() && parent.flag()) ?
static_cast<QQmlInterceptorMetaObject *>(parent.asT1()) :
nullptr);
225 QV4::ExecutionEngine *engine, QObject *obj,
const QQmlPropertyCache::ConstPtr &cache,
226 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit,
228 ~QQmlVMEMetaObject() override;
230 bool aliasTarget(
int index, QObject **target,
int *coreIndex,
int *valueTypeIndex)
const;
231 QV4::ReturnedValue vmeMethod(
int index)
const;
232 void setVmeMethod(
int index,
const QV4::Value &function);
233 QV4::ReturnedValue vmeProperty(
int index)
const;
234 void setVMEProperty(
int index,
const QV4::Value &v);
236 void connectAliasSignal(
int index,
bool indexInSignalRange);
238 static inline QQmlVMEMetaObject *get(QObject *o);
239 static QQmlVMEMetaObject *getForProperty(QObject *o,
int coreIndex);
240 static QQmlVMEMetaObject *getForMethod(QObject *o,
int coreIndex);
241 static QQmlVMEMetaObject *getForSignal(QObject *o,
int coreIndex);
243 static void list_append(QQmlListProperty<QObject> *prop, QObject *o);
244 static void list_clear(QQmlListProperty<QObject> *prop);
245 static void list_append_nosignal(QQmlListProperty<QObject> *prop, QObject *o);
246 static void list_clear_nosignal(QQmlListProperty<QObject> *prop);
248 inline int propOffset()
const;
249 inline int propCount()
const;
250 inline int aliasOffset()
const;
251 inline int aliasCount()
const;
252 inline int signalOffset()
const;
253 inline int signalCount()
const;
254 inline int methodOffset()
const;
255 inline int methodCount()
const;
257 QV4::MemberData *propertyAndMethodStorageAsMemberData()
const;
259 int readPropertyAsInt(
int id)
const;
260 bool readPropertyAsBool(
int id)
const;
261 double readPropertyAsDouble(
int id)
const;
262 QString readPropertyAsString(
int id)
const;
263 QSizeF readPropertyAsSizeF(
int id)
const;
264 QPointF readPropertyAsPointF(
int id)
const;
265 QUrl readPropertyAsUrl(
int id)
const;
266 QDate readPropertyAsDate(
int id)
const;
267 QTime readPropertyAsTime(
int id)
const;
268 QDateTime readPropertyAsDateTime(
int id)
const;
270#if QT_CONFIG(regularexpression)
271 QRegularExpression readPropertyAsRegularExpression(
int id)
const;
274 QRectF readPropertyAsRectF(
int id)
const;
275 QObject *readPropertyAsQObject(
int id)
const;
276 void initPropertyAsList(
int id)
const;
278 void writeProperty(
int id,
int v);
279 void writeProperty(
int id,
bool v);
280 void writeProperty(
int id,
double v);
281 void writeProperty(
int id,
const QString& v);
283 template<
typename VariantCompatible>
284 void writeProperty(
int id,
const VariantCompatible &v)
286 QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
288 QV4::Scope scope(m_engine);
289 QV4::Scoped<QV4::MemberData>(scope, md)->set(
290 m_engine, id, m_engine->newVariantObject(
291 QMetaType::fromType<VariantCompatible>(), &v));
295 void writeProperty(
int id, QObject *v);
297 void ensureQObjectWrapper();
299 void mark(QV4::MarkStack *markStack);
301 void connectAlias(
const QV4::CompiledData::Object *compiledObject,
int aliasId);
303 QV4::ReturnedValue method(
int)
const;
305 QV4::ReturnedValue readVarProperty(
int)
const;
306 void writeVarProperty(
int,
const QV4::Value &);
307 QVariant readPropertyAsVariant(
int)
const;
309 inline QQmlVMEMetaObject *parentVMEMetaObject()
const;
310 inline void setParentVMEMetaObject(QQmlVMEMetaObject *newParent);
312 void activate(QObject *,
int,
void **);
314 QQmlVMEVariantQObjectPtr *getQObjectGuardForProperty(
int)
const;
316 QQmlRefPointer<QQmlContextData> contextData()
const {
return m_ctxt.contextData(); }
317 QV4::ExecutionEngine *engine()
const {
return m_engine; }
318 QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit()
const
320 return m_compilationUnit;
323 void setCompilationUnit(
const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit)
325 m_compilationUnit = compilationUnit;
328 int qmlObjectId()
const {
return m_qmlObjectId; }
331 int metaCall(QObject *o, QMetaObject::Call _c,
int _id,
void **_a) override;
332 bool getListProperty(
int id, QQmlListProperty<QObject> *target);
335 friend class QQmlVMEMetaObjectEndpoint;
336 friend class QQmlVMEResolvedList;
337 friend class QQmlVMEVariantQObjectPtr;
339 const QV4::CompiledData::Object *findCompiledObject()
const {
341 if (!m_compilationUnit || !m_compilationUnit->engine)
344 Q_ASSERT(m_qmlObjectId >= 0 && m_qmlObjectId < m_compilationUnit->objectCount());
345 return m_compilationUnit->objectAt(m_qmlObjectId);
348 void writeKnownVarProperty(
int id,
const QVariant &value);
350 QV4::ExecutionEngine *m_engine;
351 QQmlGuardedContextData m_ctxt;
353 QQmlVMEMetaObjectEndpoint *m_aliasEndpoints;
354 QV4::WeakValue m_propertyAndMethodStorage;
356 QList<QQmlVMEVariantQObjectPtr *> m_varObjectGuards;
360 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
361 int m_qmlObjectId = -1;
362 int m_numAliases = 0;