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; }
120 bool intercepts(QQmlPropertyIndex propertyIndex)
const
122 for (
auto it = interceptors; it; it = it->m_next) {
123 if (it->m_propertyIndex == propertyIndex)
126 if (
auto parentInterceptor = ((parent.isT1() && parent.flag()) ?
static_cast<QQmlInterceptorMetaObject *>(parent.asT1()) :
nullptr))
127 return parentInterceptor->intercepts(propertyIndex);
131 void invalidate() { metaObject.setTag(MetaObjectInvalid); }
133 QObject *object =
nullptr;
134 QQmlPropertyCache::ConstPtr cache;
137 int metaCall(QObject *o, QMetaObject::Call c,
int id,
void **a) override;
138 bool intercept(QMetaObject::Call c,
int id,
void **a)
144 case QMetaObject::WriteProperty:
145 if (*
reinterpret_cast<
int*>(a[3]) & QQmlPropertyData::BypassInterceptor)
148 case QMetaObject::BindableProperty:
154 return doIntercept(c, id, a);
157 QBiPointer<QDynamicMetaObjectData,
const QMetaObject> parent;
159 enum MetaObjectValidity { MetaObjectValid, MetaObjectInvalid };
160 QTaggedPointer<
const QMetaObject, MetaObjectValidity> metaObject;
163 bool doIntercept(QMetaObject::Call c,
int id,
void **a);
164 QQmlPropertyValueInterceptor *interceptors =
nullptr;
184 QV4::ExecutionEngine *engine, QObject *obj,
const QQmlPropertyCache::ConstPtr &cache,
185 const QQmlRefPointer<QV4::ExecutableCompilationUnit> &qmlCompilationUnit,
187 ~QQmlVMEMetaObject() override;
189 bool aliasTarget(
int index, QObject **target,
int *coreIndex,
int *valueTypeIndex)
const;
190 QV4::ReturnedValue vmeMethod(
int index)
const;
191 void setVmeMethod(
int index,
const QV4::Value &function);
192 QV4::ReturnedValue vmeProperty(
int index)
const;
193 void setVMEProperty(
int index,
const QV4::Value &v);
195 void connectAliasSignal(
int index,
bool indexInSignalRange);
197 static inline QQmlVMEMetaObject *get(QObject *o);
198 static QQmlVMEMetaObject *getForProperty(QObject *o,
int coreIndex);
199 static QQmlVMEMetaObject *getForMethod(QObject *o,
int coreIndex);
200 static QQmlVMEMetaObject *getForSignal(QObject *o,
int coreIndex);
202 static void list_append(QQmlListProperty<QObject> *prop, QObject *o);
203 static void list_clear(QQmlListProperty<QObject> *prop);
204 static void list_append_nosignal(QQmlListProperty<QObject> *prop, QObject *o);
205 static void list_clear_nosignal(QQmlListProperty<QObject> *prop);
207 inline int propOffset()
const;
208 inline int propCount()
const;
209 inline int aliasOffset()
const;
210 inline int aliasCount()
const;
211 inline int signalOffset()
const;
212 inline int signalCount()
const;
213 inline int methodOffset()
const;
214 inline int methodCount()
const;
216 QV4::MemberData *propertyAndMethodStorageAsMemberData()
const;
218 int readPropertyAsInt(
int id)
const;
219 bool readPropertyAsBool(
int id)
const;
220 double readPropertyAsDouble(
int id)
const;
221 QString readPropertyAsString(
int id)
const;
222 QSizeF readPropertyAsSizeF(
int id)
const;
223 QPointF readPropertyAsPointF(
int id)
const;
224 QUrl readPropertyAsUrl(
int id)
const;
225 QDate readPropertyAsDate(
int id)
const;
226 QTime readPropertyAsTime(
int id)
const;
227 QDateTime readPropertyAsDateTime(
int id)
const;
229#if QT_CONFIG(regularexpression)
230 QRegularExpression readPropertyAsRegularExpression(
int id)
const;
233 QRectF readPropertyAsRectF(
int id)
const;
234 QObject *readPropertyAsQObject(
int id)
const;
235 void initPropertyAsList(
int id)
const;
237 void writeProperty(
int id,
int v);
238 void writeProperty(
int id,
bool v);
239 void writeProperty(
int id,
double v);
240 void writeProperty(
int id,
const QString& v);
242 template<
typename VariantCompatible>
243 void writeProperty(
int id,
const VariantCompatible &v)
245 QV4::MemberData *md = propertyAndMethodStorageAsMemberData();
247 QV4::Scope scope(m_engine);
248 QV4::Scoped<QV4::MemberData>(scope, md)->set(
249 m_engine, id, m_engine->newVariantObject(
250 QMetaType::fromType<VariantCompatible>(), &v));
254 void writeProperty(
int id, QObject *v);
256 void ensureQObjectWrapper();
258 void mark(QV4::MarkStack *markStack);
260 void connectAlias(
const QV4::CompiledData::Object *compiledObject,
int aliasId);
262 QV4::ReturnedValue method(
int)
const;
264 QV4::ReturnedValue readVarProperty(
int)
const;
265 void writeVarProperty(
int,
const QV4::Value &);
266 QVariant readPropertyAsVariant(
int)
const;
268 inline QQmlVMEMetaObject *parentVMEMetaObject()
const;
270 void activate(QObject *,
int,
void **);
272 QQmlVMEVariantQObjectPtr *getQObjectGuardForProperty(
int)
const;
274 QQmlRefPointer<QQmlContextData> contextData()
const {
return m_ctxt.contextData(); }
275 QV4::ExecutionEngine *engine()
const {
return m_engine; }
276 QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit()
const
278 return m_compilationUnit;
282 int metaCall(QObject *o, QMetaObject::Call _c,
int _id,
void **_a) override;
283 bool getListProperty(
int id, QQmlListProperty<QObject> *target);
286 friend class QQmlVMEMetaObjectEndpoint;
287 friend class QQmlVMEResolvedList;
288 friend class QQmlVMEVariantQObjectPtr;
290 const QV4::CompiledData::Object *findCompiledObject()
const {
292 if (!m_compilationUnit || !m_compilationUnit->engine)
295 Q_ASSERT(m_qmlObjectId >= 0 && m_qmlObjectId < m_compilationUnit->objectCount());
296 return m_compilationUnit->objectAt(m_qmlObjectId);
299 void writeKnownVarProperty(
int id,
const QVariant &value);
301 QV4::ExecutionEngine *m_engine;
302 QQmlGuardedContextData m_ctxt;
304 QQmlVMEMetaObjectEndpoint *m_aliasEndpoints;
305 QV4::WeakValue m_propertyAndMethodStorage;
307 QList<QQmlVMEVariantQObjectPtr *> m_varObjectGuards;
311 QQmlRefPointer<QV4::ExecutableCompilationUnit> m_compilationUnit;
312 int m_qmlObjectId = -1;
313 int m_numAliases = 0;