Use repr transparent for builders
This commit is contained in:
parent
d6a6aa310e
commit
38fe16f6c7
|
@ -209,12 +209,8 @@ pub struct PhysicalDeviceGpaPropertiesAmdBuilder<'a> {
|
|||
marker: ::std::marker::PhantomData<&'a ()>,
|
||||
}
|
||||
pub unsafe trait ExtendsPhysicalDeviceGpaPropertiesAmd {
|
||||
unsafe fn as_ptr_mut(&mut self) -> *mut BaseOutStructure;
|
||||
}
|
||||
unsafe impl ExtendsPhysicalDeviceProperties2 for PhysicalDeviceGpaPropertiesAmd {
|
||||
unsafe fn as_ptr_mut(&mut self) -> *mut BaseOutStructure {
|
||||
::std::mem::transmute(self)
|
||||
}
|
||||
}
|
||||
impl<'a> ::std::ops::Deref for PhysicalDeviceGpaPropertiesAmdBuilder<'a> {
|
||||
type Target = PhysicalDeviceGpaPropertiesAmd;
|
||||
|
@ -655,12 +651,8 @@ pub struct PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> {
|
|||
marker: ::std::marker::PhantomData<&'a ()>,
|
||||
}
|
||||
pub unsafe trait ExtendsPhysicalDeviceWaveLimitPropertiesAmd {
|
||||
unsafe fn as_ptr_mut(&mut self) -> *mut BaseOutStructure;
|
||||
}
|
||||
unsafe impl ExtendsPhysicalDeviceProperties2 for PhysicalDeviceWaveLimitPropertiesAmd {
|
||||
unsafe fn as_ptr_mut(&mut self) -> *mut BaseOutStructure {
|
||||
::std::mem::transmute(self)
|
||||
}
|
||||
}
|
||||
impl<'a> ::std::ops::Deref for PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> {
|
||||
type Target = PhysicalDeviceWaveLimitPropertiesAmd;
|
||||
|
@ -677,7 +669,7 @@ impl<'a> PhysicalDeviceWaveLimitPropertiesAmdBuilder<'a> {
|
|||
T: ExtendsPhysicalDeviceWaveLimitPropertiesAmd,
|
||||
{
|
||||
unsafe {
|
||||
let next_ptr = next.as_ptr_mut();
|
||||
let next_ptr = next as *mut _ as *mut BaseOutStructure;
|
||||
(*next_ptr).p_next = self.inner.p_next as _;
|
||||
self.inner.p_next = next_ptr as _;
|
||||
}
|
||||
|
|
7013
ash/src/vk.rs
7013
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -1601,7 +1601,7 @@ pub fn derive_setters(
|
|||
/// chain will look like `A -> D -> B -> C`.
|
||||
pub fn push_next<T: #extends_name>(mut self, next: &'a mut T) -> #name_builder<'a> {
|
||||
unsafe{
|
||||
let next_ptr = next.as_ptr_mut();
|
||||
let next_ptr = next as *mut T as *mut BaseOutStructure;
|
||||
(*next_ptr).p_next = self.inner.p_next as _;
|
||||
self.inner.p_next = next_ptr as _;
|
||||
}
|
||||
|
@ -1617,7 +1617,6 @@ pub fn derive_setters(
|
|||
let next_trait = if has_next && _struct.extends.is_none() {
|
||||
quote! {
|
||||
pub unsafe trait #extends_name {
|
||||
unsafe fn as_ptr_mut(&mut self) -> *mut BaseOutStructure;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1628,14 +1627,8 @@ pub fn derive_setters(
|
|||
let impl_extend_trait = if let Some(next_extends) = next_extends {
|
||||
quote! {
|
||||
unsafe impl #next_extends for #name_builder<'_> {
|
||||
unsafe fn as_ptr_mut(&mut self) -> *mut BaseOutStructure{
|
||||
::std::mem::transmute(&mut self.inner)
|
||||
}
|
||||
}
|
||||
unsafe impl #next_extends for #name {
|
||||
unsafe fn as_ptr_mut(&mut self) -> *mut BaseOutStructure{
|
||||
::std::mem::transmute(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1652,6 +1645,7 @@ pub fn derive_setters(
|
|||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
pub struct #name_builder<'a> {
|
||||
inner: #name,
|
||||
marker: ::std::marker::PhantomData<&'a ()>,
|
||||
|
|
Loading…
Reference in a new issue