Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt6 fixes (generator code) #113

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build/common.prf
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ PYTHONQT_GENERATED_PATH = $$PWD/../generated_cpp
}

VERSION = 3.2.0
greaterThan(QT_MAJOR_VERSION, 5) | greaterThan(QT_MINOR_VERSION, 9): CONFIG += c++11
win32: CONFIG += skip_target_version_ext
gcc|win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -Wuninitialized -Winit-self -ansi -pedantic
gcc|win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -Wuninitialized -Winit-self -pedantic
win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-unused-command-line-argument
#Do not issue warning to system includes
gcc:!isEmpty(QT_INSTALL_HEADERS): QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_HEADERS]
6 changes: 3 additions & 3 deletions generator/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Generator::generate()
return;
}

qStableSort(m_classes);
std::stable_sort(m_classes.begin(), m_classes.end());

foreach (AbstractMetaClass *cls, m_classes) {
if (!shouldGenerate(cls))
Expand All @@ -85,13 +85,13 @@ void Generator::printClasses()
QTextStream s(stdout);

AbstractMetaClassList classes = m_classes;
qSort(classes);
std::sort(classes.begin(), classes.end());

foreach (AbstractMetaClass *cls, classes) {
if (!shouldGenerate(cls))
continue;
write(s, cls);
s << endl << endl;
s << Qt::endl << Qt::endl;
}
}

Expand Down
4 changes: 2 additions & 2 deletions generator/generator.pri
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include($$GENERATORPATH/parser/rxx.pri)

include($$GENERATORPATH/parser/rpp/rpp.pri)

CONFIG += strict_c++ c++11
CONFIG += strict_c++
win32-msvc*{
#Disable warning C4996 (deprecated declarations)
QMAKE_CXXFLAGS += -wd4996
Expand All @@ -27,7 +27,7 @@ win32-msvc*{
}
#Do not issue warning to Qt's system includes
gcc:!isEmpty(QT_INSTALL_HEADERS): QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_HEADERS]
gcc|win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -pedantic -ansi -Winit-self -Wuninitialized
gcc|win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-deprecated-declarations -pedantic -Winit-self -Wuninitialized
clang|win32-clang-msvc: QMAKE_CXXFLAGS += -Wno-nested-anon-types -Wno-gnu-anonymous-struct -Wno-unused-private-field
win32-clang-msvc:QMAKE_CXXFLAGS += -Wno-language-extension-token -Wno-microsoft-enum-value

Expand Down
3 changes: 2 additions & 1 deletion generator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ int main(int argc, char *argv[])
FileOut::license = true;

if (args.contains("rebuild-only")) {
QStringList classes = args.value("rebuild-only").split(",", QString::SkipEmptyParts);
QStringList classes = args.value("rebuild-only").split(
",", TypeDatabase::skipEmptyParts);
TypeDatabase::instance()->setRebuildClasses(classes);
}

Expand Down
2 changes: 1 addition & 1 deletion generator/parser/codemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ QString TypeInfo::toString() const
return tmp;
}

bool TypeInfo::operator==(const TypeInfo &other)
bool TypeInfo::operator==(const TypeInfo &other) const
{
if (arrayElements().count() != other.arrayElements().count())
return false;
Expand Down
16 changes: 12 additions & 4 deletions generator/parser/codemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ struct TypeInfo
void setArguments(const QList<TypeInfo> &arguments);
void addArgument(const TypeInfo &arg) { m_arguments.append(arg); }

bool operator==(const TypeInfo &other);
bool operator!=(const TypeInfo &other) { return !(*this==other); }
bool operator==(const TypeInfo &other) const;
bool operator!=(const TypeInfo &other) const { return !(*this==other); }

// ### arrays and templates??

Expand All @@ -171,7 +171,7 @@ struct TypeInfo
uint m_reference: 1;
uint m_functionPointer: 1;
uint m_indirections: 6;
inline bool equals(TypeInfo_flags other) {
inline bool equals(TypeInfo_flags other) const {
return m_constant == other.m_constant
&& m_volatile == other.m_volatile
&& m_reference == other.m_reference
Expand Down Expand Up @@ -501,7 +501,10 @@ class _MemberModelItem: public _CodeModelItem
CodeModel::AccessPolicy _M_accessPolicy;
union
{
struct
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
/* This is an anonymous struct, not allowed in C++ (it works in G++): */
struct
{
uint _M_isConstant: 1;
uint _M_isVolatile: 1;
Expand All @@ -512,6 +515,7 @@ class _MemberModelItem: public _CodeModelItem
uint _M_isExtern: 1;
uint _M_isMutable: 1;
};
#pragma GCC diagnostic pop
uint _M_flags;
};

Expand Down Expand Up @@ -569,6 +573,9 @@ class _FunctionModelItem: public _MemberModelItem
QString _M_exception;
union
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
/* This is an anonymous struct, not allowed in C++ (it works in G++): */
struct
{
uint _M_isVirtual: 1;
Expand All @@ -578,6 +585,7 @@ class _FunctionModelItem: public _MemberModelItem
uint _M_isVariadics: 1;
uint _M_isInvokable : 1; // Qt
};
#pragma GCC diagnostic pop
uint _M_flags;
};

Expand Down
8 changes: 4 additions & 4 deletions generator/parser/codemodel_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ template <class T> class CodeModelPointer

# if QT_VERSION >= 0x050000
operator T * () const {
return QAtomicPointer<T>::load();
return QAtomicPointer<T>::loadRelaxed();
}
inline bool operator!() const { return !(bool)*this; }
operator bool () const {
return (bool)QAtomicPointer<T>::load();
return (bool)QAtomicPointer<T>::loadRelaxed();
}

inline T *operator->() { return QAtomicPointer<T>::load(); }
inline const T *operator->() const { return QAtomicPointer<T>::load(); }
inline T *operator->() { return QAtomicPointer<T>::loadRelaxed(); }
inline const T *operator->() const { return QAtomicPointer<T>::loadRelaxed(); }
inline bool operator==(const CodeModelPointer<T> &other) const { return (T*)*this == (T*)other; }
inline bool operator!=(const CodeModelPointer<T> &other) const { return (T*)*this != (T*)other; }
inline bool operator==(const T *ptr) const { return (T*)*this == ptr; }
Expand Down
1 change: 0 additions & 1 deletion generator/parser/compiler_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "codemodel.h"

class QString;
class QStringList;
struct TypeSpecifierAST;
struct DeclaratorAST;
class TokenStream;
Expand Down
4 changes: 4 additions & 0 deletions generator/parser/rpp/pp-macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,16 @@ struct pp_macro
{
int unsigned state;

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
/* This is an anonymous struct, not allowed in C++ (it works in G++): */
struct
{
int unsigned hidden: 1;
int unsigned function_like: 1;
int unsigned variadics: 1;
};
#pragma GCC diagnostic pop
};

int lines;
Expand Down
2 changes: 1 addition & 1 deletion generator/setupgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static QStringList getOperatorCodes(const AbstractMetaClass* cls) {
CodeSnipList code_snips = cls->typeEntry()->codeSnips();
for (const CodeSnip &cs : code_snips) {
if (cs.language == TypeSystem::PyWrapperOperators) {
QStringList values = cs.code().split(" ", QString::SkipEmptyParts);
QStringList values = cs.code().split(" ", TypeDatabase::skipEmptyParts);
for (QString value : values) {
r.insert(value);
}
Expand Down
14 changes: 7 additions & 7 deletions generator/typesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ QString formattedCodeHelper(QTextStream &s, Indentor &indentor, QStringList &lin
const QString line = lines.takeFirst().trimmed();
if (line.isEmpty()) {
if (!lastEmpty)
s << endl;
s << Qt::endl;
lastEmpty = true;
continue;
} else {
Expand All @@ -1781,23 +1781,23 @@ QString formattedCodeHelper(QTextStream &s, Indentor &indentor, QStringList &lin
s << indentor;
if (line.startsWith("*"))
s << " ";
s << line << endl;
s << line << Qt::endl;
if (line.endsWith("*/"))
multilineComment = false;
} else if (line.startsWith("}")) {
return line;
} else if (line.endsWith("}")) {
s << indentor << line << endl;
s << indentor << line << Qt::endl;
return 0;
} else if(line.endsWith("{")) {
s << indentor << line << endl;
s << indentor << line << Qt::endl;
QString tmp;
{
Indentation indent(indentor);
tmp = formattedCodeHelper(s, indentor, lines);
}
if (!tmp.isNull()) {
s << indentor << tmp << endl;
s << indentor << tmp << Qt::endl;
}
lastLine = tmp;
continue;
Expand All @@ -1811,7 +1811,7 @@ QString formattedCodeHelper(QTextStream &s, Indentor &indentor, QStringList &lin
!lastLine.endsWith("}") &&
!line.startsWith("{"))
s << " ";
s << line << endl;
s << line << Qt::endl;
}
lastLine = line;
}
Expand All @@ -1825,7 +1825,7 @@ QTextStream &CodeSnip::formattedCode(QTextStream &s, Indentor &indentor) const
while (!lst.isEmpty()) {
QString tmp = formattedCodeHelper(s, indentor, lst);
if (!tmp.isNull()) {
s << indentor << tmp << endl;
s << indentor << tmp << Qt::endl;
}
}
s.flush();
Expand Down
15 changes: 14 additions & 1 deletion generator/typesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,18 @@ class TypeDatabase
m_suppressedWarnings.append(s);
}

/* QString::SkipEmptyParts was moved to Qt::SplitBehavior in 15.4 and the
* QString original as deprecated then it was removed in Qt6. This
* provides compatibility with versions of Qt prior to 15.4:
*/
# if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
static const constexpr Qt::SplitBehavior skipEmptyParts =
Qt::SkipEmptyParts;
# else
static const constexpr QString::SplitBehavior skipEmptyParts =
QString::SkipEmptyParts;
# endif

bool isSuppressedWarning(const QString &s)
{
if (!m_suppressWarnings)
Expand All @@ -1159,7 +1171,8 @@ class TypeDatabase
foreach (const QString &_warning, m_suppressedWarnings) {
QString warning(QString(_warning).replace("\\*", "&place_holder_for_asterisk;"));

QStringList segs = warning.split("*", QString::SkipEmptyParts);
QStringList segs = warning.split("*", skipEmptyParts);

if (segs.size() == 0)
continue ;

Expand Down
2 changes: 0 additions & 2 deletions src/src.pri
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ DEFINES += PYTHONQT_EXPORTS

INCLUDEPATH += $$PWD

CONFIG += c++11

gcc:!no_warn:!clang:QMAKE_CXXFLAGS += -Wno-error=missing-field-initializers
*-clang*:!no_warn:QMAKE_CXXFLAGS += -Wno-error=sometimes-uninitialized

Expand Down
2 changes: 1 addition & 1 deletion tests/tests.pro
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mingw: TEST_TARGET_DIR = .

DEFINES += QT_NO_CAST_TO_ASCII

gcc: QMAKE_CXXFLAGS += -pedantic -ansi -Winit-self -Wuninitialized
gcc: QMAKE_CXXFLAGS += -pedantic -Winit-self -Wuninitialized

QT += widgets

Expand Down