On 09/21/2015 03:58 PM, Eric Blake wrote: > Rather than requiring all flat unions to explicitly create > a separate base struct, we want to allow the qapi schema > to specify the common fields via an inline dictionary. This > is similar to how commands can specify inline types for the > arguments. > > Now that the feature is legal, we can drop the former > flat-union-bad-base negative test, and instead change the > positive tests in qapi-schema-test to use it. > > Signed-off-by: Eric Blake <ebl...@redhat.com> > ---
> +++ b/scripts/qapi-visit.py > @@ -272,10 +272,17 @@ void visit_type_%(c_name)s(Visitor *v, %(c_name)s > **obj, const char *name, Error > > tag_key = variants.tag_member.name > if base: > - ret += mcgen(''' > + if not base.is_implicit(): > + ret += mcgen(''' > visit_type_%(c_name)s_fields(v, (%(c_name)s **)obj, &err); > ''', > - c_name=c_name(base.name)) > + c_name=c_name(base.name)) > + else: > + push_indent() > + ret += gen_visit_fields(base.members, '(*obj)->', False, > + 'err', 'out_obj') > + pop_indent() > + tag_key = variants.tag_member.name > else: > ret += mcgen(''' > visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err); > ''', > c_type=variants.tag_member.type.c_name(), > c_name=c_name(tag_key), name=tag_key) > ret += mcgen(''' > if (err) { > goto out_obj; > } Whoops - this results in two back-to-back 'if (err)' clauses in the generated output when an implicit base is used (harmless, other than wasted effort). I'll avoid the duplication in v6. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature