diff options
Diffstat (limited to 'src/tools')
34 files changed, 920 insertions, 590 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 65d95362f7..10bbd59bfb 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -118,7 +118,6 @@ struct Options , timing(false) , generateAssetsFileList(true) , build(true) - , gradle(false) , auxMode(false) , deploymentMechanism(Bundled) , releasePackage(false) @@ -150,7 +149,6 @@ struct Options bool timing; bool generateAssetsFileList; bool build; - bool gradle; bool auxMode; bool stripLibraries = true; ActionTimer timer; @@ -159,7 +157,6 @@ struct Options QString sdkPath; QString sdkBuildToolsVersion; QString ndkPath; - QString antTool; QString jdkPath; // Build paths @@ -212,6 +209,7 @@ struct Options bool sectionsOnly; bool protectedAuthenticationPath; bool jarSigner; + QString apkPath; // Gdbserver TriState gdbServer; @@ -369,13 +367,6 @@ Options parseOptions() options.helpRequested = true; } else if (argument.compare(QLatin1String("--verbose"), Qt::CaseInsensitive) == 0) { options.verbose = true; - } else if (argument.compare(QLatin1String("--gradle"), Qt::CaseInsensitive) == 0) { - options.gradle = true; - } else if (argument.compare(QLatin1String("--ant"), Qt::CaseInsensitive) == 0) { - if (i + 1 == arguments.size()) - options.helpRequested = true; - else - options.antTool = arguments.at(++i); } else if (argument.compare(QLatin1String("--deployment"), Qt::CaseInsensitive) == 0) { if (i + 1 == arguments.size()) { options.helpRequested = true; @@ -406,6 +397,11 @@ Options parseOptions() options.helpRequested = true; else options.jdkPath = arguments.at(++i); + } else if (argument.compare(QLatin1String("--apk"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + options.helpRequested = true; + else + options.apkPath = arguments.at(++i); } else if (argument.compare(QLatin1String("--sign"), Qt::CaseInsensitive) == 0) { if (i + 2 >= arguments.size()) { options.helpRequested = true; @@ -515,9 +511,6 @@ void printHelp() " --android-platform <platform>: Builds against the given android\n" " platform. By default, the highest available version will be\n" " used.\n" - " --gradle. Use gradle instead of ant to create and install the apk.\n" - " --ant <path/to/ant>: If unspecified, ant from the PATH will be\n" - " used.\n" " --release: Builds a package ready for release. By default, the\n" " package will be signed with a debug key.\n" " --sign <url/to/keystore> <alias>: Signs the package with the\n" @@ -557,6 +550,7 @@ void printHelp() " dependencies into the build directory and update the XML templates.\n" " The project will not be built or installed.\n" " --no-strip: Do not strip debug symbols from libraries.\n" + " --apk <path/where/to/copy/the/apk>: Path where to copy the built apk.\n" " --help: Displays this information.\n\n", qPrintable(QCoreApplication::arguments().at(0)) ); @@ -1024,16 +1018,13 @@ bool copyAndroidTemplate(const Options &options) if (options.verbose) fprintf(stdout, "Copying Android package template.\n"); - if (options.gradle && !copyGradleTemplate(options)) + if (!copyGradleTemplate(options)) return false; if (!copyAndroidTemplate(options, QLatin1String("/src/android/templates"))) return false; - if (options.gradle) - return true; - - return copyAndroidTemplate(options, QLatin1String("/src/android/java")); + return true; } bool copyAndroidSources(const Options &options) @@ -1285,36 +1276,6 @@ bool updateStringsXml(const Options &options) if (!updateFile(fileName, replacements)) return false; - if (options.gradle) - return true; - - // ant can't (easily) build multiple res folders, - // so we need to replace the "<!-- %%INSERT_STRINGS -->" placeholder - // from the main res folder - QFile stringsXml(fileName); - if (!stringsXml.open(QIODevice::ReadOnly)) { - fprintf(stderr, "Cannot open %s for reading.\n", qPrintable(fileName)); - return false; - } - - QXmlStreamReader reader(&stringsXml); - while (!reader.atEnd()) { - reader.readNext(); - if (reader.isStartElement() && - reader.name() == QLatin1String("string") && - reader.attributes().hasAttribute(QLatin1String("name")) && - reader.attributes().value(QLatin1String("name")) == QLatin1String("app_name")) { - return true; - } - } - - replacements.clear(); - replacements[QStringLiteral("<!-- %%INSERT_STRINGS -->")] = QString::fromLatin1("<string name=\"app_name\">%1</string>\n") - .arg(QFileInfo(options.applicationBinary).baseName().mid(sizeof("lib") - 1)); - - if (!updateFile(fileName, replacements)) - return false; - return true; } @@ -2220,64 +2181,6 @@ QString findInPath(const QString &fileName) return QString(); } -bool buildAntProject(const Options &options) -{ - if (options.verbose) - fprintf(stdout, "Building Android package using ant.\n"); - - QString antTool = options.antTool; - if (antTool.isEmpty()) { -#if defined(Q_OS_WIN32) - antTool = findInPath(QLatin1String("ant.bat")); -#else - antTool = findInPath(QLatin1String("ant")); -#endif - } - - if (antTool.isEmpty()) { - fprintf(stderr, "Cannot find ant in PATH. Please use --ant option to pass in the correct path.\n"); - return false; - } - - if (options.verbose) - fprintf(stdout, "Using ant: %s\n", qPrintable(antTool)); - - QString oldPath = QDir::currentPath(); - if (!QDir::setCurrent(options.outputDirectory)) { - fprintf(stderr, "Cannot current path to %s\n", qPrintable(options.outputDirectory)); - return false; - } - - QString ant = QString::fromLatin1("%1 %2").arg(shellQuote(antTool)).arg(options.releasePackage ? QLatin1String(" release") : QLatin1String(" debug")); - - FILE *antCommand = openProcess(ant); - if (antCommand == 0) { - fprintf(stderr, "Cannot run ant command: %s\n.", qPrintable(ant)); - return false; - } - - char buffer[512]; - while (fgets(buffer, sizeof(buffer), antCommand) != 0) { - fprintf(stdout, "%s", buffer); - fflush(stdout); - } - - int errorCode = pclose(antCommand); - if (errorCode != 0) { - fprintf(stderr, "Building the android package failed!\n"); - if (!options.verbose) - fprintf(stderr, " -- For more information, run this command with --verbose.\n"); - return false; - } - - if (!QDir::setCurrent(oldPath)) { - fprintf(stderr, "Cannot change back to old path: %s\n", qPrintable(oldPath)); - return false; - } - - return true; -} - typedef QMap<QByteArray, QByteArray> GradleProperties; static GradleProperties readGradleProperties(const QString &path) @@ -2335,7 +2238,7 @@ static bool mergeGradleProperties(const QString &path, GradleProperties properti return true; } -bool buildGradleProject(const Options &options) +bool buildAndroidProject(const Options &options) { GradleProperties localProperties; localProperties["sdk.dir"] = options.sdkPath.toLocal8Bit(); @@ -2403,12 +2306,6 @@ bool buildGradleProject(const Options &options) return true; } -bool buildAndroidProject(const Options &options) -{ - return options.gradle ? buildGradleProject(options) - : buildAntProject(options); -} - bool uninstallApk(const Options &options) { if (options.verbose) @@ -2445,15 +2342,11 @@ enum PackageType { QString apkPath(const Options &options, PackageType pt) { QString path(options.outputDirectory); - if (options.gradle) { - path += QLatin1String("/build/outputs/apk/"); - QString buildType(options.releasePackage ? QLatin1String("release/") : QLatin1String("debug/")); - if (QDir(path + buildType).exists()) - path += buildType; - path += QDir(options.outputDirectory).dirName() + QLatin1Char('-'); - } else { - path += QLatin1String("/bin/QtApp-"); - } + path += QLatin1String("/build/outputs/apk/"); + QString buildType(options.releasePackage ? QLatin1String("release/") : QLatin1String("debug/")); + if (QDir(path + buildType).exists()) + path += buildType; + path += QDir(options.outputDirectory).dirName() + QLatin1Char('-'); if (options.releasePackage) { path += QLatin1String("release-"); if (pt == UnsignedAPK) @@ -2503,6 +2396,14 @@ bool installApk(const Options &options) return true; } +bool copyPackage(const Options &options) +{ + fflush(stdout); + auto from = apkPath(options, options.keyStore.isEmpty() ? UnsignedAPK : SignedAPK); + QFile::remove(options.apkPath); + return QFile::copy(from, options.apkPath); +} + bool copyStdCpp(Options *options) { if (options->verbose) @@ -2873,7 +2774,8 @@ enum ErrorCode CannotSignPackage = 15, CannotInstallApk = 16, CannotGenerateAssetsFileList = 18, - CannotCopyAndroidExtraResources = 19 + CannotCopyAndroidExtraResources = 19, + CannotCopyApk = 20 }; int main(int argc, char *argv[]) @@ -2930,8 +2832,7 @@ int main(int argc, char *argv[]) } if (options.build) { - if (options.gradle) - cleanAndroidFiles(options); + cleanAndroidFiles(options); if (Q_UNLIKELY(options.timing)) fprintf(stdout, "[TIMING] %d ms: Cleaned Android file\n", options.timer.elapsed()); @@ -3005,9 +2906,6 @@ int main(int argc, char *argv[]) if (Q_UNLIKELY(options.timing)) fprintf(stdout, "[TIMING] %d ms: Updated files\n", options.timer.elapsed()); - if (!options.gradle && !createAndroidProject(options)) - return CannotCreateAndroidProject; - if (Q_UNLIKELY(options.timing)) fprintf(stdout, "[TIMING] %d ms: Created project\n", options.timer.elapsed()); @@ -3020,6 +2918,9 @@ int main(int argc, char *argv[]) if (!options.keyStore.isEmpty() && !signPackage(options)) return CannotSignPackage; + if (!options.apkPath.isEmpty() && !copyPackage(options)) + return CannotCopyApk; + if (Q_UNLIKELY(options.timing)) fprintf(stdout, "[TIMING] %d ms: Signed package\n", options.timer.elapsed()); } diff --git a/src/tools/androidtestrunner/androidtestrunner.pro b/src/tools/androidtestrunner/androidtestrunner.pro new file mode 100644 index 0000000000..641d3e0003 --- /dev/null +++ b/src/tools/androidtestrunner/androidtestrunner.pro @@ -0,0 +1,13 @@ +option(host_build) +CONFIG += console + +SOURCES += \ + main.cpp + +# Required for declarations of popen/pclose on Windows +windows: QMAKE_CXXFLAGS += -U__STRICT_ANSI__ + +DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII +DEFINES += QT_NO_FOREACH + +load(qt_app) diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp new file mode 100644 index 0000000000..e6d6f72354 --- /dev/null +++ b/src/tools/androidtestrunner/main.cpp @@ -0,0 +1,490 @@ +/**************************************************************************** +** +** Copyright (C) 2019 BogDan Vatra <bogdan@kde.org> +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the tools applications of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QCoreApplication> +#include <QDir> +#include <QHash> +#include <QRegExp> +#include <QSystemSemaphore> +#include <QXmlStreamReader> + +#include <algorithm> +#include <chrono> +#include <functional> +#include <thread> + +#ifdef Q_CC_MSVC +#define popen _popen +#define QT_POPEN_READ "rb" +#define pclose _pclose +#else +#define QT_POPEN_READ "r" +#endif + +struct Options +{ + bool helpRequested = false; + bool verbose = false; + std::chrono::seconds timeout{300}; // 5minutes + QString androidDeployQtCommand; + QString buildPath; + QString adbCommand{QStringLiteral("adb")}; + QString makeCommand; + QString package; + QString activity; + QStringList testArgsList; + QHash<QString, QString> outFiles; + QString testArgs; + QString apkPath; + QHash<QString, std::function<bool(const QByteArray &)>> checkFiles = { + {QStringLiteral("txt"), [](const QByteArray &data) -> bool { + return data.indexOf("\nFAIL! : ") < 0; + }}, + {QStringLiteral("csv"), [](const QByteArray &/*data*/) -> bool { + // It seems csv is broken + return true; + }}, + {QStringLiteral("xml"), [](const QByteArray &data) -> bool { + QXmlStreamReader reader{data}; + while (!reader.atEnd()) { + reader.readNext(); + if (reader.isStartElement() && reader.name() == QStringLiteral("Incident") && + reader.attributes().value(QStringLiteral("type")).toString() == QStringLiteral("fail")) { + return false; + } + } + return true; + }}, + {QStringLiteral("lightxml"), [](const QByteArray &data) -> bool { + return data.indexOf("\n<Incident type=\"fail\" ") < 0; + }}, + {QStringLiteral("xunitxml"), [](const QByteArray &data) -> bool { + QXmlStreamReader reader{data}; + while (!reader.atEnd()) { + reader.readNext(); + if (reader.isStartElement() && reader.name() == QStringLiteral("testcase") && + reader.attributes().value(QStringLiteral("result")).toString() == QStringLiteral("fail")) { + return false; + } + } + return true; + }}, + {QStringLiteral("teamcity"), [](const QByteArray &data) -> bool { + return data.indexOf("' message='Failure! |[Loc: ") < 0; + }}, + {QStringLiteral("tap"), [](const QByteArray &data) -> bool { + return data.indexOf("\nnot ok ") < 0; + }}, + }; +}; + +static Options g_options; + +static bool execCommand(const QString &command, QByteArray *output = nullptr, bool verbose = false) +{ + if (verbose) + fprintf(stdout, "Execute %s\n", command.toUtf8().constData()); + FILE *process = popen(command.toUtf8().constData(), QT_POPEN_READ); + + if (!process) { + fprintf(stderr, "Cannot execute command %s", qPrintable(command)); + return false; + } + char buffer[512]; + while (fgets(buffer, sizeof(buffer), process)) { + if (output) + output->append(buffer); + if (verbose) + fprintf(stdout, "%s", buffer); + } + return pclose(process) == 0; +} + +// Copy-pasted from qmake/library/ioutil.cpp +inline static bool hasSpecialChars(const QString &arg, const uchar (&iqm)[16]) +{ + for (int x = arg.length() - 1; x >= 0; --x) { + ushort c = arg.unicode()[x].unicode(); + if ((c < sizeof(iqm) * 8) && (iqm[c / 8] & (1 << (c & 7)))) + return true; + } + return false; +} + +static QString shellQuoteUnix(const QString &arg) +{ + // Chars that should be quoted (TM). This includes: + static const uchar iqm[] = { + 0xff, 0xff, 0xff, 0xff, 0xdf, 0x07, 0x00, 0xd8, + 0x00, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00, 0x78 + }; // 0-32 \'"$`<>|;&(){}*?#!~[] + + if (!arg.length()) + return QStringLiteral("\"\""); + + QString ret(arg); + if (hasSpecialChars(ret, iqm)) { + ret.replace(QLatin1Char('\''), QStringLiteral("'\\''")); + ret.prepend(QLatin1Char('\'')); + ret.append(QLatin1Char('\'')); + } + return ret; +} + +static QString shellQuoteWin(const QString &arg) +{ + // Chars that should be quoted (TM). This includes: + // - control chars & space + // - the shell meta chars "&()<>^| + // - the potential separators ,;= + static const uchar iqm[] = { + 0xff, 0xff, 0xff, 0xff, 0x45, 0x13, 0x00, 0x78, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x10 + }; + + if (!arg.length()) + return QStringLiteral("\"\""); + + QString ret(arg); + if (hasSpecialChars(ret, iqm)) { + // Quotes are escaped and their preceding backslashes are doubled. + // It's impossible to escape anything inside a quoted string on cmd + // level, so the outer quoting must be "suspended". + ret.replace(QRegExp(QStringLiteral("(\\\\*)\"")), QStringLiteral("\"\\1\\1\\^\"\"")); + // The argument must not end with a \ since this would be interpreted + // as escaping the quote -- rather put the \ behind the quote: e.g. + // rather use "foo"\ than "foo\" + int i = ret.length(); + while (i > 0 && ret.at(i - 1) == QLatin1Char('\\')) + --i; + ret.insert(i, QLatin1Char('"')); + ret.prepend(QLatin1Char('"')); + } + return ret; +} + +static QString shellQuote(const QString &arg) +{ + if (QDir::separator() == QLatin1Char('\\')) + return shellQuoteWin(arg); + else + return shellQuoteUnix(arg); +} + +static bool parseOptions() +{ + QStringList arguments = QCoreApplication::arguments(); + int i = 1; + for (; i < arguments.size(); ++i) { + const QString &argument = arguments.at(i); + if (argument.compare(QStringLiteral("--androiddeployqt"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + g_options.helpRequested = true; + else + g_options.androidDeployQtCommand = arguments.at(++i).trimmed(); + } else if (argument.compare(QStringLiteral("--adb"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + g_options.helpRequested = true; + else + g_options.adbCommand = arguments.at(++i); + } else if (argument.compare(QStringLiteral("--path"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + g_options.helpRequested = true; + else + g_options.buildPath = arguments.at(++i); + } else if (argument.compare(QStringLiteral("--make"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + g_options.helpRequested = true; + else + g_options.makeCommand = arguments.at(++i); + } else if (argument.compare(QStringLiteral("--apk"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + g_options.helpRequested = true; + else + g_options.apkPath = arguments.at(++i); + } else if (argument.compare(QStringLiteral("--activity"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + g_options.helpRequested = true; + else + g_options.activity = arguments.at(++i); + } else if (argument.compare(QStringLiteral("--timeout"), Qt::CaseInsensitive) == 0) { + if (i + 1 == arguments.size()) + g_options.helpRequested = true; + else + g_options.timeout = std::chrono::seconds{arguments.at(++i).toInt()}; + } else if (argument.compare(QStringLiteral("--help"), Qt::CaseInsensitive) == 0) { + g_options.helpRequested = true; + } else if (argument.compare(QStringLiteral("--verbose"), Qt::CaseInsensitive) == 0) { + g_options.verbose = true; + } else if (argument.compare(QStringLiteral("--"), Qt::CaseInsensitive) == 0) { + ++i; + break; + } else { + g_options.testArgsList << arguments.at(i); + } + } + for (;i < arguments.size(); ++i) + g_options.testArgsList << arguments.at(i); + + if (g_options.helpRequested || g_options.androidDeployQtCommand.isEmpty() || g_options.buildPath.isEmpty()) + return false; + + QString serial = qEnvironmentVariable("ANDROID_DEVICE_SERIAL"); + if (!serial.isEmpty()) + g_options.adbCommand += QStringLiteral(" -s %1").arg(serial); + return true; +} + +static void printHelp() +{// "012345678901234567890123456789012345678901234567890123456789012345678901" + fprintf(stderr, "Syntax: %s <options> -- [TESTARGS] \n" + "\n" + " Creates an Android package in a temp directory <destination> and\n" + " runs it on the default emulator/device or on the one specified by\n" + " \"ANDROID_DEVICE_SERIAL\" environment variable.\n\n" + " Mandatory arguments:\n" + " --androiddeployqt <androiddeployqt cmd>: The androiddeployqt:\n" + " path including its additional arguments.\n" + " --path <path>: The path where androiddeployqt will build the .apk.\n" + " Optional arguments:\n" + " --adb <adb cmd>: The Android ADB command. If missing the one from\n" + " $PATH will be used.\n" + " --activity <acitvity>: The Activity to run. If missing the first\n" + " activity from AndroidManifest.qml file will be used.\n" + " --timout <seconds>: Timeout to run the test.\n" + " Default is 5 minutes.\n" + " --make <make cmd>: make command, needed to install the qt library.\n" + " If make is missing make sure the --path is set.\n" + " --apk <apk path>: If the apk is specified and if exists, we'll skip\n" + " the package building.\n" + " -- arguments that will be passed to the test application.\n" + " --verbose: Prints out information during processing.\n" + " --help: Displays this information.\n\n", + qPrintable(QCoreApplication::arguments().at(0)) + ); +} + +static QString packageNameFromAndroidManifest(const QString &androidManifestPath) +{ + QFile androidManifestXml(androidManifestPath); + if (androidManifestXml.open(QIODevice::ReadOnly)) { + QXmlStreamReader reader(&androidManifestXml); + while (!reader.atEnd()) { + reader.readNext(); + if (reader.isStartElement() && reader.name() == QStringLiteral("manifest")) + return reader.attributes().value(QStringLiteral("package")).toString(); + } + } + return {}; +} + +static QString activityFromAndroidManifest(const QString &androidManifestPath) +{ + QFile androidManifestXml(androidManifestPath); + if (androidManifestXml.open(QIODevice::ReadOnly)) { + QXmlStreamReader reader(&androidManifestXml); + while (!reader.atEnd()) { + reader.readNext(); + if (reader.isStartElement() && reader.name() == QStringLiteral("activity")) + return reader.attributes().value(QStringLiteral("android:name")).toString(); + } + } + return {}; +} + +static void setOutputFile(QString file, QString format) +{ + if (file.isEmpty()) + file = QStringLiteral("-"); + if (format.isEmpty()) + format = QStringLiteral("txt"); + + g_options.outFiles[format] = file; +} + +static bool parseTestArgs() +{ + QRegExp newLoggingFormat{QStringLiteral("(.*),(txt|csv|xunitxml|xml|lightxml|teamcity|tap)")}; + QRegExp oldFormats{QStringLiteral("-(txt|csv|xunitxml|xml|lightxml|teamcity|tap)")}; + + QString file; + QString logType; + QString unhandledArgs; + for (int i = 0; i < g_options.testArgsList.size(); ++i) { + const QString &arg = g_options.testArgsList[i].trimmed(); + if (arg == QStringLiteral("-o")) { + if (i >= g_options.testArgsList.size() - 1) + return false; // missing file argument + + const auto &filePath = g_options.testArgsList[++i]; + if (!newLoggingFormat.exactMatch(filePath)) { + file = filePath; + } else { + const auto capturedTexts = newLoggingFormat.capturedTexts(); + setOutputFile(capturedTexts.at(1), capturedTexts.at(2)); + } + } else if (oldFormats.exactMatch(arg)) { + logType = oldFormats.capturedTexts().at(1); + } else { + unhandledArgs += QStringLiteral(" %1").arg(arg); + } + } + if (g_options.outFiles.isEmpty() || !file.isEmpty() || !logType.isEmpty()) + setOutputFile(file, logType); + + for (const auto &format : g_options.outFiles.keys()) + g_options.testArgs += QStringLiteral(" -o output.%1,%1").arg(format); + + g_options.testArgs += unhandledArgs; + g_options.testArgs = QStringLiteral("shell am start -e applicationArguments \"'%1'\" -n %2/%3").arg(shellQuote(g_options.testArgs.trimmed()), + g_options.package, + g_options.activity); + return true; +} + +static bool isRunning() { + QByteArray output; + if (!execCommand(QStringLiteral("%1 shell \"ps | grep ' %2'\"").arg(g_options.adbCommand, + shellQuote(g_options.package)), &output)) { + + return false; + } + return output.indexOf(" " + g_options.package.toUtf8()) > -1; +} + +static bool waitToFinish() +{ + using clock = std::chrono::system_clock; + auto start = clock::now(); + // wait to start + while (!isRunning()) { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + if ((clock::now() - start) > std::chrono::seconds{10}) + return false; + } + + // Wait to finish + while (isRunning()) { + std::this_thread::sleep_for(std::chrono::milliseconds(250)); + if ((clock::now() - start) > g_options.timeout) + return false; + } + return true; +} + + +static bool pullFiles() +{ + bool ret = true; + for (auto it = g_options.outFiles.constBegin(); it != g_options.outFiles.end(); ++it) { + QByteArray output; + if (!execCommand(QStringLiteral("%1 shell run-as %2 cat files/output.%3") + .arg(g_options.adbCommand, g_options.package, it.key()), &output)) { + return false; + } + auto checkerIt = g_options.checkFiles.find(it.key()); + ret &= checkerIt != g_options.checkFiles.end() && checkerIt.value()(output); + if (it.value() == QStringLiteral("-")){ + fprintf(stdout, "%s", output.constData()); + fflush(stdout); + } else { + QFile out{it.value()}; + if (!out.open(QIODevice::WriteOnly)) + return false; + out.write(output); + } + } + return ret; +} + +struct RunnerLocker +{ + RunnerLocker() + { + runner.acquire(); + } + ~RunnerLocker() + { + runner.release(); + } + QSystemSemaphore runner{QStringLiteral("androidtestrunner"), 1, QSystemSemaphore::Open}; +}; + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + if (!parseOptions()) { + printHelp(); + return 1; + } + + RunnerLocker lock; // do not install or run packages while another test is running + if (!g_options.apkPath.isEmpty() && QFile::exists(g_options.apkPath)) { + if (!execCommand(QStringLiteral("%1 install -r %2") + .arg(g_options.adbCommand, g_options.apkPath), nullptr, g_options.verbose)) { + return 1; + } + } else { + if (!g_options.makeCommand.isEmpty()) { + // we need to run make INSTALL_ROOT=path install to install the application file(s) first + if (!execCommand(QStringLiteral("%1 INSTALL_ROOT=%2 install") + .arg(g_options.makeCommand, QDir::toNativeSeparators(g_options.buildPath)), nullptr, g_options.verbose)) { + return 1; + } + } + + // Run androiddeployqt + static auto verbose = g_options.verbose ? QStringLiteral("--verbose") : QStringLiteral(); + if (!execCommand(QStringLiteral("%1 %3 --reinstall --output %2 --apk %4").arg(g_options.androidDeployQtCommand, + g_options.buildPath, + verbose, + g_options.apkPath), nullptr, true)) { + return 1; + } + } + + QString manifest = g_options.buildPath + QStringLiteral("/AndroidManifest.xml"); + g_options.package = packageNameFromAndroidManifest(manifest); + if (g_options.activity.isEmpty()) + g_options.activity = activityFromAndroidManifest(manifest); + + // parseTestArgs depends on g_options.package + if (!parseTestArgs()) + return 1; + + // start the tests + bool res = execCommand(QStringLiteral("%1 %2").arg(g_options.adbCommand, g_options.testArgs), + nullptr, g_options.verbose) && waitToFinish(); + if (res) + res &= pullFiles(); + res &= execCommand(QStringLiteral("%1 uninstall %2").arg(g_options.adbCommand, g_options.package), + nullptr, g_options.verbose); + fflush(stdout); + return res ? 0 : 1; +} diff --git a/src/tools/bootstrap/.prev_CMakeLists.txt b/src/tools/bootstrap/.prev_CMakeLists.txt index 849313dddf..464a19d32e 100644 --- a/src/tools/bootstrap/.prev_CMakeLists.txt +++ b/src/tools/bootstrap/.prev_CMakeLists.txt @@ -48,7 +48,9 @@ add_qt_module(Bootstrap ../../corelib/kernel/qcoreapplication.cpp ../../corelib/kernel/qcoreglobaldata.cpp ../../corelib/kernel/qmetatype.cpp + ../../corelib/kernel/qsharedmemory.cpp ../../corelib/kernel/qsystemerror.cpp + ../../corelib/kernel/qsystemsemaphore.cpp ../../corelib/kernel/qvariant.cpp ../../corelib/plugin/quuid.cpp ../../corelib/serialization/qdatastream.cpp @@ -72,7 +74,6 @@ add_qt_module(Bootstrap ../../corelib/tools/qcryptographichash.cpp ../../corelib/tools/qhash.cpp ../../corelib/tools/qline.cpp - ../../corelib/tools/qlinkedlist.cpp ../../corelib/tools/qlist.cpp ../../corelib/tools/qlocale.cpp ../../corelib/tools/qlocale_tools.cpp @@ -120,6 +121,12 @@ extend_target(Bootstrap CONDITION UNIX ../../corelib/io/qfilesystemiterator_unix.cpp ../../corelib/io/qfsfileengine_unix.cpp ../../corelib/kernel/qcore_unix.cpp + ../../corelib/kernel/qsharedmemory_posix.cpp + ../../corelib/kernel/qsharedmemory_systemv.cpp + ../../corelib/kernel/qsharedmemory_unix.cpp + ../../corelib/kernel/qsystemsemaphore_posix.cpp + ../../corelib/kernel/qsystemsemaphore_systemv.cpp + ../../corelib/kernel/qsystemsemaphore_unix.cpp ) extend_target(Bootstrap CONDITION WIN32 @@ -130,6 +137,8 @@ extend_target(Bootstrap CONDITION WIN32 ../../corelib/io/qfsfileengine_win.cpp ../../corelib/io/qstandardpaths_win.cpp ../../corelib/kernel/qcoreapplication_win.cpp + ../../corelib/kernel/qsharedmemory_win.cpp + ../../corelib/kernel/qsystemsemaphore_win.cpp ../../corelib/plugin/qsystemlibrary.cpp PUBLIC_LIBRARIES advapi32 @@ -142,6 +151,9 @@ extend_target(Bootstrap CONDITION WIN32 extend_target(Bootstrap CONDITION APPLE_OSX SOURCES ../../corelib/global/qoperatingsystemversion_darwin.mm + ../../corelib/io/qfilesystemengine_unix.cpp + ../../corelib/io/qfilesystemiterator_unix.cpp + ../../corelib/io/qfsfileengine_unix.cpp ../../corelib/io/qstandardpaths_mac.mm ../../corelib/kernel/qcore_foundation.mm ../../corelib/kernel/qcore_mac.cpp diff --git a/src/tools/bootstrap/CMakeLists.txt b/src/tools/bootstrap/CMakeLists.txt index ca9df20bd9..1d25e2e6e4 100644 --- a/src/tools/bootstrap/CMakeLists.txt +++ b/src/tools/bootstrap/CMakeLists.txt @@ -46,7 +46,9 @@ extend_target(Bootstrap ../../corelib/kernel/qcoreapplication.cpp ../../corelib/kernel/qcoreglobaldata.cpp ../../corelib/kernel/qmetatype.cpp + ../../corelib/kernel/qsharedmemory.cpp ../../corelib/kernel/qsystemerror.cpp + ../../corelib/kernel/qsystemsemaphore.cpp ../../corelib/kernel/qvariant.cpp ../../corelib/plugin/quuid.cpp ../../corelib/serialization/qdatastream.cpp @@ -70,7 +72,6 @@ extend_target(Bootstrap ../../corelib/tools/qcryptographichash.cpp ../../corelib/tools/qhash.cpp ../../corelib/tools/qline.cpp - ../../corelib/tools/qlinkedlist.cpp ../../corelib/tools/qlist.cpp ../../corelib/tools/qlocale.cpp ../../corelib/tools/qlocale_tools.cpp @@ -125,6 +126,12 @@ extend_target(Bootstrap CONDITION UNIX ../../corelib/io/qfilesystemiterator_unix.cpp ../../corelib/io/qfsfileengine_unix.cpp ../../corelib/kernel/qcore_unix.cpp + ../../corelib/kernel/qsharedmemory_posix.cpp + ../../corelib/kernel/qsharedmemory_systemv.cpp + ../../corelib/kernel/qsharedmemory_unix.cpp + ../../corelib/kernel/qsystemsemaphore_posix.cpp + ../../corelib/kernel/qsystemsemaphore_systemv.cpp + ../../corelib/kernel/qsystemsemaphore_unix.cpp ) extend_target(Bootstrap CONDITION WIN32 @@ -135,6 +142,8 @@ extend_target(Bootstrap CONDITION WIN32 ../../corelib/io/qfsfileengine_win.cpp ../../corelib/io/qstandardpaths_win.cpp ../../corelib/kernel/qcoreapplication_win.cpp + ../../corelib/kernel/qsharedmemory_win.cpp + ../../corelib/kernel/qsystemsemaphore_win.cpp ../../corelib/plugin/qsystemlibrary.cpp PUBLIC_LIBRARIES advapi32 @@ -147,6 +156,9 @@ extend_target(Bootstrap CONDITION WIN32 extend_target(Bootstrap CONDITION APPLE_OSX SOURCES ../../corelib/global/qoperatingsystemversion_darwin.mm + ../../corelib/io/qfilesystemengine_unix.cpp + ../../corelib/io/qfilesystemiterator_unix.cpp + ../../corelib/io/qfsfileengine_unix.cpp ../../corelib/io/qstandardpaths_mac.mm ../../corelib/kernel/qcore_foundation.mm ../../corelib/kernel/qcore_mac.cpp diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro index 40c0702f0a..757460393e 100644 --- a/src/tools/bootstrap/bootstrap.pro +++ b/src/tools/bootstrap/bootstrap.pro @@ -60,6 +60,8 @@ SOURCES += \ ../../corelib/kernel/qmetatype.cpp \ ../../corelib/kernel/qvariant.cpp \ ../../corelib/kernel/qsystemerror.cpp \ + ../../corelib/kernel/qsharedmemory.cpp \ + ../../corelib/kernel/qsystemsemaphore.cpp \ ../../corelib/plugin/quuid.cpp \ ../../corelib/serialization/qdatastream.cpp \ ../../corelib/serialization/qjson.cpp \ @@ -82,7 +84,6 @@ SOURCES += \ ../../corelib/tools/qcryptographichash.cpp \ ../../corelib/tools/qhash.cpp \ ../../corelib/tools/qlist.cpp \ - ../../corelib/tools/qlinkedlist.cpp \ ../../corelib/tools/qlocale.cpp \ ../../corelib/tools/qlocale_tools.cpp \ ../../corelib/tools/qmap.cpp \ @@ -103,6 +104,12 @@ SOURCES += \ ../../xml/sax/qxml.cpp unix:SOURCES += ../../corelib/kernel/qcore_unix.cpp \ + ../../corelib/kernel/qsharedmemory_posix.cpp \ + ../../corelib/kernel/qsharedmemory_systemv.cpp \ + ../../corelib/kernel/qsharedmemory_unix.cpp \ + ../../corelib/kernel/qsystemsemaphore_posix.cpp \ + ../../corelib/kernel/qsystemsemaphore_systemv.cpp \ + ../../corelib/kernel/qsystemsemaphore_unix.cpp \ ../../corelib/io/qfilesystemengine_unix.cpp \ ../../corelib/io/qfilesystemiterator_unix.cpp \ ../../corelib/io/qfsfileengine_unix.cpp @@ -112,12 +119,18 @@ win32:SOURCES += ../../corelib/global/qoperatingsystemversion_win.cpp \ ../../corelib/io/qfilesystemiterator_win.cpp \ ../../corelib/io/qfsfileengine_win.cpp \ ../../corelib/kernel/qcoreapplication_win.cpp \ + ../../corelib/kernel/qsharedmemory_win.cpp \ + ../../corelib/kernel/qsystemsemaphore_win.cpp \ ../../corelib/plugin/qsystemlibrary.cpp \ mac { SOURCES += \ ../../corelib/kernel/qcoreapplication_mac.cpp \ - ../../corelib/kernel/qcore_mac.cpp + ../../corelib/kernel/qcore_mac.cpp \ + ../../corelib/io/qfilesystemengine_unix.cpp \ + ../../corelib/io/qfilesystemiterator_unix.cpp \ + ../../corelib/io/qfsfileengine_unix.cpp + OBJECTIVE_SOURCES += \ ../../corelib/global/qoperatingsystemversion_darwin.mm \ ../../corelib/kernel/qcore_mac_objc.mm \ diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index ab7e400f47..41d0bbf2a1 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1001,7 +1001,7 @@ void Generator::generateMetacall() needUser |= p.user.endsWith(')'); } - fprintf(out, "\n#ifndef QT_NO_PROPERTIES\n "); + fprintf(out, "\n#ifndef QT_NO_PROPERTIES\n "); if (needElse) fprintf(out, "else "); fprintf(out, diff --git a/src/tools/moc/keywords.cpp b/src/tools/moc/keywords.cpp index 07c59d155f..7da8d94efc 100644 --- a/src/tools/moc/keywords.cpp +++ b/src/tools/moc/keywords.cpp @@ -30,12 +30,12 @@ // DO NOT EDIT. static const short keyword_trans[][128] = { - {0,0,0,0,0,0,0,0,0,561,558,0,0,0,0,0, + {0,0,0,0,0,0,0,0,0,568,565,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 561,252,559,562,8,38,239,560,25,26,236,234,30,235,27,237, + 568,252,566,569,8,38,239,567,25,26,236,234,30,235,27,237, 22,22,22,22,22,22,22,22,22,22,34,41,23,39,24,43, 0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,21,8,8,8,8,8,8,8,8,8,31,564,32,238,8, + 8,21,8,8,8,8,8,8,8,8,8,31,571,32,238,8, 0,1,2,3,4,5,6,7,8,9,8,8,10,11,12,13, 14,8,15,16,17,18,19,20,8,8,8,36,245,37,248,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -116,7 +116,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,290,222,0,0,490,0,0,0, + 0,0,0,0,0,0,0,0,290,222,0,0,497,0,0,0, 0,0,0,0,55,0,0,330,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -155,7 +155,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,514,0,0,0,0,0,0,0,0,0,0,357, + 0,0,0,0,521,0,0,0,0,0,0,0,0,0,0,357, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -177,7 +177,7 @@ static const short keyword_trans[][128] = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,42,0,0,0,28,0, - 567,567,567,567,567,567,567,567,567,567,0,0,0,0,0,0, + 574,574,574,574,574,574,574,574,574,574,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -336,7 +336,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,566,0,0,0,0,565, + 0,0,0,0,0,0,0,0,0,0,573,0,0,0,0,572, 0,0,0,0,0,0,0,0,0,0,0,0,0,258,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -372,29 +372,29 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,487,0,0,0,300,0,0,0,0,0,0,0,0,0,0, + 0,494,0,0,0,300,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,468,417,401,409,373,0,477,0,0,0,0,364,358, - 379,0,550,465,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,475,424,408,416,380,0,484,0,0,0,0,364,358, + 386,0,557,472,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,387,0,0,0, - 0,0,380,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,394,0,0,0, + 0,0,387,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,504,0,0,0,0,0,381, + 0,0,0,0,0,0,0,0,0,511,0,0,0,0,0,388, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, @@ -403,7 +403,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,405,0,0,0,0,0,0,0,0,0,0,0,406, + 0,0,0,412,0,0,0,0,0,0,0,0,0,0,0,413, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -411,14 +411,14 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,413,0,0,0,0,0,0,0,0,0,0,0,414, + 0,0,0,420,0,0,0,0,0,0,0,0,0,0,0,421, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,447,425,0,0,430,0,0,0,439,0,0, + 0,0,0,0,0,454,432,0,0,437,0,0,0,446,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, @@ -426,7 +426,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,533,0,466,0,0,0,494,0,0,500,0,0,0, + 0,0,0,540,0,473,0,0,0,501,0,0,507,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, @@ -435,7 +435,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,479,0,526,0,0,0,0,0,0,0,0,0, + 0,0,0,0,486,0,533,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -443,7 +443,7 @@ static const short keyword_trans[][128] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 542,0,0,510,0,0,0,0,0,0,0,0,0,0,0,0, + 549,0,0,517,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; @@ -828,197 +828,204 @@ static const struct {CHARACTER, 0, 65, 370, CHARACTER}, {CHARACTER, 0, 67, 371, CHARACTER}, {CHARACTER, 0, 69, 372, CHARACTER}, - {Q_NAMESPACE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 65, 374, CHARACTER}, - {CHARACTER, 0, 68, 375, CHARACTER}, - {CHARACTER, 0, 71, 376, CHARACTER}, - {CHARACTER, 0, 69, 377, CHARACTER}, - {CHARACTER, 0, 84, 378, CHARACTER}, + {Q_NAMESPACE_TOKEN, 0, 95, 373, CHARACTER}, + {CHARACTER, 0, 69, 374, CHARACTER}, + {CHARACTER, 0, 88, 375, CHARACTER}, + {CHARACTER, 0, 80, 376, CHARACTER}, + {CHARACTER, 0, 79, 377, CHARACTER}, + {CHARACTER, 0, 82, 378, CHARACTER}, + {CHARACTER, 0, 84, 379, CHARACTER}, + {Q_NAMESPACE_EXPORT_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 65, 381, CHARACTER}, + {CHARACTER, 0, 68, 382, CHARACTER}, + {CHARACTER, 0, 71, 383, CHARACTER}, + {CHARACTER, 0, 69, 384, CHARACTER}, + {CHARACTER, 0, 84, 385, CHARACTER}, {Q_GADGET_TOKEN, 0, 0, 0, CHARACTER}, {CHARACTER, 44, 0, 0, CHARACTER}, {CHARACTER, 45, 0, 0, CHARACTER}, - {CHARACTER, 0, 80, 382, CHARACTER}, - {CHARACTER, 0, 69, 383, CHARACTER}, - {CHARACTER, 0, 82, 384, CHARACTER}, - {CHARACTER, 0, 84, 385, CHARACTER}, - {CHARACTER, 0, 89, 386, CHARACTER}, + {CHARACTER, 0, 80, 389, CHARACTER}, + {CHARACTER, 0, 69, 390, CHARACTER}, + {CHARACTER, 0, 82, 391, CHARACTER}, + {CHARACTER, 0, 84, 392, CHARACTER}, + {CHARACTER, 0, 89, 393, CHARACTER}, {Q_PROPERTY_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 85, 388, CHARACTER}, - {CHARACTER, 0, 71, 389, CHARACTER}, - {CHARACTER, 0, 73, 390, CHARACTER}, - {CHARACTER, 0, 78, 391, CHARACTER}, - {CHARACTER, 0, 95, 392, CHARACTER}, - {CHARACTER, 0, 77, 393, CHARACTER}, - {CHARACTER, 0, 69, 394, CHARACTER}, - {CHARACTER, 0, 84, 395, CHARACTER}, - {CHARACTER, 0, 65, 396, CHARACTER}, - {CHARACTER, 0, 68, 397, CHARACTER}, - {CHARACTER, 0, 65, 398, CHARACTER}, - {CHARACTER, 0, 84, 399, CHARACTER}, - {CHARACTER, 0, 65, 400, CHARACTER}, + {CHARACTER, 0, 85, 395, CHARACTER}, + {CHARACTER, 0, 71, 396, CHARACTER}, + {CHARACTER, 0, 73, 397, CHARACTER}, + {CHARACTER, 0, 78, 398, CHARACTER}, + {CHARACTER, 0, 95, 399, CHARACTER}, + {CHARACTER, 0, 77, 400, CHARACTER}, + {CHARACTER, 0, 69, 401, CHARACTER}, + {CHARACTER, 0, 84, 402, CHARACTER}, + {CHARACTER, 0, 65, 403, CHARACTER}, + {CHARACTER, 0, 68, 404, CHARACTER}, + {CHARACTER, 0, 65, 405, CHARACTER}, + {CHARACTER, 0, 84, 406, CHARACTER}, + {CHARACTER, 0, 65, 407, CHARACTER}, {Q_PLUGIN_METADATA_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 402, CHARACTER}, - {CHARACTER, 0, 85, 403, CHARACTER}, - {CHARACTER, 0, 77, 404, CHARACTER}, + {CHARACTER, 0, 78, 409, CHARACTER}, + {CHARACTER, 0, 85, 410, CHARACTER}, + {CHARACTER, 0, 77, 411, CHARACTER}, {Q_ENUM_TOKEN, 46, 0, 0, CHARACTER}, {Q_ENUMS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 407, CHARACTER}, - {CHARACTER, 0, 83, 408, CHARACTER}, + {CHARACTER, 0, 78, 414, CHARACTER}, + {CHARACTER, 0, 83, 415, CHARACTER}, {Q_ENUM_NS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 76, 410, CHARACTER}, - {CHARACTER, 0, 65, 411, CHARACTER}, - {CHARACTER, 0, 71, 412, CHARACTER}, + {CHARACTER, 0, 76, 417, CHARACTER}, + {CHARACTER, 0, 65, 418, CHARACTER}, + {CHARACTER, 0, 71, 419, CHARACTER}, {Q_FLAG_TOKEN, 47, 0, 0, CHARACTER}, {Q_FLAGS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 415, CHARACTER}, - {CHARACTER, 0, 83, 416, CHARACTER}, + {CHARACTER, 0, 78, 422, CHARACTER}, + {CHARACTER, 0, 83, 423, CHARACTER}, {Q_FLAG_NS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 69, 418, CHARACTER}, - {CHARACTER, 0, 67, 419, CHARACTER}, - {CHARACTER, 0, 76, 420, CHARACTER}, - {CHARACTER, 0, 65, 421, CHARACTER}, - {CHARACTER, 0, 82, 422, CHARACTER}, - {CHARACTER, 0, 69, 423, CHARACTER}, - {CHARACTER, 0, 95, 424, CHARACTER}, + {CHARACTER, 0, 69, 425, CHARACTER}, + {CHARACTER, 0, 67, 426, CHARACTER}, + {CHARACTER, 0, 76, 427, CHARACTER}, + {CHARACTER, 0, 65, 428, CHARACTER}, + {CHARACTER, 0, 82, 429, CHARACTER}, + {CHARACTER, 0, 69, 430, CHARACTER}, + {CHARACTER, 0, 95, 431, CHARACTER}, {CHARACTER, 48, 0, 0, CHARACTER}, - {CHARACTER, 0, 76, 426, CHARACTER}, - {CHARACTER, 0, 65, 427, CHARACTER}, - {CHARACTER, 0, 71, 428, CHARACTER}, - {CHARACTER, 0, 83, 429, CHARACTER}, + {CHARACTER, 0, 76, 433, CHARACTER}, + {CHARACTER, 0, 65, 434, CHARACTER}, + {CHARACTER, 0, 71, 435, CHARACTER}, + {CHARACTER, 0, 83, 436, CHARACTER}, {Q_DECLARE_FLAGS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 431, CHARACTER}, - {CHARACTER, 0, 84, 432, CHARACTER}, - {CHARACTER, 0, 69, 433, CHARACTER}, - {CHARACTER, 0, 82, 434, CHARACTER}, - {CHARACTER, 0, 70, 435, CHARACTER}, - {CHARACTER, 0, 65, 436, CHARACTER}, - {CHARACTER, 0, 67, 437, CHARACTER}, - {CHARACTER, 0, 69, 438, CHARACTER}, - {Q_DECLARE_INTERFACE_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 78, 438, CHARACTER}, + {CHARACTER, 0, 84, 439, CHARACTER}, {CHARACTER, 0, 69, 440, CHARACTER}, - {CHARACTER, 0, 84, 441, CHARACTER}, - {CHARACTER, 0, 65, 442, CHARACTER}, - {CHARACTER, 0, 84, 443, CHARACTER}, - {CHARACTER, 0, 89, 444, CHARACTER}, - {CHARACTER, 0, 80, 445, CHARACTER}, - {CHARACTER, 0, 69, 446, CHARACTER}, + {CHARACTER, 0, 82, 441, CHARACTER}, + {CHARACTER, 0, 70, 442, CHARACTER}, + {CHARACTER, 0, 65, 443, CHARACTER}, + {CHARACTER, 0, 67, 444, CHARACTER}, + {CHARACTER, 0, 69, 445, CHARACTER}, + {Q_DECLARE_INTERFACE_TOKEN, 0, 0, 0, CHARACTER}, + {CHARACTER, 0, 69, 447, CHARACTER}, + {CHARACTER, 0, 84, 448, CHARACTER}, + {CHARACTER, 0, 65, 449, CHARACTER}, + {CHARACTER, 0, 84, 450, CHARACTER}, + {CHARACTER, 0, 89, 451, CHARACTER}, + {CHARACTER, 0, 80, 452, CHARACTER}, + {CHARACTER, 0, 69, 453, CHARACTER}, {Q_DECLARE_METATYPE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 88, 448, CHARACTER}, - {CHARACTER, 0, 84, 449, CHARACTER}, - {CHARACTER, 0, 69, 450, CHARACTER}, - {CHARACTER, 0, 78, 451, CHARACTER}, - {CHARACTER, 0, 83, 452, CHARACTER}, - {CHARACTER, 0, 73, 453, CHARACTER}, - {CHARACTER, 0, 79, 454, CHARACTER}, - {CHARACTER, 0, 78, 455, CHARACTER}, - {CHARACTER, 0, 95, 456, CHARACTER}, - {CHARACTER, 0, 73, 457, CHARACTER}, + {CHARACTER, 0, 88, 455, CHARACTER}, + {CHARACTER, 0, 84, 456, CHARACTER}, + {CHARACTER, 0, 69, 457, CHARACTER}, {CHARACTER, 0, 78, 458, CHARACTER}, - {CHARACTER, 0, 84, 459, CHARACTER}, - {CHARACTER, 0, 69, 460, CHARACTER}, - {CHARACTER, 0, 82, 461, CHARACTER}, - {CHARACTER, 0, 70, 462, CHARACTER}, - {CHARACTER, 0, 65, 463, CHARACTER}, - {CHARACTER, 0, 67, 464, CHARACTER}, - {CHARACTER, 0, 69, 438, CHARACTER}, - {CHARACTER, 49, 0, 0, CHARACTER}, - {CHARACTER, 0, 84, 467, CHARACTER}, - {CHARACTER, 0, 83, 413, CHARACTER}, - {CHARACTER, 0, 76, 469, CHARACTER}, + {CHARACTER, 0, 83, 459, CHARACTER}, + {CHARACTER, 0, 73, 460, CHARACTER}, + {CHARACTER, 0, 79, 461, CHARACTER}, + {CHARACTER, 0, 78, 462, CHARACTER}, + {CHARACTER, 0, 95, 463, CHARACTER}, + {CHARACTER, 0, 73, 464, CHARACTER}, + {CHARACTER, 0, 78, 465, CHARACTER}, + {CHARACTER, 0, 84, 466, CHARACTER}, + {CHARACTER, 0, 69, 467, CHARACTER}, + {CHARACTER, 0, 82, 468, CHARACTER}, + {CHARACTER, 0, 70, 469, CHARACTER}, {CHARACTER, 0, 65, 470, CHARACTER}, - {CHARACTER, 0, 83, 471, CHARACTER}, - {CHARACTER, 0, 83, 472, CHARACTER}, - {CHARACTER, 0, 73, 473, CHARACTER}, - {CHARACTER, 0, 78, 474, CHARACTER}, - {CHARACTER, 0, 70, 475, CHARACTER}, - {CHARACTER, 0, 79, 476, CHARACTER}, + {CHARACTER, 0, 67, 471, CHARACTER}, + {CHARACTER, 0, 69, 445, CHARACTER}, + {CHARACTER, 49, 0, 0, CHARACTER}, + {CHARACTER, 0, 84, 474, CHARACTER}, + {CHARACTER, 0, 83, 420, CHARACTER}, + {CHARACTER, 0, 76, 476, CHARACTER}, + {CHARACTER, 0, 65, 477, CHARACTER}, + {CHARACTER, 0, 83, 478, CHARACTER}, + {CHARACTER, 0, 83, 479, CHARACTER}, + {CHARACTER, 0, 73, 480, CHARACTER}, + {CHARACTER, 0, 78, 481, CHARACTER}, + {CHARACTER, 0, 70, 482, CHARACTER}, + {CHARACTER, 0, 79, 483, CHARACTER}, {Q_CLASSINFO_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 78, 478, CHARACTER}, + {CHARACTER, 0, 78, 485, CHARACTER}, {CHARACTER, 50, 0, 0, CHARACTER}, - {CHARACTER, 0, 69, 480, CHARACTER}, - {CHARACTER, 0, 82, 481, CHARACTER}, - {CHARACTER, 0, 70, 482, CHARACTER}, - {CHARACTER, 0, 65, 483, CHARACTER}, - {CHARACTER, 0, 67, 484, CHARACTER}, - {CHARACTER, 0, 69, 485, CHARACTER}, - {CHARACTER, 0, 83, 486, CHARACTER}, + {CHARACTER, 0, 69, 487, CHARACTER}, + {CHARACTER, 0, 82, 488, CHARACTER}, + {CHARACTER, 0, 70, 489, CHARACTER}, + {CHARACTER, 0, 65, 490, CHARACTER}, + {CHARACTER, 0, 67, 491, CHARACTER}, + {CHARACTER, 0, 69, 492, CHARACTER}, + {CHARACTER, 0, 83, 493, CHARACTER}, {Q_INTERFACES_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 108, 488, CHARACTER}, - {CHARACTER, 0, 115, 489, CHARACTER}, + {CHARACTER, 0, 108, 495, CHARACTER}, + {CHARACTER, 0, 115, 496, CHARACTER}, {SIGNALS, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 111, 491, CHARACTER}, - {CHARACTER, 0, 116, 492, CHARACTER}, - {CHARACTER, 0, 115, 493, CHARACTER}, + {CHARACTER, 0, 111, 498, CHARACTER}, + {CHARACTER, 0, 116, 499, CHARACTER}, + {CHARACTER, 0, 115, 500, CHARACTER}, {SLOTS, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 71, 495, CHARACTER}, - {CHARACTER, 0, 78, 496, CHARACTER}, - {CHARACTER, 0, 65, 497, CHARACTER}, - {CHARACTER, 0, 76, 498, CHARACTER}, - {Q_SIGNAL_TOKEN, 0, 83, 499, CHARACTER}, + {CHARACTER, 0, 71, 502, CHARACTER}, + {CHARACTER, 0, 78, 503, CHARACTER}, + {CHARACTER, 0, 65, 504, CHARACTER}, + {CHARACTER, 0, 76, 505, CHARACTER}, + {Q_SIGNAL_TOKEN, 0, 83, 506, CHARACTER}, {Q_SIGNALS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 79, 501, CHARACTER}, - {CHARACTER, 0, 84, 502, CHARACTER}, - {Q_SLOT_TOKEN, 0, 83, 503, CHARACTER}, + {CHARACTER, 0, 79, 508, CHARACTER}, + {CHARACTER, 0, 84, 509, CHARACTER}, + {Q_SLOT_TOKEN, 0, 83, 510, CHARACTER}, {Q_SLOTS_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 86, 505, CHARACTER}, - {CHARACTER, 0, 65, 506, CHARACTER}, - {CHARACTER, 0, 84, 507, CHARACTER}, - {CHARACTER, 0, 69, 508, CHARACTER}, - {CHARACTER, 0, 95, 509, CHARACTER}, + {CHARACTER, 0, 86, 512, CHARACTER}, + {CHARACTER, 0, 65, 513, CHARACTER}, + {CHARACTER, 0, 84, 514, CHARACTER}, + {CHARACTER, 0, 69, 515, CHARACTER}, + {CHARACTER, 0, 95, 516, CHARACTER}, {CHARACTER, 51, 0, 0, CHARACTER}, - {CHARACTER, 0, 76, 511, CHARACTER}, - {CHARACTER, 0, 79, 512, CHARACTER}, - {CHARACTER, 0, 84, 513, CHARACTER}, + {CHARACTER, 0, 76, 518, CHARACTER}, + {CHARACTER, 0, 79, 519, CHARACTER}, + {CHARACTER, 0, 84, 520, CHARACTER}, {Q_PRIVATE_SLOT_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 95, 515, CHARACTER}, - {CHARACTER, 0, 77, 516, CHARACTER}, - {CHARACTER, 0, 79, 517, CHARACTER}, - {CHARACTER, 0, 67, 518, CHARACTER}, - {CHARACTER, 0, 95, 519, CHARACTER}, - {CHARACTER, 0, 67, 520, CHARACTER}, - {CHARACTER, 0, 79, 521, CHARACTER}, - {CHARACTER, 0, 77, 522, CHARACTER}, - {CHARACTER, 0, 80, 523, CHARACTER}, - {CHARACTER, 0, 65, 524, CHARACTER}, - {CHARACTER, 0, 84, 525, CHARACTER}, + {CHARACTER, 0, 95, 522, CHARACTER}, + {CHARACTER, 0, 77, 523, CHARACTER}, + {CHARACTER, 0, 79, 524, CHARACTER}, + {CHARACTER, 0, 67, 525, CHARACTER}, + {CHARACTER, 0, 95, 526, CHARACTER}, + {CHARACTER, 0, 67, 527, CHARACTER}, + {CHARACTER, 0, 79, 528, CHARACTER}, + {CHARACTER, 0, 77, 529, CHARACTER}, + {CHARACTER, 0, 80, 530, CHARACTER}, + {CHARACTER, 0, 65, 531, CHARACTER}, + {CHARACTER, 0, 84, 532, CHARACTER}, {Q_MOC_COMPAT_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 79, 527, CHARACTER}, - {CHARACTER, 0, 75, 528, CHARACTER}, - {CHARACTER, 0, 65, 529, CHARACTER}, - {CHARACTER, 0, 66, 530, CHARACTER}, - {CHARACTER, 0, 76, 531, CHARACTER}, - {CHARACTER, 0, 69, 532, CHARACTER}, + {CHARACTER, 0, 79, 534, CHARACTER}, + {CHARACTER, 0, 75, 535, CHARACTER}, + {CHARACTER, 0, 65, 536, CHARACTER}, + {CHARACTER, 0, 66, 537, CHARACTER}, + {CHARACTER, 0, 76, 538, CHARACTER}, + {CHARACTER, 0, 69, 539, CHARACTER}, {Q_INVOKABLE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 82, 534, CHARACTER}, - {CHARACTER, 0, 73, 535, CHARACTER}, - {CHARACTER, 0, 80, 536, CHARACTER}, - {CHARACTER, 0, 84, 537, CHARACTER}, - {CHARACTER, 0, 65, 538, CHARACTER}, - {CHARACTER, 0, 66, 539, CHARACTER}, - {CHARACTER, 0, 76, 540, CHARACTER}, - {CHARACTER, 0, 69, 541, CHARACTER}, + {CHARACTER, 0, 82, 541, CHARACTER}, + {CHARACTER, 0, 73, 542, CHARACTER}, + {CHARACTER, 0, 80, 543, CHARACTER}, + {CHARACTER, 0, 84, 544, CHARACTER}, + {CHARACTER, 0, 65, 545, CHARACTER}, + {CHARACTER, 0, 66, 546, CHARACTER}, + {CHARACTER, 0, 76, 547, CHARACTER}, + {CHARACTER, 0, 69, 548, CHARACTER}, {Q_SCRIPTABLE_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 82, 543, CHARACTER}, - {CHARACTER, 0, 79, 544, CHARACTER}, - {CHARACTER, 0, 80, 545, CHARACTER}, - {CHARACTER, 0, 69, 546, CHARACTER}, - {CHARACTER, 0, 82, 547, CHARACTER}, - {CHARACTER, 0, 84, 548, CHARACTER}, - {CHARACTER, 0, 89, 549, CHARACTER}, + {CHARACTER, 0, 82, 550, CHARACTER}, + {CHARACTER, 0, 79, 551, CHARACTER}, + {CHARACTER, 0, 80, 552, CHARACTER}, + {CHARACTER, 0, 69, 553, CHARACTER}, + {CHARACTER, 0, 82, 554, CHARACTER}, + {CHARACTER, 0, 84, 555, CHARACTER}, + {CHARACTER, 0, 89, 556, CHARACTER}, {Q_PRIVATE_PROPERTY_TOKEN, 0, 0, 0, CHARACTER}, - {CHARACTER, 0, 69, 551, CHARACTER}, - {CHARACTER, 0, 86, 552, CHARACTER}, - {CHARACTER, 0, 73, 553, CHARACTER}, - {CHARACTER, 0, 83, 554, CHARACTER}, - {CHARACTER, 0, 73, 555, CHARACTER}, - {CHARACTER, 0, 79, 556, CHARACTER}, - {CHARACTER, 0, 78, 557, CHARACTER}, + {CHARACTER, 0, 69, 558, CHARACTER}, + {CHARACTER, 0, 86, 559, CHARACTER}, + {CHARACTER, 0, 73, 560, CHARACTER}, + {CHARACTER, 0, 83, 561, CHARACTER}, + {CHARACTER, 0, 73, 562, CHARACTER}, + {CHARACTER, 0, 79, 563, CHARACTER}, + {CHARACTER, 0, 78, 564, CHARACTER}, {Q_REVISION_TOKEN, 0, 0, 0, CHARACTER}, {NEWLINE, 0, 0, 0, NOTOKEN}, {QUOTE, 0, 0, 0, NOTOKEN}, {SINGLEQUOTE, 0, 0, 0, NOTOKEN}, {WHITESPACE, 0, 0, 0, NOTOKEN}, - {HASH, 0, 35, 563, HASH}, + {HASH, 0, 35, 570, HASH}, {PP_HASHHASH, 0, 0, 0, NOTOKEN}, {BACKSLASH, 0, 0, 0, NOTOKEN}, {CPP_COMMENT, 0, 0, 0, NOTOKEN}, diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 2f0ea633fa..50946443be 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -620,6 +620,13 @@ void Moc::parse() case Q_NAMESPACE_TOKEN: def.hasQNamespace = true; break; + case Q_NAMESPACE_EXPORT_TOKEN: + next(LPAREN); + while (test(IDENTIFIER)) + {} + next(RPAREN); + def.hasQNamespace = true; + break; case Q_ENUMS_TOKEN: case Q_ENUM_NS_TOKEN: parseEnumOrFlag(&def, false); diff --git a/src/tools/moc/token.h b/src/tools/moc/token.h index db9d319b78..0cc163f9e4 100644 --- a/src/tools/moc/token.h +++ b/src/tools/moc/token.h @@ -155,6 +155,7 @@ QT_BEGIN_NAMESPACE F(Q_OBJECT_TOKEN) \ F(Q_GADGET_TOKEN) \ F(Q_NAMESPACE_TOKEN) \ + F(Q_NAMESPACE_EXPORT_TOKEN) \ F(Q_PROPERTY_TOKEN) \ F(Q_PLUGIN_METADATA_TOKEN) \ F(Q_ENUMS_TOKEN) \ diff --git a/src/tools/moc/util/generate_keywords.cpp b/src/tools/moc/util/generate_keywords.cpp index df850c1bdc..9248e9e2e7 100644 --- a/src/tools/moc/util/generate_keywords.cpp +++ b/src/tools/moc/util/generate_keywords.cpp @@ -214,6 +214,7 @@ static const Keyword keywords[] = { { "return", "RETURN" }, { "Q_OBJECT", "Q_OBJECT_TOKEN" }, { "Q_NAMESPACE", "Q_NAMESPACE_TOKEN" }, + { "Q_NAMESPACE_EXPORT", "Q_NAMESPACE_EXPORT_TOKEN" }, { "Q_GADGET", "Q_GADGET_TOKEN" }, { "Q_PROPERTY", "Q_PROPERTY_TOKEN" }, { "Q_PLUGIN_METADATA", "Q_PLUGIN_METADATA_TOKEN" }, diff --git a/src/tools/qfloat16-tables/CMakeLists.txt b/src/tools/qfloat16-tables/CMakeLists.txt deleted file mode 100644 index 2fe4ed0d5c..0000000000 --- a/src/tools/qfloat16-tables/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Generated from qfloat16-tables.pro. - -##################################################################### -## qfloat16-tables Tool: -##################################################################### - -add_qt_tool(qfloat16-tables - BOOTSTRAP - TOOLS_TARGET Core # special case - SOURCES - gen_qfloat16_tables.cpp - # CONFIG = "force_bootstrap" - # INSTALLS = "lib" - # _LOADED = "qt_tool" - # _OPTION = "host_build" - # lib.CONFIG = "dummy_install" -) diff --git a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp b/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp deleted file mode 100644 index 17fc978039..0000000000 --- a/src/tools/qfloat16-tables/gen_qfloat16_tables.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 by Southwest Research Institute (R) -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <qfile.h> -#include <qdebug.h> - -quint32 convertmantissa(qint32 i) -{ - quint32 m = i << 13; // Zero pad mantissa bits - quint32 e = 0; // Zero exponent - - while (!(m & 0x00800000)) { // While not normalized - e -= 0x00800000; // Decrement exponent (1<<23) - m <<= 1; // Shift mantissa - } - m &= ~0x00800000; // Clear leading 1 bit - e += 0x38800000; // Adjust bias ((127-14)<<23) - return m | e; // Return combined number -} - -// we first build these tables up and then print them out as a separate step in order -// to more closely map the implementation given in the paper. -quint32 basetable[512]; -quint32 shifttable[512]; - -#define PRINTHEX(a) "0x" + QByteArray::number(a,16).toUpper() + "U,\n" - -qint32 main(qint32 argc, char **argv) -{ - if (argc < 2) { - qWarning() << "Must provide output filename as argument."; - return -1; - } - - QFile fid(QFile::decodeName(argv[1])); - if (!fid.open(QIODevice::WriteOnly | QIODevice::Text)) { - qWarning() << "Abort: Failed to open/create file" << fid.fileName(); - return -1; - } - quint32 i; - - fid.write("/* This file was generated by gen_qfloat16_tables.cpp */\n\n"); - fid.write("#include <QtCore/qfloat16.h>\n\n"); - - fid.write("QT_BEGIN_NAMESPACE\n\n"); - fid.write("#if !defined(__F16C__) && !defined(__ARM_FP16_FORMAT_IEEE)\n\n"); - - fid.write("const quint32 qfloat16::mantissatable[2048] = {\n"); - fid.write("0,\n"); - for (i = 1; i < 1024; i++) - fid.write(PRINTHEX(convertmantissa(i))); - for (i = 1024; i < 2048; i++) - fid.write(PRINTHEX(0x38000000U + ((i - 1024) << 13))); - fid.write("};\n\n"); - - fid.write("const quint32 qfloat16::exponenttable[64] = {\n"); - fid.write("0,\n"); - for (i = 1; i < 31; i++) - fid.write(PRINTHEX(i << 23)); - fid.write("0x47800000U,\n"); // 31 - fid.write("0x80000000U,\n"); // 32 - for (i = 33; i < 63; i++) - fid.write(PRINTHEX(0x80000000U + ((i - 32) << 23))); - fid.write("0xC7800000U,\n"); // 63 - fid.write("};\n\n"); - - fid.write("const quint32 qfloat16::offsettable[64] = {\n"); - fid.write("0,\n"); - for (i = 1; i < 32; i++) - fid.write("1024U,\n"); - fid.write("0,\n"); - for (i = 33; i < 64; i++) - fid.write("1024U,\n"); - fid.write("};\n\n"); - - qint32 e; - for (i = 0; i < 256; ++i) { - e = i - 127; - if (e < -24) { // Very small numbers map to zero - basetable[i | 0x000] = 0x0000; - basetable[i | 0x100] = 0x8000; - shifttable[i | 0x000] = 24; - shifttable[i | 0x100] = 24; - - } else if (e < -14) { // Small numbers map to denorms - basetable[i | 0x000] = (0x0400 >> (-e - 14)); - basetable[i | 0x100] = (0x0400 >> (-e - 14)) | 0x8000; - shifttable[i | 0x000] = -e - 1; - shifttable[i | 0x100] = -e - 1; - - } else if (e <= 15) { // Normal numbers just lose precision - basetable[i | 0x000] = ((e + 15) << 10); - basetable[i | 0x100] = ((e + 15) << 10) | 0x8000; - shifttable[i | 0x000] = 13; - shifttable[i | 0x100] = 13; - - } else if (e < 128) { // Large numbers map to Infinity - basetable[i | 0x000] = 0x7C00; - basetable[i | 0x100] = 0xFC00; - shifttable[i | 0x000] = 24; - shifttable[i | 0x100] = 24; - - } else { // Infinity and NaN's stay Infinity and NaN's - basetable[i | 0x000] = 0x7C00; - basetable[i | 0x100] = 0xFC00; - shifttable[i | 0x000] = 13; - shifttable[i | 0x100] = 13; - } - } - - fid.write("const quint32 qfloat16::basetable[512] = {\n"); - for (i = 0; i < 512; i++) - fid.write(PRINTHEX(basetable[i])); - - fid.write("};\n\n"); - - fid.write("const quint32 qfloat16::shifttable[512] = {\n"); - for (i = 0; i < 512; i++) - fid.write(PRINTHEX(shifttable[i])); - - fid.write("};\n\n"); - - fid.write("#endif // !__F16C__ && !__ARM_FP16_FORMAT_IEEE\n\n"); - fid.write("QT_END_NAMESPACE\n"); - fid.close(); - return 0; -} diff --git a/src/tools/qfloat16-tables/qfloat16-tables.pro b/src/tools/qfloat16-tables/qfloat16-tables.pro deleted file mode 100644 index a7d10ac197..0000000000 --- a/src/tools/qfloat16-tables/qfloat16-tables.pro +++ /dev/null @@ -1,9 +0,0 @@ -option(host_build) - -CONFIG += force_bootstrap -SOURCES += gen_qfloat16_tables.cpp - -load(qt_tool) - -lib.CONFIG = dummy_install -INSTALLS = lib diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index ee17be041e..95f70dc988 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -36,6 +36,8 @@ #include <QtCore/qfile.h> #include <QtCore/qmap.h> +#include <iterator> + namespace { void generateSeparator(int i, QTextStream &out) @@ -126,7 +128,7 @@ QString CppGenerator::endIncludeGuard(const QString &fileName) void CppGenerator::operator () () { // action table... - state_count = aut.states.size (); + state_count = static_cast<int>(aut.states.size()); terminal_count = static_cast<int>(grammar.terminals.size()); non_terminal_count = static_cast<int>(grammar.non_terminals.size()); @@ -156,7 +158,7 @@ void CppGenerator::operator () () if (grammar.isNonTerminal (a.key ())) { - Q_ASSERT (symbol >= terminal_count && symbol < grammar.names.size ()); + Q_ASSERT(symbol >= terminal_count && symbol < static_cast<int>(grammar.names.size())); GOTO (q, symbol - terminal_count) = r; } @@ -245,7 +247,7 @@ void CppGenerator::operator () () << Qt::endl; } - QBitArray used_rules (grammar.rules.count ()); + QBitArray used_rules{static_cast<int>(grammar.rules.size())}; int q = 0; for (StatePointer state = aut.states.begin (); state != aut.states.end (); ++state, ++q) @@ -259,12 +261,11 @@ void CppGenerator::operator () () } } - for (int i = 0; i < used_rules.count (); ++i) + auto rule = grammar.rules.begin(); + for (int i = 0; i < used_rules.count (); ++i, ++rule) { if (! used_rules.testBit (i)) { - RulePointer rule = grammar.rules.begin () + i; - if (rule != grammar.goal) qerr() << "*** Warning: Rule ``" << *rule << "'' is useless!" << Qt::endl; } @@ -280,7 +281,7 @@ void CppGenerator::operator () () if (u >= 0) continue; - RulePointer rule = grammar.rules.begin () + (- u - 1); + RulePointer rule = std::next(grammar.rules.begin(), - u - 1); if (state->defaultReduce == rule) u = 0; @@ -619,7 +620,7 @@ void CppGenerator::generateImpl (QTextStream &out) out << "const int " << grammar.table_name << "::rule_index [] = {"; idx = 0; - int offset = 0; + size_t offset = 0; for (RulePointer rule = grammar.rules.begin (); rule != grammar.rules.end (); ++rule, ++idx) { generateSeparator(idx, out); diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp index 8af3b3c0db..b9a9cf264f 100644 --- a/src/tools/qlalr/lalr.cpp +++ b/src/tools/qlalr/lalr.cpp @@ -51,7 +51,9 @@ QTextStream &qout() static QTextStream result(stdout, QIODevice::WriteOnly); return result; } +QT_END_NAMESPACE +namespace std { bool operator < (Name a, Name b) { return *a < *b; @@ -66,7 +68,7 @@ bool operator < (StatePointer a, StatePointer b) { return &*a < &*b; } -QT_END_NAMESPACE +} bool Read::operator < (const Read &other) const { @@ -329,7 +331,7 @@ QPair<StatePointer, bool> Automaton::internState (const State &state) struct _Bucket { - QLinkedList<ItemPointer> items; + std::list<ItemPointer> items; void insert (ItemPointer item) { items.push_back (item); } @@ -338,8 +340,8 @@ struct _Bucket { State st (aut->_M_grammar); - for (QLinkedList<ItemPointer>::iterator item = items.begin (); item != items.end (); ++item) - st.insert ((*item)->next ()); + for (auto &item : items) + st.insert(item->next()); return st; } diff --git a/src/tools/qlalr/lalr.h b/src/tools/qlalr/lalr.h index 55b65a640d..473ea89769 100644 --- a/src/tools/qlalr/lalr.h +++ b/src/tools/qlalr/lalr.h @@ -51,34 +51,22 @@ class Automaton; // names -typedef QLinkedList<QString>::iterator Name; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(QLinkedList<QString>::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE -typedef QLinkedList<Name> NameList; +typedef std::list<QString>::iterator Name; +typedef std::list<Name> NameList; typedef std::set<Name> NameSet; // items -typedef QLinkedList<Item> ItemList; +typedef std::list<Item> ItemList; typedef ItemList::iterator ItemPointer; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(ItemList::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE // rules -typedef QLinkedList<Rule> debug_infot; +typedef std::list<Rule> debug_infot; typedef debug_infot::iterator RulePointer; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(debug_infot::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE typedef QMultiMap<Name, RulePointer> RuleMap; // states -typedef QLinkedList<State> StateList; +typedef std::list<State> StateList; typedef StateList::iterator StatePointer; -QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(StateList::iterator, Q_PRIMITIVE_TYPE); -QT_END_NAMESPACE // arrows typedef QMap<Name, StatePointer> Bundle; @@ -175,7 +163,7 @@ class Node public: typedef std::set<Node<_Tp> > Repository; typedef typename Repository::iterator iterator; - typedef typename QLinkedList<iterator>::iterator edge_iterator; + typedef typename std::list<iterator>::iterator edge_iterator; public: static iterator get (_Tp data); @@ -213,7 +201,7 @@ public: // attributes mutable bool root; mutable int dfn; mutable _Tp data; - mutable QLinkedList<iterator> outs; + mutable std::list<iterator> outs; protected: inline Node () {} @@ -235,7 +223,7 @@ typename Node<_Tp>::iterator Node<_Tp>::get (_Tp data) } template <typename _Tp> -QPair<typename QLinkedList<typename Node<_Tp>::iterator>::iterator, bool> Node<_Tp>::insertEdge (typename Node<_Tp>::iterator other) const +QPair<typename std::list<typename Node<_Tp>::iterator>::iterator, bool> Node<_Tp>::insertEdge(typename Node<_Tp>::iterator other) const { edge_iterator it = std::find (outs.begin (), outs.end (), other); @@ -272,7 +260,7 @@ public: QString decl_file_name; QString impl_file_name; QString token_prefix; - QLinkedList<QString> names; + std::list<QString> names; Name start; NameSet terminals; NameSet non_terminals; @@ -401,11 +389,11 @@ private: int _M_includes_dfn; }; -QT_BEGIN_NAMESPACE +namespace std { bool operator < (Name a, Name b); bool operator < (StatePointer a, StatePointer b); bool operator < (ItemPointer a, ItemPointer b); -QT_END_NAMESPACE +} QTextStream &operator << (QTextStream &out, const Name &n); QTextStream &operator << (QTextStream &out, const Rule &r); diff --git a/src/tools/qlalr/main.cpp b/src/tools/qlalr/main.cpp index a920b13c85..6a57c7aa7a 100644 --- a/src/tools/qlalr/main.cpp +++ b/src/tools/qlalr/main.cpp @@ -106,7 +106,7 @@ int main (int argc, char *argv[]) if (! p.parse (file_name)) exit (EXIT_FAILURE); - if (grammar.rules.isEmpty ()) + if (grammar.rules.empty()) { qerr() << "*** Fatal. No rules!" << Qt::endl; exit (EXIT_FAILURE); diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 0eb6766b5a..ac87e48e39 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -99,6 +99,37 @@ int createProject(const QString &outFileName) return 0; } +// Escapes a path for use in a Depfile (Makefile syntax) +QString makefileEscape(const QString &filepath) +{ + // Always use forward slashes + QString result = QDir::cleanPath(filepath); + // Spaces are escaped with a backslash + result.replace(QLatin1Char(' '), QLatin1String("\\ ")); + // Pipes are escaped with a backslash + result.replace(QLatin1Char('|'), QLatin1String("\\|")); + // Dollars are escaped with a dollar + result.replace(QLatin1Char('$'), QLatin1String("$$")); + + return result; +} + +void writeDepFile(QIODevice &iodev, const QStringList &depsList, const QString &targetName) +{ + QTextStream out(&iodev); + out << qPrintable(makefileEscape(targetName)); + out << QLatin1Char(':'); + + // Write depfile + for (int i = 0; i < depsList.size(); ++i) { + out << QLatin1Char(' '); + + out << qPrintable(makefileEscape(depsList.at(i))); + } + + out << QLatin1Char('\n'); +} + int runRcc(int argc, char *argv[]) { QCoreApplication app(argc, argv); @@ -176,6 +207,10 @@ int runRcc(int argc, char *argv[]) QStringLiteral("Only output a mapping of resource paths to file system paths defined in the .qrc file, do not generate code.")); parser.addOption(mapOption); + QCommandLineOption depFileOption(QStringList{QStringLiteral("d"), QStringLiteral("depfile")}, + QStringLiteral("Write a depfile with the .qrc dependencies to <file>."), QStringLiteral("file")); + parser.addOption(depFileOption); + QCommandLineOption projectOption(QStringLiteral("project"), QStringLiteral("Output a resource file containing all files from the current directory.")); parser.addOption(projectOption); @@ -266,6 +301,7 @@ int runRcc(int argc, char *argv[]) QString outFilename = parser.value(outputOption); QString tempFilename = parser.value(tempOption); + QString depFilename = parser.value(depFileOption); if (projectRequested) { return createProject(outFilename); @@ -352,6 +388,28 @@ int runRcc(int argc, char *argv[]) return 0; } + // Write depfile + if (!depFilename.isEmpty()) { + QFile depout; + depout.setFileName(depFilename); + + if (outFilename.isEmpty() || outFilename == QLatin1String("-")) { + const QString msg = QString::fromUtf8("Unable to write depfile when outputting to stdout!\n"); + errorDevice.write(msg.toUtf8()); + return 1; + } + + if (!depout.open(QIODevice::WriteOnly | QIODevice::Text)) { + const QString msg = QString::fromUtf8("Unable to open depfile %1 for writing: %2\n") + .arg(depout.fileName(), depout.errorString()); + errorDevice.write(msg.toUtf8()); + return 1; + } + + writeDepFile(depout, library.dataFiles(), outFilename); + depout.close(); + } + QFile temp; if (!tempFilename.isEmpty()) { temp.setFileName(tempFilename); diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 08fb6fca5f..9acbce25ff 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -59,7 +59,7 @@ enum { CONSTANT_COMPRESSTHRESHOLD_DEFAULT = 70 }; -#if QT_CONFIG(zstd) +#if QT_CONFIG(zstd) && QT_VERSION >= QT_VERSION_CHECK(6,0,0) # define CONSTANT_COMPRESSALGO_DEFAULT RCCResourceLibrary::CompressionAlgorithm::Zstd #elif !defined(QT_NO_COMPRESS) # define CONSTANT_COMPRESSALGO_DEFAULT RCCResourceLibrary::CompressionAlgorithm::Zlib @@ -67,11 +67,8 @@ enum { # define CONSTANT_COMPRESSALGO_DEFAULT RCCResourceLibrary::CompressionAlgorithm::None #endif -#define writeString(s) write(s, sizeof(s)) - void RCCResourceLibrary::write(const char *str, int len) { - --len; // trailing \0 on string literals... int n = m_out.size(); m_out.resize(n + len); memcpy(m_out.data() + n, str, len); @@ -983,7 +980,7 @@ void RCCResourceLibrary::writeDecimal(int value) Q_ASSERT(m_format != RCCResourceLibrary::Binary); char buf[std::numeric_limits<int>::digits10 + 2]; int n = snprintf(buf, sizeof(buf), "%d", value); - write(buf, n + 1); // write() takes a size including terminating NUL + write(buf, n); } static const char hexDigits[] = "0123456789abcdef"; diff --git a/src/tools/rcc/rcc.h b/src/tools/rcc/rcc.h index b301355e4f..190c37a1f6 100644 --- a/src/tools/rcc/rcc.h +++ b/src/tools/rcc/rcc.h @@ -143,6 +143,7 @@ private: void writeChar(char c) { m_out.append(c); } void writeByteArray(const QByteArray &); void write(const char *, int len); + void writeString(const char *s) { write(s, static_cast<int>(strlen(s))); } #if QT_CONFIG(zstd) ZSTD_CCtx *m_zstdCCtx; diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 0ba49627c0..71e02ae9c9 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -69,7 +69,7 @@ static inline QString moduleHeader(const QString &module, const QString &header) namespace CPP { WriteIncludes::WriteIncludes(Uic *uic) - : m_uic(uic), m_output(uic->output()), m_laidOut(false) + : m_uic(uic), m_output(uic->output()) { // When possible (no namespace) use the "QtModule/QClass" convention // and create a re-mapping of the old header "qclass.h" to it. Do not do this diff --git a/src/tools/uic/cpp/cppwriteincludes.h b/src/tools/uic/cpp/cppwriteincludes.h index 79cbd41014..9b9ac283fe 100644 --- a/src/tools/uic/cpp/cppwriteincludes.h +++ b/src/tools/uic/cpp/cppwriteincludes.h @@ -82,7 +82,7 @@ private: void add(const QString &className, bool determineHeader = true, const QString &header = QString(), bool global = false); private: - typedef std::set<QString> OrderedSet; + using OrderedSet = std::set<QString>; void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false); void insertInclude(const QString &header, bool global); void writeHeaders(const OrderedSet &headers, bool global); @@ -97,11 +97,11 @@ private: QSet<QString> m_knownClasses; - typedef QMap<QString, QString> StringMap; + using StringMap = QMap<QString, QString>; StringMap m_classToHeader; StringMap m_oldHeaderToNewHeader; - bool m_laidOut; + bool m_laidOut = false; }; } // namespace CPP diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 440758cf41..d16c859eed 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -455,22 +455,20 @@ WriteInitialization::WriteInitialization(Uic *uic) : m_driver(uic->driver()), m_output(uic->output()), m_option(uic->option()), m_indent(m_option.indent + m_option.indent), m_dindent(m_indent + m_option.indent), - m_stdsetdef(true), - m_layoutMarginType(TopLevelMargin), - m_mainFormUsedInRetranslateUi(false), m_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly), m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly), - m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly), - m_layoutWidget(false), - m_firstThemeIcon(true) + m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly) { } void WriteInitialization::acceptUI(DomUI *node) { - m_actionGroupChain.push(0); - m_widgetChain.push(0); - m_layoutChain.push(0); + m_actionGroupChain.push(nullptr); + m_widgetChain.push(nullptr); + m_layoutChain.push(nullptr); + + if (node->hasAttributeConnectslotsbyname()) + m_connectSlotsByName = node->attributeConnectslotsbyname(); acceptLayoutDefault(node->elementLayoutDefault()); acceptLayoutFunction(node->elementLayoutFunction()); @@ -498,9 +496,7 @@ void WriteInitialization::acceptUI(DomUI *node) << language::startFunctionDefinition1("setupUi", parameterType, varName, m_option.indent); const QStringList connections = m_uic->databaseInfo()->connections(); - for (int i=0; i<connections.size(); ++i) { - QString connection = connections.at(i); - + for (const auto &connection : connections) { if (connection == QLatin1String("(default)")) continue; @@ -543,7 +539,7 @@ void WriteInitialization::acceptUI(DomUI *node) if (!m_delayedInitialization.isEmpty()) m_output << "\n" << m_delayedInitialization << "\n"; - if (m_option.autoConnection) { + if (m_option.autoConnection && m_connectSlotsByName) { m_output << "\n" << m_indent << "QMetaObject" << language::qualifier << "connectSlotsByName(" << varName << ')' << language::eol; } @@ -706,7 +702,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) addWizardPage(varName, node, parentWidget); } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QToolBox"))) { const DomProperty *plabel = attributes.value(QLatin1String("label")); - DomString *plabelString = plabel ? plabel->elementString() : 0; + DomString *plabelString = plabel ? plabel->elementString() : nullptr; QString icon; if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition @@ -729,7 +725,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) } } else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QTabWidget"))) { const DomProperty *ptitle = attributes.value(QLatin1String("title")); - DomString *ptitleString = ptitle ? ptitle->elementString() : 0; + DomString *ptitleString = ptitle ? ptitle->elementString() : nullptr; QString icon; if (const DomProperty *picon = attributes.value(QLatin1String("icon"))) icon = QLatin1String(", ") + iconCall(picon); // Side effect: Writes icon definition @@ -844,7 +840,7 @@ void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QStr const DomButtonGroup *group = m_driver->findButtonGroup(attributeName); // Legacy feature: Create missing groups on the fly as the UIC button group feature // was present before the actual Designer support (4.5) - const bool createGroupOnTheFly = group == 0; + const bool createGroupOnTheFly = group == nullptr; if (createGroupOnTheFly) { DomButtonGroup *newGroup = new DomButtonGroup; newGroup->setAttributeName(attributeName); @@ -900,8 +896,7 @@ void WriteInitialization::acceptLayout(DomLayout *node) if (m_layoutWidget) { bool left, top, right, bottom; left = top = right = bottom = false; - for (int i = 0; i < propList.size(); ++i) { - const DomProperty *p = propList.at(i); + for (const DomProperty *p : propList) { const QString propertyName = p->attributeName(); if (propertyName == QLatin1String("leftMargin") && p->kind() == DomProperty::Number) left = true; @@ -2619,7 +2614,6 @@ static void generateMultiDirectiveEnd(QTextStream &outputStream, const QSet<QStr WriteInitialization::Item::Item(const QString &itemClassName, const QString &indent, QTextStream &setupUiStream, QTextStream &retranslateUiStream, Driver *driver) : - m_parent(0), m_itemClassName(itemClassName), m_indent(indent), m_setupUiStream(setupUiStream), diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index 0ee001469c..6f8e352f6a 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -85,8 +85,8 @@ namespace CPP { struct WriteInitialization : public TreeWalker { - typedef QList<DomProperty*> DomPropertyList; - typedef QHash<QString, DomProperty*> DomPropertyMap; + using DomPropertyList = QList<DomProperty*>; + using DomPropertyMap = QHash<QString, DomProperty*>; WriteInitialization(Uic *uic); @@ -161,7 +161,7 @@ private: // special initialization // class Item { - Q_DISABLE_COPY(Item) + Q_DISABLE_COPY_MOVE(Item) public: Item(const QString &itemClassName, const QString &indent, QTextStream &setupUiStream, QTextStream &retranslateUiStream, Driver *driver); ~Item(); @@ -188,7 +188,7 @@ private: ItemData m_setupUiData; ItemData m_retranslateUiData; QList<Item *> m_children; - Item *m_parent; + Item *m_parent = nullptr; const QString m_itemClassName; const QString m_indent; @@ -244,7 +244,7 @@ private: const Option &m_option; QString m_indent; QString m_dindent; - bool m_stdsetdef; + bool m_stdsetdef = true; struct Buddy { @@ -259,13 +259,13 @@ private: QVector<Buddy> m_buddies; QSet<QString> m_buttonGroups; - typedef QHash<uint, QString> ColorBrushHash; + using ColorBrushHash = QHash<uint, QString>; ColorBrushHash m_colorBrushHash; // Map from font properties to font variable name for reuse // Map from size policy to variable for reuse - typedef QMap<FontHandle, QString> FontPropertiesNameMap; - typedef QMap<IconHandle, QString> IconPropertiesNameMap; - typedef QMap<SizePolicyHandle, QString> SizePolicyNameMap; + using FontPropertiesNameMap = QMap<FontHandle, QString>; + using IconPropertiesNameMap = QMap<IconHandle, QString>; + using SizePolicyNameMap = QMap<SizePolicyHandle, QString>; FontPropertiesNameMap m_fontPropertiesNameMap; IconPropertiesNameMap m_iconPropertiesNameMap; SizePolicyNameMap m_sizePolicyNameMap; @@ -294,11 +294,11 @@ private: // layout defaults LayoutDefaultHandler m_LayoutDefaultHandler; - int m_layoutMarginType; + int m_layoutMarginType = TopLevelMargin; QString m_generatedClass; QString m_mainFormVarName; - bool m_mainFormUsedInRetranslateUi; + bool m_mainFormUsedInRetranslateUi = false; QString m_delayedInitialization; QTextStream m_delayedOut; @@ -309,8 +309,9 @@ private: QString m_delayedActionInitialization; QTextStream m_actionOut; - bool m_layoutWidget; - bool m_firstThemeIcon; + bool m_layoutWidget = false; + bool m_firstThemeIcon = true; + bool m_connectSlotsByName = true; }; } // namespace CPP diff --git a/src/tools/uic/customwidgetsinfo.cpp b/src/tools/uic/customwidgetsinfo.cpp index d6a409152b..c838feaf73 100644 --- a/src/tools/uic/customwidgetsinfo.cpp +++ b/src/tools/uic/customwidgetsinfo.cpp @@ -95,7 +95,7 @@ bool CustomWidgetsInfo::extendsOneOf(const QString &classNameIn, bool CustomWidgetsInfo::isCustomWidgetContainer(const QString &className) const { - if (const DomCustomWidget *dcw = m_customWidgets.value(className, 0)) + if (const DomCustomWidget *dcw = m_customWidgets.value(className, nullptr)) if (dcw->hasElementContainer()) return dcw->elementContainer() != 0; return false; @@ -111,7 +111,7 @@ QString CustomWidgetsInfo::realClassName(const QString &className) const QString CustomWidgetsInfo::customWidgetAddPageMethod(const QString &name) const { - if (DomCustomWidget *dcw = m_customWidgets.value(name, 0)) + if (DomCustomWidget *dcw = m_customWidgets.value(name, nullptr)) return dcw->elementAddPageMethod(); return QString(); } diff --git a/src/tools/uic/customwidgetsinfo.h b/src/tools/uic/customwidgetsinfo.h index 8a10999027..a1b24ab042 100644 --- a/src/tools/uic/customwidgetsinfo.h +++ b/src/tools/uic/customwidgetsinfo.h @@ -62,7 +62,7 @@ public: bool isCustomWidgetContainer(const QString &className) const; private: - typedef QMap<QString, DomCustomWidget*> NameCustomWidgetMap; + using NameCustomWidgetMap = QMap<QString, DomCustomWidget*>; NameCustomWidgetMap m_customWidgets; }; diff --git a/src/tools/uic/databaseinfo.cpp b/src/tools/uic/databaseinfo.cpp index fa5d5f5df0..9b0d1614ab 100644 --- a/src/tools/uic/databaseinfo.cpp +++ b/src/tools/uic/databaseinfo.cpp @@ -33,9 +33,7 @@ QT_BEGIN_NAMESPACE -DatabaseInfo::DatabaseInfo() -{ -} +DatabaseInfo::DatabaseInfo() = default; void DatabaseInfo::acceptUI(DomUI *node) { @@ -59,10 +57,9 @@ void DatabaseInfo::acceptWidget(DomWidget *node) DomProperty *db = properties.value(QLatin1String("database")); if (db && db->elementStringList()) { QStringList info = db->elementStringList()->elementString(); - - QString connection = info.size() > 0 ? info.at(0) : QString(); - if (connection.isEmpty()) + if (info.isEmpty() || info.constFirst().isEmpty()) return; + const QString &connection = info.constFirst(); m_connections.append(connection); QString table = info.size() > 1 ? info.at(1) : QString(); diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp index eb88032e59..8b9b4806e6 100644 --- a/src/tools/uic/driver.cpp +++ b/src/tools/uic/driver.cpp @@ -256,7 +256,7 @@ bool Driver::uic(const QString &fileName, DomUI *ui, QTextStream *out) QTextStream *oldOutput = m_output; - m_output = out != 0 ? out : &m_stdout; + m_output = out != nullptr ? out : &m_stdout; Uic tool(this); const bool result = tool.write(ui); diff --git a/src/tools/uic/main.cpp b/src/tools/uic/main.cpp index e689d477bd..853538479f 100644 --- a/src/tools/uic/main.cpp +++ b/src/tools/uic/main.cpp @@ -68,6 +68,10 @@ int runUic(int argc, char *argv[]) outputOption.setValueName(QStringLiteral("file")); parser.addOption(outputOption); + QCommandLineOption noAutoConnectionOption(QStringList() << QStringLiteral("a") << QStringLiteral("no-autoconnection")); + noAutoConnectionOption.setDescription(QStringLiteral("Do not generate a call to QObject::connectSlotsByName().")); + parser.addOption(noAutoConnectionOption); + QCommandLineOption noProtOption(QStringList() << QStringLiteral("p") << QStringLiteral("no-protection")); noProtOption.setDescription(QStringLiteral("Disable header protection.")); parser.addOption(noProtOption); @@ -106,6 +110,7 @@ int runUic(int argc, char *argv[]) driver.option().dependencies = parser.isSet(dependenciesOption); driver.option().outputFile = parser.value(outputOption); + driver.option().autoConnection = !parser.isSet(noAutoConnectionOption); driver.option().headerProtection = !parser.isSet(noProtOption); driver.option().implicitIncludes = !parser.isSet(noImplicitIncludesOption); driver.option().idBased = parser.isSet(idBasedOption); @@ -130,7 +135,7 @@ int runUic(int argc, char *argv[]) return !driver.printDependencies(inputFile); } - QTextStream *out = 0; + QTextStream *out = nullptr; QFile f; if (!driver.option().outputFile.isEmpty()) { f.setFileName(driver.option().outputFile); diff --git a/src/tools/uic/treewalker.h b/src/tools/uic/treewalker.h index 7e8eda57d9..3777229517 100644 --- a/src/tools/uic/treewalker.h +++ b/src/tools/uic/treewalker.h @@ -77,6 +77,9 @@ class DomButtonGroup; struct TreeWalker { + Q_DISABLE_COPY_MOVE(TreeWalker) + + TreeWalker() = default; inline virtual ~TreeWalker() = default; virtual void acceptUI(DomUI *ui); @@ -101,7 +104,7 @@ struct TreeWalker virtual void acceptTime(DomTime *time); virtual void acceptDateTime(DomDateTime *dateTime); virtual void acceptProperty(DomProperty *property); - typedef QVector<DomWidget *> DomWidgets; + using DomWidgets = QVector<DomWidget *>; virtual void acceptIncludes(DomIncludes *includes); virtual void acceptInclude(DomInclude *incl); virtual void acceptAction(DomAction *action); diff --git a/src/tools/uic/ui4.cpp b/src/tools/uic/ui4.cpp index 984ef36274..334ced276d 100644 --- a/src/tools/uic/ui4.cpp +++ b/src/tools/uic/ui4.cpp @@ -76,6 +76,10 @@ void DomUI::read(QXmlStreamReader &reader) setAttributeIdbasedtr(attribute.value() == QLatin1String("true")); continue; } + if (name == QLatin1String("connectslotsbyname")) { + setAttributeConnectslotsbyname(attribute.value() == QLatin1String("true")); + continue; + } if (name == QLatin1String("stdsetdef")) { setAttributeStdsetdef(attribute.value().toInt()); continue; @@ -209,6 +213,9 @@ void DomUI::write(QXmlStreamWriter &writer, const QString &tagName) const if (hasAttributeIdbasedtr()) writer.writeAttribute(QStringLiteral("idbasedtr"), (attributeIdbasedtr() ? QLatin1String("true") : QLatin1String("false"))); + if (hasAttributeConnectslotsbyname()) + writer.writeAttribute(QStringLiteral("connectslotsbyname"), (attributeConnectslotsbyname() ? QLatin1String("true") : QLatin1String("false"))); + if (hasAttributeStdsetdef()) writer.writeAttribute(QStringLiteral("stdsetdef"), QString::number(attributeStdsetdef())); diff --git a/src/tools/uic/ui4.h b/src/tools/uic/ui4.h index 1710147342..08a3abf490 100644 --- a/src/tools/uic/ui4.h +++ b/src/tools/uic/ui4.h @@ -169,6 +169,11 @@ public: inline void setAttributeIdbasedtr(bool a) { m_attr_idbasedtr = a; m_has_attr_idbasedtr = true; } inline void clearAttributeIdbasedtr() { m_has_attr_idbasedtr = false; } + inline bool hasAttributeConnectslotsbyname() const { return m_has_attr_connectslotsbyname; } + inline bool attributeConnectslotsbyname() const { return m_attr_connectslotsbyname; } + inline void setAttributeConnectslotsbyname(bool a) { m_attr_connectslotsbyname = a; m_has_attr_connectslotsbyname = true; } + inline void clearAttributeConnectslotsbyname() { m_has_attr_connectslotsbyname = false; } + inline bool hasAttributeStdsetdef() const { return m_has_attr_stdsetdef; } inline int attributeStdsetdef() const { return m_attr_stdsetdef; } inline void setAttributeStdsetdef(int a) { m_attr_stdsetdef = a; m_has_attr_stdsetdef = true; } @@ -285,6 +290,9 @@ private: bool m_attr_idbasedtr = false; bool m_has_attr_idbasedtr = false; + bool m_attr_connectslotsbyname = false; + bool m_has_attr_connectslotsbyname = false; + int m_attr_stdsetdef = 0; bool m_has_attr_stdsetdef = false; diff --git a/src/tools/uic/uic.cpp b/src/tools/uic/uic.cpp index b95f1a784b..207356f28d 100644 --- a/src/tools/uic/uic.cpp +++ b/src/tools/uic/uic.cpp @@ -69,7 +69,7 @@ bool Uic::printDependencies() return false; } - DomUI *ui = 0; + DomUI *ui = nullptr; { QXmlStreamReader reader; reader.setDevice(&f); @@ -178,7 +178,7 @@ static double versionFromUiAttribute(QXmlStreamReader &reader) DomUI *Uic::parseUiFile(QXmlStreamReader &reader) { - DomUI *ui = 0; + DomUI *ui = nullptr; const QString uiElement = QLatin1String("ui"); while (!reader.atEnd()) { @@ -189,7 +189,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader) if (version < 4.0) { const QString msg = QString::fromLatin1("uic: File generated with too old version of Qt Designer (%1)").arg(version); fprintf(stderr, "%s\n", qPrintable(msg)); - return 0; + return nullptr; } ui = new DomUI(); @@ -201,7 +201,7 @@ DomUI *Uic::parseUiFile(QXmlStreamReader &reader) } if (reader.hasError()) { delete ui; - ui = 0; + ui = nullptr; fprintf(stderr, "%s\n", qPrintable(QString::fromLatin1("uic: Error in line %1, column %2 : %3") .arg(reader.lineNumber()).arg(reader.columnNumber()) .arg(reader.errorString()))); |