pvr: csbgen: Add typing information
authorMatt Coster <matt.coster@imgtec.com>
Thu, 12 May 2022 09:26:39 +0000 (10:26 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Jun 2022 09:13:22 +0000 (09:13 +0000)
commita8b80c610be0fb7b21866a23e86804c335ba8c6e
tree4b96e06e4a3f3e0588c99c9f2d2c080a4694d39e
parentf2de3716d8bf0140c744d7d21c3ce807997ea232
pvr: csbgen: Add typing information

This is generally PEP-484 stuff, but there is one functional change.
The base class Node needed to have an add() method to allow typed
dynamic dispatch. This could have been decorated @abstractmethod, but
that would require an error-raising implementation on all leaf-type
nodes. Instead, I added a base implementation that just errors out with
information from the subclass instance.

As a simple optimization, subclass implementations of add() (instead of
raising the same (or similar) error) now call super().add() in the
case of invalid child nodes.

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16884>
src/imagination/csbgen/gen_pack_header.py