diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-15 08:57:33 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-16 19:05:57 +0000 |
commit | 4da7ca32bb271355ae3e707499a3f5627de069d4 (patch) | |
tree | 73d6398c6f9c9fd16279b9b0b905934e0ce78441 /src/qml/compiler/qqmlpropertycachecreator.cpp | |
parent | f2c97b4e307a62b831f68a0278551d4375170336 (diff) |
Minor QQmlPropertyCacheCreator API cleanup
As part of removing the QQmlTypeCompiler dependency, the property cache
vector output of the creator is now passed explicitly as an out
parameter to the constructor.
Similarly the error handling is made explicit in the API instead of
implicitly passing any generated errors to the QQmlTypeCompiler.
Change-Id: Ia3013011518f59f57f2eecb526f64dec7d82cb91
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml/compiler/qqmlpropertycachecreator.cpp')
-rw-r--r-- | src/qml/compiler/qqmlpropertycachecreator.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/qml/compiler/qqmlpropertycachecreator.cpp b/src/qml/compiler/qqmlpropertycachecreator.cpp index a0bcba01ce..bd5bb3620d 100644 --- a/src/qml/compiler/qqmlpropertycachecreator.cpp +++ b/src/qml/compiler/qqmlpropertycachecreator.cpp @@ -68,34 +68,25 @@ QQmlPropertyCacheCreator::InstantiationContext::InstantiationContext(int referen } } -QQmlPropertyCacheCreator::QQmlPropertyCacheCreator(QQmlTypeCompiler *typeCompiler) +QQmlPropertyCacheCreator::QQmlPropertyCacheCreator(QQmlTypeCompiler *typeCompiler, QQmlPropertyCacheVector *propertyCaches) : QQmlCompilePass(typeCompiler) , enginePrivate(typeCompiler->enginePrivate()) , qmlObjects(*typeCompiler->qmlObjects()) , imports(typeCompiler->imports()) , resolvedTypes(typeCompiler->resolvedTypes()) + , propertyCaches(propertyCaches) { + propertyCaches->resize(qmlObjects.count()); } QQmlPropertyCacheCreator::~QQmlPropertyCacheCreator() { } -bool QQmlPropertyCacheCreator::buildMetaObjects() +QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjects() { - propertyCaches.resize(qmlObjects.count()); - InstantiationContext context; - - QQmlCompileError error = buildMetaObjectRecursively(compiler->rootObjectIndex(), context); - if (error.isSet()) { - recordError(error); - return false; - } - - compiler->setPropertyCaches(std::move(propertyCaches)); - - return true; + return buildMetaObjectRecursively(compiler->rootObjectIndex(), context); } QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, const InstantiationContext &context) @@ -111,7 +102,7 @@ QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int object // the property that references us, for the latter we only need a meta-object on the referencing object // because interceptors can't go to the shared value type instances. if (context.instantiatingProperty && QQmlValueTypeFactory::isValueType(context.instantiatingProperty->propType)) { - if (!propertyCaches.needsVMEMetaObject(context.referencingObjectIndex)) { + if (!propertyCaches->needsVMEMetaObject(context.referencingObjectIndex)) { const QmlIR::Object *obj = qmlObjects.at(context.referencingObjectIndex); auto *typeRef = resolvedTypes->value(obj->inheritedTypeNameIndex); Q_ASSERT(typeRef); @@ -143,11 +134,11 @@ QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int object if (error.isSet()) return error; } else { - propertyCaches.set(objectIndex, baseTypeCache); + propertyCaches->set(objectIndex, baseTypeCache); } } - if (QQmlPropertyCache *thisCache = propertyCaches.at(objectIndex)) { + if (QQmlPropertyCache *thisCache = propertyCaches->at(objectIndex)) { for (auto binding = obj->bindingsBegin(), end = obj->bindingsEnd(); binding != end; ++binding) if (binding->type >= QV4::CompiledData::Binding::Type_Object) { InstantiationContext context(objectIndex, &(*binding), stringAt(binding->propertyNameIndex), thisCache); @@ -226,8 +217,8 @@ QQmlCompileError QQmlPropertyCacheCreator::createMetaObject(int objectIndex, con obj->functionCount() + obj->propertyCount() + obj->aliasCount() + obj->signalCount(), obj->signalCount() + obj->propertyCount() + obj->aliasCount())); - propertyCaches.set(objectIndex, cache); - propertyCaches.setNeedsVMEMetaObject(objectIndex); + propertyCaches->set(objectIndex, cache); + propertyCaches->setNeedsVMEMetaObject(objectIndex); struct TypeData { QV4::CompiledData::Property::Type dtype; |