@@ -12,8 +12,8 @@ use quote::{quote, ToTokens};
12
12
use syn:: { parse_str, Token } ;
13
13
14
14
use 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 ,
17
17
} ;
18
18
use anyhow:: { anyhow, bail, Context , Result } ;
19
19
@@ -44,16 +44,16 @@ pub fn render(
44
44
45
45
let name = util:: name_of ( p, config. ignore_groups ) ;
46
46
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) ;
49
49
let address = util:: hex ( p. base_address as u64 ) ;
50
50
let description = util:: respace ( p. description . as_ref ( ) . unwrap_or ( & p. name ) ) ;
51
51
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) ;
53
53
let ( derive_regs, base) = if let ( Some ( df) , None ) = ( p_derivedfrom, & p_original. registers ) {
54
54
( true , Ident :: new ( & df. name . to_sanitized_snake_case ( ) , span) )
55
55
} else {
56
- ( false , name_sc . clone ( ) )
56
+ ( false , name_snake_case . clone ( ) )
57
57
} ;
58
58
59
59
let feature_attribute = if config. feature_group && p. group_name . is_some ( ) {
@@ -66,8 +66,8 @@ pub fn render(
66
66
match p_original {
67
67
Peripheral :: Array ( p, dim) => {
68
68
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) ) ;
71
71
let addresses =
72
72
( 0 ..=dim. dim ) . map ( |i| util:: hex ( p. base_address + ( i * dim. dim_increment ) as u64 ) ) ;
73
73
@@ -76,13 +76,13 @@ pub fn render(
76
76
#(
77
77
#[ doc = #description]
78
78
#feature_attribute
79
- pub struct #names_pc { _marker: PhantomData <* const ( ) > }
79
+ pub struct #names_constant_case { _marker: PhantomData <* const ( ) > }
80
80
81
81
#feature_attribute
82
- unsafe impl Send for #names_pc { }
82
+ unsafe impl Send for #names_constant_case { }
83
83
84
84
#feature_attribute
85
- impl #names_pc {
85
+ impl #names_constant_case {
86
86
///Pointer to the register block
87
87
pub const PTR : * const #base:: RegisterBlock = #addresses as * const _;
88
88
@@ -94,7 +94,7 @@ pub fn render(
94
94
}
95
95
96
96
#feature_attribute
97
- impl Deref for #names_pc {
97
+ impl Deref for #names_constant_case {
98
98
type Target = #base:: RegisterBlock ;
99
99
100
100
#[ inline( always) ]
@@ -104,7 +104,7 @@ pub fn render(
104
104
}
105
105
106
106
#feature_attribute
107
- impl core:: fmt:: Debug for #names_pc {
107
+ impl core:: fmt:: Debug for #names_constant_case {
108
108
fn fmt( & self , f: & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
109
109
f. debug_struct( #names_str) . finish( )
110
110
}
@@ -117,13 +117,13 @@ pub fn render(
117
117
out. extend ( quote ! {
118
118
#[ doc = #description]
119
119
#feature_attribute
120
- pub struct #name_pc { _marker: PhantomData <* const ( ) > }
120
+ pub struct #name_constant_case { _marker: PhantomData <* const ( ) > }
121
121
122
122
#feature_attribute
123
- unsafe impl Send for #name_pc { }
123
+ unsafe impl Send for #name_constant_case { }
124
124
125
125
#feature_attribute
126
- impl #name_pc {
126
+ impl #name_constant_case {
127
127
///Pointer to the register block
128
128
pub const PTR : * const #base:: RegisterBlock = #address as * const _;
129
129
@@ -135,7 +135,7 @@ pub fn render(
135
135
}
136
136
137
137
#feature_attribute
138
- impl Deref for #name_pc {
138
+ impl Deref for #name_constant_case {
139
139
type Target = #base:: RegisterBlock ;
140
140
141
141
#[ inline( always) ]
@@ -145,7 +145,7 @@ pub fn render(
145
145
}
146
146
147
147
#feature_attribute
148
- impl core:: fmt:: Debug for #name_pc {
148
+ impl core:: fmt:: Debug for #name_constant_case {
149
149
fn fmt( & self , f: & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
150
150
f. debug_struct( #name_str) . finish( )
151
151
}
@@ -161,7 +161,7 @@ pub fn render(
161
161
out. extend ( quote ! {
162
162
#[ doc = #description]
163
163
#feature_attribute
164
- pub use #base as #name_sc ;
164
+ pub use #base as #name_snake_case ;
165
165
} ) ;
166
166
return Ok ( out) ;
167
167
}
@@ -235,7 +235,7 @@ pub fn render(
235
235
out. extend ( quote ! {
236
236
#[ doc = #description]
237
237
#feature_attribute
238
- pub mod #name_sc #open
238
+ pub mod #name_snake_case #open
239
239
} ) ;
240
240
241
241
out. extend ( mod_items) ;
@@ -627,7 +627,7 @@ fn register_or_cluster_block(
627
627
628
628
let name = Ident :: new (
629
629
& match name {
630
- Some ( name) => name. to_sanitized_upper_case ( ) ,
630
+ Some ( name) => name. to_sanitized_constant_case ( ) ,
631
631
None => "RegisterBlock" . into ( ) ,
632
632
} ,
633
633
span,
@@ -963,7 +963,7 @@ fn cluster_block(
963
963
) -> Result < TokenStream > {
964
964
let mut mod_items = TokenStream :: new ( ) ;
965
965
966
- // name_sc needs to take into account array type.
966
+ // name_snake_case needs to take into account array type.
967
967
let description =
968
968
util:: escape_brackets ( util:: respace ( c. description . as_ref ( ) . unwrap_or ( & c. name ) ) . as_ref ( ) ) ;
969
969
@@ -975,7 +975,7 @@ fn cluster_block(
975
975
} ,
976
976
"" ,
977
977
) ;
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 ( ) ) ;
979
979
980
980
let reg_block = register_or_cluster_block ( & c. children , Some ( & mod_name) , config) ?;
981
981
@@ -1006,7 +1006,7 @@ fn cluster_block(
1006
1006
1007
1007
///Register block
1008
1008
#[ doc = #description]
1009
- pub mod #name_sc {
1009
+ pub mod #name_snake_case {
1010
1010
#mod_items
1011
1011
}
1012
1012
} )
@@ -1157,10 +1157,10 @@ fn name_to_ty_str<'a, 'b>(name: &'a str, ns: Option<&'b str>) -> Cow<'a, str> {
1157
1157
String :: from ( "self::" )
1158
1158
+ & ns. to_sanitized_snake_case ( )
1159
1159
+ "::"
1160
- + & name. to_sanitized_upper_case ( ) ,
1160
+ + & name. to_sanitized_constant_case ( ) ,
1161
1161
)
1162
1162
} else {
1163
- name. to_sanitized_upper_case ( )
1163
+ name. to_sanitized_constant_case ( )
1164
1164
}
1165
1165
}
1166
1166
@@ -1175,13 +1175,13 @@ fn name_to_wrapped_ty_str(name: &str, ns: Option<&str>) -> String {
1175
1175
"crate::Reg<self::{}::{}::{}_SPEC>" ,
1176
1176
& ns. to_sanitized_snake_case( ) ,
1177
1177
& name. to_sanitized_snake_case( ) ,
1178
- & name. to_sanitized_upper_case ( ) ,
1178
+ & name. to_sanitized_constant_case ( ) ,
1179
1179
)
1180
1180
} else {
1181
1181
format ! (
1182
1182
"crate::Reg<{}::{}_SPEC>" ,
1183
1183
& name. to_sanitized_snake_case( ) ,
1184
- & name. to_sanitized_upper_case ( ) ,
1184
+ & name. to_sanitized_constant_case ( ) ,
1185
1185
)
1186
1186
}
1187
1187
}
0 commit comments