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 Jan 2, 2024
1 parent 69485b0 commit d828edf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 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 pl[i] == sl[0]:
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 d828edf

Please sign in to comment.