@@ -12,8 +12,8 @@ use quote::{quote, ToTokens};
1212use syn:: { parse_str, Token } ;
1313
1414use crate :: util:: {
15- self , handle_cluster_error, handle_reg_error, unsuffixed, Config , FullName ,
16- ToSanitizedSnakeCase , ToSanitizedUpperCase , BITS_PER_BYTE ,
15+ self , handle_cluster_error, handle_reg_error, unsuffixed, Config , FullName , ToSanitizedCase ,
16+ BITS_PER_BYTE ,
1717} ;
1818use anyhow:: { anyhow, bail, Context , Result } ;
1919
@@ -44,16 +44,16 @@ pub fn render(
4444
4545 let name = util:: name_of ( p, config. ignore_groups ) ;
4646 let span = Span :: call_site ( ) ;
47- let name_str = name. to_sanitized_upper_case ( ) ;
48- let name_pc = Ident :: new ( & name_str, span) ;
47+ let name_str = name. to_sanitized_constant_case ( ) ;
48+ let name_constant_case = Ident :: new ( & name_str, span) ;
4949 let address = util:: hex ( p. base_address as u64 ) ;
5050 let description = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & p. name ) ) ;
5151
52- let name_sc = Ident :: new ( & name. to_sanitized_snake_case ( ) , span) ;
52+ let name_snake_case = Ident :: new ( & name. to_sanitized_snake_case ( ) , span) ;
5353 let ( derive_regs, base) = if let ( Some ( df) , None ) = ( p_derivedfrom, & p_original. registers ) {
5454 ( true , Ident :: new ( & df. name . to_sanitized_snake_case ( ) , span) )
5555 } else {
56- ( false , name_sc . clone ( ) )
56+ ( false , name_snake_case . clone ( ) )
5757 } ;
5858
5959 let feature_attribute = if config. feature_group && p. group_name . is_some ( ) {
@@ -66,8 +66,8 @@ pub fn render(
6666 match p_original {
6767 Peripheral :: Array ( p, dim) => {
6868 let names: Vec < Cow < str > > = names ( p, dim) . map ( |n| n. into ( ) ) . collect ( ) ;
69- let names_str = names. iter ( ) . map ( |n| n. to_sanitized_upper_case ( ) ) ;
70- let names_pc = names_str. clone ( ) . map ( |n| Ident :: new ( & n, span) ) ;
69+ let names_str = names. iter ( ) . map ( |n| n. to_sanitized_constant_case ( ) ) ;
70+ let names_constant_case = names_str. clone ( ) . map ( |n| Ident :: new ( & n, span) ) ;
7171 let addresses =
7272 ( 0 ..=dim. dim ) . map ( |i| util:: hex ( p. base_address + ( i * dim. dim_increment ) as u64 ) ) ;
7373
@@ -76,13 +76,13 @@ pub fn render(
7676 #(
7777 #[ doc = #description]
7878 #feature_attribute
79- pub struct #names_pc { _marker: PhantomData <* const ( ) > }
79+ pub struct #names_constant_case { _marker: PhantomData <* const ( ) > }
8080
8181 #feature_attribute
82- unsafe impl Send for #names_pc { }
82+ unsafe impl Send for #names_constant_case { }
8383
8484 #feature_attribute
85- impl #names_pc {
85+ impl #names_constant_case {
8686 ///Pointer to the register block
8787 pub const PTR : * const #base:: RegisterBlock = #addresses as * const _;
8888
@@ -94,7 +94,7 @@ pub fn render(
9494 }
9595
9696 #feature_attribute
97- impl Deref for #names_pc {
97+ impl Deref for #names_constant_case {
9898 type Target = #base:: RegisterBlock ;
9999
100100 #[ inline( always) ]
@@ -104,7 +104,7 @@ pub fn render(
104104 }
105105
106106 #feature_attribute
107- impl core:: fmt:: Debug for #names_pc {
107+ impl core:: fmt:: Debug for #names_constant_case {
108108 fn fmt( & self , f: & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
109109 f. debug_struct( #names_str) . finish( )
110110 }
@@ -117,13 +117,13 @@ pub fn render(
117117 out. extend ( quote ! {
118118 #[ doc = #description]
119119 #feature_attribute
120- pub struct #name_pc { _marker: PhantomData <* const ( ) > }
120+ pub struct #name_constant_case { _marker: PhantomData <* const ( ) > }
121121
122122 #feature_attribute
123- unsafe impl Send for #name_pc { }
123+ unsafe impl Send for #name_constant_case { }
124124
125125 #feature_attribute
126- impl #name_pc {
126+ impl #name_constant_case {
127127 ///Pointer to the register block
128128 pub const PTR : * const #base:: RegisterBlock = #address as * const _;
129129
@@ -135,7 +135,7 @@ pub fn render(
135135 }
136136
137137 #feature_attribute
138- impl Deref for #name_pc {
138+ impl Deref for #name_constant_case {
139139 type Target = #base:: RegisterBlock ;
140140
141141 #[ inline( always) ]
@@ -145,7 +145,7 @@ pub fn render(
145145 }
146146
147147 #feature_attribute
148- impl core:: fmt:: Debug for #name_pc {
148+ impl core:: fmt:: Debug for #name_constant_case {
149149 fn fmt( & self , f: & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
150150 f. debug_struct( #name_str) . finish( )
151151 }
@@ -161,7 +161,7 @@ pub fn render(
161161 out. extend ( quote ! {
162162 #[ doc = #description]
163163 #feature_attribute
164- pub use #base as #name_sc ;
164+ pub use #base as #name_snake_case ;
165165 } ) ;
166166 return Ok ( out) ;
167167 }
@@ -235,7 +235,7 @@ pub fn render(
235235 out. extend ( quote ! {
236236 #[ doc = #description]
237237 #feature_attribute
238- pub mod #name_sc #open
238+ pub mod #name_snake_case #open
239239 } ) ;
240240
241241 out. extend ( mod_items) ;
@@ -627,7 +627,7 @@ fn register_or_cluster_block(
627627
628628 let name = Ident :: new (
629629 & match name {
630- Some ( name) => name. to_sanitized_upper_case ( ) ,
630+ Some ( name) => name. to_sanitized_constant_case ( ) ,
631631 None => "RegisterBlock" . into ( ) ,
632632 } ,
633633 span,
@@ -963,7 +963,7 @@ fn cluster_block(
963963) -> Result < TokenStream > {
964964 let mut mod_items = TokenStream :: new ( ) ;
965965
966- // name_sc needs to take into account array type.
966+ // name_snake_case needs to take into account array type.
967967 let description =
968968 util:: escape_brackets ( util:: respace ( c. description . as_ref ( ) . unwrap_or ( & c. name ) ) . as_ref ( ) ) ;
969969
@@ -975,7 +975,7 @@ fn cluster_block(
975975 } ,
976976 "" ,
977977 ) ;
978- let name_sc = Ident :: new ( & mod_name. to_sanitized_snake_case ( ) , Span :: call_site ( ) ) ;
978+ let name_snake_case = Ident :: new ( & mod_name. to_sanitized_snake_case ( ) , Span :: call_site ( ) ) ;
979979
980980 let reg_block = register_or_cluster_block ( & c. children , Some ( & mod_name) , config) ?;
981981
@@ -1006,7 +1006,7 @@ fn cluster_block(
10061006
10071007 ///Register block
10081008 #[ doc = #description]
1009- pub mod #name_sc {
1009+ pub mod #name_snake_case {
10101010 #mod_items
10111011 }
10121012 } )
@@ -1157,10 +1157,10 @@ fn name_to_ty_str<'a, 'b>(name: &'a str, ns: Option<&'b str>) -> Cow<'a, str> {
11571157 String :: from ( "self::" )
11581158 + & ns. to_sanitized_snake_case ( )
11591159 + "::"
1160- + & name. to_sanitized_upper_case ( ) ,
1160+ + & name. to_sanitized_constant_case ( ) ,
11611161 )
11621162 } else {
1163- name. to_sanitized_upper_case ( )
1163+ name. to_sanitized_constant_case ( )
11641164 }
11651165}
11661166
@@ -1175,13 +1175,13 @@ fn name_to_wrapped_ty_str(name: &str, ns: Option<&str>) -> String {
11751175 "crate::Reg<self::{}::{}::{}_SPEC>" ,
11761176 & ns. to_sanitized_snake_case( ) ,
11771177 & name. to_sanitized_snake_case( ) ,
1178- & name. to_sanitized_upper_case ( ) ,
1178+ & name. to_sanitized_constant_case ( ) ,
11791179 )
11801180 } else {
11811181 format ! (
11821182 "crate::Reg<{}::{}_SPEC>" ,
11831183 & name. to_sanitized_snake_case( ) ,
1184- & name. to_sanitized_upper_case ( ) ,
1184+ & name. to_sanitized_constant_case ( ) ,
11851185 )
11861186 }
11871187}
0 commit comments