[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 11/14] qapi: add #if/#endif helpers
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH RFC 11/14] qapi: add #if/#endif helpers |
Date: |
Mon, 12 Feb 2018 08:22:04 +0100 |
From: Marc-André Lureau <address@hidden>
Add helpers to wrap generated code with #if/#endif lines.
Signed-off-by: Marc-André Lureau <address@hidden>
---
scripts/qapi/common.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 1b254d5b32..1a78dfaf3f 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -1973,6 +1973,24 @@ def guardend(name):
name=guardname(name))
+def gen_if(ifcond):
+ ret = ''
+ for ifc in ifcond:
+ ret += mcgen('''
+#if %(cond)s
+''', cond=ifc)
+ return ret
+
+
+def gen_endif(ifcond):
+ ret = ''
+ for ifc in reversed(ifcond):
+ ret += mcgen('''
+#endif /* %(cond)s */
+''', cond=ifc)
+ return ret
+
+
def gen_enum_lookup(name, values, prefix=None):
ret = mcgen('''
--
2.13.6
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH RFC 11/14] qapi: add #if/#endif helpers,
Markus Armbruster <=