From 7b4961d75be8c5f9be01b29f232434f6524b2730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 5 Jul 2018 12:09:03 -0400 Subject: [PATCH] qapi/events: add #if conditions to events Wrap generated code with #if/#endif using an 'ifcontext' on QAPIGenCSnippet objects. This makes a conditional event's qapi_event_send_FOO() compile-time conditional, but its enum QAPIEvent member remains unconditional for now. A follow up patch "qapi-event: add 'if' condition to implicit event enum" will improve this. Backports commit c3cd6aa0201c126eda8dc71b60e7aa259a3e79b9 from qemu --- qemu/scripts/qapi/events.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qemu/scripts/qapi/events.py b/qemu/scripts/qapi/events.py index 50690a1b..007c9f79 100644 --- a/qemu/scripts/qapi/events.py +++ b/qemu/scripts/qapi/events.py @@ -185,8 +185,10 @@ class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): genc.add(gen_enum_lookup(self._enum_name, self._event_names)) def visit_event(self, name, info, ifcond, arg_type, boxed): - self._genh.add(gen_event_send_decl(name, arg_type, boxed)) - self._genc.add(gen_event_send(name, arg_type, boxed, self._enum_name)) + with ifcontext(ifcond, self._genh, self._genc): + self._genh.add(gen_event_send_decl(name, arg_type, boxed)) + self._genc.add(gen_event_send(name, arg_type, boxed, + self._enum_name)) self._event_names.append(name)