[Libguestfs] [libnbd PATCH v2 7/8] python: Simplify python generator
Richard W.M. Jones
rjones at redhat.com
Tue Jun 7 13:19:10 UTC 2022
On Mon, Jun 06, 2022 at 09:08:32PM -0500, Eric Blake wrote:
> Now that none of our parameter types uses a getter sequence, we can
> simplify the code for generating nbd.py. No change to generated
> output.
> ---
> generator/Python.ml | 49 ++++++++++++++++++++++-----------------------
> 1 file changed, 24 insertions(+), 25 deletions(-)
>
> diff --git a/generator/Python.ml b/generator/Python.ml
> index 101f3e0..c49af4f 100644
> --- a/generator/Python.ml
> +++ b/generator/Python.ml
> @@ -797,31 +797,31 @@ let
> let args =
> List.map (
> function
> - | Bool n -> n, None, None
> - | BytesIn (n, _) -> n, None, None
> - | BytesOut (_, count) -> count, None, None
> - | BytesPersistIn (n, _) -> n, None, None
> - | BytesPersistOut (n, _) -> n, None, None
> - | Closure { cbname } -> cbname, None, None
> - | Enum (n, _) -> n, None, None
> - | Flags (n, _) -> n, None, None
> - | Fd n | Int n -> n, None, None
> - | Int64 n -> n, None, None
> - | Path n -> n, None, None
> - | SizeT n -> n, None, None
> - | SockAddrAndLen (n, _) -> n, None, None
> - | String n -> n, None, None
> - | StringList n -> n, None, None
> - | UInt n -> n, None, None
> - | UInt32 n -> n, None, None
> - | UInt64 n -> n, None, None
> - | UIntPtr n -> n, None, None
> + | Bool n -> n, None
> + | BytesIn (n, _) -> n, None
> + | BytesOut (_, count) -> count, None
> + | BytesPersistIn (n, _) -> n, None
> + | BytesPersistOut (n, _) -> n, None
> + | Closure { cbname } -> cbname, None
> + | Enum (n, _) -> n, None
> + | Flags (n, _) -> n, None
> + | Fd n | Int n -> n, None
> + | Int64 n -> n, None
> + | Path n -> n, None
> + | SizeT n -> n, None
> + | SockAddrAndLen (n, _) -> n, None
> + | String n -> n, None
> + | StringList n -> n, None
> + | UInt n -> n, None
> + | UInt32 n -> n, None
> + | UInt64 n -> n, None
> + | UIntPtr n -> n, None
> ) args in
> let optargs =
> List.map (
> function
> - | OClosure { cbname } -> cbname, Some "None", None
> - | OFlags (n, _, _) -> n, Some "0", None
> + | OClosure { cbname } -> cbname, Some "None"
> + | OFlags (n, _, _) -> n, Some "0"
> ) optargs in
> let args = args @ optargs in
> pr " def %s(" name;
> @@ -829,8 +829,8 @@ let
> pr "self";
> List.iter (
> function
> - | n, None, _ -> pr ", %s" n
> - | n, Some default, _ -> pr ", %s=%s" n default
> + | n, None -> pr ", %s" n
> + | n, Some default -> pr ", %s=%s" n default
> ) args);
> pr "):\n";
> let longdesc = Str.global_replace py_fn_rex "C<nbd.\\1>" longdesc in
> @@ -842,8 +842,7 @@ let
> pr "self._o";
> List.iter (
> function
> - | _, _, Some getter -> pr ", %s" getter
> - | n, _, None -> pr ", %s" n
> + | n, _ -> pr ", %s" n
> ) args);
> pr ")\n";
> pr "\n"
Reviewed-by: Richard W.M. Jones <rjones at redhat.com>
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
nbdkit - Flexible, fast NBD server with plugins
https://gitlab.com/nbdkit/nbdkit
More information about the Libguestfs
mailing list