c-for-go: Problems using cgogen with func types and functions that return char**

I have read through the Translator config documentation, and then tried to generate bindings for Harfbuzz. However, I am still having a problem understanding how to translate func types.

Here is the code I had to remove from the header files to get a working build: deepakjois/harfbuzz-go@751fea9eb085851c2623e6429ecabd17f6a5b2ba

One kind of type that I can’t wrap is this:

const char ** hb_buffer_serialize_list_formats (void);

The Go code generated for this (in cgo_helpers.go) has a mysterious function called ‘NewRef’ in it, which is not resolved.

Another kind of type that I am having trouble is func types. I am having a hard time writing rules to even ignore it. For example:

typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data,
                           hb_codepoint_t unicode, hb_codepoint_t variation_selector,
                           hb_codepoint_t *glyph,
                           void *user_data);

Any help specifically to deal with these types is appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

I have managed to compile the Go bindings for Harfbuzz after ignoring the buggy typedefs, and the functions that use them:

https://github.com/deepakjois/harfbuzz-go/blob/615f54f0f88780387b56a5ddd6dcc7699fb129b1/harfbuzz.yml

I now have a few more questions regarding adjusting the PtrTips for some functions. I will open a new issue specifically for questions, instead of cluttering up this issue. Hope that is not a problem.