On Wed Dec 13 10:58:30 2023 +0000, Giovanni Mascellani wrote:
I don't think it's a good idea to use `base_type` before having made sure that it is relevant for this type. Maybe it doesn't happen in practice now, but in theory `base_type` could happen to be `HLSL_TYPE_TECHNIQUE` even if, say, `class` is `HLSL_CLASS_STRUCT`, just because the irrelevant field was left uninitialized, and then setting `version` would be wrong. Defensively, I would try to avoid that and check `base_type` only if `class == HLSL_CLASS_OBJECT`. Speaking of that, your changes make the documentation comment for field `base_type` in `struct hlsl_type` outdated, so you should fix that too. Notice that `type` is now called `class`, so you could take the chance to fix that too.
One option to improve readability is to have additional data using the same name as its class, so record -> struct, array as it is, new struct for object to hold both version and UAV format.