In article <017501c24887$48f81d40$0300a8c0 / austin.rr.com>,
Hal E. Fulton <hal9000 / hypermetrics.com> wrote:
>----- Original Message ----- 
>From: "Edward Wilson" <web2ed / yahoo.com>
>Newsgroups: comp.lang.ruby
>To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
>Sent: Tuesday, August 20, 2002 3:10 PM
>Subject: Embeding Ruby in C/C++
>
>
>> I have been reading snippets that people have been saying about Ruby
>> not being good for embeding, over and over again in different threads.
>> 
>> I have been planning on writing an application in C++ (boo...hiss) and
>> embeding Ruby inside of it.  Basically, I want to write a FAST, RICH
>> objectory and expose Ruby to it staticly, then allow my end users to
>> use a pure Ruby API to control it.
>
>Objectory?? I don't know that word. Does that mean object respository
>or something?
> 
>> My question is: is this doable?  I have tried in the past to embed
>> Ruby and hit a wall, I have been hoping that this would be resolved as
>> Ruby matured.  Is Ruby maturing in the embedable direction?
>
>If you're wanting to control a C++ app via Ruby, SWIG
>might be an option. I've never used it personally. I
>hear it's great.

I have used swig some lately and I do highly recommend it.  You'll need to 
take a slightly different mindset, though.  Instead of embedding Ruby in 
your C++ code, you use Ruby to manipulate your C++ objects.  This approach  
actually works very well and I think offers even greater flexibility.  
Search the Ruby talk archives for a thread entitled "embed or swig?" that 
I started a few weeks back for more details.  Your end users can still 
script in Ruby and they'll have no idea that they're actually using 
objects that are defined in C++ classes - it'll all look like Ruby to 
them.

BTW: Now that Swig 1.3.14 has been released there's even less stuff you 
need to do to make swig generate wrappers for your C++ code - the new 
version now automagically supports overloaded methods in C++ (no more 
%rename declarations needed in your swig interface files). [Caveat: I 
haven't actually had a chance to try 1.3.14 yet, but it does sound very 
cool] 

Phil