aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativerewrite_p.h
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2012-02-01 08:07:39 +1000
committerQt by Nokia <qt-info@nokia.com>2012-02-09 01:34:24 +0100
commit5060b58fdde00ca3fa4dc29bd58b80138a271b10 (patch)
tree7b64064c463c4184e1666f6539ca60a9cac3f91e /src/declarative/qml/qdeclarativerewrite_p.h
parente8420af07158dc3aa5c6ea7ddae6f8be4976e454 (diff)
Rewrite multiline strings properly
Because the bindings rewriter works on code strings, it would leave multiline strings across multiple lines (which is illegal in ECMAScript. It now manually breaks them up when it sees them, by replacing a \n character with a literal \n. Since RewriteSignalHandler now likes to have the AST passed in too, the related method in QDeclarativeCompiler (and its customers) have been altered to use the QDeclarativeScript::Value instead of just a string. Task-number: QTBUG-23387 Change-Id: Id060de37e70590c9da2a902038ed02d948fdd70f Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativerewrite_p.h')
-rw-r--r--src/declarative/qml/qdeclarativerewrite_p.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/declarative/qml/qdeclarativerewrite_p.h b/src/declarative/qml/qdeclarativerewrite_p.h
index ba3f8385e7..74c408cd21 100644
--- a/src/declarative/qml/qdeclarativerewrite_p.h
+++ b/src/declarative/qml/qdeclarativerewrite_p.h
@@ -80,6 +80,7 @@ class RewriteBinding: protected AST::Visitor
unsigned _position;
TextWriter *_writer;
QString _name;
+ const QString *_code;
public:
QString operator()(const QString &code, bool *ok = 0, bool *sharable = 0);
@@ -95,6 +96,7 @@ protected:
QString rewrite(QString code, unsigned position, AST::Statement *node);
void rewriteCaseStatements(AST::StatementList *statements, bool rewriteTheLastStatement);
+ virtual bool visit(AST::StringLiteral *ast);
virtual bool visit(AST::Block *ast);
virtual bool visit(AST::ExpressionStatement *ast);
@@ -122,10 +124,21 @@ private:
int _inLoop;
};
-class RewriteSignalHandler
+class RewriteSignalHandler: protected AST::Visitor
{
+ QList<int> _strStarts;
+ QList<int> _strLens;
+ int _position;
+
public:
- QString operator()(const QString &code, const QString &name);
+ QString operator()(QDeclarativeJS::AST::Node *node, const QString &code, const QString &name);
+
+protected:
+ void rewriteMultilineStrings(QString &code);
+
+ using AST::Visitor::visit;
+ void accept(AST::Node *node);
+ virtual bool visit(AST::StringLiteral *ast);
};
} // namespace QDeclarativeRewrite