summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-30 14:11:03 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-30 14:11:03 (GMT)
commit1ba3cac3c7296320ca914f262f124ae7f2dea841 (patch)
tree40e9c04835dcfe8adccb4cedfda5e568f3c92677 /tools
parent708978d1c18cf938a4e0c29a5a90be5de4e82140 (diff)
parent51582e3d1251766a3ed941530d966e1a591cbed6 (diff)
downloadQt-1ba3cac3c7296320ca914f262f124ae7f2dea841.zip
Qt-1ba3cac3c7296320ca914f262f124ae7f2dea841.tar.gz
Qt-1ba3cac3c7296320ca914f262f124ae7f2dea841.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: qmake/generators/win32/msbuild_objectmodel.cpp qmake/generators/win32/msvc_vcxproj.cpp tests/auto/qnetworkreply/tst_qnetworkreply.cpp
Diffstat (limited to 'tools')
-rw-r--r--tools/configure/configure.pro2
-rw-r--r--tools/configure/configureapp.cpp25
-rw-r--r--tools/configure/environment.cpp7
-rw-r--r--tools/configure/tools.cpp10
-rw-r--r--tools/linguist/lupdate/qscript.cpp234
-rw-r--r--tools/linguist/lupdate/qscript.g249
-rw-r--r--tools/porting/src/errors.cpp6
-rw-r--r--tools/porting/src/errors.h6
-rw-r--r--tools/qdoc3/htmlgenerator.cpp11
-rw-r--r--tools/qdoc3/test/qt-html-templates.qdocconf11
10 files changed, 469 insertions, 92 deletions
diff --git a/tools/configure/configure.pro b/tools/configure/configure.pro
index 73f3317..a3473af 100644
--- a/tools/configure/configure.pro
+++ b/tools/configure/configure.pro
@@ -28,7 +28,7 @@ INCLUDEPATH += \
$$QT_SOURCE_TREE/src/corelib/global \
$$QT_BUILD_TREE/include \
$$QT_BUILD_TREE/include/QtCore \
- $$QT_BUILD_TREE/tools/shared
+ $$QT_SOURCE_TREE/tools/shared
HEADERS = configureapp.h environment.h tools.h\
$$QT_SOURCE_TREE/src/corelib/tools/qbytearray.h \
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 0ed16ed..3a0c14d 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -341,7 +341,7 @@ Configure::Configure(int& argc, char** argv)
dictionary[ "ACCESSIBILITY" ] = "yes";
dictionary[ "OPENGL" ] = "yes";
dictionary[ "OPENVG" ] = "no";
- dictionary[ "IPV6" ] = "yes"; // Always, dynamicly loaded
+ dictionary[ "IPV6" ] = "yes"; // Always, dynamically loaded
dictionary[ "OPENSSL" ] = "auto";
dictionary[ "DBUS" ] = "auto";
dictionary[ "S60" ] = "yes";
@@ -2164,7 +2164,7 @@ bool Configure::checkAvailability(const QString &part)
available = (paths.size() == 0);
if (!available) {
- if (epocRoot.isNull() || epocRoot == "")
+ if (epocRoot.isEmpty())
epocRoot = "<empty string>";
cout << endl
<< "The QtMultimedia audio backend will not be built because required" << endl
@@ -2682,8 +2682,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") {
@@ -2710,7 +2715,7 @@ void Configure::generateOutputVars()
QString set_config = dictionary["QCONFIG"];
if (possible_configs.contains(set_config)) {
- foreach(QString cfg, possible_configs) {
+ foreach (const QString &cfg, possible_configs) {
qtConfig += (cfg + "-config");
if (cfg == set_config)
break;
@@ -2836,7 +2841,7 @@ void Configure::generateCachefile()
QStringList buildParts;
buildParts << "libs" << "tools" << "examples" << "demos" << "docs" << "translations";
- foreach(QString item, disabledBuildParts) {
+ foreach (const QString &item, disabledBuildParts) {
buildParts.removeAll(item);
}
cacheStream << "QT_BUILD_PARTS = " << buildParts.join(" ") << endl;
@@ -3149,7 +3154,7 @@ void Configure::generateConfigfiles()
QStringList kbdDrivers = dictionary["KBD_DRIVERS"].split(" ");;
QStringList allKbdDrivers;
allKbdDrivers<<"tty"<<"usb"<<"sl5000"<<"yopy"<<"vr41xx"<<"qvfb"<<"um";
- foreach(QString kbd, allKbdDrivers) {
+ foreach (const QString &kbd, allKbdDrivers) {
if (!kbdDrivers.contains(kbd))
tmpStream<<"#define QT_NO_QWS_KBD_"<<kbd.toUpper()<<endl;
}
@@ -3157,7 +3162,7 @@ void Configure::generateConfigfiles()
QStringList mouseDrivers = dictionary["MOUSE_DRIVERS"].split(" ");
QStringList allMouseDrivers;
allMouseDrivers << "pc"<<"bus"<<"linuxtp"<<"yopy"<<"vr41xx"<<"tslib"<<"qvfb";
- foreach(QString mouse, allMouseDrivers) {
+ foreach (const QString &mouse, allMouseDrivers) {
if (!mouseDrivers.contains(mouse))
tmpStream<<"#define QT_NO_QWS_MOUSE_"<<mouse.toUpper()<<endl;
}
@@ -3165,7 +3170,7 @@ void Configure::generateConfigfiles()
QStringList gfxDrivers = dictionary["GFX_DRIVERS"].split(" ");
QStringList allGfxDrivers;
allGfxDrivers<<"linuxfb"<<"transformed"<<"qvfb"<<"vnc"<<"multiscreen"<<"ahi";
- foreach(QString gfx, allGfxDrivers) {
+ foreach (const QString &gfx, allGfxDrivers) {
if (!gfxDrivers.contains(gfx))
tmpStream<<"#define QT_NO_QWS_"<<gfx.toUpper()<<endl;
}
@@ -3173,7 +3178,7 @@ void Configure::generateConfigfiles()
tmpStream<<"#define Q_WS_QWS"<<endl;
QStringList depths = dictionary[ "QT_QWS_DEPTH" ].split(" ");
- foreach(QString depth, depths)
+ foreach (const QString &depth, depths)
tmpStream<<"#define QT_QWS_DEPTH_"+depth<<endl;
}
diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp
index 5d9851f..9446864 100644
--- a/tools/configure/environment.cpp
+++ b/tools/configure/environment.cpp
@@ -271,8 +271,7 @@ static QByteArray qt_create_environment(const QStringList &environment)
pos += tmpSize;
}
// add the user environment
- for (QStringList::ConstIterator it = environment.begin(); it != environment.end(); it++ ) {
- QString tmp = *it;
+ foreach (const QString &tmp, environment) {
uint tmpSize = sizeof(wchar_t) * (tmp.length() + 1);
envlist.resize(envlist.size() + tmpSize);
memcpy(envlist.data() + pos, tmp.utf16(), tmpSize);
@@ -376,7 +375,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
switch(GetLastError()) {
case E2BIG:
cerr << "execute: Argument list exceeds 1024 bytes" << endl;
- foreach(QString arg, arguments)
+ foreach (const QString &arg, arguments)
cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl;
break;
case ENOENT:
@@ -390,7 +389,7 @@ int Environment::execute(QStringList arguments, const QStringList &additionalEnv
break;
default:
cerr << "execute: Unknown error" << endl;
- foreach(QString arg, arguments)
+ foreach (const QString &arg, arguments)
cerr << " (" << arg.toLocal8Bit().constData() << ")" << endl;
break;
}
diff --git a/tools/configure/tools.cpp b/tools/configure/tools.cpp
index c4625af..c91f048 100644
--- a/tools/configure/tools.cpp
+++ b/tools/configure/tools.cpp
@@ -91,8 +91,8 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
QStringList components = buffer.split( '=' );
if ( components.size() >= 2 ) {
QStringList::Iterator it = components.begin();
- QString key = (*it++).trimmed().replace( "\"", QString() ).toUpper();
- QString value = (*it++).trimmed().replace( "\"", QString() );
+ QString key = (*it++).trimmed().remove('"').toUpper();
+ QString value = (*it++).trimmed().remove('"');
licenseInfo[ key ] = value;
}
}
@@ -111,7 +111,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
// Verify license info...
QString licenseKey = licenseInfo["LICENSEKEYEXT"];
QByteArray clicenseKey = licenseKey.toLatin1();
- //We check the licence
+ //We check the license
static const char * const SEP = "-";
char *licenseParts[NUMBER_OF_PARTS];
int partNumber = 0;
@@ -218,7 +218,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
if (QFile::exists(dictionary["QT_SOURCE_TREE"] + "/.LICENSE")) {
// Generic, no-suffix license
- dictionary["LICENSE_EXTENSION"] = QString();
+ dictionary["LICENSE_EXTENSION"].clear();
} else if (dictionary["LICENSE_EXTENSION"].isEmpty()) {
cout << "License file does not contain proper license key." << endl;
dictionary["DONE"] = "error";
@@ -239,7 +239,7 @@ void Tools::checkLicense(QMap<QString,QString> &dictionary, QMap<QString,QString
fromLicenseFile += "-US";
if (!CopyFile((wchar_t*)QDir::toNativeSeparators(fromLicenseFile).utf16(),
- (wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), FALSE)) {
+ (wchar_t*)QDir::toNativeSeparators(toLicenseFile).utf16(), false)) {
cout << "Failed to copy license file (" << fromLicenseFile << ")";
dictionary["DONE"] = "error";
return;
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/porting/src/errors.cpp b/tools/porting/src/errors.cpp
index 580efb5..9081dba 100644
--- a/tools/porting/src/errors.cpp
+++ b/tools/porting/src/errors.cpp
@@ -44,8 +44,8 @@
QT_BEGIN_NAMESPACE
-QT_STATIC_CONST_IMPL Error& Errors::InternalError = Error( 1, -1, QLatin1String("Internal Error") );
-QT_STATIC_CONST_IMPL Error& Errors::SyntaxError = Error( 2, -1, QLatin1String("Syntax Error before '%1'") );
-QT_STATIC_CONST_IMPL Error& Errors::ParseError = Error( 3, -1, QLatin1String("Parse Error before '%1'") );
+QT_STATIC_CONST_IMPL Error Errors::InternalError = Error( 1, -1, QLatin1String("Internal Error") );
+QT_STATIC_CONST_IMPL Error Errors::SyntaxError = Error( 2, -1, QLatin1String("Syntax Error before '%1'") );
+QT_STATIC_CONST_IMPL Error Errors::ParseError = Error( 3, -1, QLatin1String("Parse Error before '%1'") );
QT_END_NAMESPACE
diff --git a/tools/porting/src/errors.h b/tools/porting/src/errors.h
index f0ad691..dbac833 100644
--- a/tools/porting/src/errors.h
+++ b/tools/porting/src/errors.h
@@ -61,9 +61,9 @@ public:
class Errors
{
public:
- QT_STATIC_CONST Error& InternalError;
- QT_STATIC_CONST Error& SyntaxError;
- QT_STATIC_CONST Error& ParseError;
+ QT_STATIC_CONST Error InternalError;
+ QT_STATIC_CONST Error SyntaxError;
+ QT_STATIC_CONST Error ParseError;
};
QT_END_NAMESPACE
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 698b516..bc71b6e 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -3177,7 +3177,14 @@ QString HtmlGenerator::highlightedCode(const QString& markedCode,
if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) {
par1 = QStringRef();
const Node* n = marker->resolveTarget(arg.toString(), myTree, relative, self);
- addLink(linkForNode(n,relative), arg, &html);
+ if (n && n->subType() == Node::QmlBasicType) {
+ if (relative && relative->subType() == Node::QmlClass)
+ addLink(linkForNode(n,relative), arg, &html);
+ else
+ html += arg.toString();
+ }
+ else
+ addLink(linkForNode(n,relative), arg, &html);
handled = true;
}
else if (parseArg(src, headerTag, &i, srcSize, &arg, &par1)) {
@@ -3539,7 +3546,7 @@ QString HtmlGenerator::linkForNode(const Node *node, const Node *relative)
return QString();
if (node->access() == Node::Private)
return QString();
-
+
fn = fileName(node);
/* if (!node->url().isEmpty())
return fn;*/
diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf
index 1f50e80..6b1bfd2 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 &amp; 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 &amp; 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" \