Change Go types to simple unsafe Pointers instead of pointers

wrapped in structs. It could be possible to handle pointers to
pointers now.
This commit is contained in:
gmp
2019-04-30 09:14:25 -04:00
parent 0e89d2c29a
commit 3573aa9144
5 changed files with 30 additions and 50 deletions
+3 -6
View File
@@ -40,8 +40,8 @@ func NewWrapper(debug bool) *Wrapper {
#cgo LDFLAGS: -framework Foundation
`)
ret.goTypes.WriteString(`
type Id struct { ptr unsafe.Pointer }
func (o *Id) Ptr() unsafe.Pointer { return o.ptr }
type Id struct { }
func (o *Id) Ptr() unsafe.Pointer { return unsafe.Pointer(o) }
`)
return ret
}
@@ -403,10 +403,7 @@ func (w *Wrapper) Wrap(toproc []string) {
w.goCode.WriteString(fmt.Sprintf(`
func New%s() *%s {
ret := &%s{}
ret.ptr = unsafe.Pointer(C.New%s())
//ret = ret.Init()
return ret
return (*%s)(unsafe.Pointer(C.New%s()))
}
`,i.Name,i.Name,i.Name,i.Name))