-
Notifications
You must be signed in to change notification settings - Fork 11
cgo: move bindings to new package #19
Conversation
d7ad18d to
bcdd301
Compare
|
I don't fully understand. This sounds blunt, but it's not intended that way. Questions:
There is still the complexity of mapping the Go signature to the C signature, but it forces the comments, signatures, and checks to be in sync. |
|
Bluntness not noticed.
|
|
|
I can't review the perl, but LGTM. |
|
I've made some changes - at odds with some of the safety, though I can fix that, but more informative. |
|
Could you explain the distinction between (*C.double)(&a[0]) and unsafe.Pointer(&a[0])? They're basically equivalent as far as C is concerned, right? Could you give an example of the code change for what you'd like to comment on. It would be hard for me to understand the diff without an example, and unfortunately the cgo file is too big for the github diff to work. |
|
Converting to *C.double is the equivalent casting to *double, converting to unsafe.
Pointer is the equivalent of casting to *void. The use of unsafe.Pointer here is because C.char is int8 and byte is uint8, so the type conversion is otherwise not allowed.
I'll paste a snippet tomorrow when I have the safety checks re-added and some of the slop is fixed, but basically I've comverted the cases where a slice has been used to pass a single into a point to that type. This means we need to check for nil before the CGO call and I have realised that my criterion for single value parameters is a little off (it must not have a following matching ldx parameter - this misses work parameters and possibly others). It's feeling more and more complex, so maybe I'll drop it. until we have rewritten the code gen in Go.
|
|
I've decided it's too irregular to do now, for example tau is a []float64 or a *float64 depending on the function. The only way to do it here is to have a table to labels and types - how we should do blas/cgo as well in the long run. If we say that cgo/lapack is not subject to any API stability then I think we are fine. |
|
Merging on the basis of your previous LGTM which is now the current state. |
This is a clean up of the code generation (reducing the line count sigificantly and making failure much noisier prior to the CGO call - though will only catch the most egregious errors). The approach I've taken here differs significantly from that in blas/cgo where all the checks are done in the generated binding code. Here there is too much complexity, so we do the checks in the Implementation method and then call the clapack function. Also use CGO_LDFLAGS env var; this is how we do things in blas and it allows us to have code that will work with go get when the environment is correctly set up - without requiring go generate or perl use by the client.
This is a clean up of the code generation (reducing the line count
sigificantly and making failure much noisier prior to the CGO call -
though will only catch the most egregious errors).
The approach I've taken here differs significantly from that in blas/cgo
where all the checks are done in the generated binding code. Here there
is too much complexity, so we do the checks in the Implementation method
and then call the clapack function.
@btracey