-
Notifications
You must be signed in to change notification settings - Fork 151
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
Generating type alias of derived enumeratedValues. #810
Generating type alias of derived enumeratedValues. #810
Conversation
/ci diff pr |
Related to #652. Please, don't use type aliases for identical types. This makes compilation slower and grows docs. pub use oldpath as newname; |
/ci diff pr |
Please, no any |
2dc7d19
to
36dda44
Compare
The changes have been committed to the rebased repository. |
src/generate/register.rs
Outdated
match usage { | ||
Usage::Read => Some(name.to_owned() + "R"), | ||
Usage::Write => Some(name.to_owned() + "W"), | ||
Usage::ReadWrite => Some(name.to_owned()), | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also use ident
.
@Emilgardis this is yet one question we need to discuss next meeting.
Now we use:
common RW: enum_name
only R: enum_name
only W: enum_name
different R+W: enum_name
+ enum_writer_name
Should we simplify it to:
RW: enum_name
R: enum_reader_name
W: enum_writer_name
Or support both notation somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I support to simplify it.
For the following reasons.
- Simpler rules are better.
- Supporting both notations would increase maintenance costs.
- Even if the functionality changes between reads and writes, the bit names would be different and can be distinguished.
Further My Opinion .
I think it is not good that these notations are added by 'svd2rust'.
Since these notations are added by 'svdtool patch', it would be better to add the names for re-export by 'svdtool patch'.
I have created pull request rust-embedded/svdtools#205 for svdtools for this opinion.
As the master branch is much further along and away from this change, and as this request seems to have been taken into account, I would like to close this pull request for now. |
Check #816 branch first. Possibly it partially closes your needs. |
Thank you. I will check this branch. |
…d_value does not have a name. Because a derived enumerate values in patched svd are written over by a base enumerated balue.
36dda44
to
8fe79e6
Compare
/ci diff pr |
If you want to use field names for enums. |
My issue is resolved by |
svd file
generated rust code from the above svd file.
svd2rust
does not generate type aliase of SAI23SEL and SPI123SEL.I would like to append type aliase of SAI23SEL and SPI123SEL.
Because, if the enumerator names do not match the names of Field Reader and Filed Writer, you will be in trouble when you generate the code with macros.
And if the enumerator names do not match the names of Field Reader and Filed Writer, the code is difficult to write and may cause bugs.