c-for-go
c-for-go copied to clipboard
Some structs not being fully defined in types.go
Hi,
I'm sure this is a basic issue, however I'm unable to find the solution. I'm using this library to generate bindings for Nuklear UI, and have gotten it mostly working. However, some structs in types.go are defined fully like this:
// DrawVertexLayoutElement as declared in nk/nuklear.h:437
type DrawVertexLayoutElement struct {
Attribute DrawVertexLayoutAttribute
Format DrawVertexLayoutFormat
Offset Size
refeb0614d6 *C.struct_nk_draw_vertex_layout_element
allocseb0614d6 interface{}
}
While others are defined like this:
// ConfigurationStacks as declared in nk/nuklear.h:4086
type ConfigurationStacks C.struct_nk_configuration_stacks
Which is not as easy to use. Is there a way I can cause all structs to be fully defined in types.go instead of the C.* linkage? Thanks.
I have run into same issue. Some structs aren't generated fully :/
https://github.com/golang-ui/nuklear/blob/89da3f6a587a838c7b7e896de58fcdf569b9d542/nk.yml#L32
It's set in MemTips. Explanation is here:
https://github.com/xlab/c-for-go/wiki/Translator-config-section#memtips
So when set to raw, which is used as wildcard for nk_ except few, for which one can explicitly set bind or any other word that is not raw. That will result in binding generation for that struct. Note that it may not work well with any struct, so that's why it was originally not enabled for all structs.
In Nuklear there is a lot of things happening by setting some deeply nested fields in structs, while bindings work only on the top-level. So to avoid confusion and actually improve the experience, I'd advise to not enable bindings for structs, except you know it's only a single level struct.
We put Getters/Setters into etc.go: https://github.com/golang-ui/nuklear/blob/89da3f6a587a838c7b7e896de58fcdf569b9d542/nk/etc.go#L359
There was some discussion about generation of getters and setters by c-for-go, but I had no time to implement it