diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2014-11-10 11:39:03 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-12-22 21:48:11 +0100 |
commit | fa3cf15e0577fe382ac577456422ad78325a3977 (patch) | |
tree | 3323ab526433f73fb644b1692c10629f01093d62 /src/qml/compiler | |
parent | ee771dda2e9e304edea88e6d5f6e6d540a0bab97 (diff) |
Initial work on gadget support
Changed built-in QtQml value types to use gadgets. This is in preparation for
supporting external gadgets.
This replaces the mostly direct inheritance of the concrete value types with
gadgets and "dynamic" inheritance through QQmlValueType being generic. Over
time as some of the value types may become gadgets, we can remove the ones
here. It's important that these "separate" gadgets have the same memory layout
as the actual types (QPointF, etc.).
Also while QQmlValueType remains practically a singleton, it's not required
anymore to be one. Consequently the JS wrappers for value types keep their own
instance of QQmlValueType. This allows eliminating the qobject_cast in various
places that dealt with the singleton nature. This comes at a cost, making the
JS wrappers slightly heavier. However that is meant to be a temporary situation
and finally the value type wrapper should merely store the meta-object in
addition to the data and the type.
Change-Id: I15071ded0a1e54203f29ec1ecf7a9ab646d1168e
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 4 | ||||
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 18 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 339278fbe8..07ea2a6fff 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1941,8 +1941,8 @@ static QV4::IR::Type resolveMetaObjectProperty(QQmlEnginePrivate *qmlEngine, QV4 initMetaObjectResolver(resolver, cache); return QV4::IR::QObjectType; } - } else if (QQmlValueType *valueType = QQmlValueTypeFactory::valueType(property->propType)) { - if (QQmlPropertyCache *cache = qmlEngine->cache(valueType->metaObject())) { + } else if (const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(property->propType)) { + if (QQmlPropertyCache *cache = qmlEngine->cache(valueTypeMetaObject)) { initMetaObjectResolver(resolver, cache); resolver->flags |= ResolveTypeInformationOnly; return QV4::IR::QObjectType; diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index ada848f31d..7f399f0879 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -463,8 +463,8 @@ bool QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, int r if (instantiatingProperty->isQObject()) { baseTypeCache = enginePrivate->rawPropertyCacheForType(instantiatingProperty->propType); Q_ASSERT(baseTypeCache); - } else if (QQmlValueType *vt = QQmlValueTypeFactory::valueType(instantiatingProperty->propType)) { - baseTypeCache = enginePrivate->cache(vt->metaObject()); + } else if (const QMetaObject *vtmo = QQmlValueTypeFactory::metaObjectForMetaType(instantiatingProperty->propType)) { + baseTypeCache = enginePrivate->cache(vtmo); Q_ASSERT(baseTypeCache); } } @@ -1630,8 +1630,8 @@ bool QQmlComponentAndAliasResolver::resolveAliases() notifySignal = targetProperty->notifyIndex; if (!subProperty.isEmpty()) { - QQmlValueType *valueType = QQmlValueTypeFactory::valueType(type); - if (!valueType) { + const QMetaObject *valueTypeMetaObject = QQmlValueTypeFactory::metaObjectForMetaType(type); + if (!valueTypeMetaObject) { recordError(p->aliasLocation, tr("Invalid alias location")); return false; } @@ -1639,7 +1639,7 @@ bool QQmlComponentAndAliasResolver::resolveAliases() propType = type; int valueTypeIndex = - valueType->metaObject()->indexOfProperty(subProperty.toString().toUtf8().constData()); + valueTypeMetaObject->indexOfProperty(subProperty.toString().toUtf8().constData()); if (valueTypeIndex == -1) { recordError(p->aliasLocation, tr("Invalid alias location")); return false; @@ -1647,10 +1647,10 @@ bool QQmlComponentAndAliasResolver::resolveAliases() Q_ASSERT(valueTypeIndex <= 0x0000FFFF); propIdx = QQmlPropertyData::encodeValueTypePropertyIndex(propIdx, valueTypeIndex); - if (valueType->metaObject()->property(valueTypeIndex).isEnumType()) + if (valueTypeMetaObject->property(valueTypeIndex).isEnumType()) type = QVariant::Int; else - type = valueType->metaObject()->property(valueTypeIndex).userType(); + type = valueTypeMetaObject->property(valueTypeIndex).userType(); } else { if (targetProperty->isEnum()) { @@ -1887,7 +1887,7 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD if (binding->type >= QV4::CompiledData::Binding::Type_Object && !customParser) { qSwap(_seenObjectWithId, seenSubObjectWithId); - const bool subObjectValid = validateObject(binding->value.objectIndex, binding, pd && QQmlValueTypeFactory::valueType(pd->propType)); + const bool subObjectValid = validateObject(binding->value.objectIndex, binding, pd && QQmlValueTypeFactory::metaObjectForMetaType(pd->propType)); qSwap(_seenObjectWithId, seenSubObjectWithId); if (!subObjectValid) return false; @@ -1961,7 +1961,7 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD return false; } else if (binding->isGroupProperty()) { if (QQmlValueTypeFactory::isValueType(pd->propType)) { - if (QQmlValueTypeFactory::valueType(pd->propType)) { + if (QQmlValueTypeFactory::metaObjectForMetaType(pd->propType)) { if (!pd->isWritable()) { recordError(binding->location, tr("Invalid property assignment: \"%1\" is a read-only property").arg(name)); return false; |