-
Notifications
You must be signed in to change notification settings - Fork 156
add variant to reader #354
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
Conversation
src/generate/register.rs
Outdated
@@ -277,7 +277,7 @@ pub fn fields( | |||
let pc_r = Ident::from(&*format!("{}R", pc)); | |||
let _pc_r = Ident::from(&*format!("{}_R", pc)); | |||
let pc_w = Ident::from(&*format!("{}W", pc)); | |||
let _pc_w = Ident::from(&*format!("_{}W", pc)); | |||
let _pc_w = Ident::from(&*format!("{}_W", pc)); |
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.
Ugh... It's a pity we didn't notice this earlier. But would you please remove it from this PR?
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.
Ok.
Then
_pc_r => "_{}R"
?
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.
No, just remove the change from this PR and put it in a separate one.
Which file did you test it on? Don't seem to have a SVD file in reach which actually uses the changed parts. |
from #[doc = r"Reader of the field"]
pub type LATENCY_R = crate::FR<u8, LATENCYR>;
impl LATENCY_R {
#[doc = r"Enumerated values"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, LATENCYR> {
use crate::Variant::*;
match self.bits() {
0 => Val(LATENCYR::WS0),
1 => Val(LATENCYR::WS1),
2 => Val(LATENCYR::WS2),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `WS0`"]
#[inline(always)]
pub fn is_ws0(&self) -> bool {
*self == LATENCYR::WS0
} |
I've moved identical code to |
Hm, it's a pity I can't see the changes using the unmodified SVD files from |
Done. |
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.
LGTM
bors r+ |
354: add variant to reader r=therealprof a=burrbull r? @therealprof Restore access to `enum`'s by `variant` method that return `enum FIELD` when possible or `Variant`. Also replace `_to_bits` method in writer with trait. So now enums for reader and writer are identical (when they don't use different values for read and write) and can be replaced by one. See #353 . Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
Build succeeded |
r? @therealprof
Restore access to
enum
's byvariant
method that returnenum FIELD
when possible orVariant
.Also replace
_to_bits
method in writer with trait.So now enums for reader and writer are identical (when they don't use different values for read and write) and can be replaced by one.
See #353 .