On 09/21/2015 03:57 PM, Eric Blake wrote: > The code for visiting the base class of a child struct created > visit_type_Base_fields(); the code for visiting the base class > of a flat union created visit_type_Union_fields(). If the same > type is shared between a struct and a union, the two functions > differed only by whether they visited the discriminator used by > the union. But if the base class always visits all its fields, > then we don't need to revisit the discriminator specially for > a union. By consistently visiting the base class fields under > the name of the base class, we can eliminate some redundant > code. > > Now that gen_visit_struct_fields() can potentially collect more > than one function into 'ret', a regular expression searching for > whether a label was used may hit a false positive within the > body of the first function. But using a regex was overkill, > since we can easily determine when we jumped to a label. >
> visit_type_%(c_type)s(v, &(*obj)->%(c_name)s, "%(name)s", &err); > - if (err) { > - goto out_obj; > - } > - switch ((*obj)->%(c_name)s) { > ''', > - c_type=variants.tag_member.type.c_name(), > - c_name=c_name(tag_key), name=tag_key) > + c_type=variants.tag_member.type.c_name(), > + c_name=c_name(tag_key), name=tag_key) > + ret += mcgen(''' > + if (err) { > + goto out_obj; > + } > + switch ((*obj)->%(c_name)s) { Rebase snafu - I botched the generated indentation within this mcgen() by 4 spaces. Shouldn't affect a technical review, and I will fix it up for v6. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature