@@ -10,7 +10,9 @@ use quote::{quote, ToTokens};
10
10
use svd_parser:: derive_from:: DeriveFrom ;
11
11
use syn:: { parse_str, Token } ;
12
12
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
+ } ;
14
16
use anyhow:: { anyhow, bail, Context , Result } ;
15
17
16
18
use crate :: generate:: register;
@@ -19,7 +21,7 @@ pub fn render(
19
21
p_original : & Peripheral ,
20
22
all_peripherals : & [ Peripheral ] ,
21
23
defaults : & RegisterProperties ,
22
- nightly : bool ,
24
+ config : & Config ,
23
25
) -> Result < TokenStream > {
24
26
let mut out = TokenStream :: new ( ) ;
25
27
@@ -177,11 +179,11 @@ pub fn render(
177
179
178
180
// Push any register or cluster blocks into the output
179
181
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 ) ?) ;
181
183
182
184
// Push all cluster related information into the peripheral module
183
185
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 ) ?) ;
185
187
}
186
188
187
189
// Push all register related information into the peripheral module
@@ -192,6 +194,7 @@ pub fn render(
192
194
p,
193
195
all_peripherals,
194
196
& defaults,
197
+ config,
195
198
) ?) ;
196
199
}
197
200
@@ -235,10 +238,7 @@ impl Region {
235
238
let mut idents: Vec < _ > = self
236
239
. rbfs
237
240
. 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 ( ) ) )
242
242
. collect ( ) ;
243
243
if idents. is_empty ( ) {
244
244
return None ;
@@ -276,10 +276,7 @@ impl Region {
276
276
let idents: Vec < _ > = self
277
277
. rbfs
278
278
. 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 ( ) ) )
283
280
. collect ( ) ;
284
281
285
282
if idents. is_empty ( ) {
@@ -445,7 +442,7 @@ fn register_or_cluster_block(
445
442
ercs : & [ RegisterCluster ] ,
446
443
defs : & RegisterProperties ,
447
444
name : Option < & str > ,
448
- _nightly : bool ,
445
+ _config : & Config ,
449
446
) -> Result < TokenStream > {
450
447
let mut rbfs = TokenStream :: new ( ) ;
451
448
let mut accessors = TokenStream :: new ( ) ;
@@ -738,7 +735,7 @@ fn cluster_block(
738
735
defaults : & RegisterProperties ,
739
736
p : & Peripheral ,
740
737
all_peripherals : & [ Peripheral ] ,
741
- nightly : bool ,
738
+ config : & Config ,
742
739
) -> Result < TokenStream > {
743
740
let mut mod_items = TokenStream :: new ( ) ;
744
741
@@ -758,7 +755,7 @@ fn cluster_block(
758
755
759
756
let defaults = c. default_register_properties . derive_from ( defaults) ;
760
757
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 ) ?;
762
759
763
760
// Generate definition for each of the registers.
764
761
let registers = util:: only_registers ( & c. children ) ;
@@ -769,13 +766,14 @@ fn cluster_block(
769
766
p,
770
767
all_peripherals,
771
768
& defaults,
769
+ config,
772
770
) ?) ;
773
771
}
774
772
775
773
// Generate the sub-cluster blocks.
776
774
let clusters = util:: only_clusters ( & c. children ) ;
777
775
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 ) ?) ;
779
777
}
780
778
781
779
Ok ( quote ! {
0 commit comments