From 5fa7bd37eb816c203e29b51878d88739a277b392 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 17 Aug 2024 11:25:54 +1200 Subject: [PATCH] genbindings/typedefs: exclude typedefs from class pointer declarations --- cmd/genbindings/clang2il.go | 4 ++-- cmd/genbindings/emitcabi.go | 6 ++++++ cmd/genbindings/intermediate.go | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/genbindings/clang2il.go b/cmd/genbindings/clang2il.go index 881a3e48..3a3f95b0 100644 --- a/cmd/genbindings/clang2il.go +++ b/cmd/genbindings/clang2il.go @@ -96,8 +96,8 @@ func parseHeader(topLevel []interface{}) (*CppParsedHeader, error) { if typ, ok := node["type"].(map[string]interface{}); ok { if qualType, ok := typ["qualType"].(string); ok { ret.Typedefs = append(ret.Typedefs, CppTypedef{ - Name: nodename, - Typedef: qualType, + Alias: nodename, + UnderlyingType: qualType, }) } } diff --git a/cmd/genbindings/emitcabi.go b/cmd/genbindings/emitcabi.go index ead75dd9..49706c93 100644 --- a/cmd/genbindings/emitcabi.go +++ b/cmd/genbindings/emitcabi.go @@ -239,6 +239,12 @@ func getReferencedTypes(src *CppParsedHeader) []string { } } + // Some types (e.g. QRgb) are found but are typedefs, not classes + for _, td := range src.Typedefs { + delete(foundTypes, td.Alias) + } + + // Convert to sorted list foundTypesList := make([]string, 0, len(foundTypes)) for ft := range foundTypes { if strings.HasPrefix(ft, "QList<") { diff --git a/cmd/genbindings/intermediate.go b/cmd/genbindings/intermediate.go index b59bfbb1..be0355df 100644 --- a/cmd/genbindings/intermediate.go +++ b/cmd/genbindings/intermediate.go @@ -109,8 +109,8 @@ type CppClass struct { } type CppTypedef struct { - Name string - Typedef string + Alias string + UnderlyingType string } type CppParsedHeader struct {