diff mbox series

[v3,11/50] qapi-introspect: modify to_qlit() to generate #if code

Message ID 20170911110623.24981-12-marcandre.lureau@redhat.com
State New
Headers show
Series Hi, | expand

Commit Message

Marc-André Lureau Sept. 11, 2017, 11:05 a.m. UTC
The generator now accepts (obj, condition) tuples to wrap generated
QLit objects for 'obj' with #if/#endif conditions.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 scripts/qapi-introspect.py | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Markus Armbruster Dec. 7, 2017, 2:50 p.m. UTC | #1
Marc-André Lureau <marcandre.lureau@redhat.com> writes:

> The generator now accepts (obj, condition) tuples to wrap generated
> QLit objects for 'obj' with #if/#endif conditions.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  scripts/qapi-introspect.py | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
> index b1d08ec97b..dc70954e8a 100644
> --- a/scripts/qapi-introspect.py
> +++ b/scripts/qapi-introspect.py
> @@ -17,6 +17,13 @@ def to_qlit(obj, level=0, suppress_first_indent=False):
>      def indent(level):
>          return level * 4 * ' '
>  
> +    if isinstance(obj, tuple):
> +        ifobj, ifcond = obj
> +        ret = gen_if(ifcond)
> +        ret += to_qlit(ifobj, level)
> +        ret += '\n' + gen_endif(ifcond)
> +        return ret
> +
>      ret = ''
>      if not suppress_first_indent:
>          ret += indent(level)

Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox series

Patch

diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index b1d08ec97b..dc70954e8a 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -17,6 +17,13 @@  def to_qlit(obj, level=0, suppress_first_indent=False):
     def indent(level):
         return level * 4 * ' '
 
+    if isinstance(obj, tuple):
+        ifobj, ifcond = obj
+        ret = gen_if(ifcond)
+        ret += to_qlit(ifobj, level)
+        ret += '\n' + gen_endif(ifcond)
+        return ret
+
     ret = ''
     if not suppress_first_indent:
         ret += indent(level)