jsfunction += body;
jsfunction += QLatin1String("\n})");
- QQmlVMEMetaObject *vmeMetaObject =
- static_cast<QQmlVMEMetaObject*>(QObjectPrivate::get(object)->metaObject);
+ QQmlVMEMetaObject *vmeMetaObject = QQmlVMEMetaObject::get(object);
Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
public:
QQmlData()
: ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false),
- hasTaintedV8Object(false), isQueuedForDeletion(false), rootObjectInCreation(false), notifyList(0), context(0), outerContext(0),
+ hasTaintedV8Object(false), isQueuedForDeletion(false), rootObjectInCreation(false),
+ hasVMEMetaObject(false), notifyList(0), context(0), outerContext(0),
bindings(0), signalHandlers(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0),
lineNumber(0), columnNumber(0), compiledData(0), deferredIdx(0), v8objectid(0),
propertyCache(0), guards(0), extendedData(0) {
* v8 GC will check this flag, only deletes the objects when rootObjectInCreation is false.
*/
quint32 rootObjectInCreation:1;
- quint32 dummy:25;
+ quint32 hasVMEMetaObject:1;
+ quint32 dummy:24;
struct NotifyList {
quint64 connectionMask;
if (expression->hasError()) {
return false;
} else if (isVmeProperty) {
- typedef QQmlVMEMetaObject VMEMO;
if (!result.IsEmpty() && result->IsFunction()
&& !result->ToObject()->GetHiddenValue(v8engine->bindingFlagKey()).IsEmpty()) {
// we explicitly disallow this case to avoid confusion. Users can still store one
expression->delayedError()->error.setDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration."));
return false;
}
- VMEMO *vmemo = static_cast<VMEMO *>(const_cast<QMetaObject *>(object->metaObject()));
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object);
+ Q_ASSERT(vmemo);
vmemo->setVMEProperty(core.coreIndex, result);
} else if (isUndefined && core.isResettable()) {
void *args[] = { 0 };
v8::Handle<v8::Value> v8value = value; \
QObject *target = objects.top(); \
CLEAN_PROPERTY(target, instr.propertyIndex); \
- QMetaObject *mo = const_cast<QMetaObject *>(target->metaObject()); \
- QQmlVMEMetaObject *vmemo = static_cast<QQmlVMEMetaObject *>(mo); \
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(target); \
+ Q_ASSERT(vmemo); \
vmemo->setVMEProperty(instr.propertyIndex, v8value); \
QML_END_INSTR(name)
QQmlPropertyPrivate::restore(target, instr.property, CTXT);
obj->setParent(target);
vi->setTarget(prop);
- QQmlVMEMetaObject *mo = static_cast<QQmlVMEMetaObject *>((QMetaObject*)target->metaObject());
+ QQmlVMEMetaObject *mo = QQmlVMEMetaObject::get(target);
+ Q_ASSERT(mo);
mo->registerInterceptor(prop.index(), QQmlPropertyPrivate::valueTypeCoreIndex(prop), vi);
QML_END_INSTR(StoreValueInterceptor)
if (op->metaObject)
parent = static_cast<QAbstractDynamicMetaObject*>(op->metaObject);
op->metaObject = this;
+ QQmlData::get(obj)->hasVMEMetaObject = true;
propOffset = QAbstractDynamicMetaObject::propertyOffset();
methodOffset = QAbstractDynamicMetaObject::methodOffset();
void connectAliasSignal(int index);
+ static inline QQmlVMEMetaObject *get(const QObject *obj);
+
protected:
virtual int metaCall(QMetaObject::Call _c, int _id, void **_a);
friend class QV8QObjectWrapper;
};
+QQmlVMEMetaObject *QQmlVMEMetaObject::get(const QObject *obj)
+{
+ if (obj) {
+ if (QQmlData *data = QQmlData::get(obj)) {
+ if (data->hasVMEMetaObject)
+ return const_cast<QQmlVMEMetaObject *>(static_cast<const QQmlVMEMetaObject *>(obj->metaObject()));
+ }
+ }
+
+ return 0;
+}
+
QT_END_NAMESPACE
#endif // QQMLVMEMETAOBJECT_P_H
if (data.gettype() == V8HandleType) {
// This property must be a VME var property
- QQmlVMEMetaObject *vmemo = static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(output->metaObject()));
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(output);
+ Q_ASSERT(vmemo);
vmemo->setVMEProperty(instr->store.index, *data.gethandleptr());
} else {
int status = -1;
if (result->isFunction() && !result->isVMEProperty()) {
if (result->isVMEFunction()) {
- return ((QQmlVMEMetaObject *)(object->metaObject()))->vmeMethod(result->coreIndex);
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object);
+ Q_ASSERT(vmemo);
+ return vmemo->vmeMethod(result->coreIndex);
} else if (result->isV8Function()) {
return MethodClosure::createWithGlobal(engine, object, objectHandle, result->coreIndex);
} else if (result->isSignalHandler()) {
ep->captureProperty(object, result->coreIndex, result->notifyIndex);
if (result->isVMEProperty()) {
- typedef QQmlVMEMetaObject VMEMO;
- VMEMO *vmemo = const_cast<VMEMO *>(static_cast<const VMEMO *>(object->metaObject()));
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object);
+ Q_ASSERT(vmemo);
return vmemo->vmeProperty(result->coreIndex);
} else if (result->isDirect()) {
return LoadProperty<ReadAccessor::Direct>(engine, object, *result, 0);
if (!newBinding && property->isVMEProperty()) {
// allow assignment of "special" values (null, undefined, function) to var properties
- static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(object->metaObject()))->setVMEProperty(property->coreIndex, value);
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object);
+ Q_ASSERT(vmemo);
+ vmemo->setVMEProperty(property->coreIndex, value);
return;
}
} else if (property->propType == QMetaType::QString && value->IsString()) {
PROPERTY_STORE(QString, engine->toString(value->ToString()));
} else if (property->isVMEProperty()) {
- static_cast<QQmlVMEMetaObject *>(const_cast<QMetaObject *>(object->metaObject()))->setVMEProperty(property->coreIndex, value);
+ QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object);
+ Q_ASSERT(vmemo);
+ vmemo->setVMEProperty(property->coreIndex, value);
} else {
QVariant v;
if (property->isQList())
// we want to be able to track when the varProperties array of the last metaobject is disposed
QObject *cco5 = object->property("varProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
QObject *ico5 = object->property("varProperty").value<QObject*>()->property("inheritanceVarProperty").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>()->property("vp").value<QObject*>();
- QQmlVMEMetaObject *icovmemo = ((QQmlVMEMetaObject *)(ico5->metaObject()));
- QQmlVMEMetaObject *ccovmemo = ((QQmlVMEMetaObject *)(cco5->metaObject()));
+ QQmlVMEMetaObject *icovmemo = QQmlVMEMetaObject::get(ico5);
+ QQmlVMEMetaObject *ccovmemo = QQmlVMEMetaObject::get(cco5);
v8::Persistent<v8::Value> icoCanaryHandle;
v8::Persistent<v8::Value> ccoCanaryHandle;
{
{
v8::HandleScope hs;
propertyVarWeakRefCallbackCount = 0; // reset callback count.
- childObjectVarArrayValueHandle = qPersistentNew(((QQmlVMEMetaObject *)(childObject->metaObject()))->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
+ childObjectVarArrayValueHandle = qPersistentNew(QQmlVMEMetaObject::get(childObject)->vmeProperty(childObject->metaObject()->indexOfProperty("vp")));
childObjectVarArrayValueHandle.MakeWeak(&propertyVarWeakRefCallbackCount, propertyVarWeakRefCallback);
gc(engine);
QVERIFY(propertyVarWeakRefCallbackCount == 0); // should not have been collected yet.