Skip to content

Commit

Permalink
optional fields in Device when non strict, svd-parser 0.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Jan 4, 2022
1 parent 23c628f commit 1497e41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion svd-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## [v0.13.1] - 2022-01-04

- Make `version`, `description`, `width` and `address_unit_bits` on `Device` optional again

## [v0.13.0] - 2022-01-02

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

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

[Unreleased]: https://github.com/rust-embedded/svd/compare/v0.13.0...HEAD
[Unreleased]: https://github.com/rust-embedded/svd/compare/v0.13.1...HEAD
[v0.13.1]: https://github.com/rust-embedded/svd/compare/v0.13.0...svd-parser-v0.13.1
[v0.13.0]: https://github.com/rust-embedded/svd/compare/v0.12.0...v0.13.0
[v0.12.0]: https://github.com/rust-embedded/svd/compare/v0.11.0...v0.12.0
[v0.11.0]: https://github.com/rust-embedded/svd/compare/v0.10.2...v0.11.0
16 changes: 12 additions & 4 deletions svd-parser/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ impl Parse for Device {
.vendor_id(tree.get_child_text_opt("vendorID")?)
.name(tree.get_child_text("name")?)
.series(tree.get_child_text_opt("series")?)
.version(tree.get_child_text("version")?)
.description(tree.get_child_text("description")?)
.license_text(tree.get_child_text_opt("licenseText")?)
.cpu(optional::<Cpu>("cpu", tree, config)?)
.header_system_filename(tree.get_child_text_opt("headerSystemFilename")?)
.header_definitions_prefix(tree.get_child_text_opt("headerDefinitionsPrefix")?)
.address_unit_bits(tree.get_child_u32("addressUnitBits")?)
.width(tree.get_child_u32("width")?)
.default_register_properties(RegisterProperties::parse(tree, config)?)
.peripherals({
let ps: Result<Vec<_>, _> = tree
Expand All @@ -37,6 +33,18 @@ impl Parse for Device {
.collect();
ps?
});
if let Some(version) = tree.get_child_text_opt("version")? {
device = device.version(version)
}
if let Some(description) = tree.get_child_text_opt("description")? {
device = device.description(description)
}
if let Some(bits) = optional::<u32>("addressUnitBits", tree, &())? {
device = device.address_unit_bits(bits)
}
if let Some(width) = optional::<u32>("width", tree, &())? {
device = device.address_unit_bits(width)
}
if let Some(xmlns_xs) = tree.attribute("xmlns:xs") {
device = device.xmlns_xs(xmlns_xs.to_string());
}
Expand Down

0 comments on commit 1497e41

Please sign in to comment.