From 7e6f349c4462e1596102bdd3566e08533cbe5ca5 Mon Sep 17 00:00:00 2001 From: Evan Oman Date: Sat, 13 Apr 2024 21:43:18 -0500 Subject: [PATCH 1/2] Adds reference in gen_map elem fn --- bind/gen_map.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bind/gen_map.go b/bind/gen_map.go index 27c1d86..834121b 100644 --- a/bind/gen_map.go +++ b/bind/gen_map.go @@ -303,7 +303,7 @@ otherwise parameter is a python list that we copy from g.gofile.Outdent() g.gofile.Printf("}\n") if esym.go2py != "" { - g.gofile.Printf("return %s(v)%s\n", esym.go2py, esym.go2pyParenEx) + g.gofile.Printf("return %s(&v)%s\n", esym.go2py, esym.go2pyParenEx) } else { g.gofile.Printf("return v\n") } From 6079a4ceca502783b6a6cbcccb9b0458f0750b0d Mon Sep 17 00:00:00 2001 From: Evan Oman Date: Mon, 22 Apr 2024 12:22:44 -0500 Subject: [PATCH 2/2] Adds guard around pointer reference for basic types --- bind/gen_map.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bind/gen_map.go b/bind/gen_map.go index 834121b..2803438 100644 --- a/bind/gen_map.go +++ b/bind/gen_map.go @@ -303,7 +303,14 @@ otherwise parameter is a python list that we copy from g.gofile.Outdent() g.gofile.Printf("}\n") if esym.go2py != "" { - g.gofile.Printf("return %s(&v)%s\n", esym.go2py, esym.go2pyParenEx) + // If the go2py starts with handleFromPtr_, use &v, otherwise just v + val_str := "" + if strings.HasPrefix(esym.go2py, "handleFromPtr_") { + val_str = "&v" + } else { + val_str = "v" + } + g.gofile.Printf("return %s(%s)%s\n", esym.go2py, val_str, esym.go2pyParenEx) } else { g.gofile.Printf("return v\n") }