]> git.proxmox.com Git - mirror_qemu.git/commit
qapi/parser: Introduce NullSection
authorJohn Snow <jsnow@redhat.com>
Thu, 30 Sep 2021 20:57:10 +0000 (16:57 -0400)
committerMarkus Armbruster <armbru@redhat.com>
Sat, 2 Oct 2021 05:33:42 +0000 (07:33 +0200)
commitf4c05aaf148a44d80855eb45b9342feaeeb4764a
tree64bd532191e41f1ad2912a02cc2ebf35d747debf
parent1e20a77576dedf1489ce1cdb6abc4b34663637a4
qapi/parser: Introduce NullSection

Here's the weird bit. QAPIDoc generally expects -- virtually everywhere
-- that it will always have a current section. The sole exception to
this is in the case that end_comment() is called, which leaves us with
*no* section. However, in this case, we also don't expect to actually
ever mutate the comment contents ever again.

NullSection is just a Null-object that allows us to maintain the
invariant that we *always* have a current section, enforced by static
typing -- allowing us to type that field as QAPIDoc.Section instead of
the more ambiguous Optional[QAPIDoc.Section].

end_section is renamed to switch_section and now accepts as an argument
the new section to activate, clarifying that no callers ever just
unilaterally end a section; they only do so when starting a new section.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20210930205716.1148693-8-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi/parser.py