From: pp Date: 2011-03-07T11:02:38+09:00 Subject: Re: [Swig-user] Ruby director question --_5f0909e4-c60f-4a42-99a1-0701ca03feec_ Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit Thanks again for the reply.you are right, after several tries the director fully worked for me, even if I call it in this, or original virtual function empty.Now I think what really counts is what you told me... Thanks, really. > Date: Fri, 4 Mar 2011 06:36:11 +0000 > From: wsf@fultondesigns.co.uk > To: tdihp@hotmail.com > CC: swig-user@lists.sourceforge.net > Subject: Re: [Swig-user] Ruby director question > > Whether or not a method body is empty will make no difference, unless > that method calls a base class method of the same name. > > William > > On 28/02/11 13:04, 採峠 wrote: > > Thanks for the reply, William. your suggestion helps. but I found myself > > rather confused about the director.. > > > > 1. I tried my example again, it actually works. but with the restriction > > that the implementation of fun() MUST not be empty, which was what I wrote. > > > > 2. the fun() MUST be called out of original class, which is, cannot be > > called by this. otherwise it just call the original c++ implementation. > > > > Well, it smells buggy now :) > > > > -------------------------------------------------- > > From: "William S Fulton" > > Sent: Monday, February 28, 2011 12:14 AM > > To: "採峠" > > Cc: > > Subject: Re: [Swig-user] Ruby director question > > > >> On 27/02/11 02:15, 採峠 wrote: > >>> Hi, I'm new here and this is my 1st post, so no hard feelings if my > >>> question is really dumb. > >>> SO my *.i file looks like this > >>> > >>> %module(directors="1") mymod > >>> %{ > >>> #include "rubywrapper_swig.h" > >>> %} > >>> %feature("nodirector"); > >>> %feature("director") MyWorld::fun; > >>> class MyWorld{ > >>> public: > >>> MyWorld(); > >>> virtual ~MyWorld(); > >>> virtual void fun(); > >>> }; > >>> void myLoop(MyWorld* world); > >>> > >>> for testing purpose, no real loops in myLoop: > >>> > >>> void MyWorld::fun() {} > >>> void myLoop(MyWorld* world) { > >>> world->fun(); > >>> } > >>> > >>> and testing script is pretty simple > >>> > >>> require 'mymod' > >>> include Mymod > >>> class World < MyWorld > >>> def mainLogical > >>> puts 'testing...' > >>> end > >>> end > >>> world = World.new > >>> mainLoop(world) > >>> > >>> So, I expect a ''testing...' print rather than nothing, but I got > >>> nothing... > >>> I'm using ruby 1.9.2, swigwin 2.0.2 > >>> please tell me what's wrong? > >>> Thanks > >>> > >> > >> You have directors turned off by default as you have > >> %feature("nodirector"); > >> In particular, directors are turned off the MyWorld class. If you want > >> very selective directors, add in: > >> > >> %feature("director") MyWorld; > >> > >> to what you already have. > >> > >> William > >> > > > --_5f0909e4-c60f-4a42-99a1-0701ca03feec_--