Skip to content

Normalize SVD names to upper case where they were to pascal case #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2017
Merged

Normalize SVD names to upper case where they were to pascal case #85

merged 2 commits into from
Jun 5, 2017

Conversation

whitequark
Copy link
Contributor

@whitequark whitequark commented Apr 30, 2017

Fixes #76.

Depends on calebmer/inflections#2.

@whitequark
Copy link
Contributor Author

So... yes, I understand that right now, I am being that person who asks to change style conventions. However, I feel that there are a few factors in the favor of this change:

  • The current behavior is clearly broken, and cannot be fixed and still be fully compliant with Rust's naming conventions for struct names (as described in Name mangling is lossy around numbers #76);
  • Normalizing peripheral and register names to PascalCase is unprecedented in embedded development;
  • Normalizing peripheral and register names to PascalCase means there is no trivial mapping from the datasheet names to API names (unlike with snake_case, where it is a simple substitution);
  • Virtually all peripheral and register, and most enumeration names are complex abbreviations, which means that normalizing them to PascalCase always decreases readability;
  • svd2rust already has precedent for this: 7b585ac.

And I suppose if this PR is merged, then the corresponding change should be done to cortex-m as well.

@japaric
Copy link
Member

japaric commented May 6, 2017

Normalizing peripheral and register names to PascalCase is unprecedented in embedded development;

(Rust is unprecedent in embedded development :-). And C just uses integers to represent registers instead of newtypes so C code doesn't have to deal with this.)

I kinda agree with the rationale outlined here but I'd like to take my time in assessing the breakage this will cause to dependent crates.

@whitequark
Copy link
Contributor Author

Rust is unprecedent in embedded development :-)

I think you'll find the Habit bitdata types (see Habit report p.40) quite familiar, actually...

@whitequark
Copy link
Contributor Author

@japaric From your latest post:

When using the RTFM framework you have to declare all the peripherals you are going to use in this macro. Both the name of the peripheral (for example: GPIOE) and its type (for example: Gpioe) must match the device crate, stm32f30x in this case, definitions.

Seems like this PR would make that a bit cleaner :)

@japaric
Copy link
Member

japaric commented May 25, 2017

Bascially r+ but we have to wait for inflections PR to be merged. Turns out this change won't break cortex-m-rtfm because the register_block field in the peripherals! macro can be made optional. (see japaric/cortex-m-rtfm#28)

@japaric
Copy link
Member

japaric commented May 27, 2017

This is waiting on a new release of the inflections crate.

@japaric
Copy link
Member

japaric commented Jun 5, 2017

Thank you @whitequark!

@homunkulus r+

@homunkulus
Copy link
Contributor

📌 Commit 601cc70 has been approved by japaric

@homunkulus
Copy link
Contributor

⌛ Testing commit 601cc70 with merge ae89a86...

japaric pushed a commit that referenced this pull request Jun 5, 2017
Normalize SVD names to upper case where they were to pascal case

Fixes #76.

Depends on calebmer/inflections#2.
@homunkulus
Copy link
Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: japaric
Pushing ae89a86 to master...

@homunkulus homunkulus merged commit 601cc70 into rust-embedded:master Jun 5, 2017
bors bot added a commit that referenced this pull request Apr 16, 2022
591: optional PascalCase for Enum values r=Emilgardis a=burrbull

![изображение](https://user-images.githubusercontent.com/3072754/163558809-1bd00854-7cac-4017-aab4-e379d582a52a.png)
without and with `--pascal_enum_values` option

related: #85

r?adamgreig

Co-authored-by: Andrey Zgarbul <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants