diff --git a/_examples/wrapper/pywrapper/wrapper_code.go b/_examples/wrapper/pywrapper/wrapper_code.go new file mode 100644 index 0000000..a015f94 --- /dev/null +++ b/_examples/wrapper/pywrapper/wrapper_code.go @@ -0,0 +1,24 @@ +// Copyright 2015 The go-python Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package pywrapper + +import ( + "github.com/go-python/gopy/_examples/wrapper" + "fmt" +) + +type WrapperStruct struct { + data *wrapper.RealStruct +} + +func Test() string { + a := wrapper.PointerTest() + fmt.Println("%t", a) + return "Hello" +} + +func (a WrapperStruct) Test() string { + return fmt.Sprintf("%t", a.data) +} \ No newline at end of file diff --git a/_examples/wrapper/real_code.go b/_examples/wrapper/real_code.go new file mode 100644 index 0000000..5b39387 --- /dev/null +++ b/_examples/wrapper/real_code.go @@ -0,0 +1,15 @@ +// Copyright 2015 The go-python Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package wrapper + + +type RealStruct struct { + pointers map[string]*RealStruct + Channel chan int +} + +func PointerTest() *RealStruct { + return &RealStruct{} +} \ No newline at end of file diff --git a/bind/symtab.go b/bind/symtab.go index 119b959..90c7daa 100644 --- a/bind/symtab.go +++ b/bind/symtab.go @@ -99,6 +99,10 @@ type symbol struct { pychk string } +func isPrivate(s string) bool { + return (strings.ToLower(s[0:1]) == s[0:1]) +} + func (s symbol) isType() bool { return (s.kind & skType) != 0 } @@ -569,6 +573,7 @@ func (sym *symtab) addStructType(pkg *types.Package, obj types.Object, t types.T kind |= skStruct pybuf := make([]string, 0, typ.NumFields()) for i := 0; i < typ.NumFields(); i++ { + if isPrivate(typ.Field(i).Name()) { continue } ftyp := typ.Field(i).Type() fsym := sym.symtype(ftyp) if fsym == nil {