|Posted by evilrat|
in reply to sighoya
Posted in reply to sighoya
On Sunday, 6 June 2021 at 10:38:22 UTC, sighoya wrote:
On Sunday, 6 June 2021 at 10:03:11 UTC, evilrat wrote:
(oh my) gentool v0.4 is now out.
It is my fancy tool to generate extern(C++) stuff quicker, it takes regular compiler flags that you usually pass to clang and translates C/C++ code to D.
This release has one new feature: support pragma mangle on aggregates (class, struct, etc...).
Also a lot of work was put into template support, but it is still has lots of unhandled cases, so do not expect it will translate STL or Boost without need of manual fixes.
How did you parse C++ code which seems overkill to do alone. Did you enact clang for?
Yes, it's all clang under the hood.
But it's not just clang tooling that uses pre-made Tool class that has to be invoked as part of clang itself using special flag.
Instead it creates compiler instance and runs regular compilation pass in memory extracting declarations recursively (as part of older pipeline, can be done to some extent using C API with cursors), and then it converts C++ AST to D source code with minimal AST manipulation (can't be done with C API), though I'm looking into AST-to-AST translation instead and then using D compiler frontend to emit source code for better result.