There’s a Common Lisp library that has done this for a while now, cl-autowrap. I’ve used it to write bindings for GDAL, Blend2D, and a few other libraries. It’s implemented as a macro, and called like this: (cl-autowrap:c-include “gdal.h” …), and basically does exactly what you would expect. The first time can take a minute to generate all the code, but after that everything’s compiled and it just imports the FASL files in almost no time. One nice features is that it can save the intermediate JSON files so that end users of the package don’t need the library-dev package.
It takes arguments that control how names are converted to Lisp names, what gets exported, etc. I usually end up writing some with- macros and convenience functions on top of the “raw” binding, but it definitely makes the process 1000x easier and less tedious.
There’s a fork, claw, that claims to have good C++ support, though I haven’t tried it myself.
Nice to see this idea branching out to other languages.
I’m a little confused here because I thought this was a fairly common thing.
zig has translate-c and D has dpp. Both of which seem to count in my mind.
This is great. I’ve been vaguely wondering about using libraries from more popular languages with less popular languages with similar semantics (eg pony to rust).