Skip to content

Commit 1ae2f24

Browse files
author
Randall C. O'Reilly
committed
for slices with non-pointer struct element types, need to return pointer to element so that elements can be modified -- no other way to do this python-side, and generated code assumes pointer receivers
1 parent ac88620 commit 1ae2f24

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

bind/gen_slice.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,11 @@ otherwise parameter is a python list that we copy from
281281
g.gofile.Indent()
282282
g.gofile.Printf("s := *ptrFromHandle_%s(handle)\n", slNm)
283283
if esym.go2py != "" {
284-
g.gofile.Printf("return %s(s[_idx])%s\n", esym.go2py, esym.go2pyParenEx)
284+
if !esym.isPointer() && esym.isStruct() {
285+
g.gofile.Printf("return %s(&(s[_idx]))%s\n", esym.go2py, esym.go2pyParenEx)
286+
} else {
287+
g.gofile.Printf("return %s(s[_idx])%s\n", esym.go2py, esym.go2pyParenEx)
288+
}
285289
} else {
286290
g.gofile.Printf("return s[_idx]\n")
287291
}

0 commit comments

Comments
 (0)