genbindings: rename more go reserved words

This commit is contained in:
mappu 2024-08-15 19:49:38 +12:00
parent 189a93fbca
commit 5381a6b80c
2 changed files with 10 additions and 1 deletions

View File

@ -306,7 +306,7 @@ func parseMethod(node map[string]interface{}, mm *CppMethod) error {
} }
// Block reserved Go words, replace with generic parameters // Block reserved Go words, replace with generic parameters
if parmName == "default" || parmName == "const" || parmName == "func" { if goReservedWord(parmName) {
parmName += "Val" parmName += "Val"
} }

View File

@ -7,6 +7,15 @@ import (
"strings" "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 { func (p CppParameter) RenderTypeGo() string {
if p.Pointer && p.ParameterType == "char" { if p.Pointer && p.ParameterType == "char" {
return "string" return "string"