Skip to content

Commit 6937195

Browse files
bors[bot]burrbull
andauthored
Merge #193
193: optional fields in Device when non strict, svd-parser 0.13.1 r=adamgreig a=burrbull Co-authored-by: Andrey Zgarbul <[email protected]> Co-authored-by: Zgarbul Andrey <[email protected]>
2 parents 23c628f + 6868396 commit 6937195

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

svd-parser/CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## Unreleased
99

10+
## [v0.13.1] - 2022-01-04
11+
12+
- Make `version`, `description`, `width` and `address_unit_bits` on `Device` optional again
13+
1014
## [v0.13.0] - 2022-01-02
1115

1216
- Add `svd2yaml` example
@@ -23,7 +27,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2327

2428
Previous versions in common [changelog][../CHANGELOG.md].
2529

26-
[Unreleased]: https://github.com/rust-embedded/svd/compare/v0.13.0...HEAD
30+
[Unreleased]: https://github.com/rust-embedded/svd/compare/svd-parser-v0.13.1...HEAD
31+
[v0.13.1]: https://github.com/rust-embedded/svd/compare/v0.13.0...svd-parser-v0.13.1
2732
[v0.13.0]: https://github.com/rust-embedded/svd/compare/v0.12.0...v0.13.0
2833
[v0.12.0]: https://github.com/rust-embedded/svd/compare/v0.11.0...v0.12.0
2934
[v0.11.0]: https://github.com/rust-embedded/svd/compare/v0.10.2...v0.11.0

svd-parser/src/device.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@ impl Parse for Device {
1919
.vendor_id(tree.get_child_text_opt("vendorID")?)
2020
.name(tree.get_child_text("name")?)
2121
.series(tree.get_child_text_opt("series")?)
22-
.version(tree.get_child_text("version")?)
23-
.description(tree.get_child_text("description")?)
2422
.license_text(tree.get_child_text_opt("licenseText")?)
2523
.cpu(optional::<Cpu>("cpu", tree, config)?)
2624
.header_system_filename(tree.get_child_text_opt("headerSystemFilename")?)
2725
.header_definitions_prefix(tree.get_child_text_opt("headerDefinitionsPrefix")?)
28-
.address_unit_bits(tree.get_child_u32("addressUnitBits")?)
29-
.width(tree.get_child_u32("width")?)
3026
.default_register_properties(RegisterProperties::parse(tree, config)?)
3127
.peripherals({
3228
let ps: Result<Vec<_>, _> = tree
@@ -37,6 +33,18 @@ impl Parse for Device {
3733
.collect();
3834
ps?
3935
});
36+
if let Some(version) = tree.get_child_text_opt("version")? {
37+
device = device.version(version)
38+
}
39+
if let Some(description) = tree.get_child_text_opt("description")? {
40+
device = device.description(description)
41+
}
42+
if let Some(bits) = optional::<u32>("addressUnitBits", tree, &())? {
43+
device = device.address_unit_bits(bits)
44+
}
45+
if let Some(width) = optional::<u32>("width", tree, &())? {
46+
device = device.width(width)
47+
}
4048
if let Some(xmlns_xs) = tree.attribute("xmlns:xs") {
4149
device = device.xmlns_xs(xmlns_xs.to_string());
4250
}

0 commit comments

Comments
 (0)