Merge pull request #2 from MaikKlein/master

Updated from master
This commit is contained in:
Graham Wihlidal 2019-02-14 11:46:29 +01:00 committed by GitHub
commit b253d39abe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5073 additions and 1940 deletions

File diff suppressed because it is too large Load diff

@ -1 +1 @@
Subproject commit 114c3546e195819bd53a34b39f5194b2989a5b12 Subproject commit c200cb25db0f47364d3318d92c1d8e9dfff2fef1

View file

@ -427,9 +427,6 @@ impl quote::ToTokens for ConstVal {
} }
} }
impl Constant { impl Constant {
// pub fn type(&self) -> Type {
// }
pub fn value(&self) -> Option<ConstVal> { pub fn value(&self) -> Option<ConstVal> {
match *self { match *self {
Constant::Number(n) => Some(ConstVal::U64(n as u64)), Constant::Number(n) => Some(ConstVal::U64(n as u64)),
@ -871,6 +868,7 @@ pub fn generate_extension_constants<'a>(
const_cache: &mut HashSet<&'a str>, const_cache: &mut HashSet<&'a str>,
const_values: &mut HashMap<Ident, Vec<Ident>>, const_values: &mut HashMap<Ident, Vec<Ident>>,
) -> quote::Tokens { ) -> quote::Tokens {
use vk_parse::EnumSpec;
let items = extension_items let items = extension_items
.iter() .iter()
.filter_map(|item| match item { .filter_map(|item| match item {
@ -880,7 +878,6 @@ pub fn generate_extension_constants<'a>(
.flat_map(|iter| iter); .flat_map(|iter| iter);
let enum_tokens = items.filter_map(|item| match item { let enum_tokens = items.filter_map(|item| match item {
vk_parse::InterfaceItem::Enum(_enum) => { vk_parse::InterfaceItem::Enum(_enum) => {
use vk_parse::EnumSpec;
if const_cache.contains(_enum.name.as_str()) { if const_cache.contains(_enum.name.as_str()) {
return None; return None;
} }
@ -952,7 +949,22 @@ pub fn generate_extension_commands<'a>(
.collect_vec(); .collect_vec();
let name = format!("{}Fn", extension_name.to_camel_case()); let name = format!("{}Fn", extension_name.to_camel_case());
let ident = Ident::from(&name[2..]); let ident = Ident::from(&name[2..]);
generate_function_pointers(ident, &commands, fn_cache) let fp = generate_function_pointers(ident, &commands, fn_cache);
let byte_name = format!("{}\0", extension_name);
let byte_name_ident =
syn::LitByteStr::new(byte_name.as_bytes(), proc_macro2::Span::call_site());
let extension_cstr = quote! {
impl #ident {
pub fn name() -> &'static ::std::ffi::CStr {
::std::ffi::CStr::from_bytes_with_nul(#byte_name_ident).expect("Wrong extension string")
}
}
};
quote! {
#extension_cstr
#fp
}
} }
pub fn generate_extension<'a>( pub fn generate_extension<'a>(
extension: &'a vk_parse::Extension, extension: &'a vk_parse::Extension,