@@ -10,7 +10,9 @@ use quote::{quote, ToTokens};
1010use svd_parser:: derive_from:: DeriveFrom ;
1111use syn:: { parse_str, Token } ;
1212
13- use crate :: util:: { self , FullName , ToSanitizedSnakeCase , ToSanitizedUpperCase , BITS_PER_BYTE } ;
13+ use crate :: util:: {
14+ self , Config , FullName , ToSanitizedSnakeCase , ToSanitizedUpperCase , BITS_PER_BYTE ,
15+ } ;
1416use anyhow:: { anyhow, bail, Context , Result } ;
1517
1618use crate :: generate:: register;
@@ -19,7 +21,7 @@ pub fn render(
1921 p_original : & Peripheral ,
2022 all_peripherals : & [ Peripheral ] ,
2123 defaults : & RegisterProperties ,
22- nightly : bool ,
24+ config : & Config ,
2325) -> Result < TokenStream > {
2426 let mut out = TokenStream :: new ( ) ;
2527
@@ -177,11 +179,11 @@ pub fn render(
177179
178180 // Push any register or cluster blocks into the output
179181 let mut mod_items = TokenStream :: new ( ) ;
180- mod_items. extend ( register_or_cluster_block ( & ercs, & defaults, None , nightly ) ?) ;
182+ mod_items. extend ( register_or_cluster_block ( & ercs, & defaults, None , config ) ?) ;
181183
182184 // Push all cluster related information into the peripheral module
183185 for c in & clusters {
184- mod_items. extend ( cluster_block ( c, & defaults, p, all_peripherals, nightly ) ?) ;
186+ mod_items. extend ( cluster_block ( c, & defaults, p, all_peripherals, config ) ?) ;
185187 }
186188
187189 // Push all register related information into the peripheral module
@@ -192,6 +194,7 @@ pub fn render(
192194 p,
193195 all_peripherals,
194196 & defaults,
197+ config,
195198 ) ?) ;
196199 }
197200
@@ -235,10 +238,7 @@ impl Region {
235238 let mut idents: Vec < _ > = self
236239 . rbfs
237240 . iter ( )
238- . filter_map ( |f| match & f. field . ident {
239- None => None ,
240- Some ( ident) => Some ( ident. to_string ( ) ) ,
241- } )
241+ . filter_map ( |f| f. field . ident . as_ref ( ) . map ( |ident| ident. to_string ( ) ) )
242242 . collect ( ) ;
243243 if idents. is_empty ( ) {
244244 return None ;
@@ -276,10 +276,7 @@ impl Region {
276276 let idents: Vec < _ > = self
277277 . rbfs
278278 . iter ( )
279- . filter_map ( |f| match & f. field . ident {
280- None => None ,
281- Some ( ident) => Some ( ident. to_string ( ) ) ,
282- } )
279+ . filter_map ( |f| f. field . ident . as_ref ( ) . map ( |ident| ident. to_string ( ) ) )
283280 . collect ( ) ;
284281
285282 if idents. is_empty ( ) {
@@ -445,7 +442,7 @@ fn register_or_cluster_block(
445442 ercs : & [ RegisterCluster ] ,
446443 defs : & RegisterProperties ,
447444 name : Option < & str > ,
448- _nightly : bool ,
445+ _config : & Config ,
449446) -> Result < TokenStream > {
450447 let mut rbfs = TokenStream :: new ( ) ;
451448 let mut accessors = TokenStream :: new ( ) ;
@@ -738,7 +735,7 @@ fn cluster_block(
738735 defaults : & RegisterProperties ,
739736 p : & Peripheral ,
740737 all_peripherals : & [ Peripheral ] ,
741- nightly : bool ,
738+ config : & Config ,
742739) -> Result < TokenStream > {
743740 let mut mod_items = TokenStream :: new ( ) ;
744741
@@ -758,7 +755,7 @@ fn cluster_block(
758755
759756 let defaults = c. default_register_properties . derive_from ( defaults) ;
760757
761- let reg_block = register_or_cluster_block ( & c. children , & defaults, Some ( & mod_name) , nightly ) ?;
758+ let reg_block = register_or_cluster_block ( & c. children , & defaults, Some ( & mod_name) , config ) ?;
762759
763760 // Generate definition for each of the registers.
764761 let registers = util:: only_registers ( & c. children ) ;
@@ -769,13 +766,14 @@ fn cluster_block(
769766 p,
770767 all_peripherals,
771768 & defaults,
769+ config,
772770 ) ?) ;
773771 }
774772
775773 // Generate the sub-cluster blocks.
776774 let clusters = util:: only_clusters ( & c. children ) ;
777775 for c in & clusters {
778- mod_items. extend ( cluster_block ( c, & defaults, p, all_peripherals, nightly ) ?) ;
776+ mod_items. extend ( cluster_block ( c, & defaults, p, all_peripherals, config ) ?) ;
779777 }
780778
781779 Ok ( quote ! {
0 commit comments