mirror of
https://github.com/mappu/miqt.git
synced 2025-04-28 16:10:21 +00:00
Merge pull request #195 from rcalixte/qt69_const
Qt 6.9: Return type for QObjectData_dynamicMetaObject is now const
This commit is contained in:
commit
c2e299d381
@ -651,6 +651,10 @@ func ApplyQuirks(className string, mm *CppMethod) {
|
|||||||
mm.BecomesNonConstInVersion = addr("6.7")
|
mm.BecomesNonConstInVersion = addr("6.7")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if className == "QObjectData" && mm.MethodName == "dynamicMetaObject" {
|
||||||
|
mm.ReturnType.BecomesConstInVersion = addr("6.9")
|
||||||
|
}
|
||||||
|
|
||||||
if className == "QFileDialog" && mm.MethodName == "saveFileContent" && mm.IsStatic {
|
if className == "QFileDialog" && mm.MethodName == "saveFileContent" && mm.IsStatic {
|
||||||
// The prototype was changed from
|
// The prototype was changed from
|
||||||
// [Qt 5 - 6.6] void QFileDialog::saveFileContent(const QByteArray &fileContent, const QString &fileNameHint = QString())
|
// [Qt 5 - 6.6] void QFileDialog::saveFileContent(const QByteArray &fileContent, const QString &fileNameHint = QString())
|
||||||
|
@ -790,6 +790,14 @@ extern "C" {
|
|||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
// We need this macro for QObjectData::dynamicMetaObject for Qt 6.9
|
||||||
|
if filename == "qobject.h" && packageName == "qt6" {
|
||||||
|
ret.WriteString("// Based on the macro from Qt (LGPL v3), see https://www.qt.io/qt-licensing\n" +
|
||||||
|
"// Macro is trivial and used here under fair use\n" +
|
||||||
|
"// Usage does not imply derivation\n" +
|
||||||
|
"#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))\n\n")
|
||||||
|
}
|
||||||
|
|
||||||
foundTypesList := getReferencedTypes(src)
|
foundTypesList := getReferencedTypes(src)
|
||||||
|
|
||||||
ret.WriteString("#ifdef __cplusplus\n")
|
ret.WriteString("#ifdef __cplusplus\n")
|
||||||
@ -852,7 +860,16 @@ extern "C" {
|
|||||||
continue // Can't call directly, have to go through our wrapper
|
continue // Can't call directly, have to go through our wrapper
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.WriteString(fmt.Sprintf("%s %s(%s);\n", m.ReturnType.RenderTypeCabi(), cabiMethodName(c, m), emitParametersCabi(m, ifv(m.IsConst, "const ", "")+className+"*")))
|
if m.ReturnType.BecomesConstInVersion != nil && packageName == "qt6" {
|
||||||
|
ret.WriteString(fmt.Sprintf("// This method's return type was changed from non-const to const in Qt "+*m.ReturnType.BecomesConstInVersion) + "\n" +
|
||||||
|
"#if QT_VERSION >= QT_VERSION_CHECK(" + strings.Replace(*m.ReturnType.BecomesConstInVersion, `.`, `,`, -1) + ",0)\n" +
|
||||||
|
fmt.Sprintf("%s %s(%s);\n", "const "+m.ReturnType.RenderTypeCabi(), cabiMethodName(c, m), emitParametersCabi(m, ifv(m.IsConst, "const ", "")+className+"*")) +
|
||||||
|
"#else\n" +
|
||||||
|
fmt.Sprintf("%s %s(%s);\n", m.ReturnType.RenderTypeCabi(), cabiMethodName(c, m), emitParametersCabi(m, ifv(m.IsConst, "const ", "")+className+"*")) +
|
||||||
|
"#endif\n")
|
||||||
|
} else {
|
||||||
|
ret.WriteString(fmt.Sprintf("%s %s(%s);\n", m.ReturnType.RenderTypeCabi(), cabiMethodName(c, m), emitParametersCabi(m, ifv(m.IsConst, "const ", "")+className+"*")))
|
||||||
|
}
|
||||||
|
|
||||||
if m.IsSignal {
|
if m.IsSignal {
|
||||||
ret.WriteString(fmt.Sprintf("%s %s(%s* self, intptr_t slot);\n", m.ReturnType.RenderTypeCabi(), cabiConnectName(c, m), className))
|
ret.WriteString(fmt.Sprintf("%s %s(%s* self, intptr_t slot);\n", m.ReturnType.RenderTypeCabi(), cabiConnectName(c, m), className))
|
||||||
@ -1249,6 +1266,20 @@ extern "C" {
|
|||||||
"\n",
|
"\n",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
} else if m.ReturnType.BecomesConstInVersion != nil && strings.Contains(src.Filename, "qt6") {
|
||||||
|
|
||||||
|
ret.WriteString("" +
|
||||||
|
"// This method's return type was changed from non-const to const in Qt " + *m.ReturnType.BecomesConstInVersion + "\n" +
|
||||||
|
"#if QT_VERSION >= QT_VERSION_CHECK(" + strings.Replace(*m.ReturnType.BecomesConstInVersion, `.`, `,`, -1) + ",0)\n" +
|
||||||
|
"const " + m.ReturnType.RenderTypeCabi() + " " + methodPrefixName + "_" + m.SafeMethodName() + "(" + emitParametersCabi(m, ifv(m.IsConst, "const ", "")+methodPrefixName+"*") + ") {\n" +
|
||||||
|
"#else\n" +
|
||||||
|
m.ReturnType.RenderTypeCabi() + " " + methodPrefixName + "_" + m.SafeMethodName() + "(" + emitParametersCabi(m, ifv(m.IsConst, "const ", "")+methodPrefixName+"*") + ") {\n" +
|
||||||
|
"#endif\n" +
|
||||||
|
preamble + "\n" +
|
||||||
|
emitAssignCppToCabi("\treturn ", m.ReturnType, callTarget) +
|
||||||
|
"}\n\n",
|
||||||
|
)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
ret.WriteString(fmt.Sprintf(
|
ret.WriteString(fmt.Sprintf(
|
||||||
|
@ -16,7 +16,8 @@ type CppParameter struct {
|
|||||||
Optional bool
|
Optional bool
|
||||||
NoExcept bool
|
NoExcept bool
|
||||||
|
|
||||||
QtCppOriginalType *CppParameter // If we rewrote QStringList->QList<String>, this field contains the original QStringList. Otherwise, it's blank
|
QtCppOriginalType *CppParameter // If we rewrote QStringList->QList<String>, this field contains the original QStringList. Otherwise, it's blank
|
||||||
|
BecomesConstInVersion *string // "6,9"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p CppParameter) String() string {
|
func (p CppParameter) String() string {
|
||||||
|
@ -36,7 +36,13 @@ void miqt_exec_callback_QObject_disconnectNotify(QObject*, intptr_t, QMetaMethod
|
|||||||
} /* extern C */
|
} /* extern C */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This method's return type was changed from non-const to const in Qt 6.9
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6,9,0)
|
||||||
|
const QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self) {
|
||||||
|
#else
|
||||||
QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self) {
|
QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self) {
|
||||||
|
#endif
|
||||||
|
|
||||||
return self->dynamicMetaObject();
|
return self->dynamicMetaObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Based on the macro from Qt (LGPL v3), see https://www.qt.io/qt-licensing
|
||||||
|
// Macro is trivial and used here under fair use
|
||||||
|
// Usage does not imply derivation
|
||||||
|
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
class QAnyStringView;
|
class QAnyStringView;
|
||||||
class QBindingStorage;
|
class QBindingStorage;
|
||||||
@ -48,7 +53,12 @@ typedef struct QTimerEvent QTimerEvent;
|
|||||||
typedef struct QVariant QVariant;
|
typedef struct QVariant QVariant;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// This method's return type was changed from non-const to const in Qt 6.9
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6,9,0)
|
||||||
|
const QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self);
|
||||||
|
#else
|
||||||
QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self);
|
QMetaObject* QObjectData_dynamicMetaObject(const QObjectData* self);
|
||||||
|
#endif
|
||||||
void QObjectData_delete(QObjectData* self);
|
void QObjectData_delete(QObjectData* self);
|
||||||
|
|
||||||
QObject* QObject_new();
|
QObject* QObject_new();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user