From 86aaad45d7efd14abc935269142b179956d506ce Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 21 Apr 2009 16:13:24 +0200 Subject: finalize support for namespacepath --- src/declarative/qml/parser/javascriptast_p.h | 2 +- src/declarative/qml/qmlscriptparser.cpp | 15 ++++++++++----- tools/qmlconv/qmlconv.cpp | 12 ++++++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/parser/javascriptast_p.h b/src/declarative/qml/parser/javascriptast_p.h index fd0e463..9e5e3e4 100644 --- a/src/declarative/qml/parser/javascriptast_p.h +++ b/src/declarative/qml/parser/javascriptast_p.h @@ -1758,7 +1758,7 @@ public: UiImportList(UiImport *import) : import(import), - next(0) + next(this) { kind = K; } UiImportList(UiImportList *previous, UiImport *import) diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index ffdfdf4..ba127ef 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -95,6 +95,12 @@ private: QmlScriptParser *_parser; StateStack _stateStack; QStringList _scope; + + inline bool isSignalProperty(const QByteArray &propertyName) const { + return (propertyName.length() >= 3 && propertyName.startsWith("on") && + ('A' <= propertyName.at(2) && 'Z' >= propertyName.at(2))); + } + }; ProcessAST::ProcessAST(QmlScriptParser *parser) @@ -431,8 +437,7 @@ QString ProcessAST::getPrimitive(const QByteArray &propertyName, AST::Expression QTextStream out(&primitive); PrettyPretty pp(out); - if(propertyName.length() >= 3 && propertyName.startsWith("on") && - ('A' <= propertyName.at(2) && 'Z' >= propertyName.at(2))) { + if(isSignalProperty(propertyName)) { pp(expr); // here comes a cruel hack until we support functions properly with arguments for signal properties @@ -484,8 +489,9 @@ bool ProcessAST::visit(AST::UiScriptBinding *node) if (AST::ExpressionStatement *stmt = AST::cast(node->statement)) { primitive = getPrimitive(prop->name, stmt->expression); - - } else { + } else if (isSignalProperty(prop->name)) { + pp(node->statement); + } else { // do binding out << '{'; pp(node->statement); out << '}'; @@ -592,7 +598,6 @@ int QmlScriptParser::errorLine() const QMap QmlScriptParser::nameSpacePaths() const { - qWarning() << Q_FUNC_INFO << "not implemented"; return _nameSpacePaths; } diff --git a/tools/qmlconv/qmlconv.cpp b/tools/qmlconv/qmlconv.cpp index e0f9628..139a1b0 100644 --- a/tools/qmlconv/qmlconv.cpp +++ b/tools/qmlconv/qmlconv.cpp @@ -64,6 +64,14 @@ public: return; else if (xml.tokenType() == QXmlStreamReader::StartElement) startElement(); + else if (xml.tokenType() == QXmlStreamReader::ProcessingInstruction) { + if (xml.processingInstructionTarget() == QLatin1String("qtfx")) { + QString data = xml.processingInstructionData().toString().trimmed(); + if (data.startsWith(QLatin1String("namespacepath:="))) { + outString.prepend( QLatin1String("import \"") + data.mid(data.indexOf(QLatin1Char('='))+1) + QLatin1String("\"\n")); + } + } + } comment(); } } @@ -144,7 +152,7 @@ public: } else if (isSignalHandler(property)) { // if not a function name, create an anonymous function if (!isIdentifier(v)) { - v.prepend("function(){ "); + v.prepend("{ "); v.append(" }"); } } else @@ -304,7 +312,7 @@ public: void startParentChange() { QString target = xml.attributes().value("target").toString(); possiblyRemoveBraces(&target); - propertyChangeSet += StringPair(target + ".parent", xml.attributes().value("parent").toString()); + propertyChangeSet += StringPair(target + ".moveToParent", xml.attributes().value("parent").toString()); emptyLoop(); } -- cgit v0.12