Skip to content
Merged
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
12 changes: 1 addition & 11 deletions cmd/genbindings/clang2il.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,6 @@ func processClassType(node *AstNode, addNamePrefix string) (CppClass, error) {
// We produce a type named 'Connection' instead of 'QMetaObject::Connection' as expected, not sure why
nodename = "QMetaObject::Connection"
}
if nodename == "QBrushData" {
// This is to prevent QBrushData from being deleted until
// the library is built against Qt 6.10+ and it is handled
// automatically
ret.CanDelete = false
}

ret.ClassName = nodename

log.Printf("-> Processing class %q...\n", nodename)
Expand Down Expand Up @@ -325,10 +318,7 @@ nextMethod:
}

// Check if this is `= delete`
// This is to prevent QBrushData from being deleted until
// the library is built against Qt 6.10+ and it is handled
// automatically
if isExplicitlyDeleted(node) || ret.ClassName == "QBrushData" {
if isExplicitlyDeleted(node) {
continue
}

Expand Down
52 changes: 21 additions & 31 deletions cmd/genbindings/config-allowlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,9 @@ func AllowClass(className string) bool {

switch className {
case
"QTextStreamManipulator", // Only seems to contain garbage methods
"QException", // Extends std::exception, too hard
"QUnhandledException", // As above (child class)
// "QItemSelection", // Extends a QList<>, too hard
"QTextStreamManipulator", // Only seems to contain garbage methods
"QException", // Extends std::exception, too hard
"QUnhandledException", // As above (child class)
"QXmlStreamAttributes", // Extends a QList<>, too hard
"QPolygon", // Extends a QVector<QPoint> template class, too hard
"QPolygonF", // Extends a QVector<QPoint> template class, too hard
Expand All @@ -200,9 +199,24 @@ func AllowClass(className string) bool {
"QWebEngineQuotaRequest", // Qt 6 QWebEngine: Deprecated in Qt 6.9

"QUntypedPropertyData::InheritsQUntypedPropertyData", // qpropertyprivate.h . Hidden/undocumented class in Qt 6.4, removed in 6.7
"QFlag", // Converted to int
"QIncompatibleFlag", // Converted to int
"QAtomicInt", // Unsupported base type
"QFlag", // Converted to int
"QIncompatibleFlag", // Converted to int
"QAtomicInt", // Unsupported base type
"QArrayData", // internal Qt classes that should not be projected
"QBrushData", // internal Qt classes that should not be projected
"QContiguousCacheData", // internal Qt classes that should not be projected
"QObjectData", // internal Qt classes that should not be projected
"QPluginMetaData", // internal Qt classes that should not be projected
"QPluginMetaData::ElfNoteHeader", // internal Qt classes that should not be projected
"QPluginMetaData::Header", // internal Qt classes that should not be projected
"QPluginMetaData::MagicHeader", // internal Qt classes that should not be projected
"QPropertyProxyBindingData", // internal Qt classes that should not be projected
"QTextFrameLayoutData", // internal Qt classes that should not be projected
"QThreadStorageData", // internal Qt classes that should not be projected
"QWidgetData", // internal Qt classes that should not be projected
"QDBusPendingReplyBase", // internal Qt classes that should not be projected
"Qt::Disambiguated_t", // internal Qt classes that should not be projected
"QInternal", // internal Qt classes that should not be projected
"____last____":
return false
}
Expand Down Expand Up @@ -264,11 +278,6 @@ func AllowVirtualForClass(className string) bool {
return false
}

// Pure virtual dtor (should be possible to support)
if className == "QObjectData" {
return false
}

if className == "QAccessibleObject" {
return false // undefined reference to `vtable for MiqtVirtualQAccessibleObject'
}
Expand Down Expand Up @@ -408,11 +417,6 @@ func AllowMethod(className string, mm CppMethod) error {
return ErrTooComplex
}

if className == "QBrushData" && mm.MethodName == "operator=" {
// Prevent operator= for QBrushData for Qt 6.10+
return ErrTooComplex
}

if className == "QJSEngine" && mm.MethodName == "handle" {
return ErrTooComplex // Not part of the interface
}
Expand Down Expand Up @@ -440,12 +444,6 @@ func AllowCtor(className string, mm CppMethod) bool {
return false
}

if className == "QBrushData" {
// Both the main ctor and the copy constructor were changed from public to protected in Qt 6.10
// @ref https://github.com/qt/qtbase/commit/3bbc9e29ef59683351cf35c19a8bd4a030615c64
return false
}

// Default allow
return true
}
Expand Down Expand Up @@ -713,14 +711,6 @@ func ApplyQuirks(packageName, className string, mm *CppMethod) {
mm.RequireGOOS = addr("linux")
}

if className == "QArrayData" && mm.MethodName == "needsDetach" && mm.IsConst {
mm.BecomesNonConstInVersion = addr("6.7")
}

if packageName == "qt6" && className == "QObjectData" && mm.MethodName == "dynamicMetaObject" {
mm.ReturnType.BecomesConstInVersion = addr("6.9")
}

// macOS Brew does not have Qt6Network dtls functionality enabled, but we
// want these functions to exist on other platforms
// Can't block in Go-side
Expand Down
12 changes: 0 additions & 12 deletions cmd/genbindings/emitcabi.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,18 +793,6 @@ 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" +
"#ifndef QT_VERSION_CHECK\n" +
"#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))\n" +
"#endif\n" +
"\n",
)
}

foundTypesList := getReferencedTypes(src)

ret.WriteString("#ifdef __cplusplus\n")
Expand Down
90 changes: 0 additions & 90 deletions qt/gen_qarraydata.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <QArrayData>
#include <qarraydata.h>
#include "gen_qarraydata.h"

Expand All @@ -10,92 +9,3 @@ extern "C" {
} /* extern C */
#endif

int QArrayData_size(const QArrayData* self) {
return self->size;
}

void QArrayData_setSize(QArrayData* self, int size) {
self->size = static_cast<int>(size);
}

unsigned int QArrayData_alloc(const QArrayData* self) {
uint alloc_ret = self->alloc;
return static_cast<unsigned int>(alloc_ret);
}

void QArrayData_setAlloc(QArrayData* self, unsigned int alloc) {
self->alloc = static_cast<uint>(alloc);
}

unsigned int QArrayData_capacityReserved(const QArrayData* self) {
uint capacityReserved_ret = self->capacityReserved;
return static_cast<unsigned int>(capacityReserved_ret);
}

void QArrayData_setCapacityReserved(QArrayData* self, unsigned int capacityReserved) {
self->capacityReserved = static_cast<uint>(capacityReserved);
}

intptr_t QArrayData_offset(const QArrayData* self) {
qptrdiff offset_ret = self->offset;
return static_cast<intptr_t>(offset_ret);
}

void QArrayData_setOffset(QArrayData* self, intptr_t offset) {
self->offset = static_cast<qptrdiff>(offset);
}

void* QArrayData_data(QArrayData* self) {
return self->data();
}

const void* QArrayData_data2(const QArrayData* self) {
return (const void*) self->data();
}

bool QArrayData_isMutable(const QArrayData* self) {
return self->isMutable();
}

size_t QArrayData_detachCapacity(const QArrayData* self, size_t newSize) {
return self->detachCapacity(static_cast<size_t>(newSize));
}

int QArrayData_detachFlags(const QArrayData* self) {
QArrayData::AllocationOptions _ret = self->detachFlags();
return static_cast<int>(_ret);
}

int QArrayData_cloneFlags(const QArrayData* self) {
QArrayData::AllocationOptions _ret = self->cloneFlags();
return static_cast<int>(_ret);
}

QArrayData* QArrayData_allocate(size_t objectSize, size_t alignment, size_t capacity) {
return QArrayData::allocate(static_cast<size_t>(objectSize), static_cast<size_t>(alignment), static_cast<size_t>(capacity));
}

QArrayData* QArrayData_reallocateUnaligned(QArrayData* data, size_t objectSize, size_t newCapacity) {
return QArrayData::reallocateUnaligned(data, static_cast<size_t>(objectSize), static_cast<size_t>(newCapacity));
}

void QArrayData_deallocate(QArrayData* data, size_t objectSize, size_t alignment) {
QArrayData::deallocate(data, static_cast<size_t>(objectSize), static_cast<size_t>(alignment));
}

QArrayData* QArrayData_sharedNull() {
return QArrayData::sharedNull();
}

QArrayData* QArrayData_allocate2(size_t objectSize, size_t alignment, size_t capacity, int options) {
return QArrayData::allocate(static_cast<size_t>(objectSize), static_cast<size_t>(alignment), static_cast<size_t>(capacity), static_cast<QArrayData::AllocationOptions>(options));
}

QArrayData* QArrayData_reallocateUnaligned2(QArrayData* data, size_t objectSize, size_t newCapacity, int newOptions) {
return QArrayData::reallocateUnaligned(data, static_cast<size_t>(objectSize), static_cast<size_t>(newCapacity), static_cast<QArrayData::AllocationOptions>(newOptions));
}

void QArrayData_delete(QArrayData* self) {
delete self;
}

131 changes: 0 additions & 131 deletions qt/gen_qarraydata.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ package qt
*/
import "C"

import (
"runtime"
"unsafe"
)

type QArrayData__AllocationOption int

const (
Expand All @@ -31,129 +26,3 @@ const (
QtPrivate__QContainerImplHelper__Full QtPrivate__QContainerImplHelper__CutResult = 2
QtPrivate__QContainerImplHelper__Subset QtPrivate__QContainerImplHelper__CutResult = 3
)

type QArrayData struct {
h *C.QArrayData
}

func (this *QArrayData) cPointer() *C.QArrayData {
if this == nil {
return nil
}
return this.h
}

func (this *QArrayData) UnsafePointer() unsafe.Pointer {
if this == nil {
return nil
}
return unsafe.Pointer(this.h)
}

// newQArrayData constructs the type using only CGO pointers.
func newQArrayData(h *C.QArrayData) *QArrayData {
if h == nil {
return nil
}

return &QArrayData{h: h}
}

// UnsafeNewQArrayData constructs the type using only unsafe pointers.
func UnsafeNewQArrayData(h unsafe.Pointer) *QArrayData {
return newQArrayData((*C.QArrayData)(h))
}

func (this *QArrayData) Size() int {
return (int)(C.QArrayData_size(this.h))
}

func (this *QArrayData) SetSize(size int) {
C.QArrayData_setSize(this.h, (C.int)(size))
}

func (this *QArrayData) Alloc() uint {
return (uint)(C.QArrayData_alloc(this.h))
}

func (this *QArrayData) SetAlloc(alloc uint) {
C.QArrayData_setAlloc(this.h, (C.uint)(alloc))
}

func (this *QArrayData) CapacityReserved() uint {
return (uint)(C.QArrayData_capacityReserved(this.h))
}

func (this *QArrayData) SetCapacityReserved(capacityReserved uint) {
C.QArrayData_setCapacityReserved(this.h, (C.uint)(capacityReserved))
}

func (this *QArrayData) Offset() uintptr {
return (uintptr)(C.QArrayData_offset(this.h))
}

func (this *QArrayData) SetOffset(offset uintptr) {
C.QArrayData_setOffset(this.h, (C.intptr_t)(offset))
}

func (this *QArrayData) Data() unsafe.Pointer {
return (unsafe.Pointer)(C.QArrayData_data(this.h))
}

func (this *QArrayData) Data2() unsafe.Pointer {
return (unsafe.Pointer)(C.QArrayData_data2(this.h))
}

func (this *QArrayData) IsMutable() bool {
return (bool)(C.QArrayData_isMutable(this.h))
}

func (this *QArrayData) DetachCapacity(newSize uint64) uint64 {
return (uint64)(C.QArrayData_detachCapacity(this.h, (C.size_t)(newSize)))
}

func (this *QArrayData) DetachFlags() QArrayData__AllocationOption {
return (QArrayData__AllocationOption)(C.QArrayData_detachFlags(this.h))
}

func (this *QArrayData) CloneFlags() QArrayData__AllocationOption {
return (QArrayData__AllocationOption)(C.QArrayData_cloneFlags(this.h))
}

func QArrayData_Allocate(objectSize uint64, alignment uint64, capacity uint64) *QArrayData {
return newQArrayData(C.QArrayData_allocate((C.size_t)(objectSize), (C.size_t)(alignment), (C.size_t)(capacity)))
}

func QArrayData_ReallocateUnaligned(data *QArrayData, objectSize uint64, newCapacity uint64) *QArrayData {
return newQArrayData(C.QArrayData_reallocateUnaligned(data.cPointer(), (C.size_t)(objectSize), (C.size_t)(newCapacity)))
}

func QArrayData_Deallocate(data *QArrayData, objectSize uint64, alignment uint64) {
C.QArrayData_deallocate(data.cPointer(), (C.size_t)(objectSize), (C.size_t)(alignment))
}

func QArrayData_SharedNull() *QArrayData {
return newQArrayData(C.QArrayData_sharedNull())
}

func QArrayData_Allocate2(objectSize uint64, alignment uint64, capacity uint64, options QArrayData__AllocationOption) *QArrayData {
return newQArrayData(C.QArrayData_allocate2((C.size_t)(objectSize), (C.size_t)(alignment), (C.size_t)(capacity), (C.int)(options)))
}

func QArrayData_ReallocateUnaligned2(data *QArrayData, objectSize uint64, newCapacity uint64, newOptions QArrayData__AllocationOption) *QArrayData {
return newQArrayData(C.QArrayData_reallocateUnaligned2(data.cPointer(), (C.size_t)(objectSize), (C.size_t)(newCapacity), (C.int)(newOptions)))
}

// Delete this object from C++ memory.
func (this *QArrayData) Delete() {
C.QArrayData_delete(this.h)
}

// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
// from C++ memory once it is unreachable from Go memory.
func (this *QArrayData) GoGC() {
runtime.SetFinalizer(this, func(this *QArrayData) {
this.Delete()
runtime.KeepAlive(this.h)
})
}
Loading