go-python / gopy

gopy generates a CPython extension module from a go package.
BSD 3-Clause "New" or "Revised" License
2.02k stars 111 forks source link

bind: support slices as method arguments #54

Closed phil-mansfield closed 3 years ago

phil-mansfield commented 9 years ago

The package

package slice_arg

type T struct {
}

func (t T) Slice(s []float64) {
}

fails with

$ go build && gopy bind --lang=py2 .
2015/08/31 10:29:15 work: /var/folders/j0/l297p36x68dfmcrh07jptj200000gn/T/gopy-628775343
# _/private/var/folders/j0/l297p36x68dfmcrh07jptj200000gn/T/gopy-628775343
./slice_arg.go:164: cannot use s (type cgo_type_0x1114782197) as type []float64 in argument to (*slice_arg.T)(unsafe.Pointer(self)).Slice
2015/08/31 10:29:15 error dispatching command: exit status 2

The following two packages both successfully compile:

package slice_arg

type T struct {
}

func Slice(t T, s []float64) {
}
package slice_arg

type T struct {
}

func (t T) Slice(x float64) {                                            
}
sbinet commented 9 years ago

note to self: this interesting "feature" would be fixed by really harmonizing the wrapping of methods and the wrapping of functions. the refactorization of these 2 wrappings was somehow stopped in the middle.

corona10 commented 7 years ago

https://github.com/go-python/gopy/pull/129

Now CFFI engine supports this feature. :)

rcoreilly commented 3 years ago

for old version, closing