From c1b31e787babf4524908f8f6d0297510e0f3c9f0 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 26 Oct 2024 12:08:36 +1300 Subject: [PATCH] genbindings: move AllowClass from parse-time to transformation AST pass This exposes some more valid types. --- cmd/genbindings/clang2il.go | 5 ----- cmd/genbindings/transformblocklist.go | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cmd/genbindings/clang2il.go b/cmd/genbindings/clang2il.go index fc663833..9997226c 100644 --- a/cmd/genbindings/clang2il.go +++ b/cmd/genbindings/clang2il.go @@ -212,11 +212,6 @@ func processClassType(node map[string]interface{}, addNamePrefix string) (CppCla log.Printf("-> Processing class %q...\n", nodename) - // Also skip over any custom exceptions - if !AllowClass(nodename) { - return CppClass{}, ErrNoContent - } - // Skip over forward class declarations // This is determined in two ways: // 1. If the class has no inner nodes diff --git a/cmd/genbindings/transformblocklist.go b/cmd/genbindings/transformblocklist.go index 23ea14bc..83295991 100644 --- a/cmd/genbindings/transformblocklist.go +++ b/cmd/genbindings/transformblocklist.go @@ -4,6 +4,23 @@ package main // and entire classes that may be disallowed. func astTransformBlocklist(parsed *CppParsedHeader) { + // Whole-classes + + j := 0 + for _, c := range parsed.Classes { + if !AllowClass(c.ClassName) { + continue + } + + // Keep + parsed.Classes[j] = c + j++ + } + parsed.Classes = parsed.Classes[:j] // reslice + + // For the kept classes, filter ctors and methods within the class, based + // on the parameter types and return types + for i, c := range parsed.Classes { // Constructors