Inheritance from C object with different parameter count

OK, thanks. At least I am a bit further. Maybe some effort should be invested in documenting the C extension process in clear detail, since it is always very confusing if you want to do things that are a bit more complicated. Are you aware of a good place where I can find detailed information?
Greetings,
Geert.

···

-----Original Message-----
From: Esteban Manchado Velázquez [mailto:zoso@foton.es]
Sent: Monday, January 30, 2006 9:44 PM
To: ruby-talk ML
Subject: Re: inheritance from C object with different parameter count

On Mon, Jan 30, 2006 at 06:12:13PM +0900, Geert Fannes wrote:

Hello,

I'm trying to create a derived class (ruby class) from a C-implemented
class. Everything works fine, until I tried to add a parameter to the
derived class. When I derive from a pure ruby base class, everything
works as should be, extra parameter or not. Does someone know what is
going on or what I am doing wrong?

    Hmmm... weird. If you comment the "super()" call in Derived#initialize, it
dies with the exact same error. In fact, you don't even get the "init derived"
message.

    After investigating a little, I found out that changing the definition of
new to:

    rb_define_singleton_method(cBase, "new", f_new0, -1);

makes it work. I don't know if that's entirely correct (I'm not very familiar
with C extensions), but it works :slight_smile: I guess the problem is that, as you don't
redefine the "new" method in the class Derived, you get the Base one, so it
chokes. I don't know if the usual thing here is always defining "new" methods
with any parameter count...

    HTH,

--
Esteban Manchado Velázquez <zoso@foton.es> - http://www.foton.es
EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es

Hi Geert,

···

On Tue, Jan 31, 2006 at 07:32:17PM +0900, Geert Fannes wrote:

OK, thanks. At least I am a bit further. Maybe some effort should be
invested in documenting the C extension process in clear detail, since it is
always very confusing if you want to do things that are a bit more
complicated. Are you aware of a good place where I can find detailed
information?

    Not me, sorry :frowning: The only places I know with information about C
extensions are The Pickaxe and README.EXT, which comes (perhaps _came_) with
the Ruby sources. I'm not exactly a C extension guy, you know :slight_smile:

--
Esteban Manchado Velázquez <zoso@foton.es> - http://www.foton.es
EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es