@@ -32,6 +32,7 @@ pub struct Config {
32
32
pub reexport_core_peripherals : bool ,
33
33
pub reexport_interrupt : bool ,
34
34
pub ident_formats : IdentFormats ,
35
+ pub ident_formats_theme : IdentFormatsTheme ,
35
36
pub base_address_shift : u64 ,
36
37
}
37
38
@@ -178,56 +179,113 @@ pub struct IdentFormats(HashMap<String, IdentFormat>);
178
179
179
180
impl Default for IdentFormats {
180
181
fn default ( ) -> Self {
181
- let mut map = HashMap :: new ( ) ;
182
-
183
- map. insert ( "field_accessor" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ;
184
- map. insert (
185
- "field_reader" . into ( ) ,
186
- IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "R" ) ,
187
- ) ;
188
- map. insert (
189
- "field_writer" . into ( ) ,
190
- IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "W" ) ,
191
- ) ;
192
- map. insert ( "enum_name" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ;
193
- map. insert (
194
- "enum_write_name" . into ( ) ,
195
- IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "WO" ) ,
196
- ) ;
197
- map. insert ( "enum_value" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ;
198
- map. insert (
199
- "enum_value_accessor" . into ( ) ,
200
- IdentFormat :: default ( ) . snake_case ( ) ,
201
- ) ;
202
- map. insert ( "interrupt" . into ( ) , IdentFormat :: default ( ) ) ;
203
- map. insert ( "cluster" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ;
204
- map. insert (
205
- "cluster_accessor" . into ( ) ,
206
- IdentFormat :: default ( ) . snake_case ( ) ,
207
- ) ;
208
- map. insert ( "cluster_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ;
209
- map. insert ( "register" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ;
210
- map. insert (
211
- "register_spec" . into ( ) ,
212
- IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "Spec" ) ,
213
- ) ;
214
- map. insert (
215
- "register_accessor" . into ( ) ,
216
- IdentFormat :: default ( ) . snake_case ( ) ,
217
- ) ;
218
- map. insert ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ;
219
- map. insert ( "peripheral" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ;
220
- map. insert (
221
- "peripheral_singleton" . into ( ) ,
222
- IdentFormat :: default ( ) . snake_case ( ) ,
223
- ) ;
224
- map. insert ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ;
225
- map. insert (
226
- "peripheral_feature" . into ( ) ,
227
- IdentFormat :: default ( ) . snake_case ( ) ,
228
- ) ;
182
+ Self :: new_theme ( )
183
+ }
184
+ }
229
185
230
- Self ( map)
186
+ impl IdentFormats {
187
+ pub fn new_theme ( ) -> Self {
188
+ Self ( HashMap :: from ( [
189
+ ( "field_accessor" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
190
+ (
191
+ "field_reader" . into ( ) ,
192
+ IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "R" ) ,
193
+ ) ,
194
+ (
195
+ "field_writer" . into ( ) ,
196
+ IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "W" ) ,
197
+ ) ,
198
+ ( "enum_name" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
199
+ (
200
+ "enum_write_name" . into ( ) ,
201
+ IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "WO" ) ,
202
+ ) ,
203
+ ( "enum_value" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
204
+ (
205
+ "enum_value_accessor" . into ( ) ,
206
+ IdentFormat :: default ( ) . snake_case ( ) ,
207
+ ) ,
208
+ ( "interrupt" . into ( ) , IdentFormat :: default ( ) ) ,
209
+ ( "cluster" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
210
+ (
211
+ "cluster_accessor" . into ( ) ,
212
+ IdentFormat :: default ( ) . snake_case ( ) ,
213
+ ) ,
214
+ ( "cluster_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
215
+ ( "register" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
216
+ (
217
+ "register_spec" . into ( ) ,
218
+ IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "Spec" ) ,
219
+ ) ,
220
+ (
221
+ "register_accessor" . into ( ) ,
222
+ IdentFormat :: default ( ) . snake_case ( ) ,
223
+ ) ,
224
+ ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
225
+ ( "peripheral" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
226
+ (
227
+ "peripheral_singleton" . into ( ) ,
228
+ IdentFormat :: default ( ) . snake_case ( ) ,
229
+ ) ,
230
+ ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
231
+ (
232
+ "peripheral_feature" . into ( ) ,
233
+ IdentFormat :: default ( ) . snake_case ( ) ,
234
+ ) ,
235
+ ] ) )
236
+ }
237
+ pub fn legacy_theme ( ) -> Self {
238
+ Self ( HashMap :: from ( [
239
+ ( "field_accessor" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
240
+ (
241
+ "field_reader" . into ( ) ,
242
+ IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_R" ) ,
243
+ ) ,
244
+ (
245
+ "field_writer" . into ( ) ,
246
+ IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_W" ) ,
247
+ ) ,
248
+ (
249
+ "enum_name" . into ( ) ,
250
+ IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_A" ) ,
251
+ ) ,
252
+ (
253
+ "enum_write_name" . into ( ) ,
254
+ IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_AW" ) ,
255
+ ) ,
256
+ ( "enum_value" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
257
+ (
258
+ "enum_value_accessor" . into ( ) ,
259
+ IdentFormat :: default ( ) . snake_case ( ) ,
260
+ ) ,
261
+ ( "interrupt" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
262
+ ( "cluster" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
263
+ (
264
+ "cluster_accessor" . into ( ) ,
265
+ IdentFormat :: default ( ) . snake_case ( ) ,
266
+ ) ,
267
+ ( "cluster_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
268
+ ( "register" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
269
+ (
270
+ "register_spec" . into ( ) ,
271
+ IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "_SPEC" ) ,
272
+ ) ,
273
+ (
274
+ "register_accessor" . into ( ) ,
275
+ IdentFormat :: default ( ) . snake_case ( ) ,
276
+ ) ,
277
+ ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
278
+ ( "peripheral" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
279
+ (
280
+ "peripheral_singleton" . into ( ) ,
281
+ IdentFormat :: default ( ) . constant_case ( ) ,
282
+ ) ,
283
+ ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
284
+ (
285
+ "peripheral_feature" . into ( ) ,
286
+ IdentFormat :: default ( ) . snake_case ( ) ,
287
+ ) ,
288
+ ] ) )
231
289
}
232
290
}
233
291
@@ -242,3 +300,15 @@ impl DerefMut for IdentFormats {
242
300
& mut self . 0
243
301
}
244
302
}
303
+
304
+ #[ cfg_attr(
305
+ feature = "serde" ,
306
+ derive( serde:: Deserialize ) ,
307
+ serde( rename_all = "lowercase" )
308
+ ) ]
309
+ #[ derive( Clone , Copy , Debug , Default , PartialEq , Eq ) ]
310
+ pub enum IdentFormatsTheme {
311
+ #[ default]
312
+ New ,
313
+ Legacy ,
314
+ }
0 commit comments