diff --git a/generator/src/main.rs b/generator/src/main.rs index 13613a9c..6ba9dd80 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -12,7 +12,7 @@ use std::{ use heck::{ToShoutySnakeCase, ToSnakeCase, ToUpperCamelCase}; use indexmap::{IndexMap, IndexSet}; use proc_macro2::{Span, TokenStream}; -use quote::quote; +use quote::{format_ident, quote}; use regex::Regex; use syn::{Ident, LitByteStr}; use xml::{ @@ -580,6 +580,7 @@ impl Parser { } } let parent: Option = attr(attrs, "parentstruct").map(|x| x.into()); + let extends: Option> = attr(attrs, "structextends").map(Rc::from); if let Some(ref parent) = parent { self.base_headers .entry(parent.clone()) @@ -596,6 +597,7 @@ impl Parser { members, ty, extension: None, + extends, mut_next, }, ); @@ -1380,6 +1382,24 @@ impl Parser { }) .collect::>(); + let root_structs = self + .structs + .iter() + .filter_map(|(name, s)| { + if s.extension + .as_ref() + .map_or(false, |ext| self.disabled_exts.contains(ext)) + { + return None; + } + if self.is_root_struct(name) { + Some(&name[..]) + } else { + None + } + }) + .collect::>(); + let reexports = simple_structs .iter() .cloned() @@ -1447,6 +1467,9 @@ impl Parser { let whitelist = [ "XrCompositionLayerProjectionView", + "XrCompositionLayerDepthInfoKHR", + "XrCompositionLayerSpaceWarpInfoFB", + "XrCompositionLayerImageLayoutFB", "XrSwapchainSubImage", "XrActionSetCreateInfo", "XrActionCreateInfo", @@ -1456,7 +1479,7 @@ impl Parser { .collect::>(); let builders = self.structs.iter().filter_map(|(name, s)| { if whitelist.contains(&name[..]) { - Some(self.generate_builder(&struct_meta, &simple_structs, name, s)) + Some(self.generate_builder(&struct_meta, &simple_structs, &root_structs, name, s)) } else { None } @@ -1624,6 +1647,8 @@ impl Parser { base_meta |= *meta.get(&name[..]).unwrap(); } + let extends_name = format_ident!("Extends{}", base_ident); + let impl_trait_name = format_ident!("Impl{}", base_ident); let (type_params, type_args, marker, marker_init) = base_meta.type_params(); let builders = children.iter().map(|name| { let ident = xr_ty_name(name); @@ -1631,6 +1656,8 @@ impl Parser { let conds = conditions(name, s.extension.as_ref().map(|x| &x[..])); let inits = self.generate_builder_inits(s); let setters = self.generate_setters(meta, simple, s); + let next_fn = generate_next_fn(&extends_name, NextFnType::TraitImpl); + quote! { #conds #[derive(Copy, Clone)] @@ -1693,15 +1720,24 @@ impl Parser { Self::new() } } + #conds + impl #type_params #impl_trait_name<'a> for #ident #type_args { + #next_fn + } } }); + let next_fn = generate_next_fn(&extends_name, NextFnType::TraitDef); quote! { #[repr(transparent)] pub struct #base_ident #type_params { - _inner: sys::#sys_ident, + inner: sys::#sys_ident, #marker } + pub unsafe trait #extends_name {} + pub trait #impl_trait_name<'a> { + #next_fn + } #(#builders)* } } @@ -1834,6 +1870,7 @@ impl Parser { &self, meta: &HashMap<&str, StructMeta>, simple: &IndexSet<&str>, + root: &IndexSet<&str>, name: &str, s: &Struct, ) -> TokenStream { @@ -1843,6 +1880,30 @@ impl Parser { let inits = self.generate_builder_inits(s); let conds = conditions(name, s.extension.as_ref().map(|x| &x[..])); let conds2 = conds.clone(); + let is_root_struct = root.contains(name); + let extends_name = format_ident!("Extends{}", ident); + let extend_trait = if is_root_struct { + quote!(pub unsafe trait #extends_name {}) + } else { + quote!() + }; + let next_fn = if is_root_struct { + generate_next_fn(&extends_name, NextFnType::Fn) + } else { + quote!() + }; + let implement_extensions = if let Some(parent_struct) = s.extends.as_ref() { + let parent_ident = if self.base_headers.contains_key(parent_struct.as_ref()) { + base_header_ty(parent_struct.as_ref()) + } else { + xr_ty_name(parent_struct) + }; + let parent_extend_name = format_ident!("Extends{}", parent_ident); + quote!(unsafe impl #type_params #parent_extend_name for #ident #type_args {}) + } else { + quote!() + }; + quote! { #[derive(Copy, Clone)] #[repr(transparent)] @@ -1889,6 +1950,8 @@ impl Parser { } #setters + + #next_fn } impl #type_params Default for #ident #type_args { @@ -1896,6 +1959,10 @@ impl Parser { Self::new() } } + + #extend_trait + + #implement_extensions } } @@ -1976,6 +2043,16 @@ impl Parser { && !self.handles.contains(&x.ty) }) } + + /// Determine whether a struct is a root struct to be reexported with a push next function + fn is_root_struct(&self, s_name: &str) -> bool { + self.structs.iter().any(|(_, v)| { + v.extends + .as_ref() + .map(|parent_name| parent_name.as_ref() == s_name) + .unwrap_or(false) + }) + } } #[derive(Debug, Copy, Clone, Default)] @@ -2069,6 +2146,7 @@ enum ConstantValue { struct Struct { members: Vec, extension: Option>, + extends: Option>, ty: Option, mut_next: bool, } @@ -2089,6 +2167,12 @@ struct Extension { commands: Vec, } +enum NextFnType { + Fn, + TraitDef, + TraitImpl, +} + fn attr<'a>(attrs: &'a [OwnedAttribute], name: &str) -> Option<&'a str> { attrs .iter() @@ -2280,3 +2364,48 @@ fn base_header_ty(base_name: &str) -> Ident { Span::call_site(), ) } + +/// Generates a push_next function for structures that can be extended through the `next` pointer +fn generate_next_fn(extension_trait_ident: &Ident, fn_type: NextFnType) -> TokenStream { + let docs = match fn_type { + NextFnType::TraitImpl => quote!(), + _ => quote!(#[doc = "Chains a structure as the next member of this one"]), + }; + + let fn_body = match fn_type { + NextFnType::TraitDef => quote!(;), + _ => quote! { + { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + }, + }; + + let fn_accessor = match fn_type { + NextFnType::Fn => quote!(pub), + _ => quote!(), + }; + + let self_pattern = match fn_type { + NextFnType::TraitDef => quote!(self), + _ => quote!(mut self), + }; + + let inlining = match fn_type { + NextFnType::TraitDef => quote!(), + _ => quote!(#[inline]), + }; + + quote! { + #inlining + #docs + #fn_accessor fn push_next(#self_pattern, next: &'a mut T) -> Self + #fn_body + } +} diff --git a/openxr/src/generated.rs b/openxr/src/generated.rs index b902957c..79ddb029 100644 --- a/openxr/src/generated.rs +++ b/openxr/src/generated.rs @@ -4503,12 +4503,100 @@ pub(crate) mod builder { self.inner.sub_image = value.inner; self } + #[inline] + #[doc = "Chains a structure as the next member of this one"] + pub fn push_next( + mut self, + next: &'a mut T, + ) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } } impl<'a, G: Graphics> Default for CompositionLayerProjectionView<'a, G> { fn default() -> Self { Self::new() } } + pub unsafe trait ExtendsCompositionLayerProjectionView {} + #[derive(Copy, Clone)] + #[repr(transparent)] + pub struct CompositionLayerDepthInfoKHR<'a, G: Graphics> { + inner: sys::CompositionLayerDepthInfoKHR, + _marker: PhantomData<&'a G>, + } + impl<'a, G: Graphics> CompositionLayerDepthInfoKHR<'a, G> { + #[inline] + pub fn new() -> Self { + Self { + inner: sys::CompositionLayerDepthInfoKHR { + ty: sys::StructureType::COMPOSITION_LAYER_DEPTH_INFO_KHR, + ..unsafe { mem::zeroed() } + }, + _marker: PhantomData, + } + } + #[doc = r" Initialize with the supplied raw values"] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r""] + #[doc = r" The guarantees normally enforced by this builder (e.g. lifetimes) must be"] + #[doc = r" preserved."] + #[inline] + pub unsafe fn from_raw(inner: sys::CompositionLayerDepthInfoKHR) -> Self { + Self { + inner, + _marker: PhantomData, + } + } + #[inline] + pub fn into_raw(self) -> sys::CompositionLayerDepthInfoKHR { + self.inner + } + #[inline] + pub fn as_raw(&self) -> &sys::CompositionLayerDepthInfoKHR { + &self.inner + } + #[inline] + pub fn sub_image(mut self, value: SwapchainSubImage<'a, G>) -> Self { + self.inner.sub_image = value.inner; + self + } + #[inline] + pub fn min_depth(mut self, value: f32) -> Self { + self.inner.min_depth = value; + self + } + #[inline] + pub fn max_depth(mut self, value: f32) -> Self { + self.inner.max_depth = value; + self + } + #[inline] + pub fn near_z(mut self, value: f32) -> Self { + self.inner.near_z = value; + self + } + #[inline] + pub fn far_z(mut self, value: f32) -> Self { + self.inner.far_z = value; + self + } + } + impl<'a, G: Graphics> Default for CompositionLayerDepthInfoKHR<'a, G> { + fn default() -> Self { + Self::new() + } + } + unsafe impl<'a, G: Graphics> ExtendsCompositionLayerProjectionView + for CompositionLayerDepthInfoKHR<'a, G> + { + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct ActionSetCreateInfo<'a> { @@ -4633,11 +4721,154 @@ pub(crate) mod builder { Self::new() } } + #[derive(Copy, Clone)] + #[repr(transparent)] + pub struct CompositionLayerImageLayoutFB<'a> { + inner: sys::CompositionLayerImageLayoutFB, + _marker: PhantomData<&'a ()>, + } + impl<'a> CompositionLayerImageLayoutFB<'a> { + #[inline] + pub fn new() -> Self { + Self { + inner: sys::CompositionLayerImageLayoutFB { + ty: sys::StructureType::COMPOSITION_LAYER_IMAGE_LAYOUT_FB, + ..unsafe { mem::zeroed() } + }, + _marker: PhantomData, + } + } + #[doc = r" Initialize with the supplied raw values"] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r""] + #[doc = r" The guarantees normally enforced by this builder (e.g. lifetimes) must be"] + #[doc = r" preserved."] + #[inline] + pub unsafe fn from_raw(inner: sys::CompositionLayerImageLayoutFB) -> Self { + Self { + inner, + _marker: PhantomData, + } + } + #[inline] + pub fn into_raw(self) -> sys::CompositionLayerImageLayoutFB { + self.inner + } + #[inline] + pub fn as_raw(&self) -> &sys::CompositionLayerImageLayoutFB { + &self.inner + } + #[inline] + pub fn flags(mut self, value: CompositionLayerImageLayoutFlagsFB) -> Self { + self.inner.flags = value; + self + } + } + impl<'a> Default for CompositionLayerImageLayoutFB<'a> { + fn default() -> Self { + Self::new() + } + } + unsafe impl<'a> ExtendsCompositionLayerBase for CompositionLayerImageLayoutFB<'a> {} + #[derive(Copy, Clone)] + #[repr(transparent)] + pub struct CompositionLayerSpaceWarpInfoFB<'a, G: Graphics> { + inner: sys::CompositionLayerSpaceWarpInfoFB, + _marker: PhantomData<&'a G>, + } + impl<'a, G: Graphics> CompositionLayerSpaceWarpInfoFB<'a, G> { + #[inline] + pub fn new() -> Self { + Self { + inner: sys::CompositionLayerSpaceWarpInfoFB { + ty: sys::StructureType::COMPOSITION_LAYER_SPACE_WARP_INFO_FB, + ..unsafe { mem::zeroed() } + }, + _marker: PhantomData, + } + } + #[doc = r" Initialize with the supplied raw values"] + #[doc = r""] + #[doc = r" # Safety"] + #[doc = r""] + #[doc = r" The guarantees normally enforced by this builder (e.g. lifetimes) must be"] + #[doc = r" preserved."] + #[inline] + pub unsafe fn from_raw(inner: sys::CompositionLayerSpaceWarpInfoFB) -> Self { + Self { + inner, + _marker: PhantomData, + } + } + #[inline] + pub fn into_raw(self) -> sys::CompositionLayerSpaceWarpInfoFB { + self.inner + } + #[inline] + pub fn as_raw(&self) -> &sys::CompositionLayerSpaceWarpInfoFB { + &self.inner + } + #[inline] + pub fn layer_flags(mut self, value: CompositionLayerSpaceWarpInfoFlagsFB) -> Self { + self.inner.layer_flags = value; + self + } + #[inline] + pub fn motion_vector_sub_image(mut self, value: SwapchainSubImage<'a, G>) -> Self { + self.inner.motion_vector_sub_image = value.inner; + self + } + #[inline] + pub fn app_space_delta_pose(mut self, value: Posef) -> Self { + self.inner.app_space_delta_pose = value; + self + } + #[inline] + pub fn depth_sub_image(mut self, value: SwapchainSubImage<'a, G>) -> Self { + self.inner.depth_sub_image = value.inner; + self + } + #[inline] + pub fn min_depth(mut self, value: f32) -> Self { + self.inner.min_depth = value; + self + } + #[inline] + pub fn max_depth(mut self, value: f32) -> Self { + self.inner.max_depth = value; + self + } + #[inline] + pub fn near_z(mut self, value: f32) -> Self { + self.inner.near_z = value; + self + } + #[inline] + pub fn far_z(mut self, value: f32) -> Self { + self.inner.far_z = value; + self + } + } + impl<'a, G: Graphics> Default for CompositionLayerSpaceWarpInfoFB<'a, G> { + fn default() -> Self { + Self::new() + } + } + unsafe impl<'a, G: Graphics> ExtendsCompositionLayerProjectionView + for CompositionLayerSpaceWarpInfoFB<'a, G> + { + } #[repr(transparent)] pub struct CompositionLayerBase<'a, G: Graphics> { - _inner: sys::CompositionLayerBaseHeader, + inner: sys::CompositionLayerBaseHeader, _marker: PhantomData<&'a G>, } + pub unsafe trait ExtendsCompositionLayerBase {} + pub trait ImplCompositionLayerBase<'a> { + #[doc = "Chains a structure as the next member of this one"] + fn push_next(self, next: &'a mut T) -> Self; + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct CompositionLayerProjection<'a, G: Graphics> { @@ -4705,6 +4936,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a, G: Graphics> ImplCompositionLayerBase<'a> for CompositionLayerProjection<'a, G> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct CompositionLayerQuad<'a, G: Graphics> { @@ -4786,6 +5029,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a, G: Graphics> ImplCompositionLayerBase<'a> for CompositionLayerQuad<'a, G> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct CompositionLayerCylinderKHR<'a, G: Graphics> { @@ -4877,6 +5132,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a, G: Graphics> ImplCompositionLayerBase<'a> for CompositionLayerCylinderKHR<'a, G> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct CompositionLayerCubeKHR<'a, G: Graphics> { @@ -4958,6 +5225,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a, G: Graphics> ImplCompositionLayerBase<'a> for CompositionLayerCubeKHR<'a, G> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct CompositionLayerEquirectKHR<'a, G: Graphics> { @@ -5049,6 +5328,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a, G: Graphics> ImplCompositionLayerBase<'a> for CompositionLayerEquirectKHR<'a, G> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct CompositionLayerEquirect2KHR<'a, G: Graphics> { @@ -5145,11 +5436,28 @@ pub(crate) mod builder { Self::new() } } + impl<'a, G: Graphics> ImplCompositionLayerBase<'a> for CompositionLayerEquirect2KHR<'a, G> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[repr(transparent)] pub struct HapticBase<'a> { - _inner: sys::HapticBaseHeader, + inner: sys::HapticBaseHeader, _marker: PhantomData<&'a ()>, } + pub unsafe trait ExtendsHapticBase {} + pub trait ImplHapticBase<'a> { + #[doc = "Chains a structure as the next member of this one"] + fn push_next(self, next: &'a mut T) -> Self; + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct HapticVibration<'a> { @@ -5216,11 +5524,28 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplHapticBase<'a> for HapticVibration<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[repr(transparent)] pub struct BindingModificationBase<'a> { - _inner: sys::BindingModificationBaseHeaderKHR, + inner: sys::BindingModificationBaseHeaderKHR, _marker: PhantomData<&'a ()>, } + pub unsafe trait ExtendsBindingModificationBase {} + pub trait ImplBindingModificationBase<'a> { + #[doc = "Chains a structure as the next member of this one"] + fn push_next(self, next: &'a mut T) -> Self; + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct InteractionProfileDpadBindingEXT<'a> { @@ -5317,6 +5642,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplBindingModificationBase<'a> for InteractionProfileDpadBindingEXT<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct InteractionProfileAnalogThresholdVALVE<'a> { @@ -5398,11 +5735,28 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplBindingModificationBase<'a> for InteractionProfileAnalogThresholdVALVE<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[repr(transparent)] pub struct SwapchainStateBase<'a> { - _inner: sys::SwapchainStateBaseHeaderFB, + inner: sys::SwapchainStateBaseHeaderFB, _marker: PhantomData<&'a ()>, } + pub unsafe trait ExtendsSwapchainStateBase {} + pub trait ImplSwapchainStateBase<'a> { + #[doc = "Chains a structure as the next member of this one"] + fn push_next(self, next: &'a mut T) -> Self; + } #[cfg(target_os = "android")] #[derive(Copy, Clone)] #[repr(transparent)] @@ -5468,6 +5822,19 @@ pub(crate) mod builder { Self::new() } } + #[cfg(target_os = "android")] + impl<'a> ImplSwapchainStateBase<'a> for SwapchainStateAndroidSurfaceDimensionsFB<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct SwapchainStateSamplerOpenGLESFB<'a> { @@ -5569,6 +5936,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplSwapchainStateBase<'a> for SwapchainStateSamplerOpenGLESFB<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct SwapchainStateSamplerVulkanFB<'a> { @@ -5675,6 +6054,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplSwapchainStateBase<'a> for SwapchainStateSamplerVulkanFB<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct SwapchainStateFoveationFB<'a> { @@ -5736,11 +6127,28 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplSwapchainStateBase<'a> for SwapchainStateFoveationFB<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[repr(transparent)] pub struct SpaceQueryInfoBase<'a> { - _inner: sys::SpaceQueryInfoBaseHeaderFB, + inner: sys::SpaceQueryInfoBaseHeaderFB, _marker: PhantomData<&'a ()>, } + pub unsafe trait ExtendsSpaceQueryInfoBase {} + pub trait ImplSpaceQueryInfoBase<'a> { + #[doc = "Chains a structure as the next member of this one"] + fn push_next(self, next: &'a mut T) -> Self; + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct SpaceQueryInfoFB<'a> { @@ -5817,11 +6225,28 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplSpaceQueryInfoBase<'a> for SpaceQueryInfoFB<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[repr(transparent)] pub struct SpaceFilterInfoBase<'a> { - _inner: sys::SpaceFilterInfoBaseHeaderFB, + inner: sys::SpaceFilterInfoBaseHeaderFB, _marker: PhantomData<&'a ()>, } + pub unsafe trait ExtendsSpaceFilterInfoBase {} + pub trait ImplSpaceFilterInfoBase<'a> { + #[doc = "Chains a structure as the next member of this one"] + fn push_next(self, next: &'a mut T) -> Self; + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct SpaceUuidFilterInfoFB<'a> { @@ -5879,6 +6304,18 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplSpaceFilterInfoBase<'a> for SpaceUuidFilterInfoFB<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } #[derive(Copy, Clone)] #[repr(transparent)] pub struct SpaceComponentFilterInfoFB<'a> { @@ -5935,4 +6372,16 @@ pub(crate) mod builder { Self::new() } } + impl<'a> ImplSpaceFilterInfoBase<'a> for SpaceComponentFilterInfoFB<'a> { + #[inline] + fn push_next(mut self, next: &'a mut T) -> Self { + unsafe { + let other: &mut sys::BaseOutStructure = mem::transmute(next); + let next_ptr = <*mut sys::BaseOutStructure>::cast(other); + other.next = self.inner.next as _; + self.inner.next = next_ptr; + } + self + } + } } diff --git a/openxr/src/lib.rs b/openxr/src/lib.rs index 109bb52f..261db168 100644 --- a/openxr/src/lib.rs +++ b/openxr/src/lib.rs @@ -39,14 +39,9 @@ mod vive_tracker_paths; pub use vive_tracker_paths::*; mod display_refresh_rate; mod passthrough; +pub use builder::*; pub use passthrough::*; -pub use builder::{ - CompositionLayerBase, CompositionLayerCubeKHR, CompositionLayerCylinderKHR, - CompositionLayerEquirectKHR, CompositionLayerProjection, CompositionLayerProjectionView, - CompositionLayerQuad, HapticBase, HapticVibration, SwapchainSubImage, -}; - pub type Result = std::result::Result; // Reserved semantic paths