qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 4/4] qapi: generate a literal qobject for intros


From: Daniel P . Berrangé
Subject: Re: [Qemu-devel] [PATCH 4/4] qapi: generate a literal qobject for introspection
Date: Mon, 5 Mar 2018 17:59:44 +0000
User-agent: Mutt/1.9.2 (2017-12-15)

On Mon, Mar 05, 2018 at 06:29:51PM +0100, Marc-André Lureau wrote:
> Replace the generated json string with a literal qobject. The later is
> easier to deal with, at run time as well as compile time: adding #if
> conditionals will be easier than in a json string.
> 
> The output of query-qmp-schema is not changed.
> 
> Signed-off-by: Marc-André Lureau <address@hidden>
> Reviewed-by: Markus Armbruster <address@hidden>
> ---
>  scripts/qapi/introspect.py         | 76 +++++++++++++++++-------------
>  monitor.c                          |  2 +-
>  tests/test-qobject-input-visitor.c | 11 +++--
>  docs/devel/qapi-code-gen.txt       | 29 ++++++++----
>  4 files changed, 70 insertions(+), 48 deletions(-)
> 
> diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py
> index f66c397fb0..4df730377f 100644
> --- a/scripts/qapi/introspect.py
> +++ b/scripts/qapi/introspect.py


>      elif isinstance(obj, dict):
> -        elts = ['"%s": %s' % (key.replace('"', r'\"'),
> -                              to_json(obj[key], level + 1))
> -                for key in sorted(obj.keys())]
> -        ret = '{' + ', '.join(elts) + '}'
> +        elts = []
> +        for key, value in sorted(obj.iteritems()):

s/iteritems/items/  for dual Python 2+3 compatibility  which is what the
patchew failure was complaining about.

> +            elts.append(indent(level + 1) + '{ %s, %s }' %
> +                        (to_c_string(key), to_qlit(value, level + 1, True)))
> +        elts.append(indent(level + 1) + '{}')
> +        ret += 'QLIT_QDICT(((QLitDictEntry[]) {\n'
> +        ret += ',\n'.join(elts) + '\n'
> +        ret += indent(level) + '}))'

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



reply via email to

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