qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 4/4] qapi: generate a literal qobject for introspection
Date: Mon, 5 Mar 2018 17:59:44 +0000	[thread overview]
Message-ID: <20180305175944.GC17368@redhat.com> (raw)
In-Reply-To: <20180305172951.2150-5-marcandre.lureau@redhat.com>

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 <marcandre.lureau@redhat.com>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> ---
>  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	other threads:[~2018-03-05 18:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05 17:29 [Qemu-devel] [PATCH 0/4] qapi: generate a literal qobject for introspection Marc-André Lureau
2018-03-05 17:29 ` [Qemu-devel] [PATCH 1/4] qapi2texi: minor python code simplification Marc-André Lureau
2018-03-05 17:29 ` [Qemu-devel] [PATCH 2/4] qlit: use QType instead of int Marc-André Lureau
2018-03-05 17:29 ` [Qemu-devel] [PATCH 3/4] qlit: add qobject_from_qlit() Marc-André Lureau
2018-03-05 17:29 ` [Qemu-devel] [PATCH 4/4] qapi: generate a literal qobject for introspection Marc-André Lureau
2018-03-05 17:59   ` Daniel P. Berrangé [this message]
2018-03-05 17:40 ` [Qemu-devel] [PATCH 0/4] " no-reply
2018-03-08 23:18 ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180305175944.GC17368@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).