From: Alex Fenton Date: 2008-12-12T01:48:07+09:00 Subject: Re: Q: FFI and C++? Jeremy Henty wrote: > On 2008-12-11, Jason Roelofs wrote: > >> Because of the complexity that C++ adds, I doubt that any feasible >> FFI library can be made that works reliably against C++ libraries, > > I was afraid of that. > >> Rice - ... >> Rb++ - ... > > I looked at those but I thought they were targeted at generating MRI > bindings. The point of using FFI is to eliminate MRI-specific C code. > I just need to wrap C++ with C to get functions that FFI can call, eg. Latest SWIG does include C as a target language. In other words it can generate ANSI C wrapper code around C++ classes / libraries. This was a Google Summer of Code project from this year and I believe it's only available from SVN, not in a released version. http://swig.svn.sourceforge.net/viewvc/swig/branches/gsoc2008-maciekd/Doc/Manual/C.html > I already know this works, now I'm trying to save effort, particularly > with parsing C++ and autogenerating wrapper code. Maybe I could use > rbgccxml and add my own XML -> wrapper code backend. It looks as > though rbgccxml is precisely the bit of rbplusplus that I would want > to reuse. SWIG can also output a parse of C++ classes and methods to XML. But if this is all you want to do, probably the Rb++ route is better as it has existing Ruby classes for making use of the parse. I guess in theory you might also be able to generate the FFI code from this at the same time. alex