genbindings: detect and skip over receiver-method pattern

This commit is contained in:
mappu 2024-08-18 15:57:40 +12:00
parent 148d8ea6e0
commit 43e32085a1
2 changed files with 25 additions and 0 deletions

View File

@ -283,6 +283,11 @@ nextMethod:
mm.IsSignal = isSignal && !mm.IsStatic && mm.MethodName != `metaObject` mm.IsSignal = isSignal && !mm.IsStatic && mm.MethodName != `metaObject`
if mm.IsReceiverMethod() {
log.Printf("Skipping method %q using non-projectable receiver pattern parameters", mm.MethodName)
continue nextMethod
}
ret.Methods = append(ret.Methods, mm) ret.Methods = append(ret.Methods, mm)
default: default:

View File

@ -81,6 +81,26 @@ func IsArgcArgv(params []CppParameter, pos int) bool {
params[pos+1].ParameterType == "char **") params[pos+1].ParameterType == "char **")
} }
func IsReceiverMethod(params []CppParameter, pos int) bool {
// Check if the arguments starting at position=pos are the receiver/member pattern.
// QMenu->addAction is the main example of this
return (len(params) > pos+1 &&
params[pos].ParameterName == "receiver" &&
params[pos].ParameterType == "QObject" &&
params[pos].Pointer &&
params[pos+1].ParameterName == "member" &&
params[pos+1].ParameterType == "char" &&
params[pos+1].Pointer)
}
func (nm CppMethod) IsReceiverMethod() bool {
// Returns true if any of the parameters use the receiever-method pattern
for i := 0; i < len(nm.Parameters); i++ {
if IsReceiverMethod(nm.Parameters, i) {
return true
}
}
return false
} }
func (nm CppMethod) SafeMethodName() string { func (nm CppMethod) SafeMethodName() string {