qapi: Emit structs used as variants in topological order
commit1de5d4ca0752138034305f3d4e8fe17ef6503569
authorEric Blake <eblake@redhat.com>
Thu, 18 Feb 2016 06:48:24 +0000 (17 23:48 -0700)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 19 Feb 2016 10:08:57 +0000 (19 11:08 +0100)
treec914df4f8dd7a66c0b00f040812da69f477b1488
parente65d89bf1a4484e0db0f3dc820a8b209f2fb1e8b
qapi: Emit structs used as variants in topological order

Right now, we emit the branches of union types as a boxed pointer,
and it suffices to have a forward declaration of the type.  However,
a future patch will swap things to directly use the branch type,
instead of hiding it behind a pointer.  For this to work, the
compiler needs the full definition of the type, not just a forward
declaration, prior to the union that is including the branch type.
This patch just adds topological sorting to hoist all types
mentioned in a branch of a union to be fully declared before the
union itself.  The sort is always possible, because we do not
allow circular union types that include themselves as a direct
branch (it is, however, still possible to include a branch type
that itself has a pointer to the union, for a type that can
indirectly recursively nest itself - that remains safe, because
that the member of the branch type will remain a pointer, and the
QMP representation of such a type adds another {} for each recurring
layer of the union type).

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <1455778109-6278-11-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi-types.py