diff options
Diffstat (limited to 'src/lib/corelib/tools')
-rw-r--r-- | src/lib/corelib/tools/codelocation.h | 2 | ||||
-rw-r--r-- | src/lib/corelib/tools/error.h | 2 | ||||
-rw-r--r-- | src/lib/corelib/tools/id.cpp | 4 | ||||
-rw-r--r-- | src/lib/corelib/tools/id.h | 3 | ||||
-rw-r--r-- | src/lib/corelib/tools/porting.h | 55 | ||||
-rw-r--r-- | src/lib/corelib/tools/qttools.cpp | 7 | ||||
-rw-r--r-- | src/lib/corelib/tools/qttools.h | 13 | ||||
-rw-r--r-- | src/lib/corelib/tools/tools.pri | 1 | ||||
-rw-r--r-- | src/lib/corelib/tools/visualstudioversioninfo.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/tools/visualstudioversioninfo.h | 3 |
10 files changed, 76 insertions, 16 deletions
diff --git a/src/lib/corelib/tools/codelocation.h b/src/lib/corelib/tools/codelocation.h index 3e84ce2d1..158b90766 100644 --- a/src/lib/corelib/tools/codelocation.h +++ b/src/lib/corelib/tools/codelocation.h @@ -85,7 +85,7 @@ QBS_EXPORT bool operator==(const CodeLocation &cl1, const CodeLocation &cl2); QBS_EXPORT bool operator!=(const CodeLocation &cl1, const CodeLocation &cl2); QBS_EXPORT bool operator<(const CodeLocation &cl1, const CodeLocation &cl2); -inline uint qHash(const CodeLocation &cl) { return qHash(cl.toString()); } +inline auto qHash(const CodeLocation &cl) { return qHash(cl.toString()); } QDebug operator<<(QDebug debug, const CodeLocation &location); diff --git a/src/lib/corelib/tools/error.h b/src/lib/corelib/tools/error.h index ea8ddb5ec..4c6370b1e 100644 --- a/src/lib/corelib/tools/error.h +++ b/src/lib/corelib/tools/error.h @@ -126,7 +126,7 @@ void appendError(ErrorInfo &dst, const ErrorInfo &src); void handlePropertyError( const ErrorInfo &error, const SetupProjectParameters ¶ms, Internal::Logger &logger); -inline uint qHash(const ErrorInfo &e) { return qHash(e.toString()); } +inline auto qHash(const ErrorInfo &e) { return qHash(e.toString()); } inline bool operator==(const ErrorInfo &e1, const ErrorInfo &e2) { return e1.toString() == e2.toString(); } diff --git a/src/lib/corelib/tools/id.cpp b/src/lib/corelib/tools/id.cpp index 33cfd60f7..c82fc22b6 100644 --- a/src/lib/corelib/tools/id.cpp +++ b/src/lib/corelib/tools/id.cpp @@ -75,7 +75,7 @@ public: : n(length), str(s) { if (!n) - length = n = qstrlen(s); + length = n = int(qstrlen(s)); h = 0; while (length--) { h = (h << 4) + *s++; @@ -95,7 +95,7 @@ static bool operator==(const StringHolder &sh1, const StringHolder &sh2) } -static uint qHash(const StringHolder &sh) +QHashValueType qHash(const StringHolder &sh) { return sh.h; } diff --git a/src/lib/corelib/tools/id.h b/src/lib/corelib/tools/id.h index aa327833f..845ed60df 100644 --- a/src/lib/corelib/tools/id.h +++ b/src/lib/corelib/tools/id.h @@ -41,6 +41,7 @@ #define QBS_TOOLS_ID_H #include "qbs_export.h" +#include <tools/porting.h> #include <QtCore/qmetatype.h> #include <QtCore/qstring.h> @@ -84,7 +85,7 @@ private: int m_id; }; -inline uint qHash(const Id &id) { return id.uniqueIdentifier(); } +inline QHashValueType qHash(const Id &id) { return id.uniqueIdentifier(); } } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/tools/porting.h b/src/lib/corelib/tools/porting.h new file mode 100644 index 000000000..37582e8d3 --- /dev/null +++ b/src/lib/corelib/tools/porting.h @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qbs. +** +** $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$ +** +****************************************************************************/ + +#ifndef QBS_TOOLS_PORTING_H +#define QBS_TOOLS_PORTING_H + +#include <QtCore/qglobal.h> + +namespace qbs { + +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +using QHashValueType = uint; +#else +using QHashValueType = size_t; +#endif + +} + +#endif diff --git a/src/lib/corelib/tools/qttools.cpp b/src/lib/corelib/tools/qttools.cpp index c2ef91f16..40e0d0778 100644 --- a/src/lib/corelib/tools/qttools.cpp +++ b/src/lib/corelib/tools/qttools.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qttools.h" +#include "porting.h" #include <QtCore/qprocess.h> @@ -64,15 +65,15 @@ size_t hash<QVariant>::operator()(const QVariant &v) const noexcept QT_BEGIN_NAMESPACE -uint qHash(const QStringList &list) +qbs::QHashValueType qHash(const QStringList &list) { - uint s = 0; + qbs::QHashValueType s = 0; for (const QString &n : list) s ^= qHash(n) + 0x9e3779b9 + (s << 6) + (s >> 2); return s; } -uint qHash(const QProcessEnvironment &env) +qbs::QHashValueType qHash(const QProcessEnvironment &env) { return qHash(env.toStringList()); } diff --git a/src/lib/corelib/tools/qttools.h b/src/lib/corelib/tools/qttools.h index 86e81936b..bc1210d53 100644 --- a/src/lib/corelib/tools/qttools.h +++ b/src/lib/corelib/tools/qttools.h @@ -41,6 +41,7 @@ #define QBSQTTOOLS_H #include <tools/qbsassert.h> +#include <tools/porting.h> #include <tools/stlutils.h> #include <QtCore/qhash.h> @@ -136,26 +137,26 @@ template<> struct hash<QVariantHash> QT_BEGIN_NAMESPACE -uint qHash(const QStringList &list); -uint qHash(const QProcessEnvironment &env); +qbs::QHashValueType qHash(const QStringList &list); +qbs::QHashValueType qHash(const QProcessEnvironment &env); template<typename... Args> -uint qHash(const std::tuple<Args...> &tuple) +qbs::QHashValueType qHash(const std::tuple<Args...> &tuple) { return std::hash<std::tuple<Args...>>()(tuple) % std::numeric_limits<uint>::max(); } -inline uint qHash(const QVariant &v) +inline qbs::QHashValueType qHash(const QVariant &v) { return std::hash<QVariant>()(v) % std::numeric_limits<uint>::max(); } -inline uint qHash(const QVariantMap &v) +inline qbs::QHashValueType qHash(const QVariantMap &v) { return std::hash<QVariantMap>()(v) % std::numeric_limits<uint>::max(); } -inline uint qHash(const QVariantHash &v) +inline qbs::QHashValueType qHash(const QVariantHash &v) { return std::hash<QVariantHash>()(v) % std::numeric_limits<uint>::max(); } diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri index 00d87ecc7..1fdacc016 100644 --- a/src/lib/corelib/tools/tools.pri +++ b/src/lib/corelib/tools/tools.pri @@ -30,6 +30,7 @@ HEADERS += \ $$PWD/launchersocket.h \ $$PWD/msvcinfo.h \ $$PWD/persistence.h \ + $$PWD/porting.h \ $$PWD/scannerpluginmanager.h \ $$PWD/scripttools.h \ $$PWD/set.h \ diff --git a/src/lib/corelib/tools/visualstudioversioninfo.cpp b/src/lib/corelib/tools/visualstudioversioninfo.cpp index b5ee3e719..1c51cc4b9 100644 --- a/src/lib/corelib/tools/visualstudioversioninfo.cpp +++ b/src/lib/corelib/tools/visualstudioversioninfo.cpp @@ -181,7 +181,7 @@ QString VisualStudioVersionInfo::platformToolsetVersion() const return QStringLiteral("v%1").arg(m_version.majorVersion() * 10); } -quint32 qHash(const VisualStudioVersionInfo &info) +QHashValueType qHash(const VisualStudioVersionInfo &info) { return qHash(info.version().toString()); } diff --git a/src/lib/corelib/tools/visualstudioversioninfo.h b/src/lib/corelib/tools/visualstudioversioninfo.h index d4b226623..92eecb388 100644 --- a/src/lib/corelib/tools/visualstudioversioninfo.h +++ b/src/lib/corelib/tools/visualstudioversioninfo.h @@ -43,6 +43,7 @@ #include "qbs_export.h" +#include <tools/porting.h> #include <tools/version.h> #include <QtCore/qstring.h> @@ -78,7 +79,7 @@ private: Version m_version; }; -quint32 qHash(const VisualStudioVersionInfo &info); +QHashValueType qHash(const VisualStudioVersionInfo &info); } // namespace Internal } // namespace qbs |