-
Notifications
You must be signed in to change notification settings - Fork 594
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++11 generation fails if an enum value is a substring of the enum name #887
Comments
I had a super-quick look. I think the answer is to change line 306 of mavgen_cpp11.py (in function enum_remove_prefix) from: if pl[i] == sl[0]: to: if len(sl) > 1 and pl[i] == sl[0]: which protects against the abbreviated enum name ending up empty. @viktornordling - feel free to try the change on your local version if you like to try it out, and when I get a mo, I can PR it. |
Thanks @shancock884. I'll give it a spin, though I'd love to see a unit test as well! :) |
The test I did before and after the change was to edit my local xml and
temporarily change 'FIRMWARE_VERSION_TYPE_OFFICIAL' to 'FIRMWARE_VERSION',
and then run the generator command.
I am not yet familiar with the repo automated tests for cpp11, to know if
this could be included there.
…On Sun, 17 Dec 2023, 06:55 viktornordling, ***@***.***> wrote:
Thanks @shancock884 <https://github.com/shancock884>. I'll give it a
spin, though I'd love to see a unit test as well! :)
—
Reply to this email directly, view it on GitHub
<#887 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BBRZQQQWIO7X6OA6WOUR6M3YJ2JMTAVCNFSM6AAAAABANT4APSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGA2TKNJRGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thinking about it, I think this will still not cover the case where the enum name has a trailing "_". |
If you have this enum:
And run:
Things work as expected. However, if you have:
The result is:
Here's a table of what works and what doesn't:
Hope this helps with debugging! :)
The text was updated successfully, but these errors were encountered: