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

Allow derived structs in packets in new rust generator #101

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions pdl-compiler/src/backends/rust/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,6 @@ impl<'a> FieldParser<'a> {
assert_eq!(self.shift, 0, "Typedef field does not start on an octet boundary");

let decl = self.scope.typedef[type_id];
if let ast::DeclDesc::Struct { parent_id: Some(_), .. } = &decl.desc {
panic!("Derived struct used in typedef field");
}

let span = self.span;
let id = id.to_ident();
let type_id = type_id.to_ident();
Expand Down Expand Up @@ -555,11 +551,8 @@ impl<'a> FieldParser<'a> {
}
}
ast::DeclDesc::Struct { .. } => {
let width = syn::Index::from(width / 8);
quote! {
let (head, tail) = #span.split_at(#width);
#span = tail;
let #id = #type_id::decode_full(head)?;
let (#id, mut #span) = #type_id::decode(#span)?;
}
}
_ => unreachable!(),
Expand Down
4 changes: 0 additions & 4 deletions pdl-compiler/src/backends/rust/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,6 @@ impl Encoder {
assert_eq!(self.bit_shift, 0, "Typedef field does not start on an octet boundary");

let decl = scope.typedef[type_id];
if let ast::DeclDesc::Struct { parent_id: Some(_), .. } = &decl.desc {
panic!("Derived struct used in typedef field");
}

let id = id.to_ident();
let buf = &self.buf;

Expand Down
Loading