Does anybody experimented with running gcc with -fdump-tree-all and -fdump-rtl-all to make more sophisticated and fully native preprocessed data to make complex C/C++ libraries binding automation?
I tried to play with Gtk-3.0 library installed in by Debian 9 as a sample of Nim/C integration, but now I can use it only with intermediate layer C code. Such alike libraries, especially something really complex like LLVM framework with full-sized C++ API, requires a lot of options to be passed for C/C++ compiler, has a lot of preprocessor hints all over the code, and black C++ templating magic. It looks like c2nim unable to fight with this incubus.
Well we have a GTK3 wrapper in Nimble and there are project like "nimterop" etc that try to do that.
IMO everything beyond c2nim's approach is deeply flawed as the type information available in C is too weak. int fn(int count; char* args); is this a pointer to a byte array? A pointer to a single byte? A cstring? GCC doesn't know and so for high quality wrappers you need to add information, you need to write a wrapper, with tooling support, but it cannot be completely automatic.
Check out nimterop which aims to make it easier to create bindings. It uses gcc -E to tackle the preprocessor and tree-sitter to parse and generate an AST. The AST is then converted into Nim syntax.
We aren't far enough to make it absolutely seamless but here's a nimterop based LLVM wrapper that generates this output. There are still some C features that aren't yet supported but instead of erroring out, nimterop simply ignores unrecognized syntax.
nimterop doesn't yet support C++ but can leverage c2nim in this case. Here's an example C++ binding. However, advanced C++ is still beyond.
Do you mean to create the AST? Well I did look into it but it is a huge dependency, especially on Windows and Linux.
tree-sitter allows for a really light dependency that can be easily deployed cross-platform. Further, I am only looking at creating wrappers, not conversion of implementation outright so it is more than enough for working with header files.