diff --git a/cmd/genbindings/emitgo.go b/cmd/genbindings/emitgo.go index e30abc1b..d8cedfd1 100644 --- a/cmd/genbindings/emitgo.go +++ b/cmd/genbindings/emitgo.go @@ -113,7 +113,7 @@ func emitParametersGo(params []CppParameter) string { for i, p := range params { - if i == 0 && IsArgcArgv(params) { + if IsArgcArgv(params, i) { skipNext = true tmp = append(tmp, "args []string") @@ -140,7 +140,7 @@ func emitParametersGo2CABIForwarding(m CppMethod) (preamble string, fowarding st for i, p := range m.Parameters { - if i == 0 && IsArgcArgv(m.Parameters) { + if IsArgcArgv(m.Parameters, i) { skipNext = true // QApplication constructor. Convert 'args' into Qt's wanted types // Qt has a warning in the docs saying these pointers must be valid diff --git a/cmd/genbindings/intermediate.go b/cmd/genbindings/intermediate.go index 150e863e..350578c9 100644 --- a/cmd/genbindings/intermediate.go +++ b/cmd/genbindings/intermediate.go @@ -70,14 +70,17 @@ type CppMethod struct { IsSignal bool } -func IsArgcArgv(params []CppParameter) bool { +func IsArgcArgv(params []CppParameter, pos int) bool { + // Check if the arguments starting at position=pos are the argc/argv pattern. // QApplication/QGuiApplication constructors are the only expected example of this. - return (len(params) > 1 && - params[0].ParameterName == "argc" && - params[0].ParameterType == "int" && - params[0].ByRef && - params[1].ParameterName == "argv" && - params[1].ParameterType == "char **") + return (len(params) > pos+1 && + params[pos].ParameterName == "argc" && + params[pos].ParameterType == "int" && + params[pos].ByRef && + params[pos+1].ParameterName == "argv" && + params[pos+1].ParameterType == "char **") +} + } func (nm CppMethod) SafeMethodName() string {