104 QQmlInterceptorMetaObject(QObject *obj,
const QQmlPropertyCache::ConstPtr &cache);
105 ~QQmlInterceptorMetaObject() override;
107 void registerInterceptor(QQmlPropertyIndex index, QQmlPropertyValueInterceptor *interceptor);
109 static QQmlInterceptorMetaObject *get(QObject *obj);
111#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
112 const QMetaObject *toDynamicMetaObject(QObject *o)
const override;
114 QMetaObject *toDynamicMetaObject(QObject *o) override;
118 QQmlPropertyCache::ConstPtr propertyCache()
const {
return cache; }
124 void setPropertyCache(
const QQmlPropertyCache::ConstPtr &newCache)
127 metaObject = QTaggedPointer<
const QMetaObject, MetaObjectValidity>();
130 bool intercepts(QQmlPropertyIndex propertyIndex)
const
132 for (
auto it = interceptors; it; it = it->m_next) {
133 if (it->m_propertyIndex == propertyIndex)
136 if (
auto parentInterceptor = ((parent.isT1() && parent.flag()) ?
static_cast<QQmlInterceptorMetaObject *>(parent.asT1()) :
nullptr))
137 return parentInterceptor->intercepts(propertyIndex);
141 void invalidate() { metaObject.setTag(MetaObjectInvalid); }
143 QObject *object =
nullptr;
144 QQmlPropertyCache::ConstPtr cache;
147 int metaCall(QObject *o, QMetaObject::Call c,
int id,
void **a) override;
148 bool intercept(QMetaObject::Call c,
int id,
void **a)
154 case QMetaObject::WriteProperty:
155 if (*
reinterpret_cast<
int*>(a[3]) & QQmlPropertyData::BypassInterceptor)
158 case QMetaObject::BindableProperty:
164 return doIntercept(c, id, a);
167 QBiPointer<QDynamicMetaObjectData,
const QMetaObject> parent;
169 enum MetaObjectValidity { MetaObjectValid, MetaObjectInvalid };
170 QTaggedPointer<
const QMetaObject, MetaObjectValidity> metaObject;
173 bool doIntercept(QMetaObject::Call c,
int id,
void **a);
174 QQmlPropertyValueInterceptor *interceptors =
nullptr;
194 QV4::ExecutionEngine *engine, QObject *obj,
const QQmlPropertyCache::ConstPtr &cache,
195 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit,
197 ~QQmlVMEMetaObject() override;
199 bool aliasTarget(
int index, QObject **target,
int *coreIndex,
int *valueTypeIndex)
const;
200 QV4::ReturnedValue vmeMethod(
int index)
const;
201 void setVmeMethod(
int index,
const QV4::Value &function);
202 QV4::ReturnedValue vmeProperty(
int index)
const;
203 void setVMEProperty(
int index,
const QV4::Value &v);
205 void connectAliasSignal(
int index,
bool indexInSignalRange);
207 static inline QQmlVMEMetaObject *get(QObject *o);
208 static QQmlVMEMetaObject *getForProperty(QObject *o,
int coreIndex);
209 static QQmlVMEMetaObject *getForMethod(QObject *o,
int coreIndex);
210 static QQmlVMEMetaObject *getForSignal(QObject *o,
int coreIndex);
212 static void list_append(QQmlListProperty<QObject> *prop, QObject *o);
213 static void list_clear(QQmlListProperty<QObject> *prop);
214 static void list_append_nosignal(QQmlListProperty<QObject> *prop, QObject *o);
215 static void list_clear_nosignal(QQmlListProperty<QObject> *prop);
217 inline int propOffset()
const;
218 inline int propCount()
const;
219 inline int aliasOffset()
const;
220 inline int aliasCount()
const;
221 inline int signalOffset()
const;
222 inline int signalCount()
const;
223 inline int methodOffset()
const;
224 inline int methodCount()
const;
226 QV4::MemberData *propertyAndMethodStorageAsMemberData()
const;
228 int readPropertyAsInt(
int id)
const;
229 bool readPropertyAsBool(
int id)
const;
230 double readPropertyAsDouble(
int id)
const;
231 QString readPropertyAsString(
int id)
const;
232 QSizeF readPropertyAsSizeF(
int id)
const;
233 QPointF readPropertyAsPointF(
int id)
const;
234 QUrl readPropertyAsUrl(
int id)
const;
235 QDate readPropertyAsDate(
int id)
const;
236 QTime readPropertyAsTime(
int id)
const;
237 QDateTime readPropertyAsDateTime(
int id)
const;
239#if QT_CONFIG(regularexpression)
240 QRegularExpression readPropertyAsRegularExpression(
int id)
const;
243 QRectF readPropertyAsRectF(
int id)
const;
244 QObject *readPropertyAsQObject(
int id)
const;
245 void initPropertyAsList(
int id)
const;
247 void writeProperty(
int id,
int v);
248 void writeProperty(
int id,
bool v);
249 void writeProperty(
int id,
double v);
250 void writeProperty(
int id,
const QString& v);
252 template<
typename VariantCompatible>
253 void writeProperty(
int id,
const VariantCompatible &v)
255 QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
257 QV4::Scope scope(m_engine);
258 QV4::Scoped<QV4::MemberData>(scope, md)->set(
259 m_engine, id, m_engine->newVariantObject(
260 QMetaType::fromType<VariantCompatible>(), &v));
264 void writeProperty(
int id, QObject *v);
266 void ensureQObjectWrapper();
268 void mark(QV4::MarkStack *markStack);
270 void connectAlias(
const QV4::CompiledData::Object *compiledObject,
int aliasId);
272 QV4::ReturnedValue method(
int)
const;
274 QV4::ReturnedValue readVarProperty(
int)
const;
275 void writeVarProperty(
int,
const QV4::Value &);
276 QVariant readPropertyAsVariant(
int)
const;
278 inline QQmlVMEMetaObject *parentVMEMetaObject()
const;
279 inline void setParentVMEMetaObject(QQmlVMEMetaObject *newParent);
281 void activate(QObject *,
int,
void **);
283 QQmlVMEVariantQObjectPtr *getQObjectGuardForProperty(
int)
const;
285 QQmlRefPointer<QQmlContextData> contextData()
const {
return m_ctxt.contextData(); }
286 QV4::ExecutionEngine *engine()
const {
return m_engine; }
287 QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit()
const
289 return m_compilationUnit;
292 void setCompilationUnit(
const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit)
294 m_compilationUnit = compilationUnit;
297 int qmlObjectId()
const {
return m_qmlObjectId; }
300 int metaCall(QObject *o, QMetaObject::Call _c,
int _id,
void **_a) override;
301 bool getListProperty(
int id, QQmlListProperty<QObject> *target);
304 friend class QQmlVMEMetaObjectEndpoint;
305 friend class QQmlVMEResolvedList;
306 friend class QQmlVMEVariantQObjectPtr;
308 const QV4::CompiledData::Object *findCompiledObject()
const {
310 if (!m_compilationUnit || !m_compilationUnit->engine)
313 Q_ASSERT(m_qmlObjectId >= 0 && m_qmlObjectId < m_compilationUnit->objectCount());
314 return m_compilationUnit->objectAt(m_qmlObjectId);
317 void writeKnownVarProperty(
int id,
const QVariant &value);
319 QV4::ExecutionEngine *m_engine;
320 QQmlGuardedContextData m_ctxt;
322 QQmlVMEMetaObjectEndpoint *m_aliasEndpoints;
323 QV4::WeakValue m_propertyAndMethodStorage;
325 QList<QQmlVMEVariantQObjectPtr *> m_varObjectGuards;
329 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
330 int m_qmlObjectId = -1;
331 int m_numAliases = 0;