-
Notifications
You must be signed in to change notification settings - Fork 11
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
Rewrite the Rust generator #96
Conversation
hchataing
commented
Apr 23, 2024
- WIP new rust generator
- WIP split generator for root and derived packets
- WIP rewrite serializer
- WIP update generated files
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 looks much better than the old code, well done!
f61960a
to
27c07d5
Compare
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 think this looks very nice and I imagine the smaller generated files will result in an improvement in code size of the final binaries?
That might be the case, I haven't checked though. |
No, I wouldn't bother unless that seems to be a bottleneck for someone? Of course, setting up a benchmark wouldn't be super hard — perhaps you can try Divan, which I've been meaning to try out myself 😄 |
This commit performs an overhaul of the rust generator which aims at improving the API of the generated code, to make it more readable and usable. The major changes are: - packet and struct have the same generated code. This also means that packet derivation is also supported for structs now - builder declarations are removed. The generator produces a unique struct for each packet that contains the immediate data fields, and fields copied from parent declarations - constrained fields do not appear in the generated struct, but an accessor is provided that returns the constant value for the field - the trait pdl_runtime::Packet is extended with the function decode() which parses the packet from an input slice and returns the remainder data - TryFrom trait implementations are provided for all child and parent packets; these exist mostly for convenience and do not aim to be performant
27c07d5
to
5a64e66
Compare
9731af6
to
2b354fc
Compare