diff options
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qmlcompiledcomponent_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.cpp | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager_p.h | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmldom.cpp | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlparser.cpp | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlparser_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 30 | ||||
-rw-r--r-- | src/declarative/qml/qmlscriptparser_p.h | 10 | ||||
-rw-r--r-- | src/declarative/qml/qmlxmlparser.cpp | 7 | ||||
-rw-r--r-- | src/declarative/qml/qmlxmlparser_p.h | 7 |
13 files changed, 57 insertions, 18 deletions
diff --git a/src/declarative/qml/qmlcompiledcomponent_p.h b/src/declarative/qml/qmlcompiledcomponent_p.h index fa68eab..883ad64 100644 --- a/src/declarative/qml/qmlcompiledcomponent_p.h +++ b/src/declarative/qml/qmlcompiledcomponent_p.h @@ -46,8 +46,8 @@ #include <private/qmlinstruction_p.h> #include <private/qmlcompiler_p.h> #include <private/qmlrefcount_p.h> -class QmlXmlParser; +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE namespace QmlParser { class Property; @@ -77,4 +77,6 @@ private: QT_END_NAMESPACE +QT_END_HEADER + #endif // QMLCOMPILEDCOMPONENT_P_H diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index e1a88bb..8cfa148 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -42,7 +42,7 @@ #include "private/qmlcompiler_p.h" #include <qfxperf.h> #include "qmlparser_p.h" -#include "private/qmlxmlparser_p.h" +#include "private/qmlscriptparser_p.h" #include <qmlpropertyvaluesource.h> #include <qmlcomponent.h> #include "private/qmetaobjectbuilder_p.h" diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index 79d788e..b51eacd 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -50,8 +50,6 @@ class QStringList; QT_BEGIN_NAMESPACE -class QmlXmlParser; -class QmlScriptParser; class QmlEngine; class QmlComponent; class QmlCompiledComponent; diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index ca849ad..92f6b28 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -51,7 +51,6 @@ #include <qmlengine.h> #include <QFileInfo> #include <qmlbindablevalue.h> -#include "private/qmlxmlparser_p.h" #include "qmlcompiledcomponent_p.h" #include <QtCore/qdebug.h> #include <QApplication> diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index b0d121c..b05a6fa 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -40,7 +40,7 @@ ****************************************************************************/ #include <private/qmlcompositetypemanager_p.h> -#include <private/qmlxmlparser_p.h> +#include <private/qmlscriptparser_p.h> #include <private/qmlcompiledcomponent_p.h> #include <QtDeclarative/qmlengine.h> #include <QtNetwork/qnetworkreply.h> diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h index 814e753..ffa4fda 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -43,12 +43,11 @@ #define QMLCOMPOSITETYPEMANAGER_P_H #include <qglobal.h> -#include <private/qmlxmlparser_p.h> +#include <private/qmlscriptparser_p.h> #include <private/qmlrefcount_p.h> QT_BEGIN_NAMESPACE -class QmlXmlParser; class QmlEngine; class QmlCompiledComponent; class QmlComponentPrivate; @@ -100,7 +99,7 @@ private: friend class QmlCompositeTypeManager; friend class QmlCompiler; - QmlXmlParser data; + QmlScriptParser data; QList<QmlComponentPrivate *> waiters; QmlComponent *component; QmlCompiledComponent *compiledComponent; diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index bd4d987..cbe5d5d 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -41,7 +41,6 @@ #include "qmldom.h" #include "qmldom_p.h" -#include "private/qmlxmlparser_p.h" #include "private/qmlcompiler_p.h" #include "qmlcompiledcomponent_p.h" #include <QtCore/qbytearray.h> @@ -152,7 +151,7 @@ bool QmlDomDocument::load(QmlEngine *engine, const QByteArray &data) { d->error = QString(); - QmlXmlParser parser; + QmlScriptParser parser; if(!parser.parse(data)) { d->error = parser.errorDescription(); return false; diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index f019a8b..1dd0d4e 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -55,7 +55,6 @@ #include <qmlbasicscript.h> #include "private/qmetaobjectbuilder_p.h" #include <private/qmlvmemetaobject_p.h> -#include "private/qmlxmlparser_p.h" #include <private/qmlcompiler_p.h> #include <QtDebug> diff --git a/src/declarative/qml/qmlparser_p.h b/src/declarative/qml/qmlparser_p.h index 9d3f3f6..e29cdbf 100644 --- a/src/declarative/qml/qmlparser_p.h +++ b/src/declarative/qml/qmlparser_p.h @@ -55,7 +55,6 @@ QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlXmlParser; /* XXX diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 41d2534..3d406e7 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -1,5 +1,7 @@ #include "qmlscriptparser_p.h" +#include "qmlxmlparser_p.h" +#include "qmlparser_p.h" #include "parser/javascriptengine_p.h" #include "parser/javascriptparser_p.h" @@ -630,6 +632,21 @@ QmlScriptParser::~QmlScriptParser() bool QmlScriptParser::parse(const QByteArray &data, const QUrl &url) { + if (QmlComponentPrivate::isXml(data)) { + // parse using the XML parser. + QmlXmlParser xmlParser; + if (xmlParser.parse(data, url)) { + _nameSpacePaths = xmlParser.nameSpacePaths(); + root = xmlParser.takeTree(); + _typeNames = xmlParser.types(); + return true; + } + + _error = xmlParser.errorDescription(); + _errorLine = 0; // ### FIXME + return false; + } + const QString fileName = url.toString(); const QString code = QString::fromUtf8(data); // ### FIXME @@ -680,6 +697,19 @@ Object *QmlScriptParser::tree() const return root; } +void QmlScriptParser::clear() +{ + if(root) { + root->release(); + root = 0; + } + _nameSpacePaths.clear(); + _typeNames.clear(); + _error.clear(); + _scriptFile.clear(); + _errorLine = 0; +} + int QmlScriptParser::findOrCreateTypeId(const QString &name) { int index = _typeNames.indexOf(name); diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index 49128d7..0d89268 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -1,15 +1,19 @@ #ifndef QMLSCRIPTPARSER_P_H #define QMLSCRIPTPARSER_P_H +#include <QtCore/QList> +#include <QtCore/QUrl> #include <qml.h> -#include <private/qmlcomponent_p.h> -#include <private/qmlparser_p.h> QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Declarative) +namespace QmlParser { + class Object; +} + class QByteArray; class QmlScriptParser @@ -27,6 +31,8 @@ public: QmlParser::Object *tree() const; + void clear(); + // ### private: int findOrCreateTypeId(const QString &name); void setTree(QmlParser::Object *tree); diff --git a/src/declarative/qml/qmlxmlparser.cpp b/src/declarative/qml/qmlxmlparser.cpp index f001bda..0af9115 100644 --- a/src/declarative/qml/qmlxmlparser.cpp +++ b/src/declarative/qml/qmlxmlparser.cpp @@ -365,6 +365,13 @@ QmlParser::Object *QmlXmlParser::tree() const return root; } +QmlParser::Object *QmlXmlParser::takeTree() +{ + QmlParser::Object *r = root; + root = 0; + return r; +} + QString QmlXmlParser::errorDescription() const { return _error; diff --git a/src/declarative/qml/qmlxmlparser_p.h b/src/declarative/qml/qmlxmlparser_p.h index 3680172..9b45e28 100644 --- a/src/declarative/qml/qmlxmlparser_p.h +++ b/src/declarative/qml/qmlxmlparser_p.h @@ -70,6 +70,7 @@ public: QStringList types() const; QmlParser::Object *tree() const; + QmlParser::Object *takeTree(); void clear(); @@ -80,9 +81,9 @@ private: QString _error; }; -#endif // QMLXMLPARSER_P_H - - QT_END_NAMESPACE QT_END_HEADER + +#endif // QMLXMLPARSER_P_H + |