On 09/03/2015 08:30 AM, Markus Armbruster wrote: > Fixes flat unions to visit the base's base members (the previous > commit merely added them to the struct). Same test case. >
> > Signed-off-by: Markus Armbruster <arm...@redhat.com> > Reviewed-by: Eric Blake <ebl...@redhat.com> > --- > scripts/qapi-visit.py | 260 > +++++++++++++------------------- > tests/qapi-schema/qapi-schema-test.json | 3 - > tests/test-qmp-input-strict.c | 4 +- > tests/test-qmp-input-visitor.c | 4 +- > 4 files changed, 107 insertions(+), 164 deletions(-) > > +def gen_visit_union(name, base, variants): > + ret = '' > > if base: > + disc_key = variants.tag_member.name > + if not variants.tag_name: > + # we pointlessly use a different key for simple unions > + disc_key = 'type' > ret += mcgen(''' > - visit_type_%(disc_type)s(m, &(*obj)->%(c_tag)s, "%(disc_key)s", > &err); > + visit_type_%(disc_type)s(m, &(*obj)->%(c_name)s, "%(disc_key)s", > &err); > if (err) { > goto out_obj; > } > if (!visit_start_union(m, !!(*obj)->data, &err) || err) { > goto out_obj; > } > - switch ((*obj)->%(c_tag)s) { > + switch ((*obj)->%(c_name)s) { > ''', > - disc_type = disc_type, > - c_tag=c_name(tag), > + disc_type=variants.tag_member.type.c_name(), > + c_name=c_name(variants.tag_member.name), > disc_key = disc_key) See my comments on 30/32, and patches in 2 and 10. This is the final place that cannot refer to tag_member.name until after we unify the C and wire spelling. diff --git i/scripts/qapi-visit.py w/scripts/qapi-visit.py index 6819866..468080e 100644 --- i/scripts/qapi-visit.py +++ w/scripts/qapi-visit.py @@ -284,7 +284,7 @@ void visit_type_%(c_name)s(Visitor *m, %(c_name)s **obj, const char *name, Error switch ((*obj)->%(c_name)s) { ''', c_type=variants.tag_member.type.c_name(), - c_name=c_name(variants.tag_member.name), + c_name=c_name(variants.tag_name or 'kind'), name=tag_key) for var in variants.variants: -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature