From 814504306df0b76da1654a74524bdc353527d06f Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 15 Jan 2014 16:17:22 +0100 Subject: [new compiler] Add support for type and enum resolution for custom parsers This is in preparation for listmodel support, share the code for resolving types and enums between the old and the new compiler, as all it needs is the imports. Change-Id: I4908d71eee50c769108e0e2b68b03496722fa49d Reviewed-by: Lars Knoll --- src/qml/compiler/qqmltypecompiler.cpp | 7 +++++++ src/qml/compiler/qqmltypecompiler_p.h | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/qml/compiler') diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp index 56351b0013..d6dde63d4b 100644 --- a/src/qml/compiler/qqmltypecompiler.cpp +++ b/src/qml/compiler/qqmltypecompiler.cpp @@ -1120,6 +1120,11 @@ bool QQmlPropertyValidator::validate() return true; } +const QQmlImports &QQmlPropertyValidator::imports() const +{ + return *compiler->imports(); +} + bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, int objectIndex, QQmlPropertyCache *propertyCache) { QQmlCustomParser *customParser = 0; @@ -1181,7 +1186,9 @@ bool QQmlPropertyValidator::validateObject(const QV4::CompiledData::Object *obj, if (customParser && !customBindings.isEmpty()) { customParser->clearErrors(); + customParser->compiler = this; QByteArray data = customParser->compile(qmlUnit, customBindings); + customParser->compiler = 0; customParserData->insert(objectIndex, data); const QList parserErrors = customParser->errors(); if (!parserErrors.isEmpty()) { diff --git a/src/qml/compiler/qqmltypecompiler_p.h b/src/qml/compiler/qqmltypecompiler_p.h index bd136ea9e6..248cd12796 100644 --- a/src/qml/compiler/qqmltypecompiler_p.h +++ b/src/qml/compiler/qqmltypecompiler_p.h @@ -172,7 +172,7 @@ protected: QHash > *objectIndexToIdPerComponent; }; -class QQmlPropertyValidator : public QQmlCompilePass +class QQmlPropertyValidator : public QQmlCompilePass, public QQmlCustomParserCompilerBackend { Q_DECLARE_TR_FUNCTIONS(QQmlPropertyValidator) public: @@ -180,6 +180,10 @@ public: bool validate(); + // Re-implemented for QQmlCustomParser + virtual const QQmlImports &imports() const; + + private: bool validateObject(const QV4::CompiledData::Object *obj, int objectIndex, QQmlPropertyCache *propertyCache); -- cgit v1.2.3