Open Marvin-TMG opened 3 years ago
It's likely that cxxheaderparser can handle such constructs, recommend you give that a try as eventually I will abandon this fork in favor of cxxheaderparser.
Alternatively, happy to accept a fix for this. If I recall correctly, CppHeaderParser's multi-dimensional array support was indeed quite terrible, so this doesn't surprise me at all.
Thanks for the recommendation and quick reply. I will give that library a shot.
In the meantime, I managed to work around the issue with a fairly simple solution. I am running the parser twice, the first time to get all #defines, which I then do a string replace on in Python. This allows me to parse the parched code again and obtain the correct array dimensions. It’s far from elegant, but it works :)
On 22. Sep 2021, at 21:43, Dustin Spicuzza @.***> wrote:
The following message was sent from an external e-mail address! Be cautious when clicking on links, opening attachments or providing sensitive information.
It's likely that cxxheaderparserhttps://github.com/robotpy/cxxheaderparser can handle such constructs, recommend you give that a try as eventually I will abandon this fork in favor of cxxheaderparser.
Alternatively, happy to accept a fix for this. If I recall correctly, CppHeaderParser's multi-dimensional array support was indeed quite terrible, so this doesn't surprise me at all.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/robotpy/robotpy-cppheaderparser/issues/72#issuecomment-925271968, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALLMUUX2ELRU6R57RZTNLUDUDIWVVANCNFSM5EQXGJVQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
TOYOTA GAZOO Racing Europe GmbH | Toyota-Allee 7 | 50858 Köln / Cologne | Deutschland / Germany Geschäftsführer / Managing Directors: Koji Sato, Katsuyoshi Hikichi, Robertus Leupen, Matthew Harrison Sitz der GmbH / Registered Office: Köln / Cologne | HRB 9846 | Tax-No.: 22358190628 | VAT-ID No.: DE123471187 T: +49 2234 1823 0 | F: +49 2234 1823 2800 | E: @.*** | W: www.tgr-europe.com TGR-E-Datenschutzinformationen / TGR-E‘s privacy policy: https://www.tgr-europe.com/en/privacy DISCLAIMER
Are these "variables" actually #define
s? If so, note from the readme:
CppHeaderParser only does some very minimal interpretation of preprocessor directives -- and we're looking at removing some of that from this library. If you need anything complex, you should preprocess the code yourself. You can use the excellent pure python preprocessor pcpp, or the preprocessing facilities provided by your favorite compiler.
We don't implement macros in cxxheaderparser either.
I am trying to parse C structs which contain array's defined using variables.
The single dimension arrays are parsed correctly, i.e. long my1dArray[SOME_VAR];
which returns something like: 'array_size': 'SOME_VAR'
However, for multidimensional arrays the array size is not parsed correctly and returns an empty string: long my2dArray[SOME_VAR][SOME_VAR];
'array_size':1 'multi_dimensional_array':1 'multi_dimensional_array_size':''
It would be great if array sizes using variable names for multi-dimensional arrays can be supported, since now I need to write a custom parser to retrieve the dimensions myself.