summaryrefslogtreecommitdiff
path: root/scripts/qapi
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2019-02-14 16:22:38 +0100
committerMarkus Armbruster <armbru@redhat.com>2019-02-18 14:44:04 +0100
commit5d75648b56e6e400eafaa1c2c8616ffc5ae6148e (patch)
tree726cd271079330d6fd489ba0f31d773e31f04cd2 /scripts/qapi
parentc2e196a9b41235a308fb6d1c516aa91ba0a807c8 (diff)
downloadqemu-5d75648b56e6e400eafaa1c2c8616ffc5ae6148e.zip
qapi: Generate QAPIEvent stuff into separate files
Having to include qapi-events.h just for QAPIEvent is suboptimal, but quite tolerable now. It'll become problematic when we have events conditional on the target, because then qapi-events.h won't be usable from target-independent code anymore. Avoid that by generating it into separate files. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20190214152251.2073-6-armbru@redhat.com>
Diffstat (limited to 'scripts/qapi')
-rw-r--r--scripts/qapi/events.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py
index 6f39cf8196..28bbc3745d 100644
--- a/scripts/qapi/events.py
+++ b/scripts/qapi/events.py
@@ -143,12 +143,14 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
self._event_emit_name = c_name(prefix + 'qapi_event_emit')
def _begin_user_module(self, name):
+ events = self._module_basename('qapi-events', name)
types = self._module_basename('qapi-types', name)
visit = self._module_basename('qapi-visit', name)
self._genc.add(mcgen('''
#include "qemu/osdep.h"
#include "qemu-common.h"
-#include "%(prefix)sqapi-events.h"
+#include "%(prefix)sqapi-emit-events.h"
+#include "%(events)s.h"
#include "%(visit)s.h"
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
@@ -156,26 +158,34 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor):
#include "qapi/qmp-event.h"
''',
- visit=visit, prefix=self._prefix))
+ events=events, visit=visit,
+ prefix=self._prefix))
self._genh.add(mcgen('''
#include "qapi/util.h"
#include "%(types)s.h"
-
''',
types=types))
def visit_end(self):
- (genc, genh) = self._module[self._main_module]
- genh.add(gen_enum(self._event_enum_name,
- self._event_enum_members))
- genc.add(gen_enum_lookup(self._event_enum_name,
- self._event_enum_members))
- genh.add(mcgen('''
+ self._add_system_module('emit', ' * QAPI Events emission')
+ self._genc.preamble_add(mcgen('''
+#include "qemu/osdep.h"
+#include "%(prefix)sqapi-emit-events.h"
+''',
+ prefix=self._prefix))
+ self._genh.preamble_add(mcgen('''
+#include "qapi/util.h"
+'''))
+ self._genh.add(gen_enum(self._event_enum_name,
+ self._event_enum_members))
+ self._genc.add(gen_enum_lookup(self._event_enum_name,
+ self._event_enum_members))
+ self._genh.add(mcgen('''
void %(event_emit)s(%(event_enum)s event, QDict *qdict);
''',
- event_emit=self._event_emit_name,
- event_enum=self._event_enum_name))
+ event_emit=self._event_emit_name,
+ event_enum=self._event_enum_name))
def visit_event(self, name, info, ifcond, arg_type, boxed):
with ifcontext(ifcond, self._genh, self._genc):