[Libguestfs] [PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
Eric Blake
eblake at redhat.com
Sat Aug 3 13:22:38 UTC 2019
On 8/3/19 7:42 AM, Richard W.M. Jones wrote:
> For example nbd_set_debug takes a callback function. Previously this
> was defined explicitly inside the function parameters. This commit
> defines a new public typedef:
>
> typedef int (*nbd_debug_callback) (unsigned valid_flag, void *user_data,
> const char *context, const char *msg);
>
> and then uses the typedef like this:
>
> extern int nbd_set_debug_callback (struct nbd_handle *h,
> nbd_debug_callback debug_callback,
> void *debug_callback_user_data);
>
> (Previously typedefs were available, but they were written by hand and
> only used internally to the library.)
Yes, that aids legibility.
>
> This change necessitates that we uniquely name all of our closures
> across methods (the same-named closure is required to have the same
> cbargs).
>
> I took this opportunity to rename some, so especially completion
> callbacks now have the type nbd_completion_callback. The generator
> also checks they are named uniquely.
>
> This does not change the C API or ABI.
Concur.
The patch looks good to me.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190803/3fefcc5d/attachment.sig>
More information about the Libguestfs
mailing list