Skip to content

Commit fcce3e5

Browse files
committed
core_interrupts, exceptions, and priorities are optional
1 parent a95c627 commit fcce3e5

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

svd-parser/src/riscv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Parse for Riscv {
2929
.map(|i| Exception::parse(&i, config))
3030
.collect();
3131
builder = builder.exceptions(exceptions?);
32-
};
32+
}
3333

3434
if let Some(priorities) = tree.get_child("priorities") {
3535
let priorities: Result<Vec<_>, _> = priorities
@@ -38,7 +38,7 @@ impl Parse for Riscv {
3838
.map(|i| Priority::parse(&i, config))
3939
.collect();
4040
builder = builder.priorities(priorities?);
41-
};
41+
}
4242

4343
if let Some(harts) = tree.get_child("harts") {
4444
let harts: Result<Vec<_>, _> = harts
@@ -47,7 +47,7 @@ impl Parse for Riscv {
4747
.map(|i| Hart::parse(&i, config))
4848
.collect();
4949
builder = builder.harts(harts?);
50-
};
50+
}
5151

5252
builder
5353
.build(config.validate_level)

svd-rs/src/riscv.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,18 @@ impl RiscvBuilder {
9999
/// Validate and build a [`Riscv`].
100100
pub fn build(self, lvl: ValidateLevel) -> Result<Riscv, SvdError> {
101101
let riscv = Riscv {
102-
core_interrupts: self
103-
.core_interrupts
104-
.ok_or_else(|| BuildError::Uninitialized("core_interrupts".to_string()))?,
105-
exceptions: self
106-
.exceptions
107-
.ok_or_else(|| BuildError::Uninitialized("exceptions".to_string()))?,
108-
priorities: self
109-
.priorities
110-
.ok_or_else(|| BuildError::Uninitialized("priorities".to_string()))?,
102+
core_interrupts: match self.core_interrupts {
103+
Some(core_interrupts) => core_interrupts,
104+
None => Vec::new(),
105+
},
106+
exceptions: match self.exceptions {
107+
Some(exceptions) => exceptions,
108+
None => Vec::new(),
109+
},
110+
priorities: match self.priorities {
111+
Some(priorities) => priorities,
112+
None => Vec::new(),
113+
},
111114
harts: self
112115
.harts
113116
.ok_or_else(|| BuildError::Uninitialized("harts".to_string()))?,

0 commit comments

Comments
 (0)