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 void remapInterceptorPropertyIndices(
int coreBase,
const QList<
int> &oldToNew,
int delta);
166 int metaCall(QObject *o, QMetaObject::Call c,
int id,
void **a) override;
167 bool intercept(QMetaObject::Call c,
int id,
void **a)
173 case QMetaObject::WriteProperty:
174 if (*
reinterpret_cast<
int*>(a[3]) & QQmlPropertyData::BypassInterceptor)
177 case QMetaObject::BindableProperty:
178 if (object.tag() == SkipInterception) {
186 return doIntercept(c, id, a);
189 QBiPointer<QDynamicMetaObjectData,
const QMetaObject> parent;
191 enum MetaObjectValidity { MetaObjectValid, MetaObjectInvalid };
192 QTaggedPointer<
const QMetaObject, MetaObjectValidity> metaObject;
195 bool doIntercept(QMetaObject::Call c,
int id,
void **a);
196 QQmlPropertyValueInterceptor *interceptors =
nullptr;
211inline void QQmlInterceptorMetaObject::setInterceptionMode(
212 QObject *object, QQmlInterceptorMetaObject::InterceptionBehavior behavior)
214 QQmlInterceptorMetaObject *interceptorMetaObject = get(object);
215 while (interceptorMetaObject) {
216 interceptorMetaObject->object.setTag(behavior);
217 auto parent = interceptorMetaObject->parent;
218 interceptorMetaObject = ((parent.isT1() && parent.flag()) ?
static_cast<QQmlInterceptorMetaObject *>(parent.asT1()) :
nullptr);
227 QV4::ExecutionEngine *engine, QObject *obj,
const QQmlPropertyCache::ConstPtr &cache,
228 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit,
230 ~QQmlVMEMetaObject() override;
232 bool aliasTarget(
int index, QObject **target,
int *coreIndex,
int *valueTypeIndex)
const;
233 QV4::ReturnedValue vmeMethod(
int index)
const;
234 void setVmeMethod(
int index,
const QV4::Value &function);
235 QV4::ReturnedValue vmeProperty(
int index)
const;
236 void setVMEProperty(
int index,
const QV4::Value &v);
238 void remapProperties(
int newPropertyCount,
const QList<
int> &oldToNew);
240 static void connectAlias(QObject *o,
int coreIndex,
bool indexInSignalRange);
242 static inline QQmlVMEMetaObject *get(QObject *o, QV4::ExecutionEngine *engine);
243 static bool aliasTarget(QObject *o,
int coreIndex, QObject **aObject,
int *aCoreIndex,
244 int *aValueTypeIndex);
246 static void list_append(QQmlListProperty<QObject> *prop, QObject *o);
247 static void list_clear(QQmlListProperty<QObject> *prop);
248 static void list_append_nosignal(QQmlListProperty<QObject> *prop, QObject *o);
249 static void list_clear_nosignal(QQmlListProperty<QObject> *prop);
251 inline int propOffset()
const;
252 inline int propCount()
const;
253 inline int aliasOffset()
const;
254 inline int aliasCount()
const;
255 inline int signalOffset()
const;
256 inline int signalCount()
const;
257 inline int methodOffset()
const;
258 inline int methodCount()
const;
260 QV4::MemberData *propertyAndMethodStorageAsMemberData()
const;
262 int readPropertyAsInt(
int id)
const;
263 bool readPropertyAsBool(
int id)
const;
264 double readPropertyAsDouble(
int id)
const;
265 QString readPropertyAsString(
int id)
const;
266 QSizeF readPropertyAsSizeF(
int id)
const;
267 QPointF readPropertyAsPointF(
int id)
const;
268 QUrl readPropertyAsUrl(
int id)
const;
269 QDate readPropertyAsDate(
int id)
const;
270 QTime readPropertyAsTime(
int id)
const;
271 QDateTime readPropertyAsDateTime(
int id)
const;
273#if QT_CONFIG(regularexpression)
274 QRegularExpression readPropertyAsRegularExpression(
int id)
const;
277 QRectF readPropertyAsRectF(
int id)
const;
278 QObject *readPropertyAsQObject(
int id)
const;
279 void initPropertyAsList(
int id)
const;
281 void writeProperty(
int id,
int v);
282 void writeProperty(
int id,
bool v);
283 void writeProperty(
int id,
double v);
284 void writeProperty(
int id,
const QString& v);
286 template<
typename VariantCompatible>
287 void writeProperty(
int id,
const VariantCompatible &v)
289 QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
291 QV4::Scope scope(m_engine);
292 QV4::Scoped<QV4::MemberData>(scope, md)->set(
293 m_engine, id, m_engine->newVariantObject(
294 QMetaType::fromType<VariantCompatible>(), &v));
298 void writeProperty(
int id, QObject *v);
300 void ensureQObjectWrapper();
302 void mark(QV4::MarkStack *markStack);
304 void connectAlias(
const QV4::CompiledData::Object *compiledObject,
int aliasId);
306 QV4::ReturnedValue method(
int)
const;
308 QV4::ReturnedValue readVarProperty(
int)
const;
309 void writeVarProperty(
int,
const QV4::Value &);
310 QVariant readPropertyAsVariant(
int)
const;
312 inline QQmlVMEMetaObject *parentVMEMetaObject()
const;
313 inline void setParentVMEMetaObject(QQmlVMEMetaObject *newParent);
315 void activate(QObject *,
int,
void **);
317 QQmlVMEVariantQObjectPtr *getQObjectGuardForProperty(
int)
const;
319 QQmlRefPointer<QQmlContextData> contextData()
const {
return m_ctxt.contextData(); }
320 QV4::ExecutionEngine *engine()
const {
return m_engine; }
321 QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit()
const
323 return m_compilationUnit;
326 void setCompilationUnit(
const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit)
328 m_compilationUnit = compilationUnit;
331 int qmlObjectId()
const {
return m_qmlObjectId; }
334 int metaCall(QObject *o, QMetaObject::Call _c,
int _id,
void **_a) override;
335 bool getListProperty(
int id, QQmlListProperty<QObject> *target);
338 friend class QQmlVMEMetaObjectEndpoint;
339 friend class QQmlVMEResolvedList;
340 friend class QQmlVMEVariantQObjectPtr;
342 static inline QQmlVMEMetaObject *get(QObject *o);
344 const QV4::CompiledData::Object *findCompiledObject()
const {
346 if (!m_compilationUnit || !m_compilationUnit->engine)
349 Q_ASSERT(m_qmlObjectId >= 0 && m_qmlObjectId < m_compilationUnit->objectCount());
350 return m_compilationUnit->objectAt(m_qmlObjectId);
353 void writeKnownVarProperty(
int id,
const QVariant &value);
355 QV4::ExecutionEngine *m_engine;
356 QQmlGuardedContextData m_ctxt;
358 QQmlVMEMetaObjectEndpoint *m_aliasEndpoints;
359 QV4::WeakValue m_propertyAndMethodStorage;
361 QList<QQmlVMEVariantQObjectPtr *> m_varObjectGuards;
363 void remapStoredValues(
int newPropertyCount,
const QList<
int> &oldToNew);
364 void remapObjectGuards(
const QList<
int> &oldToNew);
368 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
369 int m_qmlObjectId = -1;
370 int m_numAliases = 0;