From: jjenning@... (jared l. jennings) Date: 2002-05-07T02:44:17+09:00 Subject: Re: Embedding Ruby in C++ On Tue, May 07, 2002 at 12:30:20AM +0900, Rick Bradley wrote: > * jared l. jennings (jjenning@stetson.edu) [020506 10:28]: > > I advise you to use SWIG. You'll have to check out the CVS version, but > > it's quite stable and everything. it will take care of the details. be > > warned though, it doesn't do very complex features of C++ well. > > I believe he wants to go the other way. this is how i thought of it: you wrap the classes you want to get at in ruby. now, instead of using 'require' to bring them in from a .so, you compile the wrappers into the C++ program. When the program runs, it initializes the ruby interpreter which it embeds, then calls the Init function for the wrapper, thus making the wrapped classes available to the embedded Ruby. Then in C++ when you want to get at objects created or modified by Ruby, you get a VALUE for them, and... ahm... i think you'd have to look at the wrapper code, but i think SWIG makes a struct that has a pointer to the C++ object. somewhere in there there is a pointer you can snag. so you can mess with the object, and the changes are visible to the embedded Ruby. you can frob it in ruby, and see changes in C++. both in an object-oriented way without an overage of C-writing. > | that thing. I need to > random email haiku | keep my pentium power > | in check for linux. i have never done any embedding before but i think that's it. :) -- Doubt is a pain too lonely to know that faith is his twin brother. - Gibran Khalil Gibran