qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH RFC 13/14] qapi-introspect: Add #if conditions to in


From: Markus Armbruster
Subject: [Qemu-devel] [PATCH RFC 13/14] qapi-introspect: Add #if conditions to introspection value
Date: Mon, 12 Feb 2018 08:22:06 +0100

Generated tests/test-qapi-introspect.c changes as follows:

    --- test-qapi-introspect.c.old      2018-02-11 17:36:15.039696522 +0100
    +++ tests/test-qapi-introspect.c    2018-02-11 17:36:34.455419852 +0100
    @@ -118,6 +118,9 @@ QLIT_QDICT(((QLitDictEntry[]) {
             { "ret-type", QLIT_QSTR("14"), },
             {}
         })),
    +#if defined(TEST_IF_CMD)
    +#if defined(TEST_IF_STRUCT)
    +
     QLIT_QDICT(((QLitDictEntry[]) {
             { "arg-type", QLIT_QSTR("15"), },
             { "meta-type", QLIT_QSTR("command"), },
    @@ -125,12 +128,19 @@ QLIT_QDICT(((QLitDictEntry[]) {
             { "ret-type", QLIT_QSTR("1"), },
             {}
         })),
    +#endif /* defined(TEST_IF_STRUCT) */
    +#endif /* defined(TEST_IF_CMD) */
    +
    +#if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)
    +
     QLIT_QDICT(((QLitDictEntry[]) {
             { "arg-type", QLIT_QSTR("16"), },
             { "meta-type", QLIT_QSTR("event"), },
             { "name", QLIT_QSTR("TestIfEvent"), },
             {}
         })),
    +#endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */
    +
     QLIT_QDICT(((QLitDictEntry[]) {
             { "members", QLIT_QLIST(((QLitObject[]) {
                 {}

Signed-off-by: Markus Armbruster <address@hidden>
---
 scripts/qapi/introspect.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py
index c02df95e72..342ae09422 100644
--- a/scripts/qapi/introspect.py
+++ b/scripts/qapi/introspect.py
@@ -40,6 +40,12 @@ def to_qlit(obj, level=0, suppress_first_indent=False):
         ret = 'QLIT_QDICT(((QLitDictEntry[]) {\n'
         ret += ',\n'.join(elts) + '\n'
         ret += indent(level) + '}))'
+    elif isinstance(obj, tuple):
+        # Use of tuples for conditionals is a bit of a hack
+        ifcond, begin = obj
+        if begin:
+            return gen_if(ifcond)
+        return gen_endif(ifcond)
     else:
         assert False                # not implemented
     if level > 0:
@@ -101,6 +107,9 @@ extern const QLitObject %(var)s;
         # Ignore types on first pass; visit_end() will pick up used types
         return not isinstance(entity, QAPISchemaType)
 
+    def visit_ifcond(self, ifcond, begin):
+        self._qlits.append((ifcond, begin))
+
     def _name(self, name):
         if self._unmask:
             return name
-- 
2.13.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]