@@ -15,8 +15,7 @@ use svd_parser::expand::{
1515
1616use  crate :: config:: Config ; 
1717use  crate :: util:: { 
18-     self ,  ident,  ident_to_path,  path_segment,  replace_suffix,  type_path,  unsuffixed,  FullName , 
19-     U32Ext , 
18+     self ,  ident,  ident_to_path,  path_segment,  type_path,  unsuffixed,  DimSuffix ,  FullName ,  U32Ext , 
2019} ; 
2120use  anyhow:: { anyhow,  Result } ; 
2221use  syn:: punctuated:: Punctuated ; 
@@ -55,7 +54,10 @@ pub fn render(
5554        if  let  MaybeArray :: Array ( info,  array_info)  = register { 
5655            if  let  Some ( dim_index)  = & array_info. dim_index  { 
5756                let  index:  Cow < str >  = dim_index. first ( ) . unwrap ( ) . into ( ) ; 
58-                 name = replace_suffix ( & info. fullname ( config. ignore_groups ) ,  & index) . into ( ) 
57+                 name = info
58+                     . fullname ( config. ignore_groups ) 
59+                     . expand_dim ( & index) 
60+                     . into ( ) 
5961            } 
6062        } 
6163    } 
@@ -465,15 +467,14 @@ fn render_register_mod_debug(
465467            if  field_access. can_read ( )  && f. read_action . is_none ( )  { 
466468                if  let  Field :: Array ( _,  de)  = & f { 
467469                    for  suffix in  de. indexes ( )  { 
468-                         let  f_name_n =
469-                             field_accessor ( & util:: replace_suffix ( & f. name ,  & suffix) ,  config,  span) ; 
470+                         let  f_name_n = field_accessor ( & f. name . expand_dim ( & suffix) ,  config,  span) ; 
470471                        let  f_name_n_s = format ! ( "{f_name_n}" ) ; 
471472                        r_debug_impl. extend ( quote !  { 
472473                            . field( #f_name_n_s,  & format_args!( "{}" ,  self . #f_name_n( ) . #bit_or_bits( ) ) ) 
473474                        } ) ; 
474475                    } 
475476                }  else  { 
476-                     let  f_name = util :: replace_suffix ( & f. name ,   "" ) ; 
477+                     let  f_name = f. name . remove_dim ( ) ; 
477478                    let  f_name = field_accessor ( & f_name,  config,  span) ; 
478479                    let  f_name_s = format ! ( "{f_name}" ) ; 
479480                    r_debug_impl. extend ( quote !  { 
@@ -641,7 +642,7 @@ pub fn fields(
641642            return  Err ( anyhow ! ( "incorrect field {}" ,  f. name) ) ; 
642643        } 
643644
644-         let  name = util :: replace_suffix ( & f. name ,   "" ) ; 
645+         let  name = f. name . remove_dim ( ) ; 
645646        let  name_snake_case = field_accessor ( 
646647            if  let  Field :: Array ( 
647648                _, 
@@ -694,7 +695,13 @@ pub fn fields(
694695                    ev = ( * index. evs . get ( epath) . unwrap ( ) ) . clone ( ) ; 
695696                } 
696697            }  else  if  let  Some ( path)  = fdpath. as_ref ( )  { 
697-                 epath = Some ( path. new_enum ( ev. name . clone ( ) . unwrap_or_else ( || path. name . clone ( ) ) ) ) ; 
698+                 epath = Some ( 
699+                     path. new_enum ( 
700+                         ev. name 
701+                             . clone ( ) 
702+                             . unwrap_or_else ( || path. name . remove_dim ( ) . into ( ) ) , 
703+                     ) , 
704+                 ) ; 
698705            } 
699706            lookup_results. push ( ( ev,  epath) ) ; 
700707        } 
@@ -914,12 +921,7 @@ pub fn fields(
914921                    } 
915922                    EV :: Derived ( _,  base)  => { 
916923                        let  base_ident = if  config. field_names_for_enums  { 
917-                             ident ( 
918-                                 & util:: replace_suffix ( & base. field ( ) . name ,  "" ) , 
919-                                 config, 
920-                                 fmt, 
921-                                 span, 
922-                             ) 
924+                             ident ( & base. field ( ) . name . remove_dim ( ) ,  config,  fmt,  span) 
923925                        }  else  { 
924926                            ident ( & base. name ,  config,  fmt,  span) 
925927                        } ; 
@@ -980,7 +982,7 @@ pub fn fields(
980982                    // and value if necessary. 
981983
982984                    // generate pub use field_1 reader as field_2 reader 
983-                     let  base_field = util :: replace_suffix ( & base. field . name ,   "" ) ; 
985+                     let  base_field = base. field . name . remove_dim ( ) ; 
984986                    let  base_r = ident ( & base_field,  config,  "field_reader" ,  span) ; 
985987                    if  !reader_derives. contains ( & reader_ty)  { 
986988                        let  base_path = base_syn_path ( base,  & fpath,  & base_r,  config) ?; 
@@ -1002,7 +1004,7 @@ pub fn fields(
10021004
10031005            if  let  Field :: Array ( f,  de)  = & f { 
10041006                let  increment = de. dim_increment ; 
1005-                 let  doc = util :: replace_suffix ( & description,   & brief_suffix) ; 
1007+                 let  doc = description. expand_dim ( & brief_suffix) ; 
10061008                let  first_name = svd:: array:: names ( f,  de) . next ( ) . unwrap ( ) ; 
10071009                let  note = format ! ( "NOTE: `n` is number of field in register. `n == 0` corresponds to `{first_name}` field" ) ; 
10081010                let  offset_calc = calculate_offset ( increment,  offset,  true ) ; 
@@ -1182,12 +1184,7 @@ pub fn fields(
11821184                    } 
11831185                    EV :: Derived ( _,  base)  => { 
11841186                        let  base_ident = if  config. field_names_for_enums  { 
1185-                             ident ( 
1186-                                 & util:: replace_suffix ( & base. field ( ) . name ,  "" ) , 
1187-                                 config, 
1188-                                 fmt, 
1189-                                 span, 
1190-                             ) 
1187+                             ident ( & base. field ( ) . name . remove_dim ( ) ,  config,  fmt,  span) 
11911188                        }  else  { 
11921189                            ident ( & base. name ,  config,  fmt,  span) 
11931190                        } ; 
@@ -1260,7 +1257,7 @@ pub fn fields(
12601257                } 
12611258                Some ( EV :: Derived ( _,  base) )  => { 
12621259                    // generate pub use field_1 writer as field_2 writer 
1263-                     let  base_field = util :: replace_suffix ( & base. field . name ,   "" ) ; 
1260+                     let  base_field = base. field . name . remove_dim ( ) ; 
12641261                    let  base_w = ident ( & base_field,  config,  "field_writer" ,  span) ; 
12651262                    if  !writer_derives. contains ( & writer_ty)  { 
12661263                        let  base_path = base_syn_path ( base,  & fpath,  & base_w,  config) ?; 
@@ -1301,7 +1298,7 @@ pub fn fields(
13011298            if  let  Field :: Array ( f,  de)  = & f { 
13021299                let  increment = de. dim_increment ; 
13031300                let  offset_calc = calculate_offset ( increment,  offset,  false ) ; 
1304-                 let  doc = & util :: replace_suffix ( & description,   & brief_suffix) ; 
1301+                 let  doc = & description. expand_dim ( & brief_suffix) ; 
13051302                let  first_name = svd:: array:: names ( f,  de) . next ( ) . unwrap ( ) ; 
13061303                let  note = format ! ( "NOTE: `n` is number of field in register. `n == 0` corresponds to `{first_name}` field" ) ; 
13071304                let  dim = unsuffixed ( de. dim ) ; 
@@ -1603,7 +1600,7 @@ fn base_syn_path(
16031600        let  mut  segments = Punctuated :: new ( ) ; 
16041601        segments. push ( path_segment ( Ident :: new ( "super" ,  span) ) ) ; 
16051602        segments. push ( path_segment ( ident ( 
1606-             & replace_suffix ( & base. register ( ) . name ,   "" ) , 
1603+             & base. register ( ) . name . remove_dim ( ) , 
16071604            config, 
16081605            "register_mod" , 
16091606            span, 
0 commit comments