Fix clippy lints for 1.43 (#298)
This commit is contained in:
parent
e378a85c78
commit
4d6bb3949d
7 changed files with 1716 additions and 1795 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,24 @@
|
||||||
use crate::vk::definitions::*;
|
use crate::vk::definitions::*;
|
||||||
pub const MAX_PHYSICAL_DEVICE_NAME_SIZE: usize = (256);
|
pub const MAX_PHYSICAL_DEVICE_NAME_SIZE: usize = 256;
|
||||||
pub const UUID_SIZE: usize = (16);
|
pub const UUID_SIZE: usize = 16;
|
||||||
pub const LUID_SIZE: usize = (8);
|
pub const LUID_SIZE: usize = 8;
|
||||||
pub const MAX_EXTENSION_NAME_SIZE: usize = (256);
|
pub const MAX_EXTENSION_NAME_SIZE: usize = 256;
|
||||||
pub const MAX_DESCRIPTION_SIZE: usize = (256);
|
pub const MAX_DESCRIPTION_SIZE: usize = 256;
|
||||||
pub const MAX_MEMORY_TYPES: usize = (32);
|
pub const MAX_MEMORY_TYPES: usize = 32;
|
||||||
pub const MAX_MEMORY_HEAPS: usize = (16);
|
pub const MAX_MEMORY_HEAPS: usize = 16;
|
||||||
pub const LOD_CLAMP_NONE: f32 = (1000.00);
|
pub const LOD_CLAMP_NONE: f32 = 1000.00;
|
||||||
pub const REMAINING_MIP_LEVELS: u32 = (!0);
|
pub const REMAINING_MIP_LEVELS: u32 = !0;
|
||||||
pub const REMAINING_ARRAY_LAYERS: u32 = (!0);
|
pub const REMAINING_ARRAY_LAYERS: u32 = !0;
|
||||||
pub const WHOLE_SIZE: u64 = (!0);
|
pub const WHOLE_SIZE: u64 = !0;
|
||||||
pub const ATTACHMENT_UNUSED: u32 = (!0);
|
pub const ATTACHMENT_UNUSED: u32 = !0;
|
||||||
pub const TRUE: Bool32 = (1);
|
pub const TRUE: Bool32 = 1;
|
||||||
pub const FALSE: Bool32 = (0);
|
pub const FALSE: Bool32 = 0;
|
||||||
pub const QUEUE_FAMILY_IGNORED: u32 = (!0);
|
pub const QUEUE_FAMILY_IGNORED: u32 = !0;
|
||||||
pub const QUEUE_FAMILY_EXTERNAL: u32 = (!0 - 1);
|
pub const QUEUE_FAMILY_EXTERNAL: u32 = !0 - 1;
|
||||||
pub const QUEUE_FAMILY_FOREIGN_EXT: u32 = (!0 - 2);
|
pub const QUEUE_FAMILY_FOREIGN_EXT: u32 = !0 - 2;
|
||||||
pub const SUBPASS_EXTERNAL: u32 = (!0);
|
pub const SUBPASS_EXTERNAL: u32 = !0;
|
||||||
pub const MAX_DEVICE_GROUP_SIZE: usize = (32);
|
pub const MAX_DEVICE_GROUP_SIZE: usize = 32;
|
||||||
pub const MAX_DRIVER_NAME_SIZE: usize = (256);
|
pub const MAX_DRIVER_NAME_SIZE: usize = 256;
|
||||||
pub const MAX_DRIVER_INFO_SIZE: usize = (256);
|
pub const MAX_DRIVER_INFO_SIZE: usize = 256;
|
||||||
pub const SHADER_UNUSED_KHR: u32 = (!0);
|
pub const SHADER_UNUSED_KHR: u32 = !0;
|
||||||
pub const SHADER_UNUSED_NV: u32 = SHADER_UNUSED_KHR;
|
pub const SHADER_UNUSED_NV: u32 = SHADER_UNUSED_KHR;
|
||||||
|
|
1355
ash/src/vk/enums.rs
1355
ash/src/vk/enums.rs
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -38,7 +38,6 @@ use std::cell::RefCell;
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::ops::Drop;
|
use std::ops::Drop;
|
||||||
use std::os::raw::c_void;
|
|
||||||
|
|
||||||
// Simple offset_of macro akin to C++ offsetof
|
// Simple offset_of macro akin to C++ offsetof
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate nom;
|
extern crate nom;
|
||||||
use proc_macro2;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate quote;
|
extern crate quote;
|
||||||
use syn;
|
|
||||||
pub use vk_parse;
|
pub use vk_parse;
|
||||||
pub use vkxml;
|
pub use vkxml;
|
||||||
|
|
||||||
|
@ -390,20 +388,21 @@ impl ConstVal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub trait ConstantExt {
|
pub trait ConstantExt {
|
||||||
|
fn constant(&self) -> Constant;
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident;
|
fn variant_ident(&self, enum_name: &str) -> Ident;
|
||||||
fn to_tokens(&self, ident: Option<Ident>) -> Tokens;
|
fn to_tokens(&self) -> Tokens;
|
||||||
fn notation(&self) -> Option<&str>;
|
fn notation(&self) -> Option<&str>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstantExt for vkxml::ExtensionEnum {
|
impl ConstantExt for vkxml::ExtensionEnum {
|
||||||
|
fn constant(&self) -> Constant {
|
||||||
|
Constant::from_extension_enum(self).unwrap()
|
||||||
|
}
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident {
|
fn variant_ident(&self, enum_name: &str) -> Ident {
|
||||||
variant_ident(enum_name, &self.name)
|
variant_ident(enum_name, &self.name)
|
||||||
}
|
}
|
||||||
fn to_tokens(&self, ident: Option<Ident>) -> Tokens {
|
fn to_tokens(&self) -> Tokens {
|
||||||
let expr = Constant::from_extension_enum(self)
|
Constant::from_extension_enum(self).expect("").to_tokens()
|
||||||
.expect("")
|
|
||||||
.to_tokens(ident);
|
|
||||||
quote! { #ident(#expr) }
|
|
||||||
}
|
}
|
||||||
fn notation(&self) -> Option<&str> {
|
fn notation(&self) -> Option<&str> {
|
||||||
self.notation.as_deref()
|
self.notation.as_deref()
|
||||||
|
@ -411,19 +410,21 @@ impl ConstantExt for vkxml::ExtensionEnum {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstantExt for vkxml::Constant {
|
impl ConstantExt for vkxml::Constant {
|
||||||
|
fn constant(&self) -> Constant {
|
||||||
|
Constant::from_constant(self)
|
||||||
|
}
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident {
|
fn variant_ident(&self, enum_name: &str) -> Ident {
|
||||||
variant_ident(enum_name, &self.name)
|
variant_ident(enum_name, &self.name)
|
||||||
}
|
}
|
||||||
fn to_tokens(&self, ident: Option<Ident>) -> Tokens {
|
fn to_tokens(&self) -> Tokens {
|
||||||
let expr = Constant::from_constant(self).to_tokens(ident);
|
Constant::from_constant(self).to_tokens()
|
||||||
quote! { #expr }
|
|
||||||
}
|
}
|
||||||
fn notation(&self) -> Option<&str> {
|
fn notation(&self) -> Option<&str> {
|
||||||
self.notation.as_deref()
|
self.notation.as_deref()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Constant {
|
pub enum Constant {
|
||||||
Number(i32),
|
Number(i32),
|
||||||
Hex(String),
|
Hex(String),
|
||||||
|
@ -479,32 +480,32 @@ impl Constant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_tokens(&self, ident: Option<Ident>) -> Tokens {
|
pub fn to_tokens(&self) -> Tokens {
|
||||||
match *self {
|
match *self {
|
||||||
Constant::Number(n) => {
|
Constant::Number(n) => {
|
||||||
let number = interleave_number('_', 3, &n.to_string());
|
let number = interleave_number('_', 3, &n.to_string());
|
||||||
let term = Term::intern(&number);
|
let term = Term::intern(&number);
|
||||||
quote! {#ident(#term)}
|
quote! {#term}
|
||||||
}
|
}
|
||||||
Constant::Hex(ref s) => {
|
Constant::Hex(ref s) => {
|
||||||
let number = interleave_number('_', 4, s);
|
let number = interleave_number('_', 4, s);
|
||||||
let term = Term::intern(&format!("0x{}", number));
|
let term = Term::intern(&format!("0x{}", number));
|
||||||
quote! {#ident(#term)}
|
quote! {#term}
|
||||||
}
|
}
|
||||||
Constant::Text(ref text) => {
|
Constant::Text(ref text) => {
|
||||||
quote! {#ident(#text)}
|
quote! {#text}
|
||||||
}
|
}
|
||||||
Constant::CExpr(ref expr) => {
|
Constant::CExpr(ref expr) => {
|
||||||
let (_, (_, rexpr)) = cexpr(expr).expect("Unable to parse cexpr");
|
let (_, (_, rexpr)) = cexpr(expr).expect("Unable to parse cexpr");
|
||||||
let term = Term::intern(rexpr.as_str());
|
let term = Term::intern(rexpr.as_str());
|
||||||
quote! {#ident(#term)}
|
quote! {#term}
|
||||||
}
|
}
|
||||||
Constant::BitPos(pos) => {
|
Constant::BitPos(pos) => {
|
||||||
let value = 1 << pos;
|
let value = 1 << pos;
|
||||||
let bit_string = format!("{:b}", value);
|
let bit_string = format!("{:b}", value);
|
||||||
let bit_string = interleave_number('_', 4, &bit_string);
|
let bit_string = interleave_number('_', 4, &bit_string);
|
||||||
let term = Term::intern(&format!("0b{}", bit_string));
|
let term = Term::intern(&format!("0b{}", bit_string));
|
||||||
quote! {#ident(#term)}
|
quote! {#term}
|
||||||
}
|
}
|
||||||
Constant::Alias(ref base, ref value) => {
|
Constant::Alias(ref base, ref value) => {
|
||||||
quote! {#base::#value}
|
quote! {#base::#value}
|
||||||
|
@ -938,11 +939,14 @@ pub struct ExtensionConstant<'a> {
|
||||||
pub constant: Constant,
|
pub constant: Constant,
|
||||||
}
|
}
|
||||||
impl<'a> ConstantExt for ExtensionConstant<'a> {
|
impl<'a> ConstantExt for ExtensionConstant<'a> {
|
||||||
|
fn constant(&self) -> Constant {
|
||||||
|
self.constant.clone()
|
||||||
|
}
|
||||||
fn variant_ident(&self, enum_name: &str) -> Ident {
|
fn variant_ident(&self, enum_name: &str) -> Ident {
|
||||||
variant_ident(enum_name, self.name)
|
variant_ident(enum_name, self.name)
|
||||||
}
|
}
|
||||||
fn to_tokens(&self, ident: Option<Ident>) -> Tokens {
|
fn to_tokens(&self) -> Tokens {
|
||||||
self.constant.to_tokens(ident)
|
self.constant.to_tokens()
|
||||||
}
|
}
|
||||||
fn notation(&self) -> Option<&str> {
|
fn notation(&self) -> Option<&str> {
|
||||||
None
|
None
|
||||||
|
@ -1208,7 +1212,13 @@ pub fn bitflags_impl_block(
|
||||||
.iter()
|
.iter()
|
||||||
.map(|constant| {
|
.map(|constant| {
|
||||||
let variant_ident = constant.variant_ident(enum_name);
|
let variant_ident = constant.variant_ident(enum_name);
|
||||||
let tokens = constant.to_tokens(Some(ident));
|
let constant = constant.constant();
|
||||||
|
let tokens = constant.to_tokens();
|
||||||
|
let tokens = if let Constant::Alias(_, _) = &constant {
|
||||||
|
tokens
|
||||||
|
} else {
|
||||||
|
quote!(Self(#tokens))
|
||||||
|
};
|
||||||
(variant_ident, tokens)
|
(variant_ident, tokens)
|
||||||
})
|
})
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
@ -2125,7 +2135,7 @@ pub fn generate_constant<'a>(
|
||||||
let c = Constant::from_constant(constant);
|
let c = Constant::from_constant(constant);
|
||||||
let name = constant_name(&constant.name);
|
let name = constant_name(&constant.name);
|
||||||
let ident = Ident::from(name.as_str());
|
let ident = Ident::from(name.as_str());
|
||||||
let value = c.to_tokens(None);
|
let value = c.to_tokens();
|
||||||
let ty = if name == "TRUE" || name == "FALSE" {
|
let ty = if name == "TRUE" || name == "FALSE" {
|
||||||
CType::Bool32
|
CType::Bool32
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue