From 8eddf460161b54b5e72c007a4fa19c899318980d Mon Sep 17 00:00:00 2001 From: Rich Ramalho Date: Mon, 2 Oct 2023 21:26:08 -0300 Subject: [PATCH] fix __next__ function --- bind/gen_slice.go | 6 +++++- main_test.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bind/gen_slice.go b/bind/gen_slice.go index a5694e8..bb33214 100644 --- a/bind/gen_slice.go +++ b/bind/gen_slice.go @@ -246,7 +246,11 @@ otherwise parameter is a python list that we copy from g.pywrap.Indent() g.pywrap.Printf("if self.index < len(self):\n") g.pywrap.Indent() - g.pywrap.Printf("rv = _%s_elem(self.handle, self.index)\n", qNm) + if esym.hasHandle() { + g.pywrap.Printf("rv = %s(handle=_%s_elem(self.handle, self.index))\n", esym.pyPkgId(slc.gopkg), qNm) + } else { + g.pywrap.Printf("rv = _%s_elem(self.handle, self.index)\n", qNm) + } g.pywrap.Println("self.index = self.index + 1") g.pywrap.Println("return rv") g.pywrap.Outdent() diff --git a/main_test.go b/main_test.go index 4f34797..5ab6a11 100644 --- a/main_test.go +++ b/main_test.go @@ -593,7 +593,7 @@ slices.IntSum from Python list: 10 slices.IntSum from Go slice: 10 unsigned slice elements: 1 2 3 4 signed slice elements: -1 -2 -3 -4 -struct slice: slices.Slice_Ptr_slices_S len: 3 handle: 11 [12, 13, 14] +struct slice: slices.Slice_Ptr_slices_S len: 3 handle: 11 [slices.S{Name=S0, handle=12}, slices.S{Name=S1, handle=13}, slices.S{Name=S2, handle=14}] struct slice[0]: slices.S{Name=S0, handle=15} struct slice[1]: slices.S{Name=S1, handle=16} struct slice[2].Name: S2