From: <koe...@pa...> - 2009-02-21 12:51:23
|
William, Thanks for the suggestion but I already tried that and it does not work. The problem seems to be that Ruby creates an instance of a class that inherits from the Ruby Animal class but not from the C++ Animal class. It may not even have anything to do with directors. Any help is welcome, thanks for your feedback. Cheers, Koen. >----- Oorspronkelijk bericht ----- >Van : William S Fulton [mailto:ws...@fu...] >Verzonden : vrijdag , februari 20, 2009 08:25 PM >Aan : koe...@pa... >CC : swi...@li... >Onderwerp : Re: [Swig-user] Polymorphism across C++ and Ruby using SWIG > >koe...@pa... wrote: >> Hi, >> >> I use SWIG to wrap a Ruby script around a C++ library. In Ruby, I can inherit from a C++ class from the library, and extend it with new functionality in Ruby. I can create new instances for this new class, but I cannot pass a pointer to such an instance into a C++ function that expects a pointer to the original C++ base class. I'm guessing that SWIG does not generate vtables ;-) >> >> You can find an example of my problem on stackoverflow (http://stackoverflow.com/questions/549249/polymorphism-across-c-and-ruby-using-swig). I hope somebody can point me to an elegant solution. >> > >You havn't turned on directors for the class, replace > >%feature("director") Animal::sound; > >with > >%feature("director") Animal; > >That should then give you the behaviour you want? > >William > > |