genbindings: more exceptions

This commit is contained in:
mappu 2024-08-20 20:19:15 +12:00
parent 7e78b73517
commit 306abe1fb6
2 changed files with 21 additions and 7 deletions

View File

@ -266,6 +266,11 @@ 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
}
ret.Ctors = append(ret.Ctors, mm) ret.Ctors = append(ret.Ctors, mm)
case "CXXDestructorDecl": case "CXXDestructorDecl":
@ -338,6 +343,12 @@ nextMethod:
continue nextMethod continue nextMethod
} }
if ret.ClassName == "QFile" && mm.MethodName == "moveToTrash" && len(mm.Parameters) == 2 && mm.Parameters[1].ParameterType == "QString" && mm.Parameters[1].Pointer {
// @ref https://doc.qt.io/qt-6/qfile.html#moveToTrash-1
log.Printf("Skipping method %q using complex return type by pointer argument", mm.MethodName) // TODO support this
continue nextMethod
}
ret.Methods = append(ret.Methods, mm) ret.Methods = append(ret.Methods, mm)
default: default:
@ -566,18 +577,15 @@ func parseSingleTypeString(p string) CppParameter {
insert.TypeAlias = tok insert.TypeAlias = tok
insert.ParameterType += " uintptr_t" insert.ParameterType += " uintptr_t"
} else if tok == "QStringList" {
insert.ParameterType += " QList<QString>"
} else if len(tok) > 4 && strings.HasSuffix(tok, "List") { } else if len(tok) > 4 && strings.HasSuffix(tok, "List") {
// Classes ending in --List are usually better represented as a QList // Classes ending in --List are usually better represented as a QList
// type directly, so that the binding uses proper Go slices // type directly, so that the binding uses proper Go slices
// Typedef e.g. QObjectList // Typedef e.g. QObjectList
insert.TypeAlias = tok insert.TypeAlias = tok
switch tok { switch tok {
case "QModelIndexList": case "QStringList", "QModelIndexList", "QVariantList", "QFileInfoList":
// These types are defined as a QList of values // These types are defined as a QList of values
insert.ParameterType += " QList<QModelIndex>" insert.ParameterType += " QList<" + tok[0:len(tok)-4] + ">"
case "QTextList": case "QTextList":
// This is really a custom class, preserve as-is // This is really a custom class, preserve as-is
insert.ParameterType += " " + tok insert.ParameterType += " " + tok

View File

@ -18,8 +18,7 @@ func AllowHeader(fullpath string) bool {
} }
switch fname { switch fname {
case // QtCore case "qatomic_bootstrap.h",
"qatomic_bootstrap.h",
"qatomic_cxx11.h", "qatomic_cxx11.h",
"qatomic_msvc.h", "qatomic_msvc.h",
"qgenericatomic.h", // Clang error "qgenericatomic.h", // Clang error
@ -129,6 +128,13 @@ func CheckComplexity(p CppParameter) error {
"QXmlStreamNotationDeclarations", // e.g. qxmlstream.h. As above "QXmlStreamNotationDeclarations", // e.g. qxmlstream.h. As above
"QVariantMap", // e.g. qcbormap.h "QVariantMap", // e.g. qcbormap.h
"QVariantHash", // e.g. qcbormap.h "QVariantHash", // e.g. qcbormap.h
"QCborTag", // e.g. qcborstreamreader.h.TODO Needs support for enums
"QCborSimpleType", // e.g. qcborstreamreader.h TODO Needs support for enums
"QCborKnownTags", // e.g. qcborstreamreader.h TODO Needs support for enums
"QCborNegativeInteger", // e.g. qcborstreamreader.h TODO Needs support for enums
"QtMsgType", // e.g. qdebug.h TODO Needs support for enums
"QTextStreamFunction", // e.g. qdebug.h
"QFactoryInterface", // qfactoryinterface.h
"QPlatformPixmap", // e.g. qpixmap.h. as below "QPlatformPixmap", // e.g. qpixmap.h. as below
"QPlatformScreen", // e.g. qscreen.h. as below "QPlatformScreen", // e.g. qscreen.h. as below
"QPlatformSurface", // e.g. qsurface.h. as below "QPlatformSurface", // e.g. qsurface.h. as below