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

Fix Enum Clash for OSI Lane Proto #3

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions generator/nanopb_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,12 @@ def __init__(self, names, desc, enum_options, element_path, comments):
self.names = names

# by definition, `names` include this enum's name
# This truncation to only take the last part of the enum name is to allow npb structs to be exported as external C types in Simulink, which have a character restriction limit.
# However, in some cases like in the osi_lane proto, the truncated enum members could be identical across different enums causing symbol clash issues.
# As such, we handle those cases like below explicitly to avoid symbol clashing by renaming these members slightly.
base_name = Names(names.parts[-1])
if str(Names(names.parts[:-1])) == "osi3_Lane_Classification":
base_name = "LCT_"
Comment on lines +420 to +421

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anirudh-seela can you please leave a comment here to explain why you're doing this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


if enum_options.long_names:
self.values = [(names + x.name, x.number) for x in desc.value]
Expand Down
Loading