Skip to content

Commit 3b11180

Browse files
bors[bot]burrbull
andauthored
Merge #86
86: rename RegisterClusterArrayInfo -> DimElement r=therealprof a=burrbull https://www.keil.com/pack/doc/CMSIS/SVD/html/elem_special.html#dimElementGroup_gr Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 69d5e6c + 595e7e9 commit 3b11180

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/svd/cluster.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use crate::elementext::ElementExt;
88
#[cfg(feature = "unproven")]
99
use crate::encode::Encode;
1010
use crate::error::*;
11-
use crate::svd::{clusterinfo::ClusterInfo, registerclusterarrayinfo::RegisterClusterArrayInfo};
11+
use crate::svd::{clusterinfo::ClusterInfo, dimelement::DimElement};
1212

1313
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1414
#[derive(Clone, Debug, PartialEq)]
1515
pub enum Cluster {
1616
Single(ClusterInfo),
17-
Array(ClusterInfo, RegisterClusterArrayInfo),
17+
Array(ClusterInfo, DimElement),
1818
}
1919

2020
impl Deref for Cluster {
@@ -37,7 +37,7 @@ impl Parse for Cluster {
3737
let info = ClusterInfo::parse(tree)?;
3838

3939
if tree.get_child("dimIncrement").is_some() {
40-
let array_info = RegisterClusterArrayInfo::parse(tree)?;
40+
let array_info = DimElement::parse(tree)?;
4141
if !info.name.contains("%s") {
4242
// TODO: replace with real error
4343
return Err(SVDError::from(SVDErrorKind::Other(

src/svd/registerclusterarrayinfo.rs renamed to src/svd/dimelement.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ use crate::error::SVDError;
1212

1313
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1414
#[derive(Clone, Debug, PartialEq)]
15-
pub struct RegisterClusterArrayInfo {
15+
pub struct DimElement {
1616
pub dim: u32,
1717
pub dim_increment: u32,
1818
pub dim_index: Option<Vec<String>>,
1919
// Reserve the right to add more fields to this struct
2020
_extensible: (),
2121
}
2222

23-
impl Parse for RegisterClusterArrayInfo {
24-
type Object = RegisterClusterArrayInfo;
23+
impl Parse for DimElement {
24+
type Object = DimElement;
2525
type Error = SVDError;
2626

27-
fn parse(tree: &Element) -> Result<RegisterClusterArrayInfo, SVDError> {
28-
Ok(RegisterClusterArrayInfo {
27+
fn parse(tree: &Element) -> Result<DimElement, SVDError> {
28+
Ok(DimElement {
2929
dim: tree.get_child_u32("dim")?,
3030
dim_increment: tree.get_child_u32("dimIncrement")?,
3131
dim_index: parse_optional::<DimIndex>("dimIndex", tree)?,
@@ -35,11 +35,11 @@ impl Parse for RegisterClusterArrayInfo {
3535
}
3636

3737
#[cfg(feature = "unproven")]
38-
impl Encode for RegisterClusterArrayInfo {
38+
impl Encode for DimElement {
3939
type Error = SVDError;
4040

4141
fn encode(&self) -> Result<Element, SVDError> {
42-
let mut e = new_element("registerClusterArrayInfo", None);
42+
let mut e = new_element("dimElement", None);
4343

4444
e.children
4545
.push(new_element("dim", Some(format!("{}", self.dim))));
@@ -65,20 +65,20 @@ mod tests {
6565
#[test]
6666
fn decode_encode() {
6767
let tests = vec![(
68-
RegisterClusterArrayInfo {
68+
DimElement {
6969
dim: 100,
7070
dim_increment: 4,
7171
dim_index: Some(vec!["10".to_owned(), "20".to_owned()]),
7272
_extensible: (),
7373
},
74-
"<registerClusterArrayInfo>
74+
"<dimElement>
7575
<dim>100</dim>
7676
<dimIncrement>4</dimIncrement>
7777
<dimIndex>10,20</dimIndex>
78-
</registerClusterArrayInfo>
78+
</dimElement>
7979
",
8080
)];
8181

82-
run_test::<RegisterClusterArrayInfo>(&tests[..]);
82+
run_test::<DimElement>(&tests[..]);
8383
}
8484
}

src/svd/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ pub use self::register::Register;
5252
pub mod registercluster;
5353
pub use self::registercluster::RegisterCluster;
5454

55-
pub mod registerclusterarrayinfo;
56-
pub use self::registerclusterarrayinfo::RegisterClusterArrayInfo;
55+
pub mod dimelement;
56+
pub use self::dimelement::DimElement;
5757

5858
pub mod peripheral;
5959
pub use self::peripheral::Peripheral;

src/svd/register.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ use crate::elementext::ElementExt;
99
#[cfg(feature = "unproven")]
1010
use crate::encode::Encode;
1111
use crate::error::SVDError;
12-
use crate::svd::{registerclusterarrayinfo::RegisterClusterArrayInfo, registerinfo::RegisterInfo};
12+
use crate::svd::{dimelement::DimElement, registerinfo::RegisterInfo};
1313

1414
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1515
#[derive(Clone, Debug, PartialEq)]
1616
pub enum Register {
1717
Single(RegisterInfo),
18-
Array(RegisterInfo, RegisterClusterArrayInfo),
18+
Array(RegisterInfo, DimElement),
1919
}
2020

2121
impl Deref for Register {
@@ -39,7 +39,7 @@ impl Parse for Register {
3939
let info = RegisterInfo::parse(tree)?;
4040

4141
if tree.get_child("dimIncrement").is_some() {
42-
let array_info = RegisterClusterArrayInfo::parse(tree)?;
42+
let array_info = DimElement::parse(tree)?;
4343
assert!(info.name.contains("%s"));
4444
if let Some(indices) = &array_info.dim_index {
4545
assert_eq!(array_info.dim as usize, indices.len())

0 commit comments

Comments
 (0)