@@ -25,20 +25,42 @@ pub type RegMatchIterMut<'a, 'b> = MatchIter<'b, RegisterIterMut<'a>>;
2525
2626/// Collecting methods for processing peripheral contents
2727pub ( crate ) trait PeripheralExt : InterruptExt + RegisterBlockExt {
28+ const KEYWORDS : & ' static [ & ' static str ] = & [
29+ "_include" ,
30+ "_path" ,
31+ "_delete" ,
32+ "_copy" ,
33+ "_strip" ,
34+ "_strip_end" ,
35+ "_modify" ,
36+ "_clear_fields" ,
37+ "_add" ,
38+ "_derive" ,
39+ "_expand_array" ,
40+ "_expand_cluster" ,
41+ "_array" ,
42+ "_cluster" ,
43+ "_clusters" ,
44+ "_interrupts" ,
45+ ] ;
46+
2847 /// Work through a peripheral, handling all registers
2948 fn process ( & mut self , peripheral : & Hash , config : & Config ) -> PatchResult ;
3049}
3150
3251/// Collecting methods for processing cluster contents
3352pub ( crate ) trait ClusterExt : RegisterBlockExt {
3453 const KEYWORDS : & ' static [ & ' static str ] = & [
35- "_add " ,
36- "_copy " ,
54+ "_include " ,
55+ "_path " ,
3756 "_delete" ,
38- "_derive" ,
39- "_modify" ,
57+ "_copy" ,
4058 "_strip" ,
4159 "_strip_end" ,
60+ "_modify" ,
61+ "_clear_fields" ,
62+ "_add" ,
63+ "_derive" ,
4264 "_expand_array" ,
4365 "_expand_cluster" ,
4466 "_array" ,
@@ -593,7 +615,7 @@ impl PeripheralExt for Peripheral {
593615 let ppath = BlockPath :: new ( & self . name ) ;
594616
595617 // Handle deletions
596- if let Some ( deletions) = pmod. get ( & "_delete" . to_yaml ( ) ) {
618+ if let Some ( deletions) = pmod. get_yaml ( "_delete" ) {
597619 match deletions {
598620 Yaml :: String ( rspec) => {
599621 self . delete_register ( rspec)
@@ -776,10 +798,11 @@ impl PeripheralExt for Peripheral {
776798 // Handle registers
777799 for ( rspec, register) in pmod {
778800 let rspec = rspec. str ( ) ?;
779- if !rspec. starts_with ( '_' ) {
780- self . process_register ( rspec, register. hash ( ) ?, & ppath, config)
781- . with_context ( || format ! ( "According to `{rspec}`" ) ) ?;
801+ if Self :: KEYWORDS . contains ( & rspec) {
802+ continue ;
782803 }
804+ self . process_register ( rspec, register. hash ( ) ?, & ppath, config)
805+ . with_context ( || format ! ( "According to `{rspec}`" ) ) ?;
783806 }
784807
785808 // Expand register arrays
@@ -805,10 +828,8 @@ impl PeripheralExt for Peripheral {
805828 // Handle clusters
806829 for ( cspec, cluster) in pmod. hash_iter ( "_clusters" ) {
807830 let cspec = cspec. str ( ) ?;
808- if !cspec. starts_with ( '_' ) {
809- self . process_cluster ( cspec, cluster. hash ( ) ?, & ppath, config)
810- . with_context ( || format ! ( "According to `{cspec}`" ) ) ?;
811- }
831+ self . process_cluster ( cspec, cluster. hash ( ) ?, & ppath, config)
832+ . with_context ( || format ! ( "According to `{cspec}`" ) ) ?;
812833 }
813834
814835 Ok ( ( ) )
@@ -851,7 +872,7 @@ impl InterruptExt for Peripheral {
851872impl ClusterExt for Cluster {
852873 fn pre_process ( & mut self , cmod : & Hash , parent : & BlockPath , _config : & Config ) -> PatchResult {
853874 // Handle deletions
854- if let Some ( deletions) = cmod. get ( & "_delete" . to_yaml ( ) ) {
875+ if let Some ( deletions) = cmod. get_yaml ( "_delete" ) {
855876 match deletions {
856877 Yaml :: String ( rspec) => {
857878 self . delete_register ( rspec)
@@ -1025,19 +1046,18 @@ impl ClusterExt for Cluster {
10251046 // Handle clusters
10261047 for ( cspec, cluster) in cmod. hash_iter ( "_clusters" ) {
10271048 let cspec = cspec. str ( ) ?;
1028- if !cspec. starts_with ( '_' ) {
1029- self . process_cluster ( cspec, cluster. hash ( ) ?, & cpath, config)
1030- . with_context ( || format ! ( "According to `{cspec}`" ) ) ?;
1031- }
1049+ self . process_cluster ( cspec, cluster. hash ( ) ?, & cpath, config)
1050+ . with_context ( || format ! ( "According to `{cspec}`" ) ) ?;
10321051 }
10331052
10341053 // Handle registers
10351054 for ( rspec, register) in cmod {
10361055 let rspec = rspec. str ( ) ?;
1037- if !rspec. starts_with ( '_' ) {
1038- self . process_register ( rspec, register. hash ( ) ?, & cpath, config)
1039- . with_context ( || format ! ( "According to `{rspec}`" ) ) ?;
1056+ if Self :: KEYWORDS . contains ( & rspec) {
1057+ continue ;
10401058 }
1059+ self . process_register ( rspec, register. hash ( ) ?, & cpath, config)
1060+ . with_context ( || format ! ( "According to `{rspec}`" ) ) ?;
10411061 }
10421062
10431063 self . post_process ( cmod, parent, config)
0 commit comments