Skip to content

Commit 7b585ac

Browse files
author
Jorge Aparicio
committed
change the fields of interrupt::Handlers to pascal case
this goes against Rust's naming conventions but make the struct more friendly to macros as now the field, the context token and the Interrupt variants have the exact same name
1 parent 7ac94a8 commit 7b585ac

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- [breaking change] the fields of the interrupt::Handlers struct has been
13+
changed to PascalCase.
14+
1015
## [v0.5.1] - 2017-04-01
1116

1217
### Fixed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "register", "map", "generator"]
77
license = "MIT OR Apache-2.0"
88
name = "svd2rust"
99
repository = "https://github.com/japaric/svd2rust"
10-
version = "0.5.1"
10+
version = "0.6.0"
1111

1212
[dependencies]
1313
cast = "0.2.0"

src/generate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
8585
});
8686
}
8787

88-
let name = Ident::new(&*interrupt.name.to_sanitized_snake_case());
8988
let name_pc = Ident::new(interrupt.name.to_sanitized_pascal_case());
9089
let description =
9190
format!("{} - {}",
@@ -96,7 +95,7 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
9695
.unwrap_or_else(|| interrupt.name.clone()));
9796
fields.push(quote! {
9897
#[doc = #description]
99-
pub #name: extern "C" fn(#name_pc),
98+
pub #name_pc: extern "C" fn(#name_pc),
10099
});
101100

102101
mod_items.push(quote! {
@@ -106,7 +105,7 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
106105
});
107106

108107
exprs.push(quote! {
109-
#name: exception::default_handler,
108+
#name_pc: exception::default_handler,
110109
});
111110

112111
variants.push(quote! {
@@ -130,6 +129,7 @@ pub fn interrupt(peripherals: &[Peripheral], items: &mut Vec<Tokens>) {
130129

131130
mod_items.push(quote! {
132131
/// Interrupt handlers
132+
#[allow(non_snake_case)]
133133
#[repr(C)]
134134
pub struct Handlers {
135135
#(#fields)*

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! # Usage
2020
//!
2121
//! ```
22-
//! $ svd2rust -i STM32F30x.svd | tee src/lib.rs
22+
//! $ svd2rust -i STM32F30x.svd | rustfmt | tee src/lib.rs
2323
//! //! Peripheral access API for STM32F30X microcontrollers (generated using svd2rust v0.4.0)
2424
//!
2525
//! #![deny(missing_docs)]

0 commit comments

Comments
 (0)