Remove vk:: prefix for types
This commit is contained in:
parent
be08103d1d
commit
6691e7e79f
2 changed files with 18 additions and 9 deletions
|
@ -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
|
||||||
|
|
|
@ -57,12 +57,21 @@ impl FieldExt for vkxml::Field {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_ident(&self) -> Ident {
|
fn type_ident(&self) -> Ident {
|
||||||
let prefix = &self.basetype[0..2];
|
let new_name = match self.basetype.as_str() {
|
||||||
if prefix == "Vk" {
|
"void" => "c_void",
|
||||||
Ident::from(&self.basetype[2..])
|
"char" => "c_char",
|
||||||
} else {
|
"float" => "c_float",
|
||||||
Ident::from(&self.basetype[..])
|
"long" => "c_ulong",
|
||||||
}
|
_ => {
|
||||||
|
let prefix = &self.basetype[0..2];
|
||||||
|
if prefix == "Vk" {
|
||||||
|
&self.basetype[2..]
|
||||||
|
} else {
|
||||||
|
self.basetype.as_str()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Ident::from(new_name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -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();
|
||||||
|
|
Loading…
Add table
Reference in a new issue