-
Notifications
You must be signed in to change notification settings - Fork 12
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
[CONSULT-469] - macro support for array and repeating fields in NMEA #392
base: main
Are you sure you want to change the base?
[CONSULT-469] - macro support for array and repeating fields in NMEA #392
Conversation
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.
Overall, I'm fairly happy with this. I like the way the field set declarations work. A few questions. It might be worth sitting down together for 30 to talk through a few things, mostly for my understanding.
@@ -330,11 +332,10 @@ mod tests { | |||
let data_vec: Vec<u8> = vec![154, 6, 125, 179, 152, 113]; | |||
let mut cursor = DataCursor::new(data_vec); | |||
|
|||
// 154 is 10011010, reading the first 3 bits should yield 100 = 4 | |||
// 154 is 10011010, reading the last 3 bits should yield 010 = 4 |
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.
Comment is stale
@@ -306,8 +308,8 @@ mod tests { | |||
assert!(cursor.read(16).is_ok()); | |||
let res = reader.read_from_cursor(&mut cursor); | |||
assert!(res.is_ok()); | |||
// 125 = 01111101, first four bits as byte => 00000111 = 7 | |||
assert_eq!(res.unwrap(), 7); | |||
// 125 = 01111101, last four bits as byte => 00001101 = 7 |
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.
Comment is stale
fn get_read_statement(name: &Ident, purpose: CodeGenPurpose) -> TokenStream2 { | ||
match purpose { | ||
CodeGenPurpose::Message => quote! {let #name = reader.read_from_cursor(&mut cursor)?;}, | ||
CodeGenPurpose::Fieldset => quote! {let #name = reader.read_from_cursor(cursor)?;}, | ||
} |
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'm a little confused here, why does one form need a &mut and not the other?
Also don't love that this method basically assumes that cursor
is a valid symbol in the context of the expansion, but maybe that's generaly going on and it is just more noticeable here.
} | ||
|
||
impl #impl_generics #field_set_ident for #name #src_generics #src_where_clause { | ||
fn from_data(cursor: &mut DataCursor) -> Result<Self, #error_ident> { |
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.
It bothers me a bit that into_token_stream
ends up with from_bytes
over a Vec, but into_fieldset_token_stream
ends up with a from_data
over a &mut DataCursor
. Why do they differ that way?
Also contains the following fixes
offset
property