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