genbindings: move 'qt_' prefix renaming into SafeMethodName()

This commit is contained in:
mappu 2024-08-18 19:01:23 +12:00
parent 6d09ef795b
commit 33b26204f8
2 changed files with 9 additions and 6 deletions

View File

@ -265,10 +265,6 @@ nextMethod:
var mm CppMethod var mm CppMethod
mm.MethodName = methodName mm.MethodName = methodName
if strings.HasPrefix(methodName, "qt_") { // Strip redundant Qt prefix, we know these are all Qt functions
mm.OverrideMethodName = methodName
mm.MethodName = methodName[3:]
}
if strings.Contains(methodName, `QGADGET`) { if strings.Contains(methodName, `QGADGET`) {
log.Printf("Skipping method %q with weird QGADGET behaviour\n", mm.MethodName) log.Printf("Skipping method %q with weird QGADGET behaviour\n", mm.MethodName)

View File

@ -105,6 +105,14 @@ func (nm CppMethod) IsReceiverMethod() bool {
} }
func (nm CppMethod) SafeMethodName() string { func (nm CppMethod) SafeMethodName() string {
tmp := nm.MethodName
// Strip redundant Qt prefix, we know these are all Qt functions
if strings.HasPrefix(tmp, "qt_") {
tmp = tmp[3:]
}
// Operator-overload methods have names not representable in binding // Operator-overload methods have names not representable in binding
// languages. Replace more specific cases first // languages. Replace more specific cases first
replacer := strings.NewReplacer( replacer := strings.NewReplacer(
@ -138,8 +146,7 @@ func (nm CppMethod) SafeMethodName() string {
`[]`, `Subscript`, `[]`, `Subscript`,
`()`, `Call`, `()`, `Call`,
) )
tmp = replacer.Replace(tmp)
tmp := replacer.Replace(nm.MethodName)
// Also make the first letter uppercase so it becomes public in Go // Also make the first letter uppercase so it becomes public in Go
tmp = titleCase(tmp) tmp = titleCase(tmp)