commit
1661cb88d0
7113
ash/src/vk.rs
7113
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -1353,6 +1353,10 @@ pub fn derive_debug(_struct: &vkxml::Struct, union_types: &HashSet<&str>) -> Opt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
|
if &_struct.name == "VkBaseInStructure" || &_struct.name == "VkBaseOutStructure" {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let name = name_to_tokens(&_struct.name);
|
let name = name_to_tokens(&_struct.name);
|
||||||
let name_builder = name_to_tokens(&(_struct.name.clone() + "Builder"));
|
let name_builder = name_to_tokens(&(_struct.name.clone() + "Builder"));
|
||||||
|
|
||||||
|
@ -1361,6 +1365,18 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
_ => None,
|
_ => None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let (has_next, is_next_const) = match members
|
||||||
|
.clone()
|
||||||
|
.find(|field| field.param_ident().to_string() == "p_next")
|
||||||
|
{
|
||||||
|
Some(p_next) => if p_next.type_tokens().to_string().starts_with("*const") {
|
||||||
|
(true, true)
|
||||||
|
} else {
|
||||||
|
(true, false)
|
||||||
|
},
|
||||||
|
None => (false, false),
|
||||||
|
};
|
||||||
|
|
||||||
let nofilter_count_members = [
|
let nofilter_count_members = [
|
||||||
"VkPipelineViewportStateCreateInfo.pViewports",
|
"VkPipelineViewportStateCreateInfo.pViewports",
|
||||||
"VkPipelineViewportStateCreateInfo.pScissors",
|
"VkPipelineViewportStateCreateInfo.pScissors",
|
||||||
|
@ -1522,6 +1538,37 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let mut nexts = Vec::new();
|
||||||
|
let name_builder_next = name_to_tokens(&(_struct.name.clone() + "BuilderNext"));
|
||||||
|
if let Some(extends) = &_struct.extends {
|
||||||
|
for target in extends.split(',') {
|
||||||
|
let target_ident = name_to_tokens(&(target.to_string() + "BuilderNext"));
|
||||||
|
nexts.push(quote! {
|
||||||
|
unsafe impl #target_ident for #name_builder_next {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let next_function = if has_next {
|
||||||
|
if is_next_const {
|
||||||
|
quote!{
|
||||||
|
pub fn next<T>(mut self, next: &'a T) -> #name_builder<'a> where T: #name_builder_next {
|
||||||
|
self.inner.p_next = next as *const T as *const c_void;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
quote!{
|
||||||
|
pub fn next<T>(mut self, next: &'a mut T) -> #name_builder<'a> where T: #name_builder_next {
|
||||||
|
self.inner.p_next = next as *mut T as *mut c_void;
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
quote!{}
|
||||||
|
};
|
||||||
|
|
||||||
let q = quote!{
|
let q = quote!{
|
||||||
impl #name {
|
impl #name {
|
||||||
pub fn builder<'a>() -> #name_builder<'a> {
|
pub fn builder<'a>() -> #name_builder<'a> {
|
||||||
|
@ -1537,6 +1584,10 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
marker: ::std::marker::PhantomData<&'a ()>,
|
marker: ::std::marker::PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub unsafe trait #name_builder_next {}
|
||||||
|
|
||||||
|
#(#nexts)*
|
||||||
|
|
||||||
impl<'a> ::std::ops::Deref for #name_builder<'a> {
|
impl<'a> ::std::ops::Deref for #name_builder<'a> {
|
||||||
type Target = #name;
|
type Target = #name;
|
||||||
|
|
||||||
|
@ -1548,6 +1599,8 @@ pub fn derive_setters(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
impl<'a> #name_builder<'a> {
|
impl<'a> #name_builder<'a> {
|
||||||
#(#setters)*
|
#(#setters)*
|
||||||
|
|
||||||
|
#next_function
|
||||||
|
|
||||||
pub fn build(self) -> #name {
|
pub fn build(self) -> #name {
|
||||||
self.inner
|
self.inner
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue