genbindings: rely entirely on typedefs for QList<> handling

This commit is contained in:
mappu 2024-08-29 18:07:07 +12:00
parent 3b65e1fc6f
commit 4df990b345
2 changed files with 3 additions and 18 deletions

View File

@ -689,24 +689,6 @@ func parseSingleTypeString(p string) CppParameter {
insert.Pointer = true
insert.PointerCount++
} else if len(tok) > 4 && strings.HasSuffix(tok, "List") {
// Classes ending in --List are usually better represented as a QList
// type directly, so that the binding uses proper Go slices
// Typedef e.g. QObjectList
insert.TypeAlias = tok
switch tok {
case "QStringList", "QModelIndexList", "QVariantList", "QFileInfoList":
// These types are defined as a QList of values
insert.ParameterType += " QList<" + tok[0:len(tok)-4] + ">"
case "QTextList":
// This is really a custom class, preserve as-is
insert.ParameterType += " " + tok
default:
// These types are defined as a QList of pointers.
// QList<QFoo*>. This is the most common case
insert.ParameterType += " QList<" + tok[0:len(tok)-4] + " *>"
}
} else {
// Valid part of the type name
if tok == "char" && isSigned {

View File

@ -25,6 +25,9 @@ func init() {
// @ref https://doc.qt.io/qt-5/qprocess.html#Q_PID-typedef
KnownTypedefs["Q_PID"] = CppTypedef{"WId", parseSingleTypeString("uintptr_t")}
// QString is deleted from this binding
KnownTypedefs["QStringList"] = CppTypedef{"QStringList", parseSingleTypeString("QList<QString>")}
}
type CppParameter struct {