On Tue, Jun 07, 2022 at 09:00:08AM +0100, Richard W.M. Jones wrote:
On Mon, Jun 06, 2022 at 09:08:29PM -0500, Eric Blake wrote:
> + pr ":nbd_%s\",\n" name;
You could put this pr (but without the \n) ...
> + pr " ";
> + pr_wrap ',' (fun () ->
... inside pr_wrap here, and it would mean you wouldn't need to print
spaces to indent (because pr_wrap should do it for you).
Will do. It rearranges a few more lines of generated code (now the
&py_h argument can sometimes be a line earlier), but is still legible.
It all looks sensible and equivalent to the old code, and the output
is cleaner too, so:
Reviewed-by: Richard W.M. Jones <rjones(a)redhat.com>
I get when we have more than one statement to bundle how the OCaml
(fun () -> ... ) construct makes sense, but do we need that for this hunk?
@@ -284,7 +285,10 @@ let
(* Generate the Python binding. *)
let print_python_binding name { args; optargs; ret; may_set_error } =
pr "PyObject *\n";
- pr "nbd_internal_py_%s (PyObject *self, PyObject *args)\n" name;
+ pr "nbd_internal_py_%s (" name;
+ pr_wrap ',' (fun () ->
+ pr "PyObject *self, PyObject *args");
+ pr ")\n";
pr "{\n";
pr " PyObject *py_h;\n";
pr " struct nbd_handle *h;\n";
or is there a shorter way to write that one?
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org