Skip to content

Commit 4bdd422

Browse files
committed
Cluster::KEYWORDS
1 parent 5cd2762 commit 4bdd422

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/patch/peripheral.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ pub trait PeripheralExt: InterruptExt + RegisterBlockExt {
2727

2828
/// Collecting methods for processing cluster contents
2929
pub trait ClusterExt: RegisterBlockExt {
30+
const KEYWORDS: &'static [&'static str] = &[
31+
"_add",
32+
"_copy",
33+
"_delete",
34+
"_derive",
35+
"_modify",
36+
"_strip",
37+
"_strip_end",
38+
"_expand_array",
39+
"_expand_cluster",
40+
"_array",
41+
"_cluster",
42+
"_clusters",
43+
];
44+
3045
/// Work through a cluster, handling all registers
3146
fn process(&mut self, peripheral: &Hash, pname: &str, config: &Config) -> PatchResult;
3247

@@ -716,7 +731,7 @@ impl RegisterBlockExt for Peripheral {
716731
}
717732

718733
impl ClusterExt for Cluster {
719-
fn pre_process(&mut self, pmod: &Hash, _pname: &str, config: &Config) -> PatchResult {
734+
fn pre_process(&mut self, pmod: &Hash, _pname: &str, _config: &Config) -> PatchResult {
720735
// Handle deletions
721736
if let Some(deletions) = pmod.get(&"_delete".to_yaml()) {
722737
match deletions {
@@ -878,6 +893,12 @@ impl ClusterExt for Cluster {
878893
}
879894
}
880895

896+
Ok(())
897+
}
898+
899+
fn process(&mut self, pmod: &Hash, pname: &str, config: &Config) -> PatchResult {
900+
self.pre_process(pmod, pname, config)?;
901+
881902
// Handle clusters
882903
for (cspec, cluster) in pmod.hash_iter("_clusters") {
883904
let cspec = cspec.str()?;
@@ -887,12 +908,6 @@ impl ClusterExt for Cluster {
887908
}
888909
}
889910

890-
Ok(())
891-
}
892-
893-
fn process(&mut self, pmod: &Hash, pname: &str, config: &Config) -> PatchResult {
894-
self.pre_process(pmod, pname, config)?;
895-
896911
// Handle registers
897912
for (rspec, register) in pmod {
898913
let rspec = rspec.str()?;
@@ -1381,7 +1396,7 @@ fn collect_in_cluster(
13811396

13821397
for (rspec, rmod) in cmod {
13831398
let rspec = rspec.str()?;
1384-
if rspec == "description" || rspec == "dimIncrement" || rspec.starts_with('_') {
1399+
if ["description", "dimIncrement"].contains(&rspec) || Cluster::KEYWORDS.contains(&rspec) {
13851400
continue;
13861401
}
13871402
let mut registers = Vec::new();

0 commit comments

Comments
 (0)