Re: Annotation for pointer plus GDestroyNotify

On Fri, 2018-02-09 at 07:38 +0000, philip chimento gmail com wrote:
Next up!

Annotation for pointer plus GDestroyNotify:

tl;dr: there isn't currently a way to annotate
g_memory_input_stream_new_from_data() correctly. The bindings need to
know that the destroy parameter refers to the data parameter, but the
(destroy) annotation is currently only valid in combination with

I propose a (destroy-pointer PARAM) annotation, used like so:

 * g_memory_input_stream_new_from_data:
 * @data: (array length=len) (element-type guint8) (transfer full):
input data
 * @len: length of the data, may be -1 if @data is a nul-terminated
 * @destroy: (destroy-pointer data) (nullable): function that is
called to free @data, or %NULL

The value of PARAM is the name of another function parameter. PARAM
is required (unlike with the existing (destroy) annotation where it
can be guessed.) This translates into a destroy-pointer="POS"
annotation in the GIR.

Are there any places in the API where a function takes two (transfer
full) pointers, and only one GDestroyNotify function, and uses the same
destroy notify function for both pointers (potentially at different
times)? If so, we might want to swap this round to be (destroy-func
FUNC) as an annotation on the (transfer full) pointer.

Aside from that, do we want to put any checks on this, like:
 • The FUNC has to be of type GDestroyNotify.
 • The PARAM has to have (transfer full) or (transfer container).

It seems usual for destroy notifiers to be nullable by default, so
perhaps we should explicitly say that the FUNC is implicitly
(nullable), unless marked with (not nullable)?

Philip Not-C

Attachment: signature.asc
Description: This is a digitally signed message part

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]