qapi-introspect: add preprocessor conditions to generated QLit
commitd626b6c1ae7c811d0cfd5f8dc042426dcd1bcf90
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 Jul 2018 15:56:42 +0000 (3 17:56 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 3 Jul 2018 16:38:54 +0000 (3 18:38 +0200)
tree145a1d31de273886bf0e96c497fd37999c798425
parent40bb13766af789ae468a848aec7b45742497e5a9
qapi-introspect: add preprocessor conditions to generated QLit

This commit adds 'ifcond' conditions to top-level QLit objects.
Future work will add them to object and enum type members, i.e. within
QLit objects.

Extend the QLit generator to_qlit() to accept (@obj, @cond) tuples in
addition to just @obj.  The tuple causes the QLit generated for
objects for @obj with #if/#endif conditions for @cond.

See generated tests/test-qmp-introspect.c. Example diff after this
patch:

    --- before 2018-01-08 11:55:24.757083654 +0100
    +++ tests/test-qmp-introspect.c 2018-01-08 13:08:44.477641629 +0100
    @@ -51,6 +51,8 @@
             { "name", QLIT_QSTR("EVENT_F"), },
             {}
         })),
    +#if defined(TEST_IF_CMD)
    +#if defined(TEST_IF_STRUCT)
         QLIT_QDICT(((QLitDictEntry[]) {
             { "arg-type", QLIT_QSTR("5"), },
             { "meta-type", QLIT_QSTR("command"), },
    @@ -58,12 +60,16 @@
             { "ret-type", QLIT_QSTR("0"), },
             {}
         })),
    +#endif /* defined(TEST_IF_STRUCT) */
    +#endif /* defined(TEST_IF_CMD) */

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180703155648.11933-9-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/introspect.py