diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-24 14:48:02 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-08-24 14:48:02 (GMT) |
commit | a6854d4d21ba55f9d2e9f51f2ca449ccb7d4e4d3 (patch) | |
tree | 3dac7c491363e9386fd15ac76e2557fcb835d5e2 /tools | |
parent | 1e55b0ecf415d023bbb5f291a2f26ba50c1a508b (diff) | |
parent | a55f392edc2145a071d0d59cb0fc69b0d5205a76 (diff) | |
download | Qt-a6854d4d21ba55f9d2e9f51f2ca449ccb7d4e4d3.zip Qt-a6854d4d21ba55f9d2e9f51f2ca449ccb7d4e4d3.tar.gz Qt-a6854d4d21ba55f9d2e9f51f2ca449ccb7d4e4d3.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (48 commits)
Use QElapsedTimer for the benchlib tests.
Properly implement the CPU feature disabling in qsimd.cpp.
Report the detected CPU features in the corelib boilerplate
Detect CPU features on ARM by reading the ELF auxvec.
Split the CPU-detection code into multiple functions for readability
Fixed delivering gestures to a toplevel widget.
Unroll the SSSE3 code even more to avoid the need to keep an extra variable for inverting the result
Don't try to compile the SSE2 and SSSE3 code with compilers that don't support them (e.g. ARM)
Improve on the SSSE3 with alternate aligning function.
Add the beginnings of a new SSSE3-based aligning algorithm
Small fixup
Update the SSSE3-with-alignment function to use aligned loads.
Add an ucstrncmp that uses SSSE3 with aligning.
Add an SSSE3 version of ucstrncmp
Optimise the tail comparison of ucstrncmp
Add a version of ucstrncmp with SSE2 with aligning.
Add an SSE2-optimised version of ucstrncmp
Add the ucstrncmp benchmarks
Update the data generation script to use a non-including .cpp
Update comments in QString about alignment performance.
...
Diffstat (limited to 'tools')
-rw-r--r-- | tools/configure/configureapp.cpp | 9 | ||||
-rw-r--r-- | tools/linguist/lupdate/qscript.cpp | 234 | ||||
-rw-r--r-- | tools/linguist/lupdate/qscript.g | 249 | ||||
-rw-r--r-- | tools/qdoc3/test/qt-html-templates.qdocconf | 11 |
4 files changed, 437 insertions, 66 deletions
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 0c716d1..7049306 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2667,8 +2667,13 @@ void Configure::generateOutputVars() qtConfig += "audio-backend"; } - if (dictionary["WEBKIT"] == "yes") - qtConfig += "webkit"; + if (dictionary["WEBKIT"] == "yes") { + // This include takes care of adding "webkit" to QT_CONFIG. + QString src = sourcePath + "/src/3rdparty/webkit/WebKit/qt/qt_webkit_version.pri"; + QString dst = buildPath + "/mkspecs/modules/qt_webkit_version.pri"; + QFile::remove(dst); + QFile::copy(src, dst); + } if (dictionary["DECLARATIVE"] == "yes") { if (dictionary[ "SCRIPT" ] == "no") { diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp index 188ac36..7ca0987 100644 --- a/tools/linguist/lupdate/qscript.cpp +++ b/tools/linguist/lupdate/qscript.cpp @@ -770,13 +770,16 @@ const int QScriptGrammar::action_check [] = { static void recordMessage( Translator *tor, const QString &context, const QString &text, const QString &comment, - const QString &extracomment, bool plural, const QString &fileName, int lineNo) + const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra, + bool plural, const QString &fileName, int lineNo) { TranslatorMessage msg( context, text, comment, QString(), fileName, lineNo, QStringList(), TranslatorMessage::Unfinished, plural); msg.setExtraComment(extracomment.simplified()); + msg.setId(msgid); + msg.setExtras(extra); tor->extend(msg); } @@ -784,15 +787,23 @@ static void recordMessage( namespace QScript { +class CommentProcessor +{ +public: + virtual ~CommentProcessor() {} + virtual void processComment(const QChar *chars, int length) = 0; +}; + class Lexer { public: - Lexer(); + Lexer(CommentProcessor *); ~Lexer(); - void setCode(const QString &c, int lineno); + void setCode(const QString &c, const QString &fileName, int lineno); int lex(); + QString fileName() const { return yyfilename; } int currentLineNo() const { return yylineno; } int currentColumnNo() const { return yycolumn; } @@ -872,6 +883,7 @@ public: { err = NoError; } private: + QString yyfilename; int yylineno; bool done; char *buffer8; @@ -925,6 +937,8 @@ private: void syncProhibitAutomaticSemicolon(); + void processComment(const QChar *, int); + const QChar *code; uint length; int yycolumn; @@ -951,6 +965,8 @@ private: ParenthesesState parenthesesState; int parenthesesCount; bool prohibitAutomaticSemicolon; + + CommentProcessor *commentProcessor; }; } // namespace QScript @@ -1027,7 +1043,7 @@ double integerFromString(const char *buf, int size, int radix) } // namespace QScript -QScript::Lexer::Lexer() +QScript::Lexer::Lexer(QScript::CommentProcessor *proc) : yylineno(0), size8(128), size16(128), restrKeyword(false), @@ -1038,7 +1054,8 @@ QScript::Lexer::Lexer() err(NoError), check_reserved(true), parenthesesState(IgnoreParentheses), - prohibitAutomaticSemicolon(false) + prohibitAutomaticSemicolon(false), + commentProcessor(proc) { // allocate space for read buffers buffer8 = new char[size8]; @@ -1053,9 +1070,10 @@ QScript::Lexer::~Lexer() delete [] buffer16; } -void QScript::Lexer::setCode(const QString &c, int lineno) +void QScript::Lexer::setCode(const QString &c, const QString &fileName, int lineno) { errmsg = QString(); + yyfilename = fileName; yylineno = lineno; yycolumn = 1; restrKeyword = false; @@ -1404,10 +1422,12 @@ int QScript::Lexer::lex() } else if (current == '/' && next1 == '/') { recordStartPos(); shift(1); + Q_ASSERT(pos16 == 0); state = InSingleLineComment; } else if (current == '/' && next1 == '*') { recordStartPos(); shift(1); + Q_ASSERT(pos16 == 0); state = InMultiLineComment; } else if (current == 0) { syncProhibitAutomaticSemicolon(); @@ -1547,9 +1567,12 @@ int QScript::Lexer::lex() break; case InSingleLineComment: if (isLineTerminator()) { + record16(current); // include newline + processComment(buffer16, pos16); shiftWindowsLineBreak(); yylineno++; yycolumn = 0; + pos16 = 0; terminator = true; bol = true; if (restrKeyword) { @@ -1559,6 +1582,8 @@ int QScript::Lexer::lex() state = Start; } else if (current == 0) { setDone(Eof); + } else { + record16(current); } break; case InMultiLineComment: @@ -1570,8 +1595,12 @@ int QScript::Lexer::lex() shiftWindowsLineBreak(); yylineno++; } else if (current == '*' && next1 == '/') { + processComment(buffer16, pos16); + pos16 = 0; state = Start; shift(1); + } else { + record16(current); } break; case InIdentifier: @@ -2033,10 +2062,15 @@ void QScript::Lexer::syncProhibitAutomaticSemicolon() } } +void QScript::Lexer::processComment(const QChar *chars, int length) +{ + commentProcessor->processComment(chars, length); +} + class Translator; -class QScriptParser: protected QScriptGrammar +class QScriptParser: protected QScriptGrammar, public QScript::CommentProcessor { public: QVariant val; @@ -2052,10 +2086,12 @@ public: QScriptParser(); ~QScriptParser(); - bool parse(QScript::Lexer *lexer, - const QString &fileName, - Translator *translator); + void setLexer(QScript::Lexer *); + + bool parse(Translator *translator); + QString fileName() const + { return lexer->fileName(); } inline QString errorMessage() const { return error_message; } inline int errorLineNumber() const @@ -2072,6 +2108,10 @@ protected: inline Location &loc(int index) { return location_stack [tos + index - 2]; } + std::ostream &yyMsg(int line = 0); + + virtual void processComment(const QChar *, int); + protected: int tos; int stack_size; @@ -2081,6 +2121,13 @@ protected: QString error_message; int error_lineno; int error_column; + +private: + QScript::Lexer *lexer; + QString extracomment; + QString msgid; + QString sourcetext; + TranslatorMessage::ExtraData extra; }; inline void QScriptParser::reallocateStack() @@ -2107,7 +2154,8 @@ QScriptParser::QScriptParser(): stack_size(0), sym_stack(0), state_stack(0), - location_stack(0) + location_stack(0), + lexer(0) { } @@ -2129,10 +2177,14 @@ static inline QScriptParser::Location location(QScript::Lexer *lexer) return loc; } -bool QScriptParser::parse(QScript::Lexer *lexer, - const QString &fileName, - Translator *translator) +void QScriptParser::setLexer(QScript::Lexer *lex) +{ + lexer = lex; +} + +bool QScriptParser::parse(Translator *translator) { + Q_ASSERT(lexer != 0); const int INITIAL_STATE = 0; int yytoken = -1; @@ -2214,44 +2266,70 @@ case 8: { case 66: { QString name = sym(1).toString(); if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) { + if (!sourcetext.isEmpty()) + yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n"; QVariantList args = sym(2).toList(); if (args.size() < 2) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "() requires at least two arguments.\n"; + yyMsg(identLineNo) << qPrintable(name) << "() requires at least two arguments.\n"; } else { if ((args.at(0).type() != QVariant::String) || (args.at(1).type() != QVariant::String)) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "(): both arguments must be literal strings.\n"; + yyMsg(identLineNo) << qPrintable(name) << "(): both arguments must be literal strings.\n"; } else { QString context = args.at(0).toString(); QString text = args.at(1).toString(); QString comment = args.value(2).toString(); - QString extracomment; bool plural = (args.size() > 4); recordMessage(translator, context, text, comment, extracomment, - plural, fileName, identLineNo); + msgid, extra, plural, fileName(), identLineNo); } } + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); } else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) { + if (!sourcetext.isEmpty()) + yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n"; QVariantList args = sym(2).toList(); if (args.size() < 1) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "() requires at least one argument.\n"; + yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n"; } else { if (args.at(0).type() != QVariant::String) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "(): text to translate must be a literal string.\n"; + yyMsg(identLineNo) << qPrintable(name) << "(): text to translate must be a literal string.\n"; } else { - QString context = QFileInfo(fileName).baseName(); + QString context = QFileInfo(fileName()).baseName(); QString text = args.at(0).toString(); QString comment = args.value(1).toString(); - QString extracomment; bool plural = (args.size() > 2); recordMessage(translator, context, text, comment, extracomment, - plural, fileName, identLineNo); + msgid, extra, plural, fileName(), identLineNo); } } + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); + } else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) { + if (!msgid.isEmpty()) + yyMsg(identLineNo) << "//= cannot be used with " << qPrintable(name) << "(). Ignoring\n"; + QVariantList args = sym(2).toList(); + if (args.size() < 1) { + yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n"; + } else { + if (args.at(0).type() != QVariant::String) { + yyMsg(identLineNo) << qPrintable(name) << "(): identifier must be a literal string.\n"; + } else { + msgid = args.at(0).toString(); + bool plural = (args.size() > 1); + recordMessage(translator, QString(), sourcetext, QString(), extracomment, + msgid, extra, plural, fileName(), identLineNo); + } + } + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); } } break; @@ -2278,6 +2356,44 @@ case 94: { sym(1) = QVariant(); } break; + case 171: + + case 172: + + case 173: + + case 174: + + case 175: + + case 176: + + case 177: + + case 178: + + case 179: + + case 180: + + case 181: + + case 182: + + case 183: + + case 184: + + case 185: + if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) { + yyMsg() << "Discarding unconsumed meta data\n"; + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); + } + break; + } // switch state_stack [tos] = nt_action (act, lhs [r] - TERMINAL_COUNT); @@ -2356,6 +2472,63 @@ case 94: { return false; } +std::ostream &QScriptParser::yyMsg(int line) +{ + return std::cerr << qPrintable(fileName()) << ':' << (line ? line : lexer->startLineNo()) << ": "; +} + +void QScriptParser::processComment(const QChar *chars, int length) +{ + if (!length) + return; + // Try to match the logic of the C++ parser. + if (*chars == QLatin1Char(':') && chars[1].isSpace()) { + extracomment += QString(chars+2, length-2); + } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) { + msgid = QString(chars+2, length-2).simplified(); + } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) { + QString text = QString(chars+2, length-2).trimmed(); + int k = text.indexOf(QLatin1Char(' ')); + if (k > -1) + extra.insert(text.left(k), text.mid(k + 1).trimmed()); + } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) { + sourcetext.reserve(sourcetext.length() + length-2); + ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); + int p = 2, c; + forever { + if (p >= length) + break; + c = chars[p++].unicode(); + if (isspace(c)) + continue; + if (c != '"') { + yyMsg() << "Unexpected character in meta string\n"; + break; + } + forever { + if (p >= length) { + whoops: + yyMsg() << "Unterminated meta string\n"; + break; + } + c = chars[p++].unicode(); + if (c == '"') + break; + if (c == '\\') { + if (p >= length) + goto whoops; + c = chars[p++].unicode(); + if (c == '\n') + goto whoops; + *ptr++ = '\\'; + } + *ptr++ = c; + } + } + sourcetext.resize(ptr - (ushort *)sourcetext.data()); + } +} + bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd) { @@ -2375,10 +2548,11 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData ts.setAutoDetectUnicode(true); QString code = ts.readAll(); - QScript::Lexer lexer; - lexer.setCode(code, /*lineNumber=*/1); QScriptParser parser; - if (!parser.parse(&lexer, filename, &translator)) { + QScript::Lexer lexer(&parser); + lexer.setCode(code, filename, /*lineNumber=*/1); + parser.setLexer(&lexer); + if (!parser.parse(&translator)) { std::cerr << qPrintable(filename) << ':' << parser.errorLineNumber() << ": " << qPrintable(parser.errorMessage()) << std::endl; return false; diff --git a/tools/linguist/lupdate/qscript.g b/tools/linguist/lupdate/qscript.g index 857c58a..e4c2d22 100644 --- a/tools/linguist/lupdate/qscript.g +++ b/tools/linguist/lupdate/qscript.g @@ -101,13 +101,16 @@ QT_BEGIN_NAMESPACE static void recordMessage( Translator *tor, const QString &context, const QString &text, const QString &comment, - const QString &extracomment, bool plural, const QString &fileName, int lineNo) + const QString &extracomment, const QString &msgid, const TranslatorMessage::ExtraData &extra, + bool plural, const QString &fileName, int lineNo) { TranslatorMessage msg( context, text, comment, QString(), fileName, lineNo, QStringList(), TranslatorMessage::Unfinished, plural); msg.setExtraComment(extracomment.simplified()); + msg.setId(msgid); + msg.setExtras(extra); tor->extend(msg); } @@ -115,15 +118,23 @@ static void recordMessage( namespace QScript { +class CommentProcessor +{ +public: + virtual ~CommentProcessor() {} + virtual void processComment(const QChar *chars, int length) = 0; +}; + class Lexer { public: - Lexer(); + Lexer(CommentProcessor *); ~Lexer(); - void setCode(const QString &c, int lineno); + void setCode(const QString &c, const QString &fileName, int lineno); int lex(); + QString fileName() const { return yyfilename; } int currentLineNo() const { return yylineno; } int currentColumnNo() const { return yycolumn; } @@ -203,6 +214,7 @@ public: { err = NoError; } private: + QString yyfilename; int yylineno; bool done; char *buffer8; @@ -256,6 +268,8 @@ private: void syncProhibitAutomaticSemicolon(); + void processComment(const QChar *, int); + const QChar *code; uint length; int yycolumn; @@ -282,6 +296,8 @@ private: ParenthesesState parenthesesState; int parenthesesCount; bool prohibitAutomaticSemicolon; + + CommentProcessor *commentProcessor; }; } // namespace QScript @@ -358,7 +374,7 @@ double integerFromString(const char *buf, int size, int radix) } // namespace QScript -QScript::Lexer::Lexer() +QScript::Lexer::Lexer(QScript::CommentProcessor *proc) : yylineno(0), size8(128), size16(128), restrKeyword(false), @@ -369,7 +385,8 @@ QScript::Lexer::Lexer() err(NoError), check_reserved(true), parenthesesState(IgnoreParentheses), - prohibitAutomaticSemicolon(false) + prohibitAutomaticSemicolon(false), + commentProcessor(proc) { // allocate space for read buffers buffer8 = new char[size8]; @@ -384,9 +401,10 @@ QScript::Lexer::~Lexer() delete [] buffer16; } -void QScript::Lexer::setCode(const QString &c, int lineno) +void QScript::Lexer::setCode(const QString &c, const QString &fileName, int lineno) { errmsg = QString(); + yyfilename = fileName; yylineno = lineno; yycolumn = 1; restrKeyword = false; @@ -735,10 +753,12 @@ int QScript::Lexer::lex() } else if (current == '/' && next1 == '/') { recordStartPos(); shift(1); + Q_ASSERT(pos16 == 0); state = InSingleLineComment; } else if (current == '/' && next1 == '*') { recordStartPos(); shift(1); + Q_ASSERT(pos16 == 0); state = InMultiLineComment; } else if (current == 0) { syncProhibitAutomaticSemicolon(); @@ -878,9 +898,12 @@ int QScript::Lexer::lex() break; case InSingleLineComment: if (isLineTerminator()) { + record16(current); // include newline + processComment(buffer16, pos16); shiftWindowsLineBreak(); yylineno++; yycolumn = 0; + pos16 = 0; terminator = true; bol = true; if (restrKeyword) { @@ -890,6 +913,8 @@ int QScript::Lexer::lex() state = Start; } else if (current == 0) { setDone(Eof); + } else { + record16(current); } break; case InMultiLineComment: @@ -901,8 +926,12 @@ int QScript::Lexer::lex() shiftWindowsLineBreak(); yylineno++; } else if (current == '*' && next1 == '/') { + processComment(buffer16, pos16); + pos16 = 0; state = Start; shift(1); + } else { + record16(current); } break; case InIdentifier: @@ -1364,10 +1393,15 @@ void QScript::Lexer::syncProhibitAutomaticSemicolon() } } +void QScript::Lexer::processComment(const QChar *chars, int length) +{ + commentProcessor->processComment(chars, length); +} + class Translator; -class QScriptParser: protected $table +class QScriptParser: protected $table, public QScript::CommentProcessor { public: QVariant val; @@ -1383,10 +1417,12 @@ public: QScriptParser(); ~QScriptParser(); - bool parse(QScript::Lexer *lexer, - const QString &fileName, - Translator *translator); + void setLexer(QScript::Lexer *); + bool parse(Translator *translator); + + QString fileName() const + { return lexer->fileName(); } inline QString errorMessage() const { return error_message; } inline int errorLineNumber() const @@ -1403,6 +1439,10 @@ protected: inline Location &loc(int index) { return location_stack [tos + index - 2]; } + std::ostream &yyMsg(int line = 0); + + virtual void processComment(const QChar *, int); + protected: int tos; int stack_size; @@ -1412,6 +1452,13 @@ protected: QString error_message; int error_lineno; int error_column; + +private: + QScript::Lexer *lexer; + QString extracomment; + QString msgid; + QString sourcetext; + TranslatorMessage::ExtraData extra; }; inline void QScriptParser::reallocateStack() @@ -1438,7 +1485,8 @@ QScriptParser::QScriptParser(): stack_size(0), sym_stack(0), state_stack(0), - location_stack(0) + location_stack(0), + lexer(0) { } @@ -1460,10 +1508,14 @@ static inline QScriptParser::Location location(QScript::Lexer *lexer) return loc; } -bool QScriptParser::parse(QScript::Lexer *lexer, - const QString &fileName, - Translator *translator) +void QScriptParser::setLexer(QScript::Lexer *lex) { + lexer = lex; +} + +bool QScriptParser::parse(Translator *translator) +{ + Q_ASSERT(lexer != 0); const int INITIAL_STATE = 0; int yytoken = -1; @@ -1630,44 +1682,70 @@ CallExpression: MemberExpression Arguments ; case $rule_number: { QString name = sym(1).toString(); if ((name == QLatin1String("qsTranslate")) || (name == QLatin1String("QT_TRANSLATE_NOOP"))) { + if (!sourcetext.isEmpty()) + yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n"; QVariantList args = sym(2).toList(); if (args.size() < 2) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "() requires at least two arguments.\n"; + yyMsg(identLineNo) << qPrintable(name) << "() requires at least two arguments.\n"; } else { if ((args.at(0).type() != QVariant::String) || (args.at(1).type() != QVariant::String)) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "(): both arguments must be literal strings.\n"; + yyMsg(identLineNo) << qPrintable(name) << "(): both arguments must be literal strings.\n"; } else { QString context = args.at(0).toString(); QString text = args.at(1).toString(); QString comment = args.value(2).toString(); - QString extracomment; bool plural = (args.size() > 4); recordMessage(translator, context, text, comment, extracomment, - plural, fileName, identLineNo); + msgid, extra, plural, fileName(), identLineNo); } } + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); } else if ((name == QLatin1String("qsTr")) || (name == QLatin1String("QT_TR_NOOP"))) { + if (!sourcetext.isEmpty()) + yyMsg(identLineNo) << "//% cannot be used with " << qPrintable(name) << "(). Ignoring\n"; QVariantList args = sym(2).toList(); if (args.size() < 1) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "() requires at least one argument.\n"; + yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n"; } else { if (args.at(0).type() != QVariant::String) { - std::cerr << qPrintable(fileName) << ':' << identLineNo << ": " - << qPrintable(name) << "(): text to translate must be a literal string.\n"; + yyMsg(identLineNo) << qPrintable(name) << "(): text to translate must be a literal string.\n"; } else { - QString context = QFileInfo(fileName).baseName(); + QString context = QFileInfo(fileName()).baseName(); QString text = args.at(0).toString(); QString comment = args.value(1).toString(); - QString extracomment; bool plural = (args.size() > 2); recordMessage(translator, context, text, comment, extracomment, - plural, fileName, identLineNo); + msgid, extra, plural, fileName(), identLineNo); + } + } + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); + } else if ((name == QLatin1String("qsTrId")) || (name == QLatin1String("QT_TRID_NOOP"))) { + if (!msgid.isEmpty()) + yyMsg(identLineNo) << "//= cannot be used with " << qPrintable(name) << "(). Ignoring\n"; + QVariantList args = sym(2).toList(); + if (args.size() < 1) { + yyMsg(identLineNo) << qPrintable(name) << "() requires at least one argument.\n"; + } else { + if (args.at(0).type() != QVariant::String) { + yyMsg(identLineNo) << qPrintable(name) << "(): identifier must be a literal string.\n"; + } else { + msgid = args.at(0).toString(); + bool plural = (args.size() > 1); + recordMessage(translator, QString(), sourcetext, QString(), extracomment, + msgid, extra, plural, fileName(), identLineNo); } } + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); } } break; ./ @@ -1813,20 +1891,73 @@ ExpressionNotInOpt: ; ExpressionNotInOpt: ExpressionNotIn ; Statement: Block ; +/. + case $rule_number: +./ Statement: VariableStatement ; +/. + case $rule_number: +./ Statement: EmptyStatement ; +/. + case $rule_number: +./ Statement: ExpressionStatement ; +/. + case $rule_number: +./ Statement: IfStatement ; +/. + case $rule_number: +./ Statement: IterationStatement ; +/. + case $rule_number: +./ Statement: ContinueStatement ; +/. + case $rule_number: +./ Statement: BreakStatement ; +/. + case $rule_number: +./ Statement: ReturnStatement ; +/. + case $rule_number: +./ Statement: WithStatement ; +/. + case $rule_number: +./ Statement: LabelledStatement ; +/. + case $rule_number: +./ Statement: SwitchStatement ; +/. + case $rule_number: +./ Statement: ThrowStatement ; +/. + case $rule_number: +./ Statement: TryStatement ; +/. + case $rule_number: +./ Statement: DebuggerStatement ; +/. + case $rule_number: + if (!sourcetext.isEmpty() || !extracomment.isEmpty() || !msgid.isEmpty() || !extra.isEmpty()) { + yyMsg() << "Discarding unconsumed meta data\n"; + sourcetext.clear(); + extracomment.clear(); + msgid.clear(); + extra.clear(); + } + break; +./ Block: T_LBRACE StatementListOpt T_RBRACE ; StatementList: Statement ; @@ -1988,6 +2119,63 @@ PropertyNameAndValueListOpt: PropertyNameAndValueList ; return false; } +std::ostream &QScriptParser::yyMsg(int line) +{ + return std::cerr << qPrintable(fileName()) << ':' << (line ? line : lexer->startLineNo()) << ": "; +} + +void QScriptParser::processComment(const QChar *chars, int length) +{ + if (!length) + return; + // Try to match the logic of the C++ parser. + if (*chars == QLatin1Char(':') && chars[1].isSpace()) { + extracomment += QString(chars+2, length-2); + } else if (*chars == QLatin1Char('=') && chars[1].isSpace()) { + msgid = QString(chars+2, length-2).simplified(); + } else if (*chars == QLatin1Char('~') && chars[1].isSpace()) { + QString text = QString(chars+2, length-2).trimmed(); + int k = text.indexOf(QLatin1Char(' ')); + if (k > -1) + extra.insert(text.left(k), text.mid(k + 1).trimmed()); + } else if (*chars == QLatin1Char('%') && chars[1].isSpace()) { + sourcetext.reserve(sourcetext.length() + length-2); + ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); + int p = 2, c; + forever { + if (p >= length) + break; + c = chars[p++].unicode(); + if (isspace(c)) + continue; + if (c != '"') { + yyMsg() << "Unexpected character in meta string\n"; + break; + } + forever { + if (p >= length) { + whoops: + yyMsg() << "Unterminated meta string\n"; + break; + } + c = chars[p++].unicode(); + if (c == '"') + break; + if (c == '\\') { + if (p >= length) + goto whoops; + c = chars[p++].unicode(); + if (c == '\n') + goto whoops; + *ptr++ = '\\'; + } + *ptr++ = c; + } + } + sourcetext.resize(ptr - (ushort *)sourcetext.data()); + } +} + bool loadQScript(Translator &translator, const QString &filename, ConversionData &cd) { @@ -2007,10 +2195,11 @@ bool loadQScript(Translator &translator, const QString &filename, ConversionData ts.setAutoDetectUnicode(true); QString code = ts.readAll(); - QScript::Lexer lexer; - lexer.setCode(code, /*lineNumber=*/1); QScriptParser parser; - if (!parser.parse(&lexer, filename, &translator)) { + QScript::Lexer lexer(&parser); + lexer.setCode(code, filename, /*lineNumber=*/1); + parser.setLexer(&lexer); + if (!parser.parse(&translator)) { std::cerr << qPrintable(filename) << ':' << parser.errorLineNumber() << ": " << qPrintable(parser.errorMessage()) << std::endl; return false; diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index c70bcaf..8d4d27f 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -98,10 +98,13 @@ HTML.postheader = " <div class=\"header\" id=\"qtdocheader\">\n" \ " Qt Topics</h2>\n" \ " <div id=\"list002\" class=\"list\">\n" \ " <ul id=\"ul002\" >\n" \ - " <li class=\"defaultLink\"><a href=\"qt-basic-concepts.html\">Basic Qt architecture</a></li>\n" \ - " <li class=\"defaultLink\"><a href=\"qtquick.html\">Device UI's & Qt Quick</a></li>\n" \ - " <li class=\"defaultLink\"><a href=\"qt-gui-concepts.html\">Desktop UI components</a></li>\n" \ - " <li class=\"defaultLink\"><a href=\"platform-specific.html\">Platform-specific info</a></li>\n" \ + " <li><a href=\"qt-basic-concepts.html\">Programming with Qt</a></li> \n" \ + " <li><a href=\"qtquick.html\">Device UI's & Qt Quick</a></li> \n" \ + " <li><a href=\"qt-gui-concepts.html\">UI Design with Qt</a></li> \n" \ + " <li><a href=\"developing-with-qt.html\">Cross-platform and Platform-specific</a></li> \n" \ + " <li><a href=\"platform-specific.html\">Platform-specific info</a></li> \n" \ + " <li><a href=\"technology-apis.html\">Qt and Key Technologies</a></li> \n" \ + " <li><a href=\"best-practices.html\">How-To's and Best Practices</a></li> \n" \ " </ul> \n" \ " </div>\n" \ " </div>\n" \ |