From 5381a6b80c46e7ab6e8fc82333b2cb558078fa8f Mon Sep 17 00:00:00 2001 From: mappu Date: Thu, 15 Aug 2024 19:49:38 +1200 Subject: [PATCH] genbindings: rename more go reserved words --- cmd/genbindings/clang2il.go | 2 +- cmd/genbindings/emitgo.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/genbindings/clang2il.go b/cmd/genbindings/clang2il.go index f03590ad..1568333d 100644 --- a/cmd/genbindings/clang2il.go +++ b/cmd/genbindings/clang2il.go @@ -306,7 +306,7 @@ func parseMethod(node map[string]interface{}, mm *CppMethod) error { } // Block reserved Go words, replace with generic parameters - if parmName == "default" || parmName == "const" || parmName == "func" { + if goReservedWord(parmName) { parmName += "Val" } diff --git a/cmd/genbindings/emitgo.go b/cmd/genbindings/emitgo.go index 88edef29..7b4e9ea3 100644 --- a/cmd/genbindings/emitgo.go +++ b/cmd/genbindings/emitgo.go @@ -7,6 +7,15 @@ import ( "strings" ) +func goReservedWord(s string) bool { + switch s { + case "default", "const", "func", "var", "type", "len", "new", "copy", "import": + return true + default: + return false + } +} + func (p CppParameter) RenderTypeGo() string { if p.Pointer && p.ParameterType == "char" { return "string"