Open viktornordling opened 11 months ago
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 https://github.com/ArduPilot/pymavlink/issues/887#issuecomment-1859055510, 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! :)