Skip to content

Commit

Permalink
Fix output structs in command wrappers (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMayes committed Sep 23, 2023
1 parent 94a3572 commit d31d29d
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 164 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Changed
- Added `no_std` compability for `vulkanalia` and `vulkanalia-sys` crates
- Make all extendable output structs parameters in command wrappers (see [#213](https://github.com/KyleMayes/vulkanalia/issues/213) for details)

## [0.22.0] - 2023-09-15

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ fun Registry.generateCommandWrapper(command: Command): String {
// input when the output type is an extendable struct so that the
// user can provide the extension structs for the information they
// want to be populated in the output parameter.
val extendable = getStructExtensions().containsKey(pointee.getIdentifier())
val extendable = getChainStructs().containsKey(pointee.getIdentifier())

if (output && !extendable) {
// Output pointer parameter (uninit-provided).
Expand All @@ -190,10 +190,15 @@ fun Registry.generateCommandWrapper(command: Command): String {
resultTypes.add(resultType)
resultExprs.add("${current.name}.assume_init()$exprCast")
addArgument("${current.name}.as_mut_ptr()")
} else if (output && extendable) {
} else if (output) {
// Output pointer parameter (user-provided).
params.add("${current.name}: &mut ${pointee.generate()}")
addArgument(current.name.value)
if (current.optional) {
params.add("${current.name}: Option<&mut ${pointee.generate()}>")
addArgument("${current.name}.map_or(ptr::null_mut(), |v| v)")
} else {
params.add("${current.name}: &mut ${pointee.generate()}")
addArgument(current.name.value)
}
} else if (current.type.isOpaquePointer()) {
// Input pointer parameter (opaque).
params.add("${current.name}: ${current.type.generate()}")
Expand Down
Loading

0 comments on commit d31d29d

Please sign in to comment.