@@ -485,10 +485,11 @@ pub fn fields(
485
485
unsafety = None ;
486
486
}
487
487
488
+ let mut base_pc_w = None ;
488
489
if Some ( evs) != evs_r. as_ref ( ) {
489
490
pc_w = & f. pc_w ;
490
491
491
- base. as_ref ( ) . map ( |base| {
492
+ base_pc_w = base. as_ref ( ) . map ( |base| {
492
493
let pc = base. field . to_sanitized_upper_case ( ) ;
493
494
let base_pc_w = Ident :: from ( & * format ! ( "{}_AW" , pc) ) ;
494
495
derive_from_base ( mod_items, & base, & pc_w, & base_pc_w, f. name )
@@ -515,13 +516,23 @@ pub fn fields(
515
516
let sc = & v. sc ;
516
517
517
518
let doc = util:: escape_brackets ( util:: respace ( & v. doc ) . as_ref ( ) ) ;
519
+ if let Some ( enum_) = base_pc_w. as_ref ( ) {
520
+ proxy_items. push ( quote ! {
521
+ #[ doc = #doc]
522
+ #[ inline( always) ]
523
+ pub fn #sc( self ) -> & ' a mut W {
524
+ self . variant( #enum_:: #pc)
525
+ }
526
+ } ) ;
527
+ } else {
518
528
proxy_items. push ( quote ! {
519
529
#[ doc = #doc]
520
530
#[ inline( always) ]
521
531
pub fn #sc( self ) -> & ' a mut W {
522
532
self . variant( #pc_w:: #pc)
523
533
}
524
534
} ) ;
535
+ }
525
536
}
526
537
}
527
538
@@ -685,7 +696,7 @@ fn add_from_variants(mod_items: &mut Vec<Tokens>, variants: &Vec<Variant>, pc: &
685
696
} ) ;
686
697
}
687
698
688
- fn derive_from_base ( mod_items : & mut Vec < Tokens > , base : & Base , pc : & Ident , base_pc : & Ident , fname : & str ) {
699
+ fn derive_from_base ( mod_items : & mut Vec < Tokens > , base : & Base , pc : & Ident , base_pc : & Ident , fname : & str ) -> quote :: Tokens {
689
700
let desc = format ! ( "Possible values of the field `{}`" , fname, ) ;
690
701
691
702
if let ( Some ( peripheral) , Some ( register) ) = ( & base. peripheral , & base. register ) {
@@ -699,6 +710,10 @@ fn derive_from_base(mod_items: &mut Vec<Tokens>, base: &Base, pc: &Ident, base_p
699
710
pub type #pc =
700
711
crate :: #pmod_:: #rmod_:: #base_pc;
701
712
} ) ;
713
+
714
+ quote ! {
715
+ crate :: #pmod_:: #rmod_:: #base_pc
716
+ }
702
717
} else if let Some ( register) = & base. register {
703
718
let mod_ = register. to_sanitized_snake_case ( ) ;
704
719
let mod_ = Ident :: from ( & * mod_) ;
@@ -708,11 +723,19 @@ fn derive_from_base(mod_items: &mut Vec<Tokens>, base: &Base, pc: &Ident, base_p
708
723
pub type #pc =
709
724
super :: #mod_:: #base_pc;
710
725
} ) ;
726
+
727
+ quote ! {
728
+ super :: #mod_:: #base_pc
729
+ }
711
730
} else {
712
731
mod_items. push ( quote ! {
713
732
#[ doc = #desc]
714
733
pub type #pc = #base_pc;
715
734
} ) ;
735
+
736
+ quote ! {
737
+ #base_pc
738
+ }
716
739
}
717
740
}
718
741
0 commit comments