Questions about SWIG, Ruby/DL and embedding calls to ruby withinC++ Code

C

Charles Comstock

Is there any sort of tutorial on calling ruby functions from C++ code?
I looked at the documentation for SWIG and that all seems to be for
wrapping a C++ class in a ruby object, which is all well and good for
many uses but what if you are trying to say derive from a C++ base class
and then write the code in Ruby. I'm not sure if SWIG allows this and
I'm just misreading the directions or if this is possible through some
other route. Anybody have any experience with this problem?

Charles Comstock
 
L

Lyle Johnson

Is there any sort of tutorial on calling ruby functions from C++ code?
I looked at the documentation for SWIG and that all seems to be for
wrapping a C++ class in a ruby object, which is all well and good for
many uses but what if you are trying to say derive from a C++ base class
and then write the code in Ruby. I'm not sure if SWIG allows this and
I'm just misreading the directions or if this is possible through some
other route. Anybody have any experience with this problem?

The latest versions of SWIG (in the 1.3.x development series) provide
support for so-called "director" classes, which allow you to subclass
wrapped C++ classes with Ruby classes and then override their virtual
member functions. This feature is documented a bit (see
http://www.swig.org/Doc1.3/Python.html#n32) but because the feature's
still fairly new, you may not many examples of it in the wild.

If you decide to give this a whirl and run into problems, please feel
free to follow up with me or on the SWIG users' mailing list.

Hope this helps,

Lyle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top