Add unions

This commit is contained in:
Maik Klein 2018-07-07 10:43:44 +02:00
parent 4584a8af2a
commit 21e934d5b1

View file

@ -908,9 +908,23 @@ fn generate_funcptr(fnptr: &vkxml::FunctionPointer) -> Tokens {
pub type #name = unsafe extern "system" fn() -> #ret_ty_tokens;
}
}
fn generate_union(union: &vkxml::Union) -> Tokens {
println!("{:#?}", union);
quote!{}
let name = to_type_tokens(&union.name, None);
let fields = union.elements.iter().map(|field| {
let name = field.param_ident();
let ty = field.type_tokens();
quote!{
pub #name: #ty
}
});
quote!{
#[repr(C)]
#[derive(Copy, Clone)]
pub union #name {
#(#fields),*
}
}
}
pub fn generate_definition(definition: &vkxml::DefinitionsElement) -> Option<Tokens> {
match *definition {