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

Add options for generated enum format. #12

Merged
merged 3 commits into from
May 9, 2023

Conversation

crc1021
Copy link
Contributor

@crc1021 crc1021 commented May 2, 2023

I too ran into this issue #9. Here is one way to handle that.
I addition, I usually use all upper case for enum constants, so I added an option for that as well.

pbtools/c_source/__init__.py Outdated Show resolved Hide resolved
pbtools/c_source/__init__.py Outdated Show resolved Hide resolved
pbtools/subparsers/generate_c_source.py Outdated Show resolved Hide resolved
@eerimoq
Copy link
Owner

eerimoq commented May 4, 2023

I'm tempted to never add the enum name itself as a prefix, and just rely on that enum field names are according to protobuf recommendation. That is, we can remove the --enum-prefix argument.

@crc1021
Copy link
Contributor Author

crc1021 commented May 8, 2023

I'm tempted to never add the enum name itself as a prefix, and just rely on that enum field names are according to protobuf recommendation. That is, we can remove the --enum-prefix argument.

Are you saying that the format should not even include namespace?
{field.name_snake_case}_e = {field.field_number}
or keep namespace?
{enum.namespace_snake_case}_{field.name_snake_case}_e = {field.field_number}

@eerimoq
Copy link
Owner

eerimoq commented May 8, 2023

The latter. It should include everything except the name of the enum.

@eerimoq eerimoq merged commit c1450fe into eerimoq:master May 9, 2023
@eerimoq
Copy link
Owner

eerimoq commented May 9, 2023

I'll fix tests and clean it up. Thanks for your contribution!

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.

3 participants