From: 'cduck' Chris Grierson Date: 2002-01-29T06:20:49+09:00 Subject: Re: C API/method arguments so chalk that up as a newbie not reading the documentation well enough sorry, i learned most of ruby in one night and the C API the next day. everything kind of blurred together from the overload. apologies. guy, thank you very much, though, for answering the question directly regardless. -c [ Structural Informatics Group ] [ Dept. of Biological Structure ] [ University of Washington ] [ 206.616.7356:office ] [ 206.795.4998:cell ] ------------------------------------------------------------------------ On Tue, 29 Jan 2002, ts wrote: > >>>>> "C" == C Grierson writes: > > C> i hope i'm not being a complete list newbie, but i was wondering if > C> anyone could share any resources for programming in the C API. i > C> managed to write a cracklib interface class, but i realized i don't > C> know how to deal with variable arguments and my 'initialize' insists > C> on one parameter. > > Well, you have in README.EXT > > ------------------------------------------------------------ > > ** Method Definition > > rb_define_method(VALUE klass, const char *name, VALUE (*func)(), int argc) > > Defines a method for the class. func is the function pointer. argc > is the number of arguments. if argc is -1, the function will receive > 3 arguments argc, argv, and self. if argc is -2, the function will > receive 2 arguments, self and args, where args is the Ruby array of > the method arguments. > > ------------------------------------------------------------ > > > This mean that you can write > > static VALUE > tt_init(argc, argv, obj) > int argc; > VALUE *argv, obj; > { > } > > ... > > rb_define_method(tt_cTT, "initialize", tt_init, -1); > > ... > > > when tt_init() is called argc is the number of arguments given to it. > > > Guy Decoux >