aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-06 16:45:56 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-05-06 18:32:40 +0200
commit514d5fda1909370e90b20b937b91463512f8d9af (patch)
tree5a632a41489e282455bd02d452a7b3f7e33095f3
parentc782714ad3e47b8a74342c95d64b69b6dd4cc270 (diff)
shiboken: Prepare code for building against Qt 6
Remove deprecated std function base classes which are no longer available in higher language levels. Adapt to changed hash type in Qt 6. Task-number: PYSIDE-904 Change-Id: I858b4386fa0e974650721c11aa940e77cf14deb2 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp8
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangutils.h5
-rw-r--r--sources/shiboken2/ApiExtractor/include.cpp2
-rw-r--r--sources/shiboken2/ApiExtractor/include.h6
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.cpp7
-rw-r--r--sources/shiboken2/ApiExtractor/qtcompat.h40
6 files changed, 55 insertions, 13 deletions
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp
index 8bee28cdf..df2476100 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.cpp
@@ -40,7 +40,7 @@ bool operator==(const CXCursor &c1, const CXCursor &c2)
&& std::equal(c1.data, c1.data + sizeof(c1.data) / sizeof(c1.data[0]), c2.data);
}
-uint qHash(const CXCursor &c, uint seed)
+QtCompatHashFunctionType qHash(const CXCursor &c, QtCompatHashFunctionType seed)
{
return qHash(c.kind) ^ qHash(c.xdata) ^ qHash(c.data[0])
^ qHash(c.data[1]) ^ qHash(c.data[2]) ^ seed;
@@ -52,10 +52,10 @@ bool operator==(const CXType &t1, const CXType &t2)
&& t1.data[1] == t2.data[1];
}
-uint qHash(const CXType &ct, uint seed)
+QtCompatHashFunctionType qHash(const CXType &ct, QtCompatHashFunctionType seed)
{
- return uint(ct.kind) ^ uint(0xFFFFFFFF & quintptr(ct.data[0]))
- ^ uint(0xFFFFFFFF & quintptr(ct.data[1])) ^ seed;
+ return QtCompatHashFunctionType(ct.kind) ^ QtCompatHashFunctionType(0xFFFFFFFF & quintptr(ct.data[0]))
+ ^ QtCompatHashFunctionType(0xFFFFFFFF & quintptr(ct.data[1])) ^ seed;
}
namespace clang {
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
index 738b51bb4..5f005bd5d 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangutils.h
@@ -30,6 +30,7 @@
#define CLANGUTILS_H
#include <clang-c/Index.h>
+#include <qtcompat.h>
#include <QtCore/QPair>
#include <QtCore/QString>
#include <QtCore/QStringList>
@@ -40,10 +41,10 @@
QT_FORWARD_DECLARE_CLASS(QDebug)
bool operator==(const CXCursor &c1, const CXCursor &c2);
-uint qHash(const CXCursor &c, uint seed = 0);
+QtCompatHashFunctionType qHash(const CXCursor &c, QtCompatHashFunctionType seed = 0);
bool operator==(const CXType &t1, const CXType &t2);
-uint qHash(const CXType &ct, uint seed);
+QtCompatHashFunctionType qHash(const CXType &ct, QtCompatHashFunctionType seed);
namespace clang {
diff --git a/sources/shiboken2/ApiExtractor/include.cpp b/sources/shiboken2/ApiExtractor/include.cpp
index 82cb1d95b..6c2cce3a9 100644
--- a/sources/shiboken2/ApiExtractor/include.cpp
+++ b/sources/shiboken2/ApiExtractor/include.cpp
@@ -41,7 +41,7 @@ QString Include::toString() const
return QLatin1String("import ") + m_name + QLatin1Char(';');
}
-uint qHash(const Include& inc)
+QtCompatHashFunctionType qHash(const Include& inc)
{
return qHash(inc.m_name);
}
diff --git a/sources/shiboken2/ApiExtractor/include.h b/sources/shiboken2/ApiExtractor/include.h
index f7dfea5a7..2219fba55 100644
--- a/sources/shiboken2/ApiExtractor/include.h
+++ b/sources/shiboken2/ApiExtractor/include.h
@@ -29,6 +29,8 @@
#ifndef INCLUDE_H
#define INCLUDE_H
+#include <qtcompat.h>
+
#include <QString>
#include <QVector>
@@ -76,13 +78,13 @@ public:
return m_type == other.m_type && m_name == other.m_name;
}
- friend uint qHash(const Include&);
+ friend QtCompatHashFunctionType qHash(const Include&);
private:
IncludeType m_type = IncludePath;
QString m_name;
};
-uint qHash(const Include& inc);
+QtCompatHashFunctionType qHash(const Include& inc);
QTextStream& operator<<(QTextStream& out, const Include& include);
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const Include &i);
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
index 4a69948da..a33887836 100644
--- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
@@ -40,7 +40,7 @@
#include <QtCore/QStack>
// Predicate to find an item by name in a list of QSharedPointer<Item>
-template <class T> class ModelItemNamePredicate : public std::unary_function<bool, QSharedPointer<T> >
+template <class T> class ModelItemNamePredicate
{
public:
explicit ModelItemNamePredicate(const QString &name) : m_name(name) {}
@@ -196,8 +196,7 @@ TypeInfo TypeInfo::resolveType(CodeModelItem __item, TypeInfo const &__type, con
// Handler for clang::parseTemplateArgumentList() that populates
// TypeInfo::m_instantiations
-class TypeInfoTemplateArgumentHandler :
- public std::binary_function<void, int, const QStringRef &>
+class TypeInfoTemplateArgumentHandler
{
public:
explicit TypeInfoTemplateArgumentHandler(TypeInfo *t)
@@ -872,7 +871,7 @@ namespace {
// Predicate to match a non-template class name against the class list.
// "Vector" should match "Vector" as well as "Vector<T>" (as seen for methods
// from within the class "Vector").
-class ClassNamePredicate : public std::unary_function<bool, ClassModelItem>
+class ClassNamePredicate
{
public:
explicit ClassNamePredicate(const QString &name) : m_name(name) {}
diff --git a/sources/shiboken2/ApiExtractor/qtcompat.h b/sources/shiboken2/ApiExtractor/qtcompat.h
new file mode 100644
index 000000000..89a1db008
--- /dev/null
+++ b/sources/shiboken2/ApiExtractor/qtcompat.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt for Python.
+**
+** $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 QTCOMPAT_H
+#define QTCOMPAT_H
+
+#include <QtCore/QtGlobal>
+
+#if QT_VERSION >= 0x060000
+using QtCompatHashFunctionType = size_t;
+#else
+using QtCompatHashFunctionType = uint;
+#endif
+
+#endif // QTCOMPAT_H