Skip to content

Commit 417d402

Browse files
committed
cluster add/modify (rust) draft
1 parent ce6ff66 commit 417d402

File tree

3 files changed

+873
-260
lines changed

3 files changed

+873
-260
lines changed

src/patch/device.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::collections::HashSet;
66
use std::{fs::File, io::Read, path::Path};
77

88
use super::iterators::{MatchIter, Matched};
9-
use super::peripheral::PeripheralExt;
9+
use super::peripheral::{PeripheralExt, RegisterBlockExt};
1010
use super::yaml_ext::{AsType, GetVal};
1111
use super::{abspath, matchname, PatchResult, VAL_LVL};
1212
use super::{make_address_block, make_address_blocks, make_cpu, make_interrupt, make_peripheral};
@@ -302,7 +302,7 @@ impl DeviceExt for Device {
302302
make_peripheral(hash, true)?.derived_from(Some(pderive.into())),
303303
)
304304
} else {
305-
return Err(anyhow!("derive: incorrect syntax for {}", pname));
305+
return Err(anyhow!("derive: incorrect syntax for {pname}"));
306306
};
307307

308308
if !pderive.contains('.') {

src/patch/mod.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,22 @@ fn make_register(radd: &Hash) -> Result<RegisterInfoBuilder> {
408408
fn make_cluster(cadd: &Hash) -> Result<ClusterInfoBuilder> {
409409
let mut cnew = ClusterInfo::builder()
410410
.description(cadd.get_string("description")?)
411-
.default_register_properties(get_register_properties(cadd)?);
411+
.default_register_properties(get_register_properties(cadd)?)
412+
.children(match cadd.get_hash("registers")? {
413+
Some(h) => {
414+
let mut ch = Vec::new();
415+
for (rname, val) in h {
416+
ch.push(RegisterCluster::Register(
417+
make_register(val.hash()?)?
418+
.name(rname.str()?.into())
419+
.build(VAL_LVL)?
420+
.single(),
421+
));
422+
}
423+
ch
424+
}
425+
_ => Vec::new(),
426+
});
412427

413428
if let Some(name) = cadd.get_str("name")? {
414429
cnew = cnew.name(name.into());

0 commit comments

Comments
 (0)