From: Bruce Ingalls Date: 2001-12-09T23:58:24+09:00 Subject: [ruby-talk:28033] Re: Boost.Ruby ? Issac wrote: > I'm starting to wonder about whether it's a good idea to extend > Ruby with C++ .... > I think this is because of C++'s name-mangling. .... > From: "Joel VanderWerf" >>Issac wrote: >>>Of all the ways to extend Python with C++, my favorite is Boost.Python >>>http://www.boost.org/libs/python/doc/ . >>>Does something like this exist for Ruby? >>> >>I have written something almost but not quite entirely unlike it ;). To >>wit, the CGenerator module in RAA, and the forthcoming (this weekend if >>I'm not too lazy) CShadow module. >> >>Disclaimer: it works with C code, not C++. (I wrote C++ code for two >>years, and that's enough. Seriously, though, it would be a good idea for >>it to work with C++ as well.) >> >>CGenerator is a Ruby interface to the Ruby C API. .... >>At the moment, these simple C structs, with their associated Ruby >>objects, are enough for my purposes, but it would be quite nice to allow >>a C++ object as the "shadow" of a Ruby object. It looks like >>Boost.Python would be a good source of ideas for this project. I'd be interested to see how the Boost.Python people pulled this off. I see that you already noticed that name mangling is *not* portable between brands of compilers. Perhaps Boost assumes a GCC compatible compiler? This is a bit of a hack, but a useful intermediate step: You can have "extern c" statements (possibly called as a macro which detects if the compiler is C, and does nothing, but is active for C++) C++ users would have to pass what they can of their /C++ class/, into a /C struct/.