From: Joel VanderWerf Date: 2004-08-17T13:31:50+09:00 Subject: Re: Embedding Ruby as plugin Tobias Grimm wrote: > Hi! > > I have an application written in C++, that provides a plugin interface. > What I would like to do now, is to implement a plugin, that allows to > execute a ruby script, like this: > > 1) Application loads plugin.so > 2) Application invokes plugin > 3) Plugin creates object "interface" of class Interface > 4) Plugin loads rubyscript.rb > 5) rubyscript.rb uses interface object created in 3) to send messages to > the plugin > > I used SWIG to create a wrapper for the Interface class that the ruby > script should use. If I simply wanted to create an ruby extension, the > wrapper should just be compiled to a lib, that ruby can load with a > require statement. But now the wrapper is part of the plugin, which > itself is loaded by the application. How do I get the ruby script know > about the Interface class and the interface object to use? Not sure I understand. Where is the ruby interpreter in this picture? Your C++ app embeds it? Or plugin.so embeds it? What if you just set a global variable, $interface, before loading rubyscript.rb, which references this global? Is the problem then that you don't want to use a global, for the usual good reasons?