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

Improve support for open enums in generated pytnon #93

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

hchataing
Copy link
Collaborator

  • previously generated tags x_START and x_END for tag ranges,
    but IntEnum declarations are closed so parsing a value
    in these ranges would fail
  • instead removed declaration for range bounds,
    and relax the generated code to use
    Union[IntEnum, int] instead of IntEnum
  • provide IntEnum.from_int to validate values to are not
    matched to tags, that they are correctly inside of the
    ranges

@hchataing hchataing requested a review from mgeisler December 22, 2023 09:23
- previously generated tags x_START and x_END for tag ranges,
  but IntEnum declarations are closed so parsing a value
  in these ranges would fail
- instead removed declaration for range bounds,
  and relax the generated code to use
  Union[IntEnum, int] instead of IntEnum
- provide IntEnum.from_int to validate values to are not
  matched to tags, that they are correctly inside of the
  ranges
Test enum declarations with exhaustive configurations for the
following criterias:

1. truncated: is the enum width a multiple of 8 or not ?
    this characteristic has an impact for some language generators
2. complete: does the enum define all possible values ?
3. open: does the enum allow for unknown or undefined values ?
4. with range: does the enum use a tag range declarations ?
@hchataing hchataing merged commit c847947 into google:main Jan 2, 2024
6 checks passed
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