diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-04-28 15:58:01 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-04-28 15:58:22 +0200 |
commit | f345ec530741ebf8b0047c22ae4be7bc66c7e8ad (patch) | |
tree | 2e52ea62a04ecc3e661e61cf8a72fe5d0275796c | |
parent | cfccdd178c9fb8de6bb9507c2c8f904cafce0366 (diff) | |
parent | d25bfeb4c5ecb3d10b87a9f5e2e9e68e05592bfc (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I7d2d0be168d55ffe9bf368f130d1407992be9d1c
-rw-r--r-- | ApiExtractor/apiextractor.cpp | 8 | ||||
-rw-r--r-- | ApiExtractor/apiextractor.h | 9 | ||||
-rw-r--r-- | ApiExtractor/clangparser/compilersupport.cpp | 22 | ||||
-rw-r--r-- | ApiExtractor/header_paths.h | 62 | ||||
-rw-r--r-- | ApiExtractor/typedatabase.cpp | 22 | ||||
-rw-r--r-- | generator/main.cpp | 27 | ||||
-rw-r--r-- | generator/shiboken2/cppgenerator.cpp | 2 | ||||
-rw-r--r-- | generator/shiboken2/shibokengenerator.cpp | 17 | ||||
-rw-r--r-- | tests/libsample/photon.h | 14 |
9 files changed, 137 insertions, 46 deletions
diff --git a/ApiExtractor/apiextractor.cpp b/ApiExtractor/apiextractor.cpp index a83136e..abb7c08 100644 --- a/ApiExtractor/apiextractor.cpp +++ b/ApiExtractor/apiextractor.cpp @@ -79,12 +79,12 @@ void ApiExtractor::addTypesystemSearchPath(const QStringList& paths) addTypesystemSearchPath(path); } -void ApiExtractor::addIncludePath(const QString& path) +void ApiExtractor::addIncludePath(const HeaderPath& path) { m_includePaths << path; } -void ApiExtractor::addIncludePath(const QStringList& paths) +void ApiExtractor::addIncludePath(const HeaderPaths& paths) { m_includePaths << paths; } @@ -271,8 +271,8 @@ bool ApiExtractor::run() m_builder->setGlobalHeader(m_cppFileName); QByteArrayList arguments; arguments.reserve(m_includePaths.size() + 1); - for (const QString &i : qAsConst(m_includePaths)) - arguments.append(QByteArrayLiteral("-I") + QFile::encodeName(i)); + for (const HeaderPath &headerPath : qAsConst(m_includePaths)) + arguments.append(HeaderPath::includeOption(headerPath)); arguments.append(QFile::encodeName(preprocessedCppFileName)); qCDebug(lcShiboken) << __FUNCTION__ << arguments; const bool result = m_builder->build(arguments); diff --git a/ApiExtractor/apiextractor.h b/ApiExtractor/apiextractor.h index ea46e1b..ac90f5b 100644 --- a/ApiExtractor/apiextractor.h +++ b/ApiExtractor/apiextractor.h @@ -33,6 +33,7 @@ #include "dependency.h" #include "abstractmetalang_typedefs.h" #include "apiextractormacros.h" +#include "header_paths.h" #include "typedatabase_typedefs.h" #include "typesystem_typedefs.h" #include <QStringList> @@ -68,9 +69,9 @@ public: void setSilent(bool value); void addTypesystemSearchPath(const QString& path); void addTypesystemSearchPath(const QStringList& paths); - void addIncludePath(const QString& path); - void addIncludePath(const QStringList& paths); - QStringList includePaths() const { return m_includePaths; } + void addIncludePath(const HeaderPath& path); + void addIncludePath(const HeaderPaths& paths); + HeaderPaths includePaths() const { return m_includePaths; } void setLogDirectory(const QString& logDir); bool setApiVersion(const QString& package, const QString& version); void setDropTypeEntries(QString dropEntries); @@ -95,7 +96,7 @@ public: private: QString m_typeSystemFileName; QString m_cppFileName; - QStringList m_includePaths; + HeaderPaths m_includePaths; AbstractMetaBuilder* m_builder; QString m_logDirectory; diff --git a/ApiExtractor/clangparser/compilersupport.cpp b/ApiExtractor/clangparser/compilersupport.cpp index 0346b0a..df82f90 100644 --- a/ApiExtractor/clangparser/compilersupport.cpp +++ b/ApiExtractor/clangparser/compilersupport.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include "compilersupport.h" +#include "header_paths.h" #include <QtCore/QDebug> #include <QtCore/QProcess> @@ -76,21 +77,6 @@ static bool runProcess(const QString &program, const QStringList &arguments, return true; } -class HeaderPath { -public: - explicit HeaderPath(const QByteArray &p = QByteArray()) : path(p), isFramework(false) {} - - QByteArray path; - bool isFramework; // macOS framework path -}; - -static QByteArray includeOption(const HeaderPath &p) -{ - return (p.isFramework ? QByteArrayLiteral("-F") : QByteArrayLiteral("-I")) + p.path; -} - -typedef QList<HeaderPath> HeaderPaths; - #if defined(Q_CC_GNU) static QByteArray frameworkPath() { return QByteArrayLiteral(" (framework directory)"); } @@ -121,7 +107,7 @@ static HeaderPaths gppInternalIncludePaths(const QString &compiler) } else { HeaderPath headerPath(line.trimmed()); if (headerPath.path.endsWith(frameworkPath())) { - headerPath.isFramework = true; + headerPath.m_isFramework = true; headerPath.path.truncate(headerPath.path.size() - frameworkPath().size()); } result.append(headerPath); @@ -160,7 +146,9 @@ QByteArrayList emulatedCompilerOptions() const HeaderPaths headerPaths; #endif std::transform(headerPaths.cbegin(), headerPaths.cend(), - std::back_inserter(result), includeOption); + std::back_inserter(result), [](const HeaderPath &p) { + return HeaderPath::includeOption(p, true); + }); return result; } diff --git a/ApiExtractor/header_paths.h b/ApiExtractor/header_paths.h new file mode 100644 index 0000000..3bc26ef --- /dev/null +++ b/ApiExtractor/header_paths.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of PySide2. +** +** $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$ +** +****************************************************************************/ + +#ifndef HEADER_PATHS_H +#define HEADER_PATHS_H + +#include <QByteArray> +#include <QList> +#include <QString> + +class HeaderPath { +public: + explicit HeaderPath(const QByteArray &p = QByteArray()) : path(p), m_isFramework(false) {} + explicit HeaderPath(const QString &s = QString(), bool isFramework = false) : + path(s.toLatin1()), m_isFramework(isFramework) {} + + QByteArray path; + bool m_isFramework; // macOS framework path + + static QByteArray includeOption(const HeaderPath &p, bool systemInclude = false) + { + QByteArray option; + + if (p.m_isFramework) + option = QByteArrayLiteral("-F"); + else if (systemInclude) + option = QByteArrayLiteral("-isystem"); + else + option = QByteArrayLiteral("-I"); + + return option + p.path; + } +}; + +typedef QList<HeaderPath> HeaderPaths; + +#endif // HEADER_PATHS_H diff --git a/ApiExtractor/typedatabase.cpp b/ApiExtractor/typedatabase.cpp index d9a741f..8530d15 100644 --- a/ApiExtractor/typedatabase.cpp +++ b/ApiExtractor/typedatabase.cpp @@ -384,14 +384,16 @@ bool TypeDatabase::isSuppressedWarning(const QString& s) const QString TypeDatabase::modifiedTypesystemFilepath(const QString& tsFile) const { - if (!QFile::exists(tsFile)) { - int idx = tsFile.lastIndexOf(QLatin1Char('/')); - QString fileName = idx >= 0 ? tsFile.right(tsFile.length() - idx - 1) : tsFile; - for (const QString &path : m_typesystemPaths) { - QString filepath(path + QLatin1Char('/') + fileName); - if (QFile::exists(filepath)) - return filepath; - } + const QFileInfo tsFi(tsFile); + if (tsFi.isAbsolute()) // No point in further lookups + return tsFi.absoluteFilePath(); + if (tsFi.isFile()) // Make path absolute + return tsFi.absoluteFilePath(); + const QString fileName = tsFi.fileName(); + for (const QString &path : m_typesystemPaths) { + const QFileInfo fi(path + QLatin1Char('/') + fileName); + if (fi.isFile()) + return fi.absoluteFilePath(); } return tsFile; } @@ -402,13 +404,17 @@ bool TypeDatabase::parseFile(const QString &filename, bool generate) if (m_parsedTypesystemFiles.contains(filepath)) return m_parsedTypesystemFiles[filepath]; + m_parsedTypesystemFiles[filepath] = true; // Prevent recursion when including self. + QFile file(filepath); if (!file.exists()) { + m_parsedTypesystemFiles[filepath] = false; qCWarning(lcShiboken).noquote().nospace() << "Can't find " << filename << ", typesystem paths: " << m_typesystemPaths.join(QLatin1String(", ")); return false; } if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + m_parsedTypesystemFiles[filepath] = false; qCWarning(lcShiboken).noquote().nospace() << "Can't open " << QDir::toNativeSeparators(filename) << ": " << file.errorString(); return false; diff --git a/generator/main.cpp b/generator/main.cpp index f0e334d..25b50b0 100644 --- a/generator/main.cpp +++ b/generator/main.cpp @@ -156,6 +156,7 @@ static bool processProjectFile(QFile& projectFile, QMap<QString, QString>& args) return false; QStringList includePaths; + QStringList frameworkIncludePaths; QStringList typesystemPaths; QStringList apiVersions; @@ -176,6 +177,8 @@ static bool processProjectFile(QFile& projectFile, QMap<QString, QString>& args) if (key == "include-path") includePaths << QDir::toNativeSeparators(value); + else if (key == "framework-include-path") + frameworkIncludePaths << QDir::toNativeSeparators(value); else if (key == "typesystem-path") typesystemPaths << QDir::toNativeSeparators(value); else if (key == "api-version") @@ -191,6 +194,10 @@ static bool processProjectFile(QFile& projectFile, QMap<QString, QString>& args) if (!includePaths.isEmpty()) args.insert(QLatin1String("include-paths"), includePaths.join(QLatin1String(PATH_SPLITTER))); + if (!frameworkIncludePaths.isEmpty()) + args.insert(QLatin1String("framework-include-paths"), + frameworkIncludePaths.join(QLatin1String(PATH_SPLITTER))); + if (!typesystemPaths.isEmpty()) args.insert(QLatin1String("typesystem-paths"), typesystemPaths.join(QLatin1String(PATH_SPLITTER))); if (!apiVersions.isEmpty()) @@ -301,6 +308,8 @@ void printUsage() QLatin1String("The directory where the generated files will be written")); generalOptions.insert(QLatin1String("include-paths=<path>[" PATH_SPLITTER "<path>" PATH_SPLITTER "...]"), QLatin1String("Include paths used by the C++ parser")); + generalOptions.insert(QLatin1String("framework-include-paths=<path>[" PATH_SPLITTER "<path>" PATH_SPLITTER "...]"), + QLatin1String("Framework include paths used by the C++ parser")); generalOptions.insert(QLatin1String("typesystem-paths=<path>[" PATH_SPLITTER "<path>" PATH_SPLITTER "...]"), QLatin1String("Paths used when searching for typesystems")); generalOptions.insert(QLatin1String("documentation-only"), @@ -460,8 +469,22 @@ int main(int argc, char *argv[]) extractor.addTypesystemSearchPath(path.split(QLatin1String(PATH_SPLITTER))); path = argsHandler.removeArg(QLatin1String("include-paths")); - if (!path.isEmpty()) - extractor.addIncludePath(path.split(QLatin1String(PATH_SPLITTER))); + if (!path.isEmpty()) { + const QStringList includePathListList = path.split(QLatin1String(PATH_SPLITTER)); + for (const QString &s : qAsConst(includePathListList)) { + const bool isFramework = false; + extractor.addIncludePath(HeaderPath(s, isFramework)); + } + } + + path = argsHandler.removeArg(QLatin1String("framework-include-paths")); + if (!path.isEmpty()) { + const QStringList frameworkPathList = path.split(QLatin1String(PATH_SPLITTER)); + const bool isFramework = true; + for (const QString &s : qAsConst(frameworkPathList)) { + extractor.addIncludePath(HeaderPath(s, isFramework)); + } + } QString cppFileName = argsHandler.removeArg(QLatin1String("arg-1")); QString typeSystemFileName = argsHandler.removeArg(QLatin1String("arg-2")); diff --git a/generator/shiboken2/cppgenerator.cpp b/generator/shiboken2/cppgenerator.cpp index df2fd4a..f8b90af 100644 --- a/generator/shiboken2/cppgenerator.cpp +++ b/generator/shiboken2/cppgenerator.cpp @@ -266,7 +266,7 @@ void CppGenerator::generateClass(QTextStream &s, GeneratorContext &classContext) s << endl << "// main header" << endl << "#include \"" << headerfile << '"' << endl; // PYSIDE-500: Use also includes for inherited wrapper classes, because - // with the protected hack, we sometimes need to cast inherited wrappers. + // without the protected hack, we sometimes need to cast inherited wrappers. s << endl << "// inherited wrapper classes" << endl; AbstractMetaClass *basis = metaClass->baseClass(); for (; basis; basis = basis->baseClass()) { diff --git a/generator/shiboken2/shibokengenerator.cpp b/generator/shiboken2/shibokengenerator.cpp index ffce283..2dd8f06 100644 --- a/generator/shiboken2/shibokengenerator.cpp +++ b/generator/shiboken2/shibokengenerator.cpp @@ -1647,6 +1647,17 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, s << INDENT << "// End of code injection" << endl; } +static QString msgWrongIndex(const char *varName, const QString &capture, const AbstractMetaFunction *func) +{ + QString result; + QTextStream str(&result); + str << "Wrong index for " << varName << " variable (" << capture << ") on "; + if (const AbstractMetaClass *c = func->implementingClass()) + str << c->name() << "::"; + str << func->signature(); + return result; +} + void ShibokenGenerator::writeCodeSnips(QTextStream& s, const CodeSnipList& codeSnips, TypeSystem::CodeSnipPosition position, @@ -1682,8 +1693,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, const QRegularExpressionMatch match = pyArgsRegexCheck.match(code); if (match.hasMatch()) { qCWarning(lcShiboken).noquote().nospace() - << "Wrong index for %PYARG variable (" << match.captured(1) - << ") on " << func->signature(); + << msgWrongIndex("%PYARG", match.captured(1), func); return; } code.replace(QLatin1String("%PYARG_1"), QLatin1String(PYTHON_ARG)); @@ -1711,8 +1721,7 @@ void ShibokenGenerator::writeCodeSnips(QTextStream& s, while (rit.hasNext()) { QRegularExpressionMatch match = rit.next(); qCWarning(lcShiboken).noquote().nospace() - << "Wrong index for %ARG#_TYPE variable (" << match.captured(1) - << ") on " << func->signature(); + << msgWrongIndex("%ARG#_TYPE", match.captured(1), func); } // Replace template variable for return variable name. diff --git a/tests/libsample/photon.h b/tests/libsample/photon.h index e3baa12..d8b1be4 100644 --- a/tests/libsample/photon.h +++ b/tests/libsample/photon.h @@ -108,21 +108,23 @@ LIBSAMPLE_API int countValueDuplicators(const std::list<TemplateBase<DuplicatorT // // NOTE: For reasons that should be fairly obvious, this test unfortunately can // only be "run" when building in C++11 mode. -#if __cplusplus < 201103L -#define noexcept +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) +# define PHOTON_NOEXCEPT noexcept +#else +# define PHOTON_NOEXCEPT #endif class Pointer { public: - Pointer() noexcept : px(0) {} + Pointer() PHOTON_NOEXCEPT : px(0) {} Pointer(int* p) : px(p) {} - void reset() noexcept { Pointer().swap(*this); } + void reset() PHOTON_NOEXCEPT { Pointer().swap(*this); } - int* get() const noexcept { return px; } + int* get() const PHOTON_NOEXCEPT { return px; } int& operator*() const { return *px; } - void swap(Pointer& rhs) noexcept + void swap(Pointer& rhs) PHOTON_NOEXCEPT { int* tmp = px; px = rhs.px; |