From a5dafbf132a07ccf758f069bdd0e266422ea5876 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 23 Nov 2024 19:34:22 +1300 Subject: [PATCH] genbindings: fix trying to add super parameters for pure virtual methods --- cmd/genbindings/emitgo.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/genbindings/emitgo.go b/cmd/genbindings/emitgo.go index 2eaf9b27..0c835ae5 100644 --- a/cmd/genbindings/emitgo.go +++ b/cmd/genbindings/emitgo.go @@ -965,8 +965,9 @@ import "C" // Add a package-private function to call the C++ base class method // QWidget_virtualbase_PaintEvent + // This is only possible if the function is not pure-virtual - { + if !m.IsPureVirtual { preamble, forwarding := gfs.emitParametersGo2CABIForwarding(m) forwarding = "unsafe.Pointer(this.h)" + strings.TrimPrefix(forwarding, `this.h`) // TODO integrate properly @@ -989,7 +990,10 @@ import "C" { var cgoNamedParams []string - var paramNames []string = []string{"(&" + goClassName + "{h: self}).callVirtualBase_" + m.SafeMethodName()} + var paramNames []string + if !m.IsPureVirtual { + paramNames = append(paramNames, "(&"+goClassName+"{h: self}).callVirtualBase_"+m.SafeMethodName()) + } conversion := "" if len(m.Parameters) > 0 { @@ -1009,10 +1013,14 @@ import "C" superCbType := `func(` + gfs.emitParametersGo(m.Parameters) + `) ` + m.ReturnType.renderReturnTypeGo(&gfs) - goCbType := `func(super ` + superCbType - if len(m.Parameters) > 0 { - goCbType += `, ` + gfs.emitParametersGo(m.Parameters) + goCbType := `func(` + if !m.IsPureVirtual { + goCbType += `super ` + superCbType + if len(m.Parameters) > 0 { + goCbType += `, ` + } } + goCbType += gfs.emitParametersGo(m.Parameters) goCbType += `) ` + m.ReturnType.renderReturnTypeGo(&gfs) ret.WriteString(`func (this *` + goClassName + `) On` + m.SafeMethodName() + `(slot ` + goCbType + `) {