From 2fa9049ddf75a3c057fc5c881f9d9faad5ce6c29 Mon Sep 17 00:00:00 2001 From: mae Date: Tue, 21 Apr 2009 13:16:59 +0200 Subject: load foo.js for a foo.dui if it exists. This lets us use the import keyword for real modules. Fix qmlconv, also get rid of the function() for signal properties. --- src/declarative/qml/qmlscriptparser.cpp | 10 ++++++++++ src/declarative/qml/qmlscriptparser_p.h | 4 ++++ tools/qmlconv/qmlconv.cpp | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qmlscriptparser.cpp b/src/declarative/qml/qmlscriptparser.cpp index 950b357..6d49d3f 100644 --- a/src/declarative/qml/qmlscriptparser.cpp +++ b/src/declarative/qml/qmlscriptparser.cpp @@ -193,6 +193,16 @@ Object *ProcessAST::defineObjectBinding(int line, if (! _parser->tree()) { _parser->setTree(obj); + + if (!_parser->scriptFile().isEmpty()) { + _stateStack.pushObject(obj); + Object *scriptObject= defineObjectBinding(line, 0, QLatin1String("Script")); + _stateStack.pushObject(scriptObject); + defineProperty(QLatin1String("src"), line, _parser->scriptFile()); + _stateStack.pop(); // scriptObject + _stateStack.pop(); // object + } + } else { const State state = _stateStack.top(); Value *v = new Value; diff --git a/src/declarative/qml/qmlscriptparser_p.h b/src/declarative/qml/qmlscriptparser_p.h index b24662e..6c7c0f1 100644 --- a/src/declarative/qml/qmlscriptparser_p.h +++ b/src/declarative/qml/qmlscriptparser_p.h @@ -31,12 +31,16 @@ public: int findOrCreateTypeId(const QString &name); void setTree(QmlParser::Object *tree); + void setScriptFile(const QString &filename) {_scriptFile = filename; } + QString scriptFile() const { return _scriptFile; } + private: QMap _nameSpacePaths; QmlParser::Object *root; QStringList _typeNames; QString _error; int _errorLine; + QString _scriptFile; }; QT_END_NAMESPACE diff --git a/tools/qmlconv/qmlconv.cpp b/tools/qmlconv/qmlconv.cpp index a3a3f79..e0f9628 100644 --- a/tools/qmlconv/qmlconv.cpp +++ b/tools/qmlconv/qmlconv.cpp @@ -314,7 +314,7 @@ public: out << depthString() << "Connection {" << endl; ++depth; out << depthString() << "signal: " << sender + "." + xml.attributes().value("signal").toString() << endl; - out << depthString() << "onSignal: function(){ " << xml.attributes().value("script").toString() << " }" << endl; + out << depthString() << "onSignal: { " << xml.attributes().value("script").toString() << " }" << endl; --depth; out << depthString() << "}" << endl; emptyLoop(); @@ -322,6 +322,7 @@ public: void startScript() { if (xml.attributes().hasAttribute(QLatin1String("src"))) { + /* QString import; QTextStream ts(&import); ts << "import \""; @@ -329,6 +330,7 @@ public: ts << "\"" << endl; ts.flush(); outString.prepend(import); + */ } QString text = xml.readElementText(); if (!text.trimmed().isEmpty()) { -- cgit v0.12