summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2016-06-15 09:24:51 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2016-06-16 20:21:46 +0000
commit54d92bbcbf9cde4d66cfea9053e66e7b072a7ada (patch)
tree873595de774c2aea74ed64c51d5d6845bbd1b99a
parentebe51b92a353ba17e6293c280b77aab3f2a02a90 (diff)
downloadqtdeclarative-54d92bbcbf9cde4d66cfea9053e66e7b072a7ada.tar.gz
Separate non-generic code out of QQmlPropertyCacheCreator
Some code is not suitable for a future conversion of the class to a template, which is now moved out. This includes the tr() handling as well as the instantiation context, which does not require any parameterization. Change-Id: Ib40e24ebb7166c8649ca218f02558a737d39fe53 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/compiler/qqmlpropertycachecreator.cpp34
-rw-r--r--src/qml/compiler/qqmlpropertycachecreator_p.h30
2 files changed, 35 insertions, 29 deletions
diff --git a/src/qml/compiler/qqmlpropertycachecreator.cpp b/src/qml/compiler/qqmlpropertycachecreator.cpp
index c6cd29a317..47b9dad19a 100644
--- a/src/qml/compiler/qqmlpropertycachecreator.cpp
+++ b/src/qml/compiler/qqmlpropertycachecreator.cpp
@@ -43,9 +43,9 @@
QT_BEGIN_NAMESPACE
-static QAtomicInt classIndexCounter(0);
+QAtomicInt QQmlPropertyCacheCreatorBase::classIndexCounter(0);
-QQmlPropertyCacheCreator::InstantiationContext::InstantiationContext()
+QQmlBindingInstantiationContext::QQmlBindingInstantiationContext()
: referencingObjectIndex(-1)
, instantiatingBinding(nullptr)
, instantiatingProperty(nullptr)
@@ -53,7 +53,7 @@ QQmlPropertyCacheCreator::InstantiationContext::InstantiationContext()
}
-QQmlPropertyCacheCreator::InstantiationContext::InstantiationContext(int referencingObjectIndex, const QV4::CompiledData::Binding *instantiatingBinding, const QString &instantiatingPropertyName, const QQmlPropertyCache *referencingObjectPropertyCache)
+QQmlBindingInstantiationContext::QQmlBindingInstantiationContext(int referencingObjectIndex, const QV4::CompiledData::Binding *instantiatingBinding, const QString &instantiatingPropertyName, const QQmlPropertyCache *referencingObjectPropertyCache)
: referencingObjectIndex(referencingObjectIndex)
, instantiatingBinding(instantiatingBinding)
, instantiatingProperty(nullptr)
@@ -84,11 +84,11 @@ QQmlPropertyCacheCreator::~QQmlPropertyCacheCreator()
QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjects()
{
- InstantiationContext context;
+ QQmlBindingInstantiationContext context;
return buildMetaObjectRecursively(compiler->rootObjectIndex(), context);
}
-QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, const InstantiationContext &context)
+QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context)
{
const QmlIR::Object *obj = qmlObjects.at(objectIndex);
@@ -140,7 +140,7 @@ QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int object
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);
+ QQmlBindingInstantiationContext context(objectIndex, &(*binding), stringAt(binding->propertyNameIndex), thisCache);
QQmlCompileError error = buildMetaObjectRecursively(binding->value.objectIndex, context);
if (error.isSet())
return error;
@@ -151,7 +151,7 @@ QQmlCompileError QQmlPropertyCacheCreator::buildMetaObjectRecursively(int object
return noError;
}
-QQmlPropertyCache *QQmlPropertyCacheCreator::propertyCacheForObject(const QmlIR::Object *obj, const QQmlPropertyCacheCreator::InstantiationContext &context, QQmlCompileError *error) const
+QQmlPropertyCache *QQmlPropertyCacheCreator::propertyCacheForObject(const QmlIR::Object *obj, const QQmlBindingInstantiationContext &context, QQmlCompileError *error) const
{
if (context.instantiatingProperty) {
if (context.instantiatingProperty->isQObject()) {
@@ -165,15 +165,15 @@ QQmlPropertyCache *QQmlPropertyCacheCreator::propertyCacheForObject(const QmlIR:
if (typeRef->isFullyDynamicType) {
if (obj->propertyCount() > 0 || obj->aliasCount() > 0) {
- *error = QQmlCompileError(obj->location, tr("Fully dynamic types cannot declare new properties."));
+ *error = QQmlCompileError(obj->location, QQmlPropertyCacheCreatorBase::tr("Fully dynamic types cannot declare new properties."));
return nullptr;
}
if (obj->signalCount() > 0) {
- *error = QQmlCompileError(obj->location, tr("Fully dynamic types cannot declare new signals."));
+ *error = QQmlCompileError(obj->location, QQmlPropertyCacheCreatorBase::tr("Fully dynamic types cannot declare new signals."));
return nullptr;
}
if (obj->functionCount() > 0) {
- *error = QQmlCompileError(obj->location, tr("Fully Dynamic types cannot declare new functions."));
+ *error = QQmlCompileError(obj->location, QQmlPropertyCacheCreatorBase::tr("Fully Dynamic types cannot declare new functions."));
return nullptr;
}
}
@@ -201,7 +201,7 @@ QQmlPropertyCache *QQmlPropertyCacheCreator::propertyCacheForObject(const QmlIR:
const QMetaObject *attachedMo = qmltype ? qmltype->attachedPropertiesType(enginePrivate) : 0;
if (!attachedMo) {
- *error = QQmlCompileError(context.instantiatingBinding->location, tr("Non-existent attached object"));
+ *error = QQmlCompileError(context.instantiatingBinding->location, QQmlPropertyCacheCreatorBase::tr("Non-existent attached object"));
return nullptr;
}
return enginePrivate->cache(attachedMo);
@@ -277,14 +277,14 @@ QQmlCompileError QQmlPropertyCacheCreator::createMetaObject(int objectIndex, con
bool notInRevision = false;
QQmlPropertyData *d = resolver.property(stringAt(p->nameIndex), &notInRevision);
if (d && d->isFinal())
- return QQmlCompileError(p->location, tr("Cannot override FINAL property"));
+ return QQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Cannot override FINAL property"));
}
for (auto a = obj->aliasesBegin(), end = obj->aliasesEnd(); a != end; ++a) {
bool notInRevision = false;
QQmlPropertyData *d = resolver.property(stringAt(a->nameIndex), &notInRevision);
if (d && d->isFinal())
- return QQmlCompileError(a->location, tr("Cannot override FINAL property"));
+ return QQmlCompileError(a->location, QQmlPropertyCacheCreatorBase::tr("Cannot override FINAL property"));
}
int effectivePropertyIndex = cache->propertyIndexCacheStart;
@@ -357,7 +357,7 @@ QQmlCompileError QQmlPropertyCacheCreator::createMetaObject(int objectIndex, con
const QString customTypeName = stringAt(param->customTypeNameIndex);
QQmlType *qmltype = 0;
if (!imports->resolveType(customTypeName, &qmltype, 0, 0, 0))
- return QQmlCompileError(s->location, tr("Invalid signal parameter type: %1").arg(customTypeName));
+ return QQmlCompileError(s->location, QQmlPropertyCacheCreatorBase::tr("Invalid signal parameter type: %1").arg(customTypeName));
if (qmltype->isComposite()) {
QQmlTypeData *tdata = enginePrivate->typeLoader.getType(qmltype->sourceUrl());
@@ -383,7 +383,7 @@ QQmlCompileError QQmlPropertyCacheCreator::createMetaObject(int objectIndex, con
QString signalName = stringAt(s->nameIndex);
if (seenSignals.contains(signalName))
- return QQmlCompileError(s->location, tr("Duplicate signal name: invalid override of property change signal or superclass signal"));
+ return QQmlCompileError(s->location, QQmlPropertyCacheCreatorBase::tr("Duplicate signal name: invalid override of property change signal or superclass signal"));
seenSignals.insert(signalName);
cache->appendSignal(signalName, flags, effectiveMethodIndex++,
@@ -397,7 +397,7 @@ QQmlCompileError QQmlPropertyCacheCreator::createMetaObject(int objectIndex, con
const QString slotName = stringAt(function->nameIndex);
if (seenSignals.contains(slotName))
- return QQmlCompileError(function->location, tr("Duplicate method name: invalid override of property change signal or superclass signal"));
+ return QQmlCompileError(function->location, QQmlPropertyCacheCreatorBase::tr("Duplicate method name: invalid override of property change signal or superclass signal"));
// Note: we don't append slotName to the seenSignals list, since we don't
// protect against overriding change signals or methods with properties.
@@ -432,7 +432,7 @@ QQmlCompileError QQmlPropertyCacheCreator::createMetaObject(int objectIndex, con
QQmlType *qmltype = 0;
if (!imports->resolveType(stringAt(p->customTypeNameIndex), &qmltype, 0, 0, 0)) {
- return QQmlCompileError(p->location, tr("Invalid property type"));
+ return QQmlCompileError(p->location, QQmlPropertyCacheCreatorBase::tr("Invalid property type"));
}
Q_ASSERT(qmltype);
diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h
index 6d575c6a99..f78aa69cfe 100644
--- a/src/qml/compiler/qqmlpropertycachecreator_p.h
+++ b/src/qml/compiler/qqmlpropertycachecreator_p.h
@@ -54,9 +54,23 @@
QT_BEGIN_NAMESPACE
-class QQmlPropertyCacheCreator
+struct QQmlBindingInstantiationContext {
+ QQmlBindingInstantiationContext();
+ QQmlBindingInstantiationContext(int referencingObjectIndex, const QV4::CompiledData::Binding *instantiatingBinding, const QString &instantiatingPropertyName, const QQmlPropertyCache *referencingObjectPropertyCache);
+ int referencingObjectIndex;
+ const QV4::CompiledData::Binding *instantiatingBinding;
+ QQmlPropertyData *instantiatingProperty;
+};
+
+struct QQmlPropertyCacheCreatorBase
+{
+ Q_DECLARE_TR_FUNCTIONS(QQmlPropertyCacheCreatorBase)
+public:
+ static QAtomicInt classIndexCounter;
+};
+
+class QQmlPropertyCacheCreator : public QQmlPropertyCacheCreatorBase
{
- Q_DECLARE_TR_FUNCTIONS(QQmlPropertyCacheCreator)
public:
QQmlPropertyCacheCreator(QQmlPropertyCacheVector *propertyCaches, QQmlEnginePrivate *enginePrivate, const QQmlTypeCompiler *compiler, const QQmlImports *imports);
~QQmlPropertyCacheCreator();
@@ -64,16 +78,8 @@ public:
QQmlCompileError buildMetaObjects();
protected:
- struct InstantiationContext {
- InstantiationContext();
- InstantiationContext(int referencingObjectIndex, const QV4::CompiledData::Binding *instantiatingBinding, const QString &instantiatingPropertyName, const QQmlPropertyCache *referencingObjectPropertyCache);
- int referencingObjectIndex;
- const QV4::CompiledData::Binding *instantiatingBinding;
- QQmlPropertyData *instantiatingProperty;
- };
-
- QQmlCompileError buildMetaObjectRecursively(int objectIndex, const InstantiationContext &context);
- QQmlPropertyCache *propertyCacheForObject(const QmlIR::Object *obj, const InstantiationContext &context, QQmlCompileError *error) const;
+ QQmlCompileError buildMetaObjectRecursively(int objectIndex, const QQmlBindingInstantiationContext &context);
+ QQmlPropertyCache *propertyCacheForObject(const QmlIR::Object *obj, const QQmlBindingInstantiationContext &context, QQmlCompileError *error) const;
QQmlCompileError createMetaObject(int objectIndex, const QmlIR::Object *obj, QQmlPropertyCache *baseTypeCache);
QString stringAt(int index) const { return compiler->stringAt(index); }