Skip to content

Commit

Permalink
change case defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Feb 16, 2024
1 parent 2cad65c commit b6132c0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 32 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
include:
- { rust: stable, vendor: Atmel, options: all }
- { rust: stable, vendor: Atmel, options: "" }
- { rust: stable, vendor: Freescale, options: "--strict --atomics" }
- { rust: stable, vendor: Freescale, options: all }
- { rust: stable, vendor: Freescale, options: "" }
- { rust: stable, vendor: Fujitsu, options: "" }
- { rust: stable, vendor: Fujitsu, options: "--atomics" }
Expand Down Expand Up @@ -88,8 +88,9 @@ jobs:
# Use nightly for architectures which don't support stable
- { rust: nightly, vendor: MSP430, options: "--atomics" }
- { rust: nightly, vendor: MSP430, options: "" }
- { rust: nightly, vendor: Espressif, options: "--atomics" }
- { rust: nightly, vendor: Espressif, options: "" }
# Workaround for _1token0
- { rust: nightly, vendor: Espressif, options: "--atomics --ident-format register::c:" }
- { rust: nightly, vendor: Espressif, options: "--ident-format register:::Reg" }

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

- Bump MSRV to 1.74
- Add `base-address-shift` config flag
- Fix case changing bugs, add `--ident-format` (`-f`) option flag
- Use `PascalCase` for type idents, fix case changing bugs, add `--ident-format` (`-f`) option flag

## [v0.31.5] - 2024-01-04

Expand Down
25 changes: 11 additions & 14 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,46 +183,43 @@ impl Default for IdentFormats {
map.insert("field_accessor".into(), IdentFormat::default().snake_case());
map.insert(
"field_reader".into(),
IdentFormat::default().constant_case().suffix("_R"),
IdentFormat::default().pascal_case().suffix("R"),
);
map.insert(
"field_writer".into(),
IdentFormat::default().constant_case().suffix("_W"),
);
map.insert(
"enum_name".into(),
IdentFormat::default().constant_case().suffix("_A"),
IdentFormat::default().pascal_case().suffix("W"),
);
map.insert("enum_name".into(), IdentFormat::default().pascal_case());
map.insert(
"enum_write_name".into(),
IdentFormat::default().constant_case().suffix("_AW"),
IdentFormat::default().pascal_case().suffix("WO"),
);
map.insert("enum_value".into(), IdentFormat::default().constant_case());
map.insert("enum_value".into(), IdentFormat::default().pascal_case());
map.insert(
"enum_value_accessor".into(),
IdentFormat::default().snake_case(),
);
map.insert("interrupt".into(), IdentFormat::default().constant_case());
map.insert("cluster".into(), IdentFormat::default().constant_case());
map.insert("interrupt".into(), IdentFormat::default());
map.insert("cluster".into(), IdentFormat::default().pascal_case());
map.insert(
"cluster_accessor".into(),
IdentFormat::default().snake_case(),
);
map.insert("cluster_mod".into(), IdentFormat::default().snake_case());
map.insert("register".into(), IdentFormat::default().constant_case());
map.insert("register".into(), IdentFormat::default().pascal_case());
map.insert(
"register_spec".into(),
IdentFormat::default().pascal_case().suffix("_SPEC"),
IdentFormat::default().pascal_case().suffix("Spec"),
);
map.insert(
"register_accessor".into(),
IdentFormat::default().snake_case(),
);
map.insert("register_mod".into(), IdentFormat::default().snake_case());
map.insert("peripheral".into(), IdentFormat::default().constant_case());
map.insert("peripheral".into(), IdentFormat::default().pascal_case());
map.insert(
"peripheral_singleton".into(),
IdentFormat::default().constant_case(),
IdentFormat::default().snake_case(),
);
map.insert("peripheral_mod".into(), IdentFormat::default().snake_case());
map.insert(
Expand Down
38 changes: 24 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,20 +558,30 @@
//! `CONSTANT_CASE` (pass `constant` or `c`) and `leave_CASE_as_in_SVD` (pass `unchanged` or ``).
//!
//! There are identificator formats by default in the table.
//!
//! | IdentifierType | Prefix | Case 0.31 | Suffix |
//! |----------------------------------------------------------------------------------|:------:|:---------:|:-----------:|
//! | field_reader | | constant | _R |
//! | field_writer | | constant | _W |
//! | enum_name | | constant | _A |
//! | enum_write_name | | constant | _AW |
//! | enum_value | | constant | |
//! | interrupt | | constant | |
//! | peripheral_singleton | | constant | |
//! | peripheral <br> register <br> cluster | | constant | |
//! | register_spec | | constant | _SPEC |
//! | cluster_accessor <br> register_accessor<br>field_accessor<br>enum_value_accessor | | snake | |
//! | cluster_mod <br> register_mod <br> peripheral_mod | | snake | |
//! Since `svd2rust` 0.32 defaults have been changed.
//!
//! | IdentifierType | Prefix | Case | Case 0.31 | Suffix | Suffix 0.31 |
//! |----------------------------------------------------------------------------------|:------:|:---------:|:---------:|:------:|:-----------:|
//! | field_reader | | pascal | constant | R | _R |
//! | field_writer | | pascal | constant | W | _W |
//! | enum_name | | pascal | constant | | _A |
//! | enum_write_name | | pascal | constant | WO | _AW |
//! | enum_value | | pascal | constant | | |
//! | interrupt | | unchanged | constant | | |
//! | peripheral_singleton | | snake | constant | | |
//! | peripheral <br> register <br> cluster | | pascal | constant | | |
//! | register_spec | | pascal | constant | Spec | _SPEC |
//! | cluster_accessor <br> register_accessor<br>field_accessor<br>enum_value_accessor | | snake | snake | | |
//! | cluster_mod <br> register_mod <br> peripheral_mod | | snake | snake | | |
//!
//! To revert old behavior for `field_reader` you need to pass flag `-f field_reader::c:_R`. And repeat similar for other idents.
//!
//! Also you can do the same in config file:
//! ```toml
//! [ident_formats.field_reader]
//! case = constant
//! suffix = "_R"
//! ```
#![recursion_limit = "128"]

use quote::quote;
Expand Down

0 comments on commit b6132c0

Please sign in to comment.