Live data from Hacker News

SWIG author on the complexity of SWIG

code.activestate.com

11–12 of 12 posts

Re: SWIG author on the complexity of SWIG

#11
post #4

I wrote a library that makes C++ callable from script languages, but instead of parsing headers it uses C++11 template metaprogramming and type inference, so it always parses exactly what the types are because it runs in the same compiler as your code. Unlike SWIG it is becoming simpler over time as I develop more powerful abstractions and I do understand 100% of how it works (although admittedly you have to have adv…

I must say, as a developer of C++ bindings for Guile, a former Io dabbler, and TiddlyWiki user, I am impressed with this project.

Hats off to you sir. Oh, I also do the occasional motorcycle maintenance as well.

Re: SWIG author on the complexity of SWIG

#12
post #8

I've been thinking about how to do this effectively and cleanly for a while now, and I wonder if the right path isn't to use clang to parse the C or C++ code and then generate interfaces from the LLVM IR. As far as I know, all the metadata you need is there, so it might prove simpler than parsing things on your own.

We've done this. A modified clang-interpreter spits out some json. Python scripts consume the it and generate reflection data, script bindings etc.

We're very happy with the results. It's a little bit slower than hand parsing the headers, but the robustness more than compensates for it. We set up a unity build (just for the headers) to make up the speed difference.

Post reply on HN