103 QQmlInterceptorMetaObject(QObject *obj,
const QQmlPropertyCache::ConstPtr &cache);
104 ~QQmlInterceptorMetaObject() override;
106 void registerInterceptor(QQmlPropertyIndex index, QQmlPropertyValueInterceptor *interceptor);
108 static QQmlInterceptorMetaObject *get(QObject *obj);
110#if QT_VERSION >= QT_VERSION_CHECK(7
, 0
, 0
)
111 const QMetaObject *toDynamicMetaObject(QObject *o)
const override;
113 QMetaObject *toDynamicMetaObject(QObject *o) override;
117 QQmlPropertyCache::ConstPtr propertyCache()
const {
return cache; }
119 bool intercepts(QQmlPropertyIndex propertyIndex)
const
121 for (
auto it = interceptors; it; it = it->m_next) {
122 if (it->m_propertyIndex == propertyIndex)
125 if (
auto parentInterceptor = ((parent.isT1() && parent.flag()) ?
static_cast<QQmlInterceptorMetaObject *>(parent.asT1()) :
nullptr))
126 return parentInterceptor->intercepts(propertyIndex);
130 void invalidate() { metaObject.setTag(MetaObjectInvalid); }
132 QObject *object =
nullptr;
133 QQmlPropertyCache::ConstPtr cache;
136 int metaCall(QObject *o, QMetaObject::Call c,
int id,
void **a) override;
137 bool intercept(QMetaObject::Call c,
int id,
void **a)
143 case QMetaObject::WriteProperty:
144 if (*
reinterpret_cast<
int*>(a[3]) & QQmlPropertyData::BypassInterceptor)
147 case QMetaObject::BindableProperty:
153 return doIntercept(c, id, a);
156 QBiPointer<QDynamicMetaObjectData,
const QMetaObject> parent;
158 enum MetaObjectValidity { MetaObjectValid, MetaObjectInvalid };
159 QTaggedPointer<
const QMetaObject, MetaObjectValidity> metaObject;
162 bool doIntercept(QMetaObject::Call c,
int id,
void **a);
163 QQmlPropertyValueInterceptor *interceptors =
nullptr;
183 QV4::ExecutionEngine *engine, QObject *obj,
const QQmlPropertyCache::ConstPtr &cache,
184 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit,
186 ~QQmlVMEMetaObject() override;
188 bool aliasTarget(
int index, QObject **target,
int *coreIndex,
int *valueTypeIndex)
const;
189 QV4::ReturnedValue vmeMethod(
int index)
const;
190 void setVmeMethod(
int index,
const QV4::Value &function);
191 QV4::ReturnedValue vmeProperty(
int index)
const;
192 void setVMEProperty(
int index,
const QV4::Value &v);
194 void connectAliasSignal(
int index,
bool indexInSignalRange);
196 static inline QQmlVMEMetaObject *get(QObject *o);
197 static QQmlVMEMetaObject *getForProperty(QObject *o,
int coreIndex);
198 static QQmlVMEMetaObject *getForMethod(QObject *o,
int coreIndex);
199 static QQmlVMEMetaObject *getForSignal(QObject *o,
int coreIndex);
201 static void list_append(QQmlListProperty<QObject> *prop, QObject *o);
202 static void list_clear(QQmlListProperty<QObject> *prop);
203 static void list_append_nosignal(QQmlListProperty<QObject> *prop, QObject *o);
204 static void list_clear_nosignal(QQmlListProperty<QObject> *prop);
206 inline int propOffset()
const;
207 inline int propCount()
const;
208 inline int aliasOffset()
const;
209 inline int aliasCount()
const;
210 inline int signalOffset()
const;
211 inline int signalCount()
const;
212 inline int methodOffset()
const;
213 inline int methodCount()
const;
215 QV4::MemberData *propertyAndMethodStorageAsMemberData()
const;
217 int readPropertyAsInt(
int id)
const;
218 bool readPropertyAsBool(
int id)
const;
219 double readPropertyAsDouble(
int id)
const;
220 QString readPropertyAsString(
int id)
const;
221 QSizeF readPropertyAsSizeF(
int id)
const;
222 QPointF readPropertyAsPointF(
int id)
const;
223 QUrl readPropertyAsUrl(
int id)
const;
224 QDate readPropertyAsDate(
int id)
const;
225 QTime readPropertyAsTime(
int id)
const;
226 QDateTime readPropertyAsDateTime(
int id)
const;
228#if QT_CONFIG(regularexpression)
229 QRegularExpression readPropertyAsRegularExpression(
int id)
const;
232 QRectF readPropertyAsRectF(
int id)
const;
233 QObject *readPropertyAsQObject(
int id)
const;
234 void initPropertyAsList(
int id)
const;
236 void writeProperty(
int id,
int v);
237 void writeProperty(
int id,
bool v);
238 void writeProperty(
int id,
double v);
239 void writeProperty(
int id,
const QString& v);
241 template<
typename VariantCompatible>
242 void writeProperty(
int id,
const VariantCompatible &v)
244 QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
246 QV4::Scope scope(m_engine);
247 QV4::Scoped<QV4::MemberData>(scope, md)->set(
248 m_engine, id, m_engine->newVariantObject(
249 QMetaType::fromType<VariantCompatible>(), &v));
253 void writeProperty(
int id, QObject *v);
255 void ensureQObjectWrapper();
257 void mark(QV4::MarkStack *markStack);
259 void connectAlias(
const QV4::CompiledData::Object *compiledObject,
int aliasId);
261 QV4::ReturnedValue method(
int)
const;
263 QV4::ReturnedValue readVarProperty(
int)
const;
264 void writeVarProperty(
int,
const QV4::Value &);
265 QVariant readPropertyAsVariant(
int)
const;
267 inline QQmlVMEMetaObject *parentVMEMetaObject()
const;
269 void activate(QObject *,
int,
void **);
271 QQmlVMEVariantQObjectPtr *getQObjectGuardForProperty(
int)
const;
273 QQmlRefPointer<QQmlContextData> contextData()
const {
return m_ctxt.contextData(); }
274 QV4::ExecutionEngine *engine()
const {
return m_engine; }
275 QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit()
const
277 return m_compilationUnit;
281 int metaCall(QObject *o, QMetaObject::Call _c,
int _id,
void **_a) override;
282 bool getListProperty(
int id, QQmlListProperty<QObject> *target);
285 friend class QQmlVMEMetaObjectEndpoint;
286 friend class QQmlVMEResolvedList;
287 friend class QQmlVMEVariantQObjectPtr;
289 const QV4::CompiledData::Object *findCompiledObject()
const {
291 if (!m_compilationUnit || !m_compilationUnit->engine)
294 Q_ASSERT(m_qmlObjectId >= 0 && m_qmlObjectId < m_compilationUnit->objectCount());
295 return m_compilationUnit->objectAt(m_qmlObjectId);
298 void writeKnownVarProperty(
int id,
const QVariant &value);
300 QV4::ExecutionEngine *m_engine;
301 QQmlGuardedContextData m_ctxt;
303 QQmlVMEMetaObjectEndpoint *m_aliasEndpoints;
304 QV4::WeakValue m_propertyAndMethodStorage;
306 QList<QQmlVMEVariantQObjectPtr *> m_varObjectGuards;
310 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
311 int m_qmlObjectId = -1;
312 int m_numAliases = 0;