Skip to content

Commit

Permalink
generator: Mark QNX c_void types as opaque to get raw pointers
Browse files Browse the repository at this point in the history
Long ago in #339 I added "opaque" types to ensure that pointers to it
stay as pointers in FFI rather than get converted to `&mut` borrows
which don't carry the load of an arbitrary pointer value to "something
unknown" (= opaque).  When the QNX types were added in #429 and #760
some time later, they weren't added to this list and turned into borrows
making them impossible to be handled safely in user code.
  • Loading branch information
MarijnS95 committed Oct 3, 2024
1 parent 5916329 commit 17ae186
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

### Changed

- Treat QNX "void" type aliases as "opaque" to make them raw pointers instead of borrows in public structures (#950)

### Added

- Update Vulkan-Headers to 1.3.296 (#910)
Expand Down
6 changes: 3 additions & 3 deletions ash/src/vk/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9264,12 +9264,12 @@ impl<'a> ScreenSurfaceCreateInfoQNX<'a> {
self
}
#[inline]
pub fn context(mut self, context: &'a mut _screen_context) -> Self {
pub fn context(mut self, context: *mut _screen_context) -> Self {
self.context = context;
self
}
#[inline]
pub fn window(mut self, window: &'a mut _screen_window) -> Self {
pub fn window(mut self, window: *mut _screen_window) -> Self {
self.window = window;
self
}
Expand Down Expand Up @@ -56278,7 +56278,7 @@ unsafe impl<'a> TaggedStructure for ImportScreenBufferInfoQNX<'a> {
unsafe impl ExtendsMemoryAllocateInfo for ImportScreenBufferInfoQNX<'_> {}
impl<'a> ImportScreenBufferInfoQNX<'a> {
#[inline]
pub fn buffer(mut self, buffer: &'a mut _screen_buffer) -> Self {
pub fn buffer(mut self, buffer: *mut _screen_buffer) -> Self {
self.buffer = buffer;
self
}
Expand Down
3 changes: 3 additions & 0 deletions generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ fn is_opaque_type(ty: &str) -> bool {
| "CAMetalLayer"
| "IDirectFB"
| "IDirectFBSurface"
| "_screen_buffer"
| "_screen_context"
| "_screen_window"
)
}

Expand Down

0 comments on commit 17ae186

Please sign in to comment.