Remove vk:: prefix for types

This commit is contained in:
Maik Klein 2018-03-09 22:05:31 +01:00
parent be08103d1d
commit 6691e7e79f
2 changed files with 18 additions and 9 deletions

View file

@ -5,7 +5,7 @@ use std::collections::HashMap;
use std::io::Write; use std::io::Write;
fn main() { fn main() {
let file = File::open("vk_new.xml").expect("vk"); let file = File::open("New-Vulkan-XML-Format/vk_new.xml").expect("vknew");
let spec = vkxml::Registry::from_file(file).expect(""); let spec = vkxml::Registry::from_file(file).expect("");
let commands: HashMap<vkxml::Identifier, &vkxml::Command> = spec.elements let commands: HashMap<vkxml::Identifier, &vkxml::Command> = spec.elements

View file

@ -57,13 +57,22 @@ impl FieldExt for vkxml::Field {
} }
fn type_ident(&self) -> Ident { fn type_ident(&self) -> Ident {
let new_name = match self.basetype.as_str() {
"void" => "c_void",
"char" => "c_char",
"float" => "c_float",
"long" => "c_ulong",
_ => {
let prefix = &self.basetype[0..2]; let prefix = &self.basetype[0..2];
if prefix == "Vk" { if prefix == "Vk" {
Ident::from(&self.basetype[2..]) &self.basetype[2..]
} else { } else {
Ident::from(&self.basetype[..]) self.basetype.as_str()
} }
} }
};
Ident::from(new_name)
}
} }
use std::collections::HashMap; use std::collections::HashMap;
pub type CommandMap<'a> = HashMap<vkxml::Identifier, &'a vkxml::Command>; pub type CommandMap<'a> = HashMap<vkxml::Identifier, &'a vkxml::Command>;
@ -109,12 +118,12 @@ pub fn gen_load(feature: &vkxml::Feature, commands: &CommandMap) -> quote::Token
.map(|field| { .map(|field| {
let name = field.param_ident(); let name = field.param_ident();
let ty = field.type_ident(); let ty = field.type_ident();
quote!{#name: vk::#ty} quote!{#name: #ty}
}) })
.collect(); .collect();
let return_ty = cmd.return_type.type_ident(); let return_ty = cmd.return_type.type_ident();
quote!{ quote!{
#fn_name_snake: extern "system" fn(#(#params,)*) -> vk::#return_ty #fn_name_snake: extern "system" fn(#(#params,)*) -> #return_ty
} }
}) })
.collect(); .collect();