diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-06-25 09:53:01 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-06-25 12:15:55 +0200 |
commit | fbf6f7400a5b5ae10267171e201391ce1ff8eb96 (patch) | |
tree | 18e22092c2764fea16442fd814f230d4fe095a49 /tools | |
parent | c21a6a9f2c2d635aca3bf88a6431c560b16b1cc6 (diff) | |
parent | 9999591e69a0908cd3fbe14646fb98881e32061b (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
src/plugins/qmltooling/packetprotocol/qpacketprotocol.cpp
src/quick/handlers/qquickhandlerpoint.cpp
src/quick/handlers/qquicksinglepointhandler.cpp
tests/auto/qml/ecmascripttests/test262
Change-Id: I8908ec8c6116ca626fbd269af7625d4c429429ca
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlcachegen/Qt5QuickCompilerConfig.cmake | 2 | ||||
-rw-r--r-- | tools/qmlcachegen/generateloader.cpp | 58 | ||||
-rw-r--r-- | tools/qmlcachegen/qtquickcompiler.prf | 12 |
3 files changed, 63 insertions, 9 deletions
diff --git a/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake b/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake index 26838a5163..49ba4edde9 100644 --- a/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake +++ b/tools/qmlcachegen/Qt5QuickCompilerConfig.cmake @@ -44,7 +44,7 @@ function(QTQUICK_COMPILER_ADD_RESOURCES outfiles) set(rcc_file_with_compilation_units) - execute_process(COMMAND ${rcc_path} -list \"${input_resource}\" OUTPUT_VARIABLE rcc_contents) + execute_process(COMMAND ${rcc_path} -list "${input_resource}" OUTPUT_VARIABLE rcc_contents) string(REGEX REPLACE "[\r\n]+" ";" rcc_contents ${rcc_contents}) foreach(it ${rcc_contents}) get_filename_component(extension ${it} EXT) diff --git a/tools/qmlcachegen/generateloader.cpp b/tools/qmlcachegen/generateloader.cpp index 96528a9477..68aacf78ce 100644 --- a/tools/qmlcachegen/generateloader.cpp +++ b/tools/qmlcachegen/generateloader.cpp @@ -35,6 +35,52 @@ #include <QFileInfo> #include <QSaveFile> +/*! + * \internal + * Mangles \a str to be a unique C++ identifier. Characters that are invalid for C++ identifiers + * are replaced by the pattern \c _0x<hex>_ where <hex> is the hexadecimal unicode + * representation of the character. As identifiers with leading underscores followed by either + * another underscore or a capital letter are reserved in C++, we also escape those, by escaping + * the first underscore, using the above method. + * + * \note + * Although C++11 allows for non-ascii (unicode) characters to be used in identifiers, + * many compilers forgot to read the spec and do not implement this. Some also do not + * implement C99 identifiers, because that is \e {at the implementation's discretion}. So, + * we are stuck with plain old boring identifiers. + */ +QString mangledIdentifier(const QString &str) +{ + Q_ASSERT(!str.isEmpty()); + + QString mangled; + mangled.reserve(str.size()); + + int i = 0; + if (str.startsWith(QLatin1Char('_')) && str.size() > 1) { + QChar ch = str.at(1); + if (ch == QLatin1Char('_') + || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))) { + mangled += QLatin1String("_0x5f_"); + ++i; + } + } + + for (int ei = str.length(); i != ei; ++i) { + auto c = str.at(i).unicode(); + if ((c >= QLatin1Char('0') && c <= QLatin1Char('9')) + || (c >= QLatin1Char('a') && c <= QLatin1Char('z')) + || (c >= QLatin1Char('A') && c <= QLatin1Char('Z')) + || c == QLatin1Char('_')) { + mangled += c; + } else { + mangled += QLatin1String("_0x") + QString::number(c, 16) + QLatin1Char('_'); + } + } + + return mangled; +} + QString symbolNamespaceForPath(const QString &relativePath) { QFileInfo fi(relativePath); @@ -47,12 +93,8 @@ QString symbolNamespaceForPath(const QString &relativePath) } symbol += fi.baseName(); symbol += QLatin1Char('_'); - symbol += fi.suffix(); - symbol.replace(QLatin1Char('.'), QLatin1Char('_')); - symbol.replace(QLatin1Char('+'), QLatin1Char('_')); - symbol.replace(QLatin1Char('-'), QLatin1Char('_')); - symbol.replace(QLatin1Char(' '), QLatin1Char('_')); - return symbol; + symbol += fi.completeSuffix(); + return mangledIdentifier(symbol); } struct VirtualDirectoryEntry @@ -318,7 +360,7 @@ bool generateLoader(const QStringList &compiledFiles, const QString &outputFileN stream << " QHash<QString, const QQmlPrivate::CachedQmlUnit*> resourcePathToCachedUnit;\n"; stream << " static const QQmlPrivate::CachedQmlUnit *lookupCachedUnit(const QUrl &url);\n"; stream << "};\n\n"; - stream << "Q_GLOBAL_STATIC(Registry, unitRegistry);\n"; + stream << "Q_GLOBAL_STATIC(Registry, unitRegistry)\n"; stream << "\n\n"; stream << "Registry::Registry() {\n"; @@ -368,7 +410,7 @@ bool generateLoader(const QStringList &compiledFiles, const QString &outputFileN stream << " Q_INIT_RESOURCE(" << qtResourceNameForFile(newResourceFile) << ");\n"; stream << " return 1;\n"; stream << "}\n"; - stream << "Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(" << initFunction << "));\n"; + stream << "Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(" << initFunction << "))\n"; const QString cleanupFunction = QLatin1String("qCleanupResources_") + suffix; stream << QStringLiteral("int QT_MANGLE_NAMESPACE(%1)() {\n").arg(cleanupFunction); diff --git a/tools/qmlcachegen/qtquickcompiler.prf b/tools/qmlcachegen/qtquickcompiler.prf index 9fa982ca0f..d05908560d 100644 --- a/tools/qmlcachegen/qtquickcompiler.prf +++ b/tools/qmlcachegen/qtquickcompiler.prf @@ -14,6 +14,13 @@ defineReplace(qmlCacheResourceFileOutputName) { return($${name}) } +defineTest(qtQuickSkippedResourceFile) { + for(skippedRes, QTQUICK_COMPILER_SKIPPED_RESOURCES) { + equals(1, $$skippedRes): return(true) + } + return(false) +} + # Flatten RESOURCES that may contain individual files or objects load(resources) @@ -21,6 +28,11 @@ NEWRESOURCES = QMLCACHE_RESOURCE_FILES = for(res, RESOURCES) { + qtQuickSkippedResourceFile($$res) { + NEWRESOURCES += $$res + next() + } + absRes = $$absolute_path($$res, $$_PRO_FILE_PWD_) rccContents = $$system($$QMAKE_RCC_DEP -list $$system_quote($$absRes),lines) contains(rccContents,.*\\.js$)|contains(rccContents,.*\\.qml$) { |