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 static void connectAlias(QObject *o,
int coreIndex,
bool indexInSignalRange);
238 static inline QQmlVMEMetaObject *get(QObject *o, QV4::ExecutionEngine *engine);
239 static bool aliasTarget(QObject *o,
int coreIndex, QObject **aObject,
int *aCoreIndex,
240 int *aValueTypeIndex);
242 static void list_append(QQmlListProperty<QObject> *prop, QObject *o);
243 static void list_clear(QQmlListProperty<QObject> *prop);
244 static void list_append_nosignal(QQmlListProperty<QObject> *prop, QObject *o);
245 static void list_clear_nosignal(QQmlListProperty<QObject> *prop);
247 inline int propOffset()
const;
248 inline int propCount()
const;
249 inline int aliasOffset()
const;
250 inline int aliasCount()
const;
251 inline int signalOffset()
const;
252 inline int signalCount()
const;
253 inline int methodOffset()
const;
254 inline int methodCount()
const;
256 QV4::MemberData *propertyAndMethodStorageAsMemberData()
const;
258 int readPropertyAsInt(
int id)
const;
259 bool readPropertyAsBool(
int id)
const;
260 double readPropertyAsDouble(
int id)
const;
261 QString readPropertyAsString(
int id)
const;
262 QSizeF readPropertyAsSizeF(
int id)
const;
263 QPointF readPropertyAsPointF(
int id)
const;
264 QUrl readPropertyAsUrl(
int id)
const;
265 QDate readPropertyAsDate(
int id)
const;
266 QTime readPropertyAsTime(
int id)
const;
267 QDateTime readPropertyAsDateTime(
int id)
const;
269#if QT_CONFIG(regularexpression)
270 QRegularExpression readPropertyAsRegularExpression(
int id)
const;
273 QRectF readPropertyAsRectF(
int id)
const;
274 QObject *readPropertyAsQObject(
int id)
const;
275 void initPropertyAsList(
int id)
const;
277 void writeProperty(
int id,
int v);
278 void writeProperty(
int id,
bool v);
279 void writeProperty(
int id,
double v);
280 void writeProperty(
int id,
const QString& v);
282 template<
typename VariantCompatible>
283 void writeProperty(
int id,
const VariantCompatible &v)
285 QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
287 QV4::Scope scope(m_engine);
288 QV4::Scoped<QV4::MemberData>(scope, md)->set(
289 m_engine, id, m_engine->newVariantObject(
290 QMetaType::fromType<VariantCompatible>(), &v));
294 void writeProperty(
int id, QObject *v);
296 void ensureQObjectWrapper();
298 void mark(QV4::MarkStack *markStack);
300 void connectAlias(
const QV4::CompiledData::Object *compiledObject,
int aliasId);
302 QV4::ReturnedValue method(
int)
const;
304 QV4::ReturnedValue readVarProperty(
int)
const;
305 void writeVarProperty(
int,
const QV4::Value &);
306 QVariant readPropertyAsVariant(
int)
const;
308 inline QQmlVMEMetaObject *parentVMEMetaObject()
const;
309 inline void setParentVMEMetaObject(QQmlVMEMetaObject *newParent);
311 void activate(QObject *,
int,
void **);
313 QQmlVMEVariantQObjectPtr *getQObjectGuardForProperty(
int)
const;
315 QQmlRefPointer<QQmlContextData> contextData()
const {
return m_ctxt.contextData(); }
316 QV4::ExecutionEngine *engine()
const {
return m_engine; }
317 QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit()
const
319 return m_compilationUnit;
322 void setCompilationUnit(
const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit)
324 m_compilationUnit = compilationUnit;
327 int qmlObjectId()
const {
return m_qmlObjectId; }
330 int metaCall(QObject *o, QMetaObject::Call _c,
int _id,
void **_a) override;
331 bool getListProperty(
int id, QQmlListProperty<QObject> *target);
334 friend class QQmlVMEMetaObjectEndpoint;
335 friend class QQmlVMEResolvedList;
336 friend class QQmlVMEVariantQObjectPtr;
338 static inline QQmlVMEMetaObject *get(QObject *o);
340 const QV4::CompiledData::Object *findCompiledObject()
const {
342 if (!m_compilationUnit || !m_compilationUnit->engine)
345 Q_ASSERT(m_qmlObjectId >= 0 && m_qmlObjectId < m_compilationUnit->objectCount());
346 return m_compilationUnit->objectAt(m_qmlObjectId);
349 void writeKnownVarProperty(
int id,
const QVariant &value);
351 QV4::ExecutionEngine *m_engine;
352 QQmlGuardedContextData m_ctxt;
354 QQmlVMEMetaObjectEndpoint *m_aliasEndpoints;
355 QV4::WeakValue m_propertyAndMethodStorage;
357 QList<QQmlVMEVariantQObjectPtr *> m_varObjectGuards;
361 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
362 int m_qmlObjectId = -1;
363 int m_numAliases = 0;