@@ -77,18 +77,18 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
77
77
78
78
match & p {
79
79
Peripheral :: Array ( p, dim) => {
80
- let mut snake_names = Vec :: with_capacity ( dim. dim as _ ) ;
80
+ let mut feature_names = Vec :: with_capacity ( dim. dim as _ ) ;
81
81
for pi in svd:: peripheral:: expand ( p, dim) {
82
82
let name = & pi. name ;
83
83
let description = pi. description . as_deref ( ) . unwrap_or ( & p. name ) ;
84
84
let p_ty = ident ( name, & config. ident_formats . peripheral , span) ;
85
85
let name_str = p_ty. to_string ( ) ;
86
86
let address = util:: hex ( pi. base_address + config. base_address_shift ) ;
87
- let p_snake = name . to_sanitized_snake_case ( ) ;
88
- snake_names . push ( p_snake . to_string ( ) ) ;
87
+ let feature_name = config . ident_formats . peripheral_feature . apply ( name ) ;
88
+ feature_names . push ( feature_name . to_string ( ) ) ;
89
89
let mut feature_attribute_n = feature_attribute. clone ( ) ;
90
90
if config. feature_peripheral {
91
- feature_attribute_n. extend ( quote ! { #[ cfg( feature = #p_snake ) ] } )
91
+ feature_attribute_n. extend ( quote ! { #[ cfg( feature = #feature_name ) ] } )
92
92
} ;
93
93
// Insert the peripherals structure
94
94
out. extend ( quote ! {
@@ -132,7 +132,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
132
132
} ) ;
133
133
}
134
134
135
- let feature_any_attribute = quote ! { #[ cfg( any( #( feature = #snake_names ) , * ) ) ] } ;
135
+ let feature_any_attribute = quote ! { #[ cfg( any( #( feature = #feature_names ) , * ) ) ] } ;
136
136
137
137
// Derived peripherals may not require re-implementation, and will instead
138
138
// use a single definition of the non-derived version.
@@ -147,9 +147,9 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
147
147
}
148
148
}
149
149
Peripheral :: Single ( _) => {
150
- let p_snake = name . to_sanitized_snake_case ( ) ;
150
+ let feature_name = config . ident_formats . peripheral_feature . apply ( & name ) ;
151
151
if config. feature_peripheral {
152
- feature_attribute. extend ( quote ! { #[ cfg( feature = #p_snake ) ] } )
152
+ feature_attribute. extend ( quote ! { #[ cfg( feature = #feature_name ) ] } )
153
153
} ;
154
154
// Insert the peripheral structure
155
155
out. extend ( quote ! {
@@ -981,12 +981,13 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
981
981
} else {
982
982
util:: replace_suffix ( & cluster. name , "" )
983
983
} ;
984
- let ty = name_to_ty ( & ty_name) ;
984
+ let span = Span :: call_site ( ) ;
985
+ let ty = name_to_ty ( ident ( & ty_name, & config. ident_formats . cluster , span) ) ;
985
986
986
987
match cluster {
987
988
Cluster :: Single ( info) => {
988
989
let doc = make_comment ( cluster_size, info. address_offset , & description) ;
989
- let name: Ident = info. name . to_snake_case_ident ( Span :: call_site ( ) ) ;
990
+ let name: Ident = ident ( & info. name , & config . ident_formats . cluster_accessor , span ) ;
990
991
let syn_field = new_syn_field ( name. clone ( ) , ty. clone ( ) ) ;
991
992
cluster_expanded. push ( RegisterBlockField {
992
993
syn_field,
@@ -1029,12 +1030,15 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1029
1030
let array_convertible = sequential_addresses && convert_list;
1030
1031
1031
1032
if convert_list {
1032
- let span = Span :: call_site ( ) ;
1033
- let nb_name_sc = if let Some ( dim_name) = array_info. dim_name . as_ref ( ) {
1034
- dim_name. to_snake_case_ident ( span)
1035
- } else {
1036
- ty_name. to_snake_case_ident ( span)
1037
- } ;
1033
+ let accessor_name = ident (
1034
+ if let Some ( dim_name) = array_info. dim_name . as_ref ( ) {
1035
+ dim_name
1036
+ } else {
1037
+ & ty_name
1038
+ } ,
1039
+ & config. ident_formats . cluster_accessor ,
1040
+ span,
1041
+ ) ;
1038
1042
let doc = make_comment (
1039
1043
cluster_size * array_info. dim ,
1040
1044
info. address_offset ,
@@ -1044,7 +1048,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1044
1048
accessors. push ( if array_convertible {
1045
1049
ArrayAccessor {
1046
1050
doc,
1047
- name : nb_name_sc . clone ( ) ,
1051
+ name : accessor_name . clone ( ) ,
1048
1052
ty : ty. clone ( ) ,
1049
1053
offset : unsuffixed ( info. address_offset ) ,
1050
1054
dim : unsuffixed ( array_info. dim ) ,
@@ -1054,7 +1058,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1054
1058
} else {
1055
1059
RawArrayAccessor {
1056
1060
doc,
1057
- name : nb_name_sc . clone ( ) ,
1061
+ name : accessor_name . clone ( ) ,
1058
1062
ty : ty. clone ( ) ,
1059
1063
offset : unsuffixed ( info. address_offset ) ,
1060
1064
dim : unsuffixed ( array_info. dim ) ,
@@ -1076,7 +1080,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1076
1080
doc,
1077
1081
name : idx_name,
1078
1082
ty : ty. clone ( ) ,
1079
- basename : nb_name_sc . clone ( ) ,
1083
+ basename : accessor_name . clone ( ) ,
1080
1084
i,
1081
1085
}
1082
1086
. into ( ) ,
@@ -1088,7 +1092,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1088
1092
} else {
1089
1093
zst_type ( )
1090
1094
} ;
1091
- let syn_field = new_syn_field ( nb_name_sc , array_ty) ;
1095
+ let syn_field = new_syn_field ( accessor_name , array_ty) ;
1092
1096
cluster_expanded. push ( RegisterBlockField {
1093
1097
syn_field,
1094
1098
offset : info. address_offset ,
@@ -1106,7 +1110,7 @@ fn expand_cluster(cluster: &Cluster, config: &Config) -> Result<Vec<RegisterBloc
1106
1110
ci. address_offset ,
1107
1111
ci. description . as_deref ( ) . unwrap_or ( & ci. name ) ,
1108
1112
) ;
1109
- let name = ci. name . to_snake_case_ident ( Span :: call_site ( ) ) ;
1113
+ let name = ident ( & ci. name , & config . ident_formats . cluster_accessor , span ) ;
1110
1114
let syn_field = new_syn_field ( name. clone ( ) , ty. clone ( ) ) ;
1111
1115
1112
1116
cluster_expanded. push ( RegisterBlockField {
@@ -1155,8 +1159,9 @@ fn expand_register(
1155
1159
match register {
1156
1160
Register :: Single ( info) => {
1157
1161
let doc = make_comment ( register_size, info. address_offset , & description) ;
1158
- let ty = name_to_ty ( & ty_name) ;
1159
- let name = ty_name. to_snake_case_ident ( Span :: call_site ( ) ) ;
1162
+ let span = Span :: call_site ( ) ;
1163
+ let ty = name_to_ty ( ident ( & ty_name, & config. ident_formats . register , span) ) ;
1164
+ let name: Ident = ident ( & ty_name, & config. ident_formats . register_accessor , span) ;
1160
1165
let syn_field = new_syn_field ( name. clone ( ) , ty. clone ( ) ) ;
1161
1166
register_expanded. push ( RegisterBlockField {
1162
1167
syn_field,
@@ -1210,15 +1215,18 @@ fn expand_register(
1210
1215
} ;
1211
1216
let array_convertible = ac && sequential_addresses;
1212
1217
let array_proxy_convertible = ac && disjoint_sequential_addresses;
1213
- let ty = name_to_ty ( & ty_name) ;
1218
+ let span = Span :: call_site ( ) ;
1219
+ let ty = name_to_ty ( ident ( & ty_name, & config. ident_formats . register , span) ) ;
1214
1220
1215
1221
if array_convertible || array_proxy_convertible {
1216
- let span = Span :: call_site ( ) ;
1217
- let nb_name_sc = if let Some ( dim_name) = array_info. dim_name . as_ref ( ) {
1218
- util:: fullname ( dim_name, & info. alternate_group , config. ignore_groups )
1219
- . to_snake_case_ident ( span)
1222
+ let accessor_name = if let Some ( dim_name) = array_info. dim_name . as_ref ( ) {
1223
+ ident (
1224
+ & util:: fullname ( dim_name, & info. alternate_group , config. ignore_groups ) ,
1225
+ & config. ident_formats . register ,
1226
+ span,
1227
+ )
1220
1228
} else {
1221
- ty_name. to_snake_case_ident ( span)
1229
+ ident ( & ty_name, & config . ident_formats . register , span)
1222
1230
} ;
1223
1231
let doc = make_comment (
1224
1232
register_size * array_info. dim ,
@@ -1229,7 +1237,7 @@ fn expand_register(
1229
1237
accessors. push ( if array_convertible {
1230
1238
ArrayAccessor {
1231
1239
doc,
1232
- name : nb_name_sc . clone ( ) ,
1240
+ name : accessor_name . clone ( ) ,
1233
1241
ty : ty. clone ( ) ,
1234
1242
offset : unsuffixed ( info. address_offset ) ,
1235
1243
dim : unsuffixed ( array_info. dim ) ,
@@ -1239,7 +1247,7 @@ fn expand_register(
1239
1247
} else {
1240
1248
RawArrayAccessor {
1241
1249
doc,
1242
- name : nb_name_sc . clone ( ) ,
1250
+ name : accessor_name . clone ( ) ,
1243
1251
ty : ty. clone ( ) ,
1244
1252
offset : unsuffixed ( info. address_offset ) ,
1245
1253
dim : unsuffixed ( array_info. dim ) ,
@@ -1263,7 +1271,7 @@ fn expand_register(
1263
1271
doc,
1264
1272
name : idx_name,
1265
1273
ty : ty. clone ( ) ,
1266
- basename : nb_name_sc . clone ( ) ,
1274
+ basename : accessor_name . clone ( ) ,
1267
1275
i,
1268
1276
}
1269
1277
. into ( ) ,
@@ -1275,7 +1283,7 @@ fn expand_register(
1275
1283
} else {
1276
1284
zst_type ( )
1277
1285
} ;
1278
- let syn_field = new_syn_field ( nb_name_sc , array_ty) ;
1286
+ let syn_field = new_syn_field ( accessor_name , array_ty) ;
1279
1287
register_expanded. push ( RegisterBlockField {
1280
1288
syn_field,
1281
1289
offset : info. address_offset ,
@@ -1293,7 +1301,7 @@ fn expand_register(
1293
1301
info. address_offset ,
1294
1302
ri. description . as_deref ( ) . unwrap_or ( & ri. name ) ,
1295
1303
) ;
1296
- let name = ri. name . to_snake_case_ident ( Span :: call_site ( ) ) ;
1304
+ let name = ident ( & ri. name , & config . ident_formats . register , span ) ;
1297
1305
let syn_field = new_syn_field ( name. clone ( ) , ty. clone ( ) ) ;
1298
1306
1299
1307
register_expanded. push ( RegisterBlockField {
0 commit comments