Gennady
5/5/2005 3:40:00 PM
For a long time I've been doing C++/Ruby interfacing mannually. And
about 2 weeks ago I got to giving SWIG a try (version 1.3.24).
I was truelly amazed with what I got. It transforms your C++ classes
into Ruby classes practically seamlessly, even giving you opportunity to
adjust to naming conventions simply by edditing a SWIG interface file.
Included typemaps allow you, for example, return std::string from your
C++ method, and automatically gets converted and returned to the Ruby
world as Ruby string, without you doing a stir. Isn't it amazing? ;-)
However, you can still use ruby C API in your C++ methods if you need
it. In particular, I use it to implement iterator-like methods using
rb_is_block_given_p() and rb_yield and SWIG's SWIG_NewPointerObj(...)
function.
After throwing away tons of now unnecessary code, I am fully convinced
that SWIG is the way to go for C++/Ruby integration.
Gennady.
Nikolai Weibull wrote:
> Piers Harding, May 5:
>
>
>>It continues the conversation.
>
>
> Ah, not very obvious when you push down what I was saying to the bottom
> of your message. Perhaps cut out only the vital parts of my message,
> paste them at the top, and then write your reply?
>
>
>>You came up with one set of suggestions based around rubyembed, and
>>Swing. I just demonstrated that you can do it without that if you
>>prefer not to go down that path.
>
>
> I assume you mean SWIG. Sure, that's a valid point; I've never really
> liked SWIG myself,
> nikolai
>