@@ -178,9 +178,36 @@ impl IdentFormat {
178
178
pub struct IdentFormats ( HashMap < String , IdentFormat > ) ;
179
179
180
180
impl IdentFormats {
181
- pub fn new_theme ( ) -> Self {
181
+ fn common ( ) -> Self {
182
182
Self ( HashMap :: from ( [
183
183
( "field_accessor" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
184
+ (
185
+ "register_accessor" . into ( ) ,
186
+ IdentFormat :: default ( ) . snake_case ( ) ,
187
+ ) ,
188
+ (
189
+ "enum_value_accessor" . into ( ) ,
190
+ IdentFormat :: default ( ) . snake_case ( ) ,
191
+ ) ,
192
+ ( "cluster" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
193
+ (
194
+ "cluster_accessor" . into ( ) ,
195
+ IdentFormat :: default ( ) . snake_case ( ) ,
196
+ ) ,
197
+ ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
198
+ ( "cluster_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
199
+ ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
200
+ (
201
+ "peripheral_feature" . into ( ) ,
202
+ IdentFormat :: default ( ) . snake_case ( ) ,
203
+ ) ,
204
+ ] ) )
205
+ }
206
+
207
+ pub fn new_theme ( ) -> Self {
208
+ let mut map = Self :: common ( ) ;
209
+
210
+ map. extend ( [
184
211
(
185
212
"field_reader" . into ( ) ,
186
213
IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "R" ) ,
@@ -195,42 +222,25 @@ impl IdentFormats {
195
222
IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "WO" ) ,
196
223
) ,
197
224
( "enum_value" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
198
- (
199
- "enum_value_accessor" . into ( ) ,
200
- IdentFormat :: default ( ) . snake_case ( ) ,
201
- ) ,
202
225
( "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
226
( "register" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
210
227
(
211
228
"register_spec" . into ( ) ,
212
229
IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "Spec" ) ,
213
230
) ,
214
- (
215
- "register_accessor" . into ( ) ,
216
- IdentFormat :: default ( ) . snake_case ( ) ,
217
- ) ,
218
- ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
219
231
( "peripheral" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
220
232
(
221
233
"peripheral_singleton" . into ( ) ,
222
234
IdentFormat :: default ( ) . snake_case ( ) ,
223
235
) ,
224
- ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
225
- (
226
- "peripheral_feature" . into ( ) ,
227
- IdentFormat :: default ( ) . snake_case ( ) ,
228
- ) ,
229
- ] ) )
236
+ ] ) ;
237
+
238
+ map
230
239
}
231
240
pub fn legacy_theme ( ) -> Self {
232
- Self ( HashMap :: from ( [
233
- ( "field_accessor" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
241
+ let mut map = Self :: common ( ) ;
242
+
243
+ map. extend ( [
234
244
(
235
245
"field_reader" . into ( ) ,
236
246
IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_R" ) ,
@@ -248,38 +258,21 @@ impl IdentFormats {
248
258
IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_AW" ) ,
249
259
) ,
250
260
( "enum_value" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
251
- (
252
- "enum_value_accessor" . into ( ) ,
253
- IdentFormat :: default ( ) . snake_case ( ) ,
254
- ) ,
255
261
( "interrupt" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
256
262
( "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
263
( "register" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
263
264
(
264
265
"register_spec" . into ( ) ,
265
266
IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_SPEC" ) ,
266
267
) ,
267
- (
268
- "register_accessor" . into ( ) ,
269
- IdentFormat :: default ( ) . snake_case ( ) ,
270
- ) ,
271
- ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
272
268
( "peripheral" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
273
269
(
274
270
"peripheral_singleton" . into ( ) ,
275
271
IdentFormat :: default ( ) . constant_case ( ) ,
276
272
) ,
277
- ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
278
- (
279
- "peripheral_feature" . into ( ) ,
280
- IdentFormat :: default ( ) . snake_case ( ) ,
281
- ) ,
282
- ] ) )
273
+ ] ) ;
274
+
275
+ map
283
276
}
284
277
}
285
278
0 commit comments