Merge pull request #110 from MatusT/generator
Default trait: set pointers to std::ptr::null()/null_mut()
This commit is contained in:
commit
898e9791b7
2 changed files with 421 additions and 392 deletions
778
ash/src/vk.rs
778
ash/src/vk.rs
File diff suppressed because it is too large
Load diff
|
@ -1157,8 +1157,37 @@ pub fn derive_default(_struct: &vkxml::Struct) -> Option<Tokens> {
|
||||||
#param_ident: unsafe { ::std::mem::zeroed() }
|
#param_ident: unsafe { ::std::mem::zeroed() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if field.reference.is_some()
|
} else if let Some(ref reference) = field.reference {
|
||||||
|| is_static_array(field)
|
match reference {
|
||||||
|
vkxml::ReferenceType::Pointer => {
|
||||||
|
if field.is_const {
|
||||||
|
quote!{
|
||||||
|
#param_ident: ::std::ptr::null()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
quote!{
|
||||||
|
#param_ident: ::std::ptr::null_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vkxml::ReferenceType::PointerToPointer => {
|
||||||
|
quote!{
|
||||||
|
#param_ident: ::std::ptr::null_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vkxml::ReferenceType::PointerToConstPointer => {
|
||||||
|
if field.is_const {
|
||||||
|
quote!{
|
||||||
|
#param_ident: ::std::ptr::null()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
quote!{
|
||||||
|
#param_ident: ::std::ptr::null_mut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if is_static_array(field)
|
||||||
|| is_pfn(field)
|
|| is_pfn(field)
|
||||||
|| handles.contains(&field.basetype.as_str())
|
|| handles.contains(&field.basetype.as_str())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue