Skip to content

Commit

Permalink
cxx-qt-lib: workaround GCC bug for explicit specialisation outside na…
Browse files Browse the repository at this point in the history
…mespace

This works around issues such as below with MinGW81
specialization of 'template<class T> struct rust::cxxbridge1::IsRelocatable' in different namespace

Due to the following bug that was solved in GCC 7
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374

Related to KDAB#640
  • Loading branch information
ahayzen-kdab committed Jul 31, 2023
1 parent 7b7cc19 commit a5215f3
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 16 deletions.
8 changes: 7 additions & 1 deletion crates/cxx-qt-gen/include/cxxqt_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ cxxQtThreadQueue(const CxxQtThread<T>& cxxQtThread,
} // namespace cxxqtlib1
} // namespace rust

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<typename T>
struct rust::IsRelocatable<::rust::cxxqtlib1::CxxQtThread<T>> : ::std::true_type
struct IsRelocatable<::rust::cxxqtlib1::CxxQtThread<T>> : ::std::true_type
{
};

} // namespace rust
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qbytearray.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<QByteArray> : ::std::true_type
struct IsRelocatable<QByteArray> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {

Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qdatetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<QDateTime> : ::std::true_type
struct IsRelocatable<QDateTime> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {

Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

// This has static asserts in the cpp file to ensure this is valid.
template<typename K, typename V>
struct rust::IsRelocatable<QHash<K, V>> : ::std::true_type
struct IsRelocatable<QHash<K, V>> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {
namespace qhash {
Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include "qlist_qvector.h"
#else
// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

// This has static asserts in the cpp file to ensure this is valid.
template<typename T>
struct rust::IsRelocatable<QList<T>> : ::std::true_type
struct IsRelocatable<QList<T>> : ::std::true_type
{
};

} // namespace rust
#endif

namespace rust {
Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qlist_qvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

// This has static asserts in the cpp file to ensure this is valid.
template<typename T>
struct rust::IsRelocatable<QList<T>> : ::std::true_type
struct IsRelocatable<QList<T>> : ::std::true_type
{
};

} // namespace rust

#endif
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

// This has static asserts in the cpp file to ensure this is valid.
template<typename K, typename V>
struct rust::IsRelocatable<QMap<K, V>> : ::std::true_type
struct IsRelocatable<QMap<K, V>> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {
namespace qmap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<::QMetaObject::Connection> : ::std::true_type
struct IsRelocatable<::QMetaObject::Connection> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

// This has static asserts in the cpp file to ensure this is valid.
template<>
struct rust::IsRelocatable<QPersistentModelIndex> : ::std::true_type
struct IsRelocatable<QPersistentModelIndex> : ::std::true_type
{
};

} // namespace rust
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qset.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

// This has static asserts in the cpp file to ensure this is valid.
template<typename T>
struct rust::IsRelocatable<QSet<T>> : ::std::true_type
struct IsRelocatable<QSet<T>> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {
namespace qset {
Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<QString> : ::std::true_type
struct IsRelocatable<QString> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {

Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qstringlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<QStringList> : ::std::true_type
struct IsRelocatable<QStringList> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {

Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qurl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<QUrl> : ::std::true_type
struct IsRelocatable<QUrl> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {

Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qvariant.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@

#include "rust/cxx.h"

// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<QVariant> : ::std::true_type
struct IsRelocatable<QVariant> : ::std::true_type
{
};

} // namespace rust

namespace rust {
namespace cxxqtlib1 {
namespace qvariant {
Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/core/qvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#include "qlist_qvector.h"
#else
// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

// This has static asserts in the cpp file to ensure this is valid.
template<typename T>
struct rust::IsRelocatable<QVector<T>> : ::std::true_type
struct IsRelocatable<QVector<T>> : ::std::true_type
{
};

} // namespace rust
#endif

namespace rust {
Expand Down
8 changes: 7 additions & 1 deletion crates/cxx-qt-lib-headers/include/gui/qcolor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
// QColor still had copy & move constructors in Qt 5 but they were basically
// trivial.
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// Define namespace otherwise we hit a GCC bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
namespace rust {

template<>
struct rust::IsRelocatable<QColor> : ::std::true_type
struct IsRelocatable<QColor> : ::std::true_type
{
};

} // namespace rust
#endif

namespace rust {
Expand Down

0 comments on commit a5215f3

Please sign in to comment.