-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[C++] Add Command-Line Flag to Suppress MIN and MAX Enums #7705
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
aff35b0
to
0aff518
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.
Generally good, just some small nits.
0aff518
to
c08b2aa
Compare
The changes I just force pushed are rebased off of the tip of master (e1a2f68) if you want to compare the changes. |
c08b2aa
to
dd5e97e
Compare
The changes I just force pushed are rebased off of the tip of master (a078130) if you want to compare the changes. |
Add the --no-minmax-values flag to prevent flatc from generating C++ enums with MIN and MAX enumerated values that otherwise would be set to the inclusive lower and upper bound respectively of the enum. This command-line flag is needed to avoid collisions when an enum that is being ported to FlatBuffers already has a MIN or MAX enumerated value. It is also needed to work around a long-standing problem with magic_enum that causes magic_enum to not see enumerated values that are not unique. For example, if FlatBuffers sets MIN = FOO and MAX = BAR, MIN and FOO share the same underlying value so they are not unique. The same is true of MAX and BAR. This prevents magic_enum from converting FOO and BAR to and from strings as well as causing magic_enum to return a count of enumerated values that is two fewer than it should be.
Head branch was pushed to by a user without write access
dd5e97e
to
06181ce
Compare
Sorry, I thought I was being helpful rebasing my branch off of the latest master, but this seems to have revoked the approval. |
Add the --no-minmax-values flag to prevent flatc from generating C++ enums with MIN and MAX enumerated values that otherwise would be set to the inclusive lower and upper bound respectively of the enum. This command-line flag is needed to avoid collisions when an enum that is being ported to FlatBuffers already has a MIN or MAX enumerated value. It is also needed to work around a long-standing problem with magic_enum that causes magic_enum to not see enumerated values that are not unique. For example, if FlatBuffers sets MIN = FOO and MAX = BAR, MIN and FOO share the same underlying value so they are not unique. The same is true of MAX and BAR. This prevents magic_enum from converting FOO and BAR to and from strings as well as causing magic_enum to return a count of enumerated values that is two fewer than it should be. Co-authored-by: Paul Serice <paul@serice.net>
Add the --no-minmax-values flag to prevent flatc from generating C++ enums with MIN and MAX enumerated values that otherwise would be set to the inclusive lower and upper bound respectively of the enum.
This command-line flag is needed to avoid collisions when an enum that is being ported to FlatBuffers already has a MIN or MAX enumerated value.
It is also needed to work around a long-standing problem with magic_enum that causes magic_enum to not see enumerated values that are not unique. For example, if FlatBuffers sets MIN = FOO and MAX = BAR, MIN and FOO share the same underlying value so they are not unique. The same is true of MAX and BAR. This prevents magic_enum from converting FOO and BAR to and from strings as well as causing magic_enum to return a count of enumerated values that is two fewer than it should be.
Unit tests have been added to tests/flatc/flatc_cpp_tests.py for each combination of --no-minmax-values and scoped enums, prefixed enums, and non-prefixed enums.