On Sun, Jul 22, 2012 at 7:18 PM, Jeff Hodges <
je...@somethingsimilar.com> wrote:
> Just about everything you want comes from using SWIG. See
> <
http://www.swig.org/Doc2.0/Go.html> and
> <
http://golang.org/misc/swig/>. I'd recommend taking a swing with it,
> first.
>
> Unfortunately, unless the header files are straightforward and you
> know their format ahead of time (like those perl scripts do since the
> headers in question are de facto standards), there's no such thing as
> a "simple" header parsing tool. C is just rather difficult to parse,
> generically. SWIG is almost certainly what you want.
>
> If you're really ambitious, you could probably make something work
> with libclang. binet has
> <
http://go.pkgdoc.org/bitbucket.org/binet/go-clang/pkg/clang> but I
> can't quite tell if it's fleshed out in the direction you want to take
> it. Of course, using it would, you know, require more code to be
> written and you'd probably have just a worse version of SWIG by the
> end of it.
go-clang was indeed written with this use case in mind.
I am working on a tool to automatically wrap *any* C/C++ library.
we (in high energy physics) already have such a tool, called reflex,
which generates such kind of reflection informations (for automatic
I/O serialization and python bindings generation) based on gcc-xml.
my first version is based on such a scaffolding, but I tried to write
in such a way that it would be trivial to switch to another source of
reflection informations (gcc-xml -> CLang) as in HEP we're also
migrating away from gcc-xml to use CLang (and CLing, the C++
interpreter built on top of CLang).
it is not ready for public consumption yet.
but if you want to have a look:
https://github.com/sbinet/go-cxxdict
no doc, no readme :}
-s