@@ -178,9 +178,36 @@ impl IdentFormat {
178178pub struct IdentFormats ( HashMap < String , IdentFormat > ) ;
179179
180180impl IdentFormats {
181- pub fn new_theme ( ) -> Self {
181+ fn common ( ) -> Self {
182182 Self ( HashMap :: from ( [
183183 ( "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 ( [
184211 (
185212 "field_reader" . into ( ) ,
186213 IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "R" ) ,
@@ -195,42 +222,25 @@ impl IdentFormats {
195222 IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "WO" ) ,
196223 ) ,
197224 ( "enum_value" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
198- (
199- "enum_value_accessor" . into ( ) ,
200- IdentFormat :: default ( ) . snake_case ( ) ,
201- ) ,
202225 ( "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 ( ) ) ,
209226 ( "register" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
210227 (
211228 "register_spec" . into ( ) ,
212229 IdentFormat :: default ( ) . pascal_case ( ) . suffix ( "Spec" ) ,
213230 ) ,
214- (
215- "register_accessor" . into ( ) ,
216- IdentFormat :: default ( ) . snake_case ( ) ,
217- ) ,
218- ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
219231 ( "peripheral" . into ( ) , IdentFormat :: default ( ) . pascal_case ( ) ) ,
220232 (
221233 "peripheral_singleton" . into ( ) ,
222234 IdentFormat :: default ( ) . snake_case ( ) ,
223235 ) ,
224- ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
225- (
226- "peripheral_feature" . into ( ) ,
227- IdentFormat :: default ( ) . snake_case ( ) ,
228- ) ,
229- ] ) )
236+ ] ) ;
237+
238+ map
230239 }
231240 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 ( [
234244 (
235245 "field_reader" . into ( ) ,
236246 IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_R" ) ,
@@ -248,38 +258,21 @@ impl IdentFormats {
248258 IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_AW" ) ,
249259 ) ,
250260 ( "enum_value" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
251- (
252- "enum_value_accessor" . into ( ) ,
253- IdentFormat :: default ( ) . snake_case ( ) ,
254- ) ,
255261 ( "interrupt" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
256262 ( "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 ( ) ) ,
262263 ( "register" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
263264 (
264265 "register_spec" . into ( ) ,
265266 IdentFormat :: default ( ) . constant_case ( ) . suffix ( "_SPEC" ) ,
266267 ) ,
267- (
268- "register_accessor" . into ( ) ,
269- IdentFormat :: default ( ) . snake_case ( ) ,
270- ) ,
271- ( "register_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
272268 ( "peripheral" . into ( ) , IdentFormat :: default ( ) . constant_case ( ) ) ,
273269 (
274270 "peripheral_singleton" . into ( ) ,
275271 IdentFormat :: default ( ) . constant_case ( ) ,
276272 ) ,
277- ( "peripheral_mod" . into ( ) , IdentFormat :: default ( ) . snake_case ( ) ) ,
278- (
279- "peripheral_feature" . into ( ) ,
280- IdentFormat :: default ( ) . snake_case ( ) ,
281- ) ,
282- ] ) )
273+ ] ) ;
274+
275+ map
283276 }
284277}
285278
0 commit comments