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.lur...@redhat.com> > Reviewed-by: Markus Armbruster <arm...@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 :|