diff --git a/src/transform/mod.rs b/src/transform/mod.rs index eaaae34..fe560ff 100644 --- a/src/transform/mod.rs +++ b/src/transform/mod.rs @@ -11,14 +11,14 @@ impl Sanitize { pub fn run(&self, ir: &mut IR) -> anyhow::Result<()> { map_names(ir, |k, p| match k { NameKind::Device => *p = sanitize_path(p), - NameKind::DevicePeripheral => *p = p.to_sanitized_upper_case().to_string(), - NameKind::DeviceInterrupt => *p = p.to_sanitized_upper_case().to_string(), + NameKind::DevicePeripheral => *p = p.to_sanitized_constant_case().to_string(), + NameKind::DeviceInterrupt => *p = p.to_sanitized_constant_case().to_string(), NameKind::Block => *p = sanitize_path(p), NameKind::Fieldset => *p = sanitize_path(p), NameKind::Enum => *p = sanitize_path(p), NameKind::BlockItem => *p = p.to_sanitized_snake_case().to_string(), NameKind::Field => *p = p.to_sanitized_snake_case().to_string(), - NameKind::EnumVariant => *p = p.to_sanitized_upper_case().to_string(), + NameKind::EnumVariant => *p = p.to_sanitized_constant_case().to_string(), }); Ok(()) } diff --git a/src/util.rs b/src/util.rs index 45dcab6..54a0000 100644 --- a/src/util.rs +++ b/src/util.rs @@ -34,6 +34,7 @@ fn sanitize_ident(s: String) -> String { pub trait StringExt { fn to_sanitized_pascal_case(&self) -> String; fn to_sanitized_upper_case(&self) -> String; + fn to_sanitized_constant_case(&self) -> String; fn to_sanitized_snake_case(&self) -> String; } @@ -46,6 +47,10 @@ impl StringExt for str { sanitize_ident(self.to_upper_case()) } + fn to_sanitized_constant_case(&self) -> String { + sanitize_ident(self.to_constant_case()) + } + fn to_sanitized_pascal_case(&self) -> String { sanitize_ident(self.to_pascal_case()) }