diff options
Diffstat (limited to 'src/declarative/qml/qmlscriptparser.cpp')
-rw-r--r-- | src/declarative/qml/qmlscriptparser.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
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); |