Skip to content

Commit

Permalink
process displayName in collection in array
Browse files Browse the repository at this point in the history
  • Loading branch information
kossnikita committed Oct 27, 2023
1 parent 79959a7 commit fa406c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This changelog tracks the Rust `svdtools` project. See
## [Unreleased]

* Move field with derived enums before other
* Support `displayName` in `_array` of registers

## [v0.3.4] 2023-10-14

Expand Down
13 changes: 10 additions & 3 deletions src/patch/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1217,11 +1217,18 @@ fn collect_in_array(
if desc != "_original" {
rinfo.description = Some(desc.into());
}
} else if dim_index[0] == "0" {
if let Some(desc) = rinfo.description.as_mut() {
*desc = desc.replace('0', "%s");
} else if let Some(desc) = rinfo.description.as_mut() {
*desc = desc.replace(dim_index[0].chars().next().unwrap(), "%s");
}

if let Some(dname) = rmod.get_str("displayName")? {
if dname != "_original" {
rinfo.display_name = Some(dname.into());
}
} else if let Some(dname) = rinfo.display_name.as_mut() {
*dname = dname.replace(dim_index[0].chars().next().unwrap(), "%s");
}

let mut reg = rinfo.array(
DimElement::builder()
.dim(dim as u32)
Expand Down

0 comments on commit fa406c7

Please sign in to comment.