Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gvaradarajan
Copy link
Member

Also contains the following fixes

  • adjustment for number field parsing (it turns out I was somewhat mistaken on the format)
  • incorrect advancement of the cursor for when a field is annotated with the offset property

@gvaradarajan gvaradarajan requested a review from a team as a code owner January 27, 2025 21:34
@gvaradarajan gvaradarajan requested a review from acmorrow January 27, 2025 21:34
Copy link
Member

@acmorrow acmorrow left a 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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is stale

Comment on lines +197 to +201
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)?;},
}
Copy link
Member

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> {
Copy link
Member

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?

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.

2 participants