diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-15 16:00:39 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-17 04:03:21 +0000 |
commit | 88af61180be2636e9b2f0714bed448d7d9270adc (patch) | |
tree | 557f496bea2f8cb77f4946623b0b97d7d7ed26c6 | |
parent | 2997b7ea99906801c9cb92a7e095c8044c86dc0a (diff) |
Minor QQmlPropertyValidator/QQmlCustomParser cleanup
The QQmlCustomParser already has an imports bi-pointer, so there's no
need for the property validator to implement an interface anymore.
Change-Id: Iabe9810ff26afdbc0c51efde3b20383c8f4f2348
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r-- | src/qml/compiler/qqmltypecompiler.cpp | 18 | ||||
-rw-r--r-- | src/qml/compiler/qqmltypecompiler_p.h | 5 | ||||
-rw-r--r-- | src/qml/qml/qqmlcustomparser.cpp | 8 |
3 files changed, 15 insertions, 16 deletions
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 67cd969d82..19c221c766 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1336,9 +1336,9 @@ bool QQmlDeferredAndCustomParserBindingScanner::scanObject(int objectIndex) QQmlPropertyValidator::QQmlPropertyValidator(QQmlTypeCompiler *typeCompiler, const QQmlPropertyCacheVector *propertyCaches) : QQmlCompilePass(typeCompiler) , enginePrivate(typeCompiler->enginePrivate()) + , imports(*typeCompiler->imports()) , qmlUnit(typeCompiler->qmlUnit()) , resolvedTypes(typeCompiler->resolvedTypes) - , customParsers(typeCompiler->customParserCache()) , propertyCaches(propertyCaches) { } @@ -1352,11 +1352,6 @@ bool QQmlPropertyValidator::validate() return true; } -const QQmlImports &QQmlPropertyValidator::imports() const -{ - return *compiler->imports(); -} - typedef QVarLengthArray<const QV4::CompiledData::Binding *, 8> GroupPropertyVector; struct BindingFinder @@ -1400,7 +1395,12 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD } } - QQmlCustomParser *customParser = customParsers.value(obj->inheritedTypeNameIndex); + QQmlCustomParser *customParser = 0; + if (auto typeRef = resolvedTypes.value(obj->inheritedTypeNameIndex)) { + if (typeRef->type) + customParser = typeRef->type->customParser(); + } + QList<const QV4::CompiledData::Binding*> customBindings; // Collect group properties first for sanity checking @@ -1491,7 +1491,7 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD if (name.constData()->isUpper() && !binding->isAttachedProperty()) { QQmlType *type = 0; QQmlImportNamespace *typeNamespace = 0; - compiler->imports()->resolveType(stringAt(binding->propertyNameIndex), &type, 0, 0, &typeNamespace); + imports.resolveType(stringAt(binding->propertyNameIndex), &type, 0, 0, &typeNamespace); if (typeNamespace) recordError(binding->location, tr("Invalid use of namespace")); else @@ -1606,7 +1606,7 @@ bool QQmlPropertyValidator::validateObject(int objectIndex, const QV4::CompiledD customParser->clearErrors(); customParser->validator = this; customParser->engine = enginePrivate; - customParser->imports = compiler->imports(); + customParser->imports = &imports; customParser->verifyBindings(qmlUnit, customBindings); customParser->validator = 0; customParser->engine = 0; diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h index f00a940808..f0909d56fa 100644 --- a/src/qml/compiler/qqmltypecompiler_p.h +++ b/src/qml/compiler/qqmltypecompiler_p.h @@ -307,9 +307,6 @@ public: bool validate(); - const QQmlImports &imports() const; - QQmlEnginePrivate *engine() const { return enginePrivate; } - private: bool validateObject(int objectIndex, const QV4::CompiledData::Binding *instantiatingBinding, bool populatingValueTypeGroupProperty = false) const; bool validateLiteralBinding(QQmlPropertyCache *propertyCache, QQmlPropertyData *property, const QV4::CompiledData::Binding *binding) const; @@ -318,9 +315,9 @@ private: bool canCoerce(int to, QQmlPropertyCache *fromMo) const; QQmlEnginePrivate *enginePrivate; + const QQmlImports &imports; const QV4::CompiledData::Unit *qmlUnit; const QHash<int, QV4::CompiledData::CompilationUnit::ResolvedTypeReference*> &resolvedTypes; - const QHash<int, QQmlCustomParser*> &customParsers; const QQmlPropertyCacheVector * const propertyCaches; // collected state variables, essentially write-only diff --git a/src/qml/qml/qqmlcustomparser.cpp b/src/qml/qml/qqmlcustomparser.cpp index e9f747a440..30eed4d551 100644 --- a/src/qml/qml/qqmlcustomparser.cpp +++ b/src/qml/qml/qqmlcustomparser.cpp @@ -165,11 +165,13 @@ int QQmlCustomParser::evaluateEnum(const QByteArray& script, bool *ok) const */ const QMetaObject *QQmlCustomParser::resolveType(const QString& name) const { + if (!imports.isT1()) + return nullptr; QQmlType *qmltype = 0; - if (!validator->imports().resolveType(name, &qmltype, 0, 0, 0)) - return 0; + if (!imports.asT1()->resolveType(name, &qmltype, 0, 0, 0)) + return nullptr; if (!qmltype) - return 0; + return nullptr; return qmltype->metaObject(); } |