From eca87471ee2dff90281883f00a3015073f60a527 Mon Sep 17 00:00:00 2001 From: mappu Date: Tue, 19 Nov 2024 19:25:48 +1300 Subject: [PATCH] genbindings/types: pointer and return type fixes --- cmd/genbindings/emitcabi.go | 3 +++ cmd/genbindings/emitgo.go | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cmd/genbindings/emitcabi.go b/cmd/genbindings/emitcabi.go index 3af268dc..a3b8cde0 100644 --- a/cmd/genbindings/emitcabi.go +++ b/cmd/genbindings/emitcabi.go @@ -35,6 +35,9 @@ func (p CppParameter) RenderTypeCabi() string { return "struct miqt_map " + cppComment("tuple of "+inner1.RenderTypeCabi()+" and "+inner2.RenderTypeCabi()) } else if (p.Pointer || p.ByRef) && p.QtClassType() { + if p.PointerCount > 1 { + return cabiClassName(p.ParameterType) + strings.Repeat("*", p.PointerCount) + } return cabiClassName(p.ParameterType) + "*" } else if p.QtClassType() && !p.Pointer { diff --git a/cmd/genbindings/emitgo.go b/cmd/genbindings/emitgo.go index 80324043..7d94d3aa 100644 --- a/cmd/genbindings/emitgo.go +++ b/cmd/genbindings/emitgo.go @@ -13,7 +13,7 @@ import ( func goReservedWord(s string) bool { switch s { case "default", "const", "func", "var", "type", "len", "new", "copy", "import", "range", "string", "map", "int", "select", - "ret": // not a language-reserved word, but a binding-reserved word + "super", "ret": // not language-reserved words, but a binding-reserved words return true default: return false @@ -154,6 +154,20 @@ func (p CppParameter) RenderTypeGo(gfs *goFileState) string { return ret // ignore const } +func (p CppParameter) renderReturnTypeGo(gfs *goFileState) string { + ret := p.RenderTypeGo(gfs) + if ret == "void" { + ret = "" + } + + if p.QtClassType() && p.ParameterType != "QString" && p.ParameterType != "QByteArray" && !(p.Pointer || p.ByRef) { + // FIXME normalize this part + ret = "*" + ret + } + + return ret +} + func (p CppParameter) parameterTypeCgo() string { if p.ParameterType == "QString" { return "C.struct_miqt_string" @@ -703,6 +717,8 @@ import "C" goClassName := cabiClassName(c.ClassName) + // Type definition + ret.WriteString(` type ` + goClassName + ` struct { h *C.` + goClassName + `