From 2a93cbf2d38bca4d26c062a4e0a1ee580e5d54fd Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 18 Aug 2024 15:56:48 +1200 Subject: [PATCH] genbindings: detect signals --- cmd/genbindings/clang2il.go | 13 +++++++++++++ cmd/genbindings/intermediate.go | 1 + 2 files changed, 14 insertions(+) diff --git a/cmd/genbindings/clang2il.go b/cmd/genbindings/clang2il.go index bc78ed30..1068090a 100644 --- a/cmd/genbindings/clang2il.go +++ b/cmd/genbindings/clang2il.go @@ -159,6 +159,8 @@ func processClassType(node map[string]interface{}, className string) (CppClass, } } + isSignal := false + // Parse all methods nextMethod: @@ -190,6 +192,15 @@ nextMethod: panic("unexpected access visibility '" + access + "'") } + // Clang sees Q_SIGNALS/signals as being a macro for `public` + // If this AccessSpecDecl was imported from a macro, assume it's signals + isSignal = false + if loc, ok := node["loc"].(map[string]interface{}); ok { + if _, ok := loc["expansionLoc"].(map[string]interface{}); ok { + isSignal = true + } + } + case "FriendDecl": // Safe to ignore @@ -270,6 +281,8 @@ nextMethod: return CppClass{}, err } + mm.IsSignal = isSignal && !mm.IsStatic && mm.MethodName != `metaObject` + ret.Methods = append(ret.Methods, mm) default: diff --git a/cmd/genbindings/intermediate.go b/cmd/genbindings/intermediate.go index a62daf1e..150e863e 100644 --- a/cmd/genbindings/intermediate.go +++ b/cmd/genbindings/intermediate.go @@ -67,6 +67,7 @@ type CppMethod struct { ReturnType CppParameter // Name not used Parameters []CppParameter IsStatic bool + IsSignal bool } func IsArgcArgv(params []CppParameter) bool {