From d6ea4ccf806aa477440d9304ea5a8de817f43e50 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 18 Aug 2024 19:02:43 +1200 Subject: [PATCH] genbindings: many more exceptions --- cmd/genbindings/clang2il.go | 13 ++++++++++++- cmd/genbindings/exceptions.go | 14 +++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/cmd/genbindings/clang2il.go b/cmd/genbindings/clang2il.go index bf3147c..5a6214e 100644 --- a/cmd/genbindings/clang2il.go +++ b/cmd/genbindings/clang2il.go @@ -282,6 +282,17 @@ nextMethod: return CppClass{}, err } + for _, p := range mm.Parameters { + if strings.HasSuffix(p.ParameterType, "Private") { + log.Printf("Skipping method %q taking Private type", mm.MethodName) + continue nextMethod + } + } + if strings.HasSuffix(mm.ReturnType.ParameterType, "Private") { + log.Printf("Skipping method %q returning Private type", mm.MethodName) + continue nextMethod + } + mm.IsSignal = isSignal && !mm.IsStatic && mm.MethodName != `metaObject` if mm.IsReceiverMethod() { @@ -466,7 +477,7 @@ func parseSingleTypeString(p string) CppParameter { insert.ParameterType += " uintptr_t" } else if tok == "QStringList" { insert.ParameterType += " QList" - } else if len(tok) > 4 && strings.HasSuffix(tok, "List") { + } else if len(tok) > 4 && strings.HasSuffix(tok, "List") && tok != "QTextList" { // Typedef e.g. QObjectList // QObjectList is a pointer, but QStringList is a whole custom class insert.ParameterType += " QList<" + tok[0:len(tok)-4] + " *>" diff --git a/cmd/genbindings/exceptions.go b/cmd/genbindings/exceptions.go index cad1f2f..6fef98a 100644 --- a/cmd/genbindings/exceptions.go +++ b/cmd/genbindings/exceptions.go @@ -6,7 +6,11 @@ import ( func AllowDelete(c CppClass) bool { switch c.ClassName { - case "QClipboard": + case "QClipboard", + "QSessionManager", + "QTextObject", + "QTextBlockGroup", + "QInputMethod": return false // The destructor is marked private. TODO grab this from the AST } return true @@ -52,15 +56,23 @@ func CheckComplexity(p CppParameter) error { case "QList", // e.g. QVariant constructor - this has a deleted copy-constructor so we can't get it over the CABI boundary by value "QPolygon", "QPolygonF", // QPolygon extends a template type + "QGenericMatrix", "QMatrix3x3", // extends a template type "QLatin1String", "QStringView", // e.g. QColor constructors and QColor::SetNamedColor() overloads. These are usually optional alternatives to QString + "QStringRef", // e.g. QLocale::toLongLong and similar overloads. As above "QGradientStop", "QGradientStops", // QPair<>-related types, but we can't see through the typedef to block based on QPair alone "void **", // e.g. qobjectdefs.h QMetaObject->Activate() + "QGraphicsItem **", // e.g. QGraphicsItem::IsBlockedByModalPanel() overload "char *&", // e.g. QDataStream.operator<<() "qfloat16", // e.g. QDataStream - there is no such half-float type in C or Go "char16_t", // e.g. QChar() constructor overload, just unnecessary "picture_io_handler", // e.g. QPictureIO::DefineIOHandler callback function "QPlatformNativeInterface", // e.g. QGuiApplication::platformNativeInterface(). Private type, could probably expose as uintptr. n.b. Changes in Qt6 "QFunctionPointer", // e.g. QGuiApplication_PlatformFunction + "QGraphicsEffectSource", // e.g. used by qgraphicseffect.h, but the definition is in ???? + "QAbstractUndoItem", // e.g. Defined in qtextdocument.h + "QPlatformPixmap", // e.g. qpixmap.h. as below + "QPlatformScreen", // e.g. qscreen.h. as below + "QPlatformSurface", // e.g. qsurface.h. as below "QPlatformMenu": // e.g. QMenu_PlatformMenu. Defined in the QPA, could probably expose as uintptr return ErrTooComplex }