qemu/scripts
Eric Blake 88d4ef8b5c qapi: Track owner of each object member
Future commits will migrate semantic checking away from parsing
and over to the various QAPISchema*.check() methods.  But to
report an error message about an incorrect semantic use of a
member of an object type, it helps to know which type, command,
or event owns the member.  In particular, when a member is
inherited from a base type, it is desirable to associate the
member name with the base type (and not the type calling
member.check()).

Rather than packing additional information into the seen array
passed to each member.check() (as in seen[m.name] = {'member':m,
'owner':type}), it is easier to have each member track the name
of the owner type in the first place (keeping things simpler
with the existing seen[m.name] = m).  The new member.owner field
is set via a new set_owner() method, called when registering
the members and variants arrays with an object or variant type.
Track only a name, and not the actual type object, to avoid
creating a circular python reference chain.

Note that Variants.set_owner() method does not set the owner
for the tag_member field; this field is set earlier either as
part of an object's non-variant members, or explicitly by
alternates.

The source information is intended for human consumption in
error messages, and a new describe() method is added to access
the resulting information.  For example, given the qapi:
  { 'command': 'foo', 'data': { 'string': 'str' } }
an implementation of visit_command() that calls
  arg_type.members[0].describe()
will see "'string' (parameter of foo)".

To make the human-readable name of implicit types work without
duplicating efforts, the describe() method has to reverse the
name of implicit types, via the helper _pretty_owner().

No change to generated code.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1447836791-369-16-git-send-email-eblake@redhat.com>
[Incorrect & unused -wrapper case in _pretty_owner() dropped]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2015-12-17 08:21:27 +01:00
..
kvm
qemu-guest-agent
qemugdb
qmp
tracetool
acpi_extract.py
acpi_extract_preprocess.py
analyse-9p-simpletrace.py
analyze-migration.py
check-qerror.sh
checkpatch.pl
cleanup-trace-events.pl
cocci-macro-file.h
coverity-model.c
create_config
disas-objdump.pl
dump-guest-memory.py
extract-vsssdk-headers
feature_to_c.sh
get_maintainer.pl
gtester-cat
hxtool
make-release
make_device_config.sh
ordereddict.py
qapi-commands.py
qapi-event.py
qapi-introspect.py
qapi-types.py qapi-types: Simplify gen_struct_field[s] 2015-12-17 08:21:26 +01:00
qapi-visit.py
qapi.py qapi: Track owner of each object member 2015-12-17 08:21:27 +01:00
qemu-binfmt-conf.sh
qemu-gdb.py
qtest.py
refresh-pxe-roms.sh
shaderinclude.pl
signrom.py
simpletrace.py
switch-timer-api
texi2pod.pl
tracetool.py
update-acpi.sh
update-linux-headers.sh
vmstate-static-checker.py