generator: Improve alias readability by using Self::
as type (#409)
All enumeration aliases already extend the base type by being placed in its `impl` block. Use `Self::` instead of repeating the type name. DRY.
This commit is contained in:
parent
8d60a7eec2
commit
5bc52dcd0a
File diff suppressed because it is too large
Load diff
|
@ -211,7 +211,7 @@ impl StructureType {
|
||||||
#[doc = "Generated from 'VK_VERSION_1_1'"]
|
#[doc = "Generated from 'VK_VERSION_1_1'"]
|
||||||
impl StructureType {
|
impl StructureType {
|
||||||
pub const PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES: Self =
|
pub const PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES: Self =
|
||||||
StructureType::PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES;
|
Self::PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES;
|
||||||
}
|
}
|
||||||
#[doc = "Generated from 'VK_VERSION_1_1'"]
|
#[doc = "Generated from 'VK_VERSION_1_1'"]
|
||||||
impl StructureType {
|
impl StructureType {
|
||||||
|
@ -547,7 +547,7 @@ impl StructureType {
|
||||||
#[doc = "Generated from 'VK_VERSION_1_1'"]
|
#[doc = "Generated from 'VK_VERSION_1_1'"]
|
||||||
impl StructureType {
|
impl StructureType {
|
||||||
pub const PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES: Self =
|
pub const PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES: Self =
|
||||||
StructureType::PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES;
|
Self::PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES;
|
||||||
}
|
}
|
||||||
#[doc = "Generated from 'VK_VERSION_1_2'"]
|
#[doc = "Generated from 'VK_VERSION_1_2'"]
|
||||||
impl StructureType {
|
impl StructureType {
|
||||||
|
|
|
@ -437,7 +437,7 @@ pub enum Constant {
|
||||||
BitPos(u32),
|
BitPos(u32),
|
||||||
CExpr(vkxml::CExpression),
|
CExpr(vkxml::CExpression),
|
||||||
Text(String),
|
Text(String),
|
||||||
Alias(Ident, Ident),
|
Alias(Ident),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl quote::ToTokens for Constant {
|
impl quote::ToTokens for Constant {
|
||||||
|
@ -462,7 +462,7 @@ impl quote::ToTokens for Constant {
|
||||||
let bit_string = interleave_number('_', 4, &bit_string);
|
let bit_string = interleave_number('_', 4, &bit_string);
|
||||||
syn::LitInt::new(&format!("0b{}", bit_string), Span::call_site()).to_tokens(tokens);
|
syn::LitInt::new(&format!("0b{}", bit_string), Span::call_site()).to_tokens(tokens);
|
||||||
}
|
}
|
||||||
Constant::Alias(ref base, ref value) => tokens.extend(quote!(#base::#value)),
|
Constant::Alias(ref value) => tokens.extend(quote!(Self::#value)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1065,12 +1065,11 @@ pub fn generate_extension_constants<'a>(
|
||||||
}
|
}
|
||||||
EnumSpec::Alias { alias, extends } => {
|
EnumSpec::Alias { alias, extends } => {
|
||||||
if let Some(extends) = extends {
|
if let Some(extends) = extends {
|
||||||
let ident = name_to_tokens(&extends);
|
|
||||||
let key = variant_ident(&extends, &alias);
|
let key = variant_ident(&extends, &alias);
|
||||||
if key == "DISPATCH_BASE" {
|
if key == "DISPATCH_BASE" {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some((Constant::Alias(ident, key), Some(extends.clone()), true))
|
Some((Constant::Alias(key), Some(extends.clone()), true))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -1336,7 +1335,7 @@ pub fn bitflags_impl_block(
|
||||||
.map(|constant| {
|
.map(|constant| {
|
||||||
let variant_ident = constant.variant_ident(enum_name);
|
let variant_ident = constant.variant_ident(enum_name);
|
||||||
let constant = constant.constant();
|
let constant = constant.constant();
|
||||||
let tokens = if let Constant::Alias(_, _) = &constant {
|
let tokens = if let Constant::Alias(_) = &constant {
|
||||||
quote!(#constant)
|
quote!(#constant)
|
||||||
} else {
|
} else {
|
||||||
quote!(Self(#constant))
|
quote!(Self(#constant))
|
||||||
|
|
Loading…
Reference in a new issue