Skip to content

Commit 1a8be6f

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 3eb2ebc commit 1a8be6f

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased] - ReleaseDate
99

10+
### Changed
11+
12+
- Treat QNX "void" type aliases and `SECURITY_ATTRIBUTES` as "opaque" to make them raw pointers instead of borrows in public structures. (#950)
13+
1014
### Added
1115

1216
- Added `push()` method to all root structs to insert a single extension-struct in the pointer chain. (#909)

ash/src/vk/definitions.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10273,12 +10273,12 @@ impl<'a> ScreenSurfaceCreateInfoQNX<'a> {
1027310273
self
1027410274
}
1027510275
#[inline]
10276-
pub fn context(mut self, context: &'a mut _screen_context) -> Self {
10276+
pub fn context(mut self, context: *mut _screen_context) -> Self {
1027710277
self.context = context;
1027810278
self
1027910279
}
1028010280
#[inline]
10281-
pub fn window(mut self, window: &'a mut _screen_window) -> Self {
10281+
pub fn window(mut self, window: *mut _screen_window) -> Self {
1028210282
self.window = window;
1028310283
self
1028410284
}
@@ -11356,7 +11356,7 @@ unsafe impl<'a> TaggedStructure for ExportMemoryWin32HandleInfoNV<'a> {
1135611356
unsafe impl Extends<MemoryAllocateInfo<'_>> for ExportMemoryWin32HandleInfoNV<'_> {}
1135711357
impl<'a> ExportMemoryWin32HandleInfoNV<'a> {
1135811358
#[inline]
11359-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
11359+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
1136011360
self.p_attributes = attributes;
1136111361
self
1136211362
}
@@ -13892,7 +13892,7 @@ unsafe impl<'a> TaggedStructure for ExportMemoryWin32HandleInfoKHR<'a> {
1389213892
unsafe impl Extends<MemoryAllocateInfo<'_>> for ExportMemoryWin32HandleInfoKHR<'_> {}
1389313893
impl<'a> ExportMemoryWin32HandleInfoKHR<'a> {
1389413894
#[inline]
13895-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
13895+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
1389613896
self.p_attributes = attributes;
1389713897
self
1389813898
}
@@ -14555,7 +14555,7 @@ unsafe impl<'a> TaggedStructure for ExportSemaphoreWin32HandleInfoKHR<'a> {
1455514555
unsafe impl Extends<SemaphoreCreateInfo<'_>> for ExportSemaphoreWin32HandleInfoKHR<'_> {}
1455614556
impl<'a> ExportSemaphoreWin32HandleInfoKHR<'a> {
1455714557
#[inline]
14558-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
14558+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
1455914559
self.p_attributes = attributes;
1456014560
self
1456114561
}
@@ -15074,7 +15074,7 @@ unsafe impl<'a> TaggedStructure for ExportFenceWin32HandleInfoKHR<'a> {
1507415074
unsafe impl Extends<FenceCreateInfo<'_>> for ExportFenceWin32HandleInfoKHR<'_> {}
1507515075
impl<'a> ExportFenceWin32HandleInfoKHR<'a> {
1507615076
#[inline]
15077-
pub fn attributes(mut self, attributes: &'a SECURITY_ATTRIBUTES) -> Self {
15077+
pub fn attributes(mut self, attributes: *const SECURITY_ATTRIBUTES) -> Self {
1507815078
self.p_attributes = attributes;
1507915079
self
1508015080
}
@@ -59553,7 +59553,7 @@ unsafe impl<'a> TaggedStructure for ImportScreenBufferInfoQNX<'a> {
5955359553
unsafe impl Extends<MemoryAllocateInfo<'_>> for ImportScreenBufferInfoQNX<'_> {}
5955459554
impl<'a> ImportScreenBufferInfoQNX<'a> {
5955559555
#[inline]
59556-
pub fn buffer(mut self, buffer: &'a mut _screen_buffer) -> Self {
59556+
pub fn buffer(mut self, buffer: *mut _screen_buffer) -> Self {
5955759557
self.buffer = buffer;
5955859558
self
5955959559
}

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)