[gtkada] Cairo : Binding hints for cairo_image_surface_create_from_png_stream

Nicolas Setton setton at adacore.com
Fri Sep 9 15:07:24 CEST 2011


Hello David,

> 
> As those cairo services [1] do not seem to be part of the current GTKAda
> bindings, I am trying to add them.
> 
> I have a pain concerning cairo_image_surface_create_from_png_stream [2],
> as the cairo_read_func_t type seems to require in the Ada world a
> function that would have out parameter to be able to proceed a memory

you mean cairo_write_func_t?

> allocation for the data parameter [2] (thus, using an anonymous access
> type does not seems to be sufficient).
> 
> Any tips that could help me achieve this in Ada using the current GNAT
> GPL 2011 is most welcome.

Are you sure you need to allocate the data in *cairo_write_func_t? My interpretation of the spec is that an already allocated buffer is passed to the function, all the function needs to do is to fill the data in the buffer.

Note that you should not pass directly the user's function to the C callback, you should use a wrapper of your own (with Pragma Convention (C)) which in turn calls the user-provided function.

Hope this helps!

Nicolas


More information about the gtkada mailing list