Pino Toscano
2016-Feb-03 12:25 UTC
[Libguestfs] [PATCH] generator: simplify generated code for always-available features
Just refer to the dummy function directly, instead of using #define's. --- generator/daemon.ml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/generator/daemon.ml b/generator/daemon.ml index 7ffea7b..d1689e1 100644 --- a/generator/daemon.ml +++ b/generator/daemon.ml @@ -732,19 +732,15 @@ and generate_daemon_optgroups_c () pr " return 1;\n"; pr "}\n"; pr "\n"; - - List.iter ( - fun group -> - pr "#define optgroup_%s_available dummy_available\n" group; - ) optgroups_retired; - - pr "\n"; ); pr "struct optgroup optgroups[] = {\n"; List.iter ( fun group -> - pr " { \"%s\", optgroup_%s_available },\n" group group + if List.mem group optgroups_retired then + pr " { \"%s\", dummy_available },\n" group + else + pr " { \"%s\", optgroup_%s_available },\n" group group ) optgroups_names_all; pr " { NULL, NULL }\n"; pr "};\n" -- 2.5.0
Richard W.M. Jones
2016-Feb-03 13:29 UTC
Re: [Libguestfs] [PATCH] generator: simplify generated code for always-available features
On Wed, Feb 03, 2016 at 01:25:30PM +0100, Pino Toscano wrote:> Just refer to the dummy function directly, instead of using #define's. > --- > generator/daemon.ml | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/generator/daemon.ml b/generator/daemon.ml > index 7ffea7b..d1689e1 100644 > --- a/generator/daemon.ml > +++ b/generator/daemon.ml > @@ -732,19 +732,15 @@ and generate_daemon_optgroups_c () > pr " return 1;\n"; > pr "}\n"; > pr "\n"; > - > - List.iter ( > - fun group -> > - pr "#define optgroup_%s_available dummy_available\n" group; > - ) optgroups_retired; > - > - pr "\n"; > ); > > pr "struct optgroup optgroups[] = {\n"; > List.iter ( > fun group -> > - pr " { \"%s\", optgroup_%s_available },\n" group group > + if List.mem group optgroups_retired then > + pr " { \"%s\", dummy_available },\n" group > + else > + pr " { \"%s\", optgroup_%s_available },\n" group group > ) optgroups_names_all; > pr " { NULL, NULL }\n"; > pr "};\n"ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Reasonably Related Threads
- Re: [PATCH] daemon: scrub-file: resolve the path before calling scrub (RHBZ#1099490).
- [PATCH 16/27] daemon: Generate OCaml wrappers for optgroup_*_available functions.
- Re: [PATCH 1/4] generator: add always-available optgroups
- [PATCH v2 01/23] daemon: Allow parts of the daemon and APIs to be written in OCaml.
- [PATCH] Clarify the error message when unavailable functions are called (RHBZ#679737).