Skip to content

Commit 7a9539c

Browse files
committed
generator: Mark QNX c_void types as opaque to get raw pointers
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. Likewise in #433 I changed the "platform type" for `SECURITY_ATTRIBUTES` (which is a POD) to `c_void` but the borrow in the builder remains. With a `c_void` it's more useful to map these as a raw `*const` pointer too.
1 parent eed4c8f commit 7a9539c

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

Changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
### Changed
2020

21+
- `push_next()` has been renamed to `extend()` and marked as `unsafe`. Users are encouraged to call `push()` for singular structs instead. (#909)
22+
- Treat QNX "void" type aliases and `SECURITY_ATTRIBUTES` as "opaque" to make them raw pointers instead of borrows in public structures. (#950)
2123
- Enable passing mutable arrays of `pNext`-initialized structs for these remaining extension functions: (#966)
2224
- `VK_EXT_tooling_info`: `get_physical_device_tool_properties()`;
2325
- `VK_KHR_cooperative_matrix`: `get_physical_device_cooperative_matrix_properties()`;
@@ -26,7 +28,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2628
- `get_pipeline_executable_properties()`;
2729
- `get_pipeline_executable_statistics()`.
2830
The expected length of this array can be queried with the respective `*_len()` variant of these functions.
29-
- `push_next()` has been renamed to `extend()` and marked as `unsafe`. Users are encouraged to call `push()` for singular structs instead. (#909)
3031
- Changed and renamed `RawPtr::as_raw_ptr(&self)` trait function to a by-value `RawPtr::to_raw_ptr(self)` function. (#965)
3132
- All `Extends{Root}` traits have been replaced with a single `Extends<Root>` trait using generics. (#971)
3233
- Moved `push()` and `extend()` methods from individual Vulkan structs (builders) into the `TaggedStructure` trait. (#994)

ash/src/vk/definitions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8689,12 +8689,12 @@ impl<'a> ScreenSurfaceCreateInfoQNX<'a> {
86898689
self
86908690
}
86918691
#[inline]
8692-
pub fn context(mut self, context: &'a mut _screen_context) -> Self {
8692+
pub fn context(mut self, context: *mut _screen_context) -> Self {
86938693
self.context = context;
86948694
self
86958695
}
86968696
#[inline]
8697-
pub fn window(mut self, window: &'a mut _screen_window) -> Self {
8697+
pub fn window(mut self, window: *mut _screen_window) -> Self {
86988698
self.window = window;
86998699
self
87008700
}
@@ -9684,7 +9684,7 @@ unsafe impl<'a> TaggedStructure<'a> for ExportMemoryWin32HandleInfoNV<'a> {
96849684
unsafe impl Extends<MemoryAllocateInfo<'_>> for ExportMemoryWin32HandleInfoNV<'_> {}
96859685
impl<'a> ExportMemoryWin32HandleInfoNV<'a> {
96869686
#[inline]
9687-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
9687+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
96889688
self.p_attributes = attributes;
96899689
self
96909690
}
@@ -11868,7 +11868,7 @@ unsafe impl<'a> TaggedStructure<'a> for ExportMemoryWin32HandleInfoKHR<'a> {
1186811868
unsafe impl Extends<MemoryAllocateInfo<'_>> for ExportMemoryWin32HandleInfoKHR<'_> {}
1186911869
impl<'a> ExportMemoryWin32HandleInfoKHR<'a> {
1187011870
#[inline]
11871-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
11871+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
1187211872
self.p_attributes = attributes;
1187311873
self
1187411874
}
@@ -12487,7 +12487,7 @@ unsafe impl<'a> TaggedStructure<'a> for ExportSemaphoreWin32HandleInfoKHR<'a> {
1248712487
unsafe impl Extends<SemaphoreCreateInfo<'_>> for ExportSemaphoreWin32HandleInfoKHR<'_> {}
1248812488
impl<'a> ExportSemaphoreWin32HandleInfoKHR<'a> {
1248912489
#[inline]
12490-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
12490+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
1249112491
self.p_attributes = attributes;
1249212492
self
1249312493
}
@@ -13006,7 +13006,7 @@ unsafe impl<'a> TaggedStructure<'a> for ExportFenceWin32HandleInfoKHR<'a> {
1300613006
unsafe impl Extends<FenceCreateInfo<'_>> for ExportFenceWin32HandleInfoKHR<'_> {}
1300713007
impl<'a> ExportFenceWin32HandleInfoKHR<'a> {
1300813008
#[inline]
13009-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
13009+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
1301013010
self.p_attributes = attributes;
1301113011
self
1301213012
}
@@ -54989,7 +54989,7 @@ unsafe impl<'a> TaggedStructure<'a> for ImportScreenBufferInfoQNX<'a> {
5498954989
unsafe impl Extends<MemoryAllocateInfo<'_>> for ImportScreenBufferInfoQNX<'_> {}
5499054990
impl<'a> ImportScreenBufferInfoQNX<'a> {
5499154991
#[inline]
54992-
pub fn buffer(mut self, buffer: &'a mut _screen_buffer) -> Self {
54992+
pub fn buffer(mut self, buffer: *mut _screen_buffer) -> Self {
5499354993
self.buffer = buffer;
5499454994
self
5499554995
}

generator/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ fn is_opaque_type(ty: &str) -> bool {
300300
| "CAMetalLayer"
301301
| "IDirectFB"
302302
| "IDirectFBSurface"
303+
| "_screen_buffer"
304+
| "_screen_context"
305+
| "_screen_window"
306+
| "SECURITY_ATTRIBUTES"
303307
)
304308
}
305309

0 commit comments

Comments
 (0)