On 9/8/20 8:57 AM, Richard W.M. Jones wrote:
diff --git a/generator/C.ml b/generator/C.ml index deb77fa..280b319 100644 --- a/generator/C.ml +++ b/generator/C.ml @@ -99,16 +99,17 @@ let rec name_of_arg = function | UInt64 n -> [n]
let rec print_arg_list ?(wrap = false) ?maxcol ?handle ?types ?(parens = true) + ?(closure_mark) args optargs =
You don't need parens around here, you can just write ?closure_mark
Leftovers from when I tried to initialize the default here, before realizing...
+ if parens then pr "("; + if wrap then + pr_wrap ?maxcol ',' + (fun () -> print_arg_list' ?handle ?types ?closure_mark args optargs) + else + print_arg_list' ?handle ?types ?closure_mark args optargs; + if parens then pr ")" + +and print_arg_list' ?(handle = false) ?(types = true) ?(closure_mark = "")
...it actually needed to be here.
...
args optargs = | Closure { cbname; cbargs } -> if types then pr "nbd_%s_callback " cbname; - pr "%s_callback" cbname + pr "%s%s_callback" closure_mark cbname
Perhaps make it type safe?
type closure_mark = AddressOf | Dereference
It's a tri-state: Direct (empty string, for public API and elsewhere we don't need decoration), AddressOf (when calling into internal function from the public API, to decorate with &), and Derereference (when declaring the internal function, to decorate with *). But yes, that seems a little cleaner than an open-coded string. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org