Skip to content

Commit

Permalink
MavGen Cpp11: Handle enums which are substrings of enum name
Browse files Browse the repository at this point in the history
  • Loading branch information
shancock884 committed Dec 19, 2023
1 parent 5a823c5 commit ad78cbe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions generator/mavgen_cpp11.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,17 @@ def enum_remove_prefix(prefix, s):
'''remove prefix from enum entry'''
pl = prefix.split('_')
sl = s.split('_')
lastmatch = None

for i in range(len(pl)):
if len(sl) > 1 and pl[i] == sl[0]:
sl = sl[1:]
lastmatch = pl[i]
else:
break

if sl[0][0].isdigit():
sl.insert(0, pl[-1])
if (len(sl[0]) == 0 or sl[0][0].isdigit()) and lastmatch is not None:
sl.insert(0, lastmatch)

ret = '_'.join(sl)
return MACROS.get(ret, ret)
Expand Down

0 comments on commit ad78cbe

Please sign in to comment.