unicorn/qemu/scripts
Eric Blake 155c507ed4
qapi: Visit variants in visit_type_FOO_fields()
We initially created the static visit_type_FOO_fields() helper
function for reuse of code - we have cases where the initial
setup for a visit has different allocation (depending on whether
the fields represent a stand-alone type or are embedded as part
of a larger type), but where the actual field visits are
identical once a pointer is available.

Up until the previous patch, visit_type_FOO_fields() was only
used for structs (no variants), so it was covering every field
for each type where it was emitted.

Meanwhile, the code for visiting unions looks like:

static visit_type_U_fields() {
visit base;
visit local_members;
}
visit_type_U() {
visit_start_struct();
visit_type_U_fields();
visit variants;
visit_end_struct();
}

which splits the fields of the union visit across two functions.
Move the code to visit variants to live inside visit_type_U_fields(),
while making it conditional on having variants so that all other
instances of the helper function remain unchanged. This is also
a step closer towards unifying struct and union visits, and towards
allowing one union type to be the branch of another flat union.

The resulting diff to the generated code is a bit hard to read,
but it can be verified that it touches only union types, and that
the end result is the following general structure:

static visit_type_U_fields() {
visit base;
visit local_members;
visit variants;
}
visit_type_U() {
visit_start_struct();
visit_type_U_fields();
visit_end_struct();
}

Backports commit 9a5cd424d5f06fb5293eb264456d89343c557558 from qemu
2018-02-20 15:53:30 -05:00
..
create_config more cleanup qemu/configure 2017-01-19 14:11:54 +08:00
make_device_config.sh
ordereddict.py
qapi-event.py qapi: Drop unused 'kind' for struct/enum visit 2018-02-19 23:43:54 -05:00
qapi-types.py qapi: Swap visit_* arguments for consistent 'name' placement 2018-02-19 22:45:07 -05:00
qapi-visit.py qapi: Visit variants in visit_type_FOO_fields() 2018-02-20 15:53:30 -05:00
qapi.py qapi: Forbid 'any' inside an alternate 2018-02-20 15:47:16 -05:00