diff mbox series

[v3,02/49] qapi/events: generate event enum in main module

Message ID 20180321115211.17937-3-marcandre.lureau@redhat.com
State New
Headers show
Series qapi: add #if pre-processor conditions to generated code | expand

Commit Message

Marc-André Lureau March 21, 2018, 11:51 a.m. UTC
The event generator produces an enum, and put it in the last visited
module. It fits better in the main module, since it's the set of all
visited events, from all modules.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/qapi/events.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Markus Armbruster June 18, 2018, 2:33 p.m. UTC | #1
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> The event generator produces an enum, and put it in the last visited
> module. It fits better in the main module, since it's the set of all
> visited events, from all modules.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  scripts/qapi/events.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py
> index 3dc523cf39..3e448ae523 100644
> --- a/scripts/qapi/events.py
> +++ b/scripts/qapi/events.py
> @@ -180,8 +180,9 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
>                               types=types))
>  
>      def visit_end(self):
> -        self._genh.add(gen_enum(self._enum_name, self._event_names))
> -        self._genc.add(gen_enum_lookup(self._enum_name, self._event_names))
> +        (genc, genh) = self._module[self._main_module]
> +        genh.add(gen_enum(self._enum_name, self._event_names))
> +        genc.add(gen_enum_lookup(self._enum_name, self._event_names))
>  
>      def visit_event(self, name, info, arg_type, boxed):
>          self._genh.add(gen_event_send_decl(name, arg_type, boxed))

Much better indeed.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox series

Patch

diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py
index 3dc523cf39..3e448ae523 100644
--- a/scripts/qapi/events.py
+++ b/scripts/qapi/events.py
@@ -180,8 +180,9 @@  class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
                              types=types))
 
     def visit_end(self):
-        self._genh.add(gen_enum(self._enum_name, self._event_names))
-        self._genc.add(gen_enum_lookup(self._enum_name, self._event_names))
+        (genc, genh) = self._module[self._main_module]
+        genh.add(gen_enum(self._enum_name, self._event_names))
+        genc.add(gen_enum_lookup(self._enum_name, self._event_names))
 
     def visit_event(self, name, info, arg_type, boxed):
         self._genh.add(gen_event_send_decl(name, arg_type, boxed))