Skip to content

Commit

Permalink
Merge pull request #264 from rust-embedded/merge
Browse files Browse the repository at this point in the history
Keep position when merge fields, release 0.4
  • Loading branch information
burrbull authored Jan 6, 2025
2 parents d5379fc + a0c7bf3 commit 666ee0d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ This changelog tracks the Rust `svdtools` project. See

## [Unreleased]

## [v0.4.0] 2025-01-06

* **breaking** Support "?~" in field `_modify` & `_derive`
* Keep position when merge fields

## [v0.3.21] 2024-12-31

* `_derive` field
Expand Down Expand Up @@ -195,7 +200,8 @@ Other changes:

* Initial release with feature-parity with the Python project.

[Unreleased]: https://github.com/rust-embedded/svdtools/compare/v0.3.21...HEAD
[Unreleased]: https://github.com/rust-embedded/svdtools/compare/v0.4.0...HEAD
[v0.4.0]: https://github.com/rust-embedded/svdtools/compare/v0.3.21...v0.4.0
[v0.3.21]: https://github.com/rust-embedded/svdtools/compare/v0.3.20...v0.3.21
[v0.3.20]: https://github.com/rust-embedded/svdtools/compare/v0.3.19...v0.3.20
[v0.3.19]: https://github.com/rust-embedded/svdtools/compare/v0.3.18...v0.3.19
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "svdtools"
version = "0.3.21"
version = "0.4.0"
repository = "https://github.com/rust-embedded/svdtools/"
description = "Tool for modifying bugs in CMSIS SVD"
authors = ["Andrey Zgarbul <[email protected]>", "MarcoIeni"]
Expand Down
15 changes: 9 additions & 6 deletions src/patch/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,23 +454,26 @@ impl RegisterExt for Register {
"Could not find any fields to merge {rpath}:{key}. Present fields: {present}.`"
));
}
let mut bitwidth = 0;
let mut bitoffset = u32::MAX;
let mut first = true;
let mut desc = None;
if let Some(fields) = self.fields.as_mut() {
for f in fields.iter_mut() {
let mut bitwidth = 0;
let mut bitoffset = u32::MAX;
let mut pos = usize::MAX;
let mut first = true;
let mut desc = None;
for (i, f) in fields.iter_mut().enumerate() {
if names.contains(&f.name) {
if first {
desc.clone_from(&f.description);
first = false;
}
bitwidth += f.bit_range.width;
bitoffset = bitoffset.min(f.bit_range.offset);
pos = pos.min(i);
}
}
fields.retain(|f| !names.contains(&f.name));
fields.push(
fields.insert(
pos,
FieldInfo::builder()
.name(name)
.description(desc)
Expand Down

0 comments on commit 666ee0d

Please sign in to comment.