Skip to content

Commit 30eb398

Browse files
committed
change case defaults
1 parent 41b9ca1 commit 30eb398

File tree

4 files changed

+40
-32
lines changed

4 files changed

+40
-32
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
include:
5757
- { rust: stable, vendor: Atmel, options: all }
5858
- { rust: stable, vendor: Atmel, options: "" }
59-
- { rust: stable, vendor: Freescale, options: "--strict --atomics" }
59+
- { rust: stable, vendor: Freescale, options: all }
6060
- { rust: stable, vendor: Freescale, options: "" }
6161
- { rust: stable, vendor: Fujitsu, options: "" }
6262
- { rust: stable, vendor: Fujitsu, options: "--atomics" }
@@ -88,8 +88,9 @@ jobs:
8888
# Use nightly for architectures which don't support stable
8989
- { rust: nightly, vendor: MSP430, options: "--atomics" }
9090
- { rust: nightly, vendor: MSP430, options: "" }
91-
- { rust: nightly, vendor: Espressif, options: "--atomics" }
92-
- { rust: nightly, vendor: Espressif, options: "" }
91+
# Workaround for _1token0
92+
- { rust: nightly, vendor: Espressif, options: "--atomics --ident-format register::c:" }
93+
- { rust: nightly, vendor: Espressif, options: "--ident-format register:::Reg" }
9394

9495
steps:
9596
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1010
- Bump MSRV to 1.74
1111
- generic unsafe `W::bits` + safe `W::set`
1212
- Add `base-address-shift` config flag
13-
- Fix case changing bugs, add `--ident-format` (`-f`) option flag
13+
- Use `PascalCase` for type idents, fix case changing bugs, add `--ident-format` (`-f`) option flag
1414

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

src/config.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,46 +183,43 @@ impl Default for IdentFormats {
183183
map.insert("field_accessor".into(), IdentFormat::default().snake_case());
184184
map.insert(
185185
"field_reader".into(),
186-
IdentFormat::default().constant_case().suffix("_R"),
186+
IdentFormat::default().pascal_case().suffix("R"),
187187
);
188188
map.insert(
189189
"field_writer".into(),
190-
IdentFormat::default().constant_case().suffix("_W"),
191-
);
192-
map.insert(
193-
"enum_name".into(),
194-
IdentFormat::default().constant_case().suffix("_A"),
190+
IdentFormat::default().pascal_case().suffix("W"),
195191
);
192+
map.insert("enum_name".into(), IdentFormat::default().pascal_case());
196193
map.insert(
197194
"enum_write_name".into(),
198-
IdentFormat::default().constant_case().suffix("_AW"),
195+
IdentFormat::default().pascal_case().suffix("WO"),
199196
);
200-
map.insert("enum_value".into(), IdentFormat::default().constant_case());
197+
map.insert("enum_value".into(), IdentFormat::default().pascal_case());
201198
map.insert(
202199
"enum_value_accessor".into(),
203200
IdentFormat::default().snake_case(),
204201
);
205-
map.insert("interrupt".into(), IdentFormat::default().constant_case());
206-
map.insert("cluster".into(), IdentFormat::default().constant_case());
202+
map.insert("interrupt".into(), IdentFormat::default());
203+
map.insert("cluster".into(), IdentFormat::default().pascal_case());
207204
map.insert(
208205
"cluster_accessor".into(),
209206
IdentFormat::default().snake_case(),
210207
);
211208
map.insert("cluster_mod".into(), IdentFormat::default().snake_case());
212-
map.insert("register".into(), IdentFormat::default().constant_case());
209+
map.insert("register".into(), IdentFormat::default().pascal_case());
213210
map.insert(
214211
"register_spec".into(),
215-
IdentFormat::default().pascal_case().suffix("_SPEC"),
212+
IdentFormat::default().pascal_case().suffix("Spec"),
216213
);
217214
map.insert(
218215
"register_accessor".into(),
219216
IdentFormat::default().snake_case(),
220217
);
221218
map.insert("register_mod".into(), IdentFormat::default().snake_case());
222-
map.insert("peripheral".into(), IdentFormat::default().constant_case());
219+
map.insert("peripheral".into(), IdentFormat::default().pascal_case());
223220
map.insert(
224221
"peripheral_singleton".into(),
225-
IdentFormat::default().constant_case(),
222+
IdentFormat::default().snake_case(),
226223
);
227224
map.insert("peripheral_mod".into(), IdentFormat::default().snake_case());
228225
map.insert(

src/lib.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -558,20 +558,30 @@
558558
//! `CONSTANT_CASE` (pass `constant` or `c`) and `leave_CASE_as_in_SVD` (pass `unchanged` or ``).
559559
//!
560560
//! There are identificator formats by default in the table.
561-
//!
562-
//! | IdentifierType | Prefix | Case 0.31 | Suffix |
563-
//! |----------------------------------------------------------------------------------|:------:|:---------:|:-----------:|
564-
//! | field_reader | | constant | _R |
565-
//! | field_writer | | constant | _W |
566-
//! | enum_name | | constant | _A |
567-
//! | enum_write_name | | constant | _AW |
568-
//! | enum_value | | constant | |
569-
//! | interrupt | | constant | |
570-
//! | peripheral_singleton | | constant | |
571-
//! | peripheral <br> register <br> cluster | | constant | |
572-
//! | register_spec | | constant | _SPEC |
573-
//! | cluster_accessor <br> register_accessor<br>field_accessor<br>enum_value_accessor | | snake | |
574-
//! | cluster_mod <br> register_mod <br> peripheral_mod | | snake | |
561+
//! Since `svd2rust` 0.32 defaults have been changed.
562+
//!
563+
//! | IdentifierType | Prefix | Case | Case 0.31 | Suffix | Suffix 0.31 |
564+
//! |----------------------------------------------------------------------------------|:------:|:---------:|:---------:|:------:|:-----------:|
565+
//! | field_reader | | pascal | constant | R | _R |
566+
//! | field_writer | | pascal | constant | W | _W |
567+
//! | enum_name | | pascal | constant | | _A |
568+
//! | enum_write_name | | pascal | constant | WO | _AW |
569+
//! | enum_value | | pascal | constant | | |
570+
//! | interrupt | | unchanged | constant | | |
571+
//! | peripheral_singleton | | snake | constant | | |
572+
//! | peripheral <br> register <br> cluster | | pascal | constant | | |
573+
//! | register_spec | | pascal | constant | Spec | _SPEC |
574+
//! | cluster_accessor <br> register_accessor<br>field_accessor<br>enum_value_accessor | | snake | snake | | |
575+
//! | cluster_mod <br> register_mod <br> peripheral_mod | | snake | snake | | |
576+
//!
577+
//! To revert old behavior for `field_reader` you need to pass flag `-f field_reader::c:_R`. And repeat similar for other idents.
578+
//!
579+
//! Also you can do the same in config file:
580+
//! ```toml
581+
//! [ident_formats.field_reader]
582+
//! case = constant
583+
//! suffix = "_R"
584+
//! ```
575585
#![recursion_limit = "128"]
576586

577587
use quote::quote;

0 commit comments

Comments
 (0)