[Libguestfs] [PATCH 16/27] daemon: Generate OCaml wrappers for optgroup_*_available functions.
Pino Toscano
ptoscano at redhat.com
Thu Jul 20 15:07:24 UTC 2017
On Friday, 14 July 2017 15:39:24 CEST Richard W.M. Jones wrote:
> It is sometimes useful to be able to call these from OCaml code.
> ---
> generator/daemon.ml | 23 ++++++++++++++++++++++-
> 1 file changed, 22 insertions(+), 1 deletion(-)
I see in patch #19:
external available : unit -> bool =
"guestfs_int_daemon_optgroup_lvm2_available" "noalloc"
I think it'd be better to generate daemon/optgroups.ml{,i} instead,
so there is no need for manual extern declarations.
> diff --git a/generator/daemon.ml b/generator/daemon.ml
> index fd01e5d8a..1d7461f8c 100644
> --- a/generator/daemon.ml
> +++ b/generator/daemon.ml
> @@ -976,6 +976,10 @@ let generate_daemon_optgroups_c () =
> generate_header CStyle GPLv2plus;
>
> pr "#include <config.h>\n";
> + pr "#include <stdio.h>\n";
> + pr "#include <stdlib.h>\n";
Not a problem, but are they needed?
> @@ -999,7 +1003,24 @@ let generate_daemon_optgroups_c () =
> pr " { \"%s\", optgroup_%s_available },\n" group group
> ) optgroups_names_all;
> pr " { NULL, NULL }\n";
> - pr "};\n"
> + pr "};\n";
> + pr "\n";
> + pr "/* Wrappers so these functions can be called from OCaml code. */\n";
> + List.iter (
> + fun group ->
> + if not (List.mem group optgroups_retired) then (
> + pr "extern value guestfs_int_daemon_optgroup_%s_available (value);\n"
> + group;
> + pr "\n";
> + pr "/* NB: This is a \"noalloc\" call. */\n";
> + pr "value\n";
> + pr "guestfs_int_daemon_optgroup_%s_available (value unitv)\n" group;
> + pr "{\n";
> + pr " return Val_bool (optgroup_%s_available ());\n" group;
> + pr "}\n";
> + pr "\n"
> + )
> + ) optgroups_names_all
I'd use 'optgroups_names' here, that contains only non-retired optgroups
(thus avoiding the check in the iteration).
--
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20170720/d932e2f7/attachment.sig>
More information about the Libguestfs
mailing list