Skip to content

Commit 666ee0d

Browse files
authored
Merge pull request #264 from rust-embedded/merge
Keep position when merge fields, release 0.4
2 parents d5379fc + a0c7bf3 commit 666ee0d

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

CHANGELOG-rust.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This changelog tracks the Rust `svdtools` project. See
55

66
## [Unreleased]
77

8+
## [v0.4.0] 2025-01-06
9+
10+
* **breaking** Support "?~" in field `_modify` & `_derive`
11+
* Keep position when merge fields
12+
813
## [v0.3.21] 2024-12-31
914

1015
* `_derive` field
@@ -195,7 +200,8 @@ Other changes:
195200

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

198-
[Unreleased]: https://github.com/rust-embedded/svdtools/compare/v0.3.21...HEAD
203+
[Unreleased]: https://github.com/rust-embedded/svdtools/compare/v0.4.0...HEAD
204+
[v0.4.0]: https://github.com/rust-embedded/svdtools/compare/v0.3.21...v0.4.0
199205
[v0.3.21]: https://github.com/rust-embedded/svdtools/compare/v0.3.20...v0.3.21
200206
[v0.3.20]: https://github.com/rust-embedded/svdtools/compare/v0.3.19...v0.3.20
201207
[v0.3.19]: https://github.com/rust-embedded/svdtools/compare/v0.3.18...v0.3.19

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "svdtools"
3-
version = "0.3.21"
3+
version = "0.4.0"
44
repository = "https://github.com/rust-embedded/svdtools/"
55
description = "Tool for modifying bugs in CMSIS SVD"
66
authors = ["Andrey Zgarbul <[email protected]>", "MarcoIeni"]

src/patch/register.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -454,23 +454,26 @@ impl RegisterExt for Register {
454454
"Could not find any fields to merge {rpath}:{key}. Present fields: {present}.`"
455455
));
456456
}
457-
let mut bitwidth = 0;
458-
let mut bitoffset = u32::MAX;
459-
let mut first = true;
460-
let mut desc = None;
461457
if let Some(fields) = self.fields.as_mut() {
462-
for f in fields.iter_mut() {
458+
let mut bitwidth = 0;
459+
let mut bitoffset = u32::MAX;
460+
let mut pos = usize::MAX;
461+
let mut first = true;
462+
let mut desc = None;
463+
for (i, f) in fields.iter_mut().enumerate() {
463464
if names.contains(&f.name) {
464465
if first {
465466
desc.clone_from(&f.description);
466467
first = false;
467468
}
468469
bitwidth += f.bit_range.width;
469470
bitoffset = bitoffset.min(f.bit_range.offset);
471+
pos = pos.min(i);
470472
}
471473
}
472474
fields.retain(|f| !names.contains(&f.name));
473-
fields.push(
475+
fields.insert(
476+
pos,
474477
FieldInfo::builder()
475478
.name(name)
476479
.description(desc)

0 commit comments

Comments
 (0)