]> git.ipfire.org Git - thirdparty/qemu.git/commit
qapi: Clean up doc comment checking for implicit union base
authorMarkus Armbruster <armbru@redhat.com>
Thu, 24 Oct 2019 11:02:28 +0000 (13:02 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 29 Oct 2019 06:35:16 +0000 (07:35 +0100)
commit7faefad184201b10c2db4270b2bb93e2a5e9552b
tree51f5bb310f6c83e0746d388f837a76a85411f3e5
parent36a43905ffcac8767947626a6761df63fc020841
qapi: Clean up doc comment checking for implicit union base

An object type's doc comment describes the type's members, less the
ones defined in a named base type.  Cases:

* Struct: the members are defined in 'data' and inherited from 'base'.
  Since the base type cannot be implicit, the doc comment describes
  just 'data'.

* Simple union: the only member is the implicit tag member @type, and
  the doc comment describes it.

* Flat union with implicit base type: the members are defined in
  'base', and the doc comment describes it.

* Flat union with named base type: the members are inherited from
  'base'.  The doc comment describes no members.

Before we can check a doc comment with .check_doc(), we need
.connect_doc() connect each of its "argument sections" to the member
it documents.

For structs and simple unions, this is straightforward: the members in
question are in .local_members, and .connect_doc() connects them.

For flat unions with a named base type, it's trivial: .local_members
is empty, and .connect_doc() does nothing.

For flat unions with an implicit base type, it's tricky.  We have
QAPISchema._make_implicit_object_type() forward the union's doc
comment to the implicit base type, so that the base type's
.connect_doc() connects the members.  The union's .connect_doc() does
nothing, as .local_members is empty.

Dirt effect: we check the doc comment twice, once for the union type,
and once for the implicit base type.

This is needlessly brittle and hard to understand.  Clean up as
follows.  Make the union's .connect_doc() connect an implicit base's
members itself.  Do not forward the union's doc comment to its
implicit base type.

Requires extending .connect_doc() so it can work with a doc comment
other than self.doc.  Add an optional argument for that.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20191024110237.30963-11-armbru@redhat.com>
scripts/qapi/schema.py