Add explicit return type to funcpointer definitions in Vulkan XML #2577
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposal: Explicit return types for funcpointers
Currently, it is not possible to fully analyze function pointer signatures in the Vulkan XML in a purely static way.
While the function arguments and the function name are accessible, the return type is not.
This makes it difficult to parse function pointers reliably in generators and analysis tools.
Additionally, the missing return type makes it very hard to construct a proper topological order of type dependencies, since the dependency chain cannot be resolved statically.
Suggested change
The
requires
attribute of the<type>
element could be used to store the return type explicitly.At the moment, the
requires
attribute is only used for redundant information that can already be derived from the function arguments.Using it consistently for return types instead would remove this redundancy and make the return type available in a static, machine-readable way.
For example:
With this change, the return type, arguments, and function name can all be determined statically and unambiguously.
It would also make it possible to construct a correct topological ordering of all types.
Alternative option
If using
requires
for return types is considered semantically unclear, a dedicatedreturns
attribute could be introduced to make the intent explicit (at the cost of a schema extension).Summary
requires
to specify the return type explicitlyreturns
attribute for stronger semantic clarity