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

rust fixup #123

Merged
merged 4 commits into from
Jan 29, 2025
Merged

rust fixup #123

merged 4 commits into from
Jan 29, 2025

Conversation

hchataing
Copy link
Collaborator

  • Split the decl and parent size in the schema
  • Refine the specialize() implementation of the rust backend

decl_size contains the size of the fields declared in the
current decl, payload field excluded.

parent_size contains the size of the parent decl, payload field
excluded.

total_size() still returns the total combined size of the
decl (parent_size + decl_size + payload_size)
The previous implementation only considered constraint values
of immediate child packets which made the generated function
impossible to disambiguate the following child packets:

- alias declarations which exist to organize child
  declarations into groups

```
packet Alias : Packet { _payload_ }
```

- child declarations using the same constraint values. This may
occur in procotol specifications where fields get added to a
packet specification without additional means of disambiguating
the version.

```
packet ChildV1 : Packet (op_code = 1) {
  a : 8,
}
packet ChildV2 : Packet (op_code = 1) {
  a : 8,
  b : 16,
}
```

This patch addresses both issues by considering constraints in
recursive child declarations as well as the child declaration
size.

This patch does _not_ resolve the case where ambiguous child
declarations do not have a static size, and which would require
a trial and error approach.
@hchataing hchataing merged commit 27d63c1 into main Jan 29, 2025
8 checks passed
@hchataing hchataing deleted the rust-fixup branch January 29, 2025 23:17
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