From 3b65e1fc6f35fb4a74fe09035ce162e0e4b9ab82 Mon Sep 17 00:00:00 2001 From: mappu Date: Thu, 29 Aug 2024 17:38:34 +1200 Subject: [PATCH] genbindings: more exceptions, merge existing exceptions --- cmd/genbindings/clang2il.go | 18 ------------------ cmd/genbindings/exceptions.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/cmd/genbindings/clang2il.go b/cmd/genbindings/clang2il.go index 2244d2b..8092db0 100644 --- a/cmd/genbindings/clang2il.go +++ b/cmd/genbindings/clang2il.go @@ -347,24 +347,6 @@ nextMethod: // an existing class instance mm.IsStatic = true - // Some QFoo constructors take a QFooPrivate - for _, p := range mm.Parameters { - if strings.Contains(p.ParameterType, "Private") { - log.Printf("Skipping constructor taking Private type") - continue nextMethod - } - } - - if ret.ClassName == "QDebug" && len(mm.Parameters) == 1 && mm.Parameters[0].ParameterType == "QString" && mm.Parameters[0].Pointer { - log.Printf("Skipping ctor taking QString pointer") - continue nextMethod - } - - if ret.ClassName == "QXmlStreamWriter" && len(mm.Parameters) == 1 && mm.Parameters[0].ParameterType == "QString" && mm.Parameters[0].Pointer { - log.Printf("Skipping ctor taking QString pointer") // qxmlstream.h 4th constructor overload - continue nextMethod - } - ret.Ctors = append(ret.Ctors, mm) case "CXXDestructorDecl": diff --git a/cmd/genbindings/exceptions.go b/cmd/genbindings/exceptions.go index 57ad162..6b5ce35 100644 --- a/cmd/genbindings/exceptions.go +++ b/cmd/genbindings/exceptions.go @@ -126,7 +126,14 @@ func CheckComplexity(p CppParameter, isReturnType bool) error { return ErrTooComplex // e.g. QAbstractItemModel::QPrivateSignal } + // Some QFoo constructors take a QFooPrivate + if p.ParameterType[0] == 'Q' && strings.HasSuffix(p.ParameterType, "Private") && !isReturnType { + return ErrTooComplex + } + // If any parameters are QString*, skip the method + // QDebug constructor + // QXmlStreamWriter constructor // QFile::moveToTrash // QLockFile::getLockInfo // QTextDecoder::toUnicode @@ -159,6 +166,9 @@ func CheckComplexity(p CppParameter, isReturnType bool) error { "char16_t", // e.g. QChar() constructor overload, just unnecessary "char32_t", // e.g. QDebug().operator<< overload, unnecessary "wchar_t", // e.g. qstringview.h overloads, unnecessary + "QStringView::const_pointer", // e.g. qstringview.h data() + "QStringView::const_iterator", // e.g. qstringview.h + "QStringView::value_type", // e.g. qstringview.h "FILE", // e.g. qfile.h constructors "qInternalCallback", // e.g. qnamespace.h "picture_io_handler", // e.g. QPictureIO::DefineIOHandler callback function