wc-duck / datalibrary

Open Source Data Library for data serialization.
Other
42 stars 8 forks source link

Inline arrays of enums seems to break c-header-writing #137

Open lundmark opened 3 years ago

lundmark commented 3 years ago

https://pastecode.io/s/1j7TQi4rOE

This patch fixes an issue with writing a c-header with inline-arrays of enums. I expect there to be a better solution for this issue maybe generally, but unfortunately I did not have time to dive deeper for a better fix.

Unfortunately I couldn't get a diff to paste correctly in github so I added it to pastecode instead.

wc-duck commented 3 years ago

That solution do not really look ideal no... But I have some things to test now at least... I'll try to find some time to look at it during the week!

lundmark commented 3 years ago

Yeah the code was actually copy-paste from a different place. I think it's because DL doesn't require enums to be defined before used in the typelibrary.

To be honest I think that DL should ensure that the enum is defined and then just start by going through all the enum definitions in the typelibrary before anything else.

wc-duck commented 3 years ago

Something like that yes... Do you have a typelib to repro the issue?

lundmark commented 3 years ago

Unfortunately I haven't been able to extract the parts of the typelib that causes this issue, and the typelibs are too huge and with too much secret-stuff so I can't send them either :/ But it should be easy to reproduce?

wc-duck commented 3 years ago

I can't seem to reproduce this... things I have tried is just inline arrays of enums (these tests has been there for a long while) and declaring the enum after the struct using it, that also works. Could it be if the enum is from another typelib all together?

lundmark commented 3 years ago

Hi, sorry for the late answer.

Yes it is possible but unlikely that it's from a different typelib. Maybe it's possible to track down the other fix that I copied in order to get this working, and see what happens if you remove that one? The patch is basically a copy-paste from a different part of the code.