qapi: add #if/#endif helpers
commitded9fc28b5a07213f3e5e8ac7ea0494b85813de1
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 3 Jul 2018 15:56:40 +0000 (3 17:56 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 3 Jul 2018 16:38:53 +0000 (3 18:38 +0200)
treeab324b1d74043c2481ffb5a7b3b3fb896d03c06e
parent485d948ce86f5a096dc848ec31b70cd66452d40d
qapi: add #if/#endif helpers

Add helpers to wrap generated code with #if/#endif lines.

A later patch wants to use QAPIGen for generating C snippets rather
than full C files with copyright headers etc.  Splice in class
QAPIGenCCode between QAPIGen and QAPIGenC.

Add a 'with' statement context manager that will be used to wrap
generator visitor methods.  The manager will check if code was
generated before adding #if/#endif lines on QAPIGenCSnippet
objects. Used in the following patches.

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