E
Eric Hofreiter
--0-822842872-1131850184=:77918
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Well, it turns out writing C extensions wasn't as easy as I had originall=
y thought, and for only one reason: poor documentation. Maybe I'm missin=
g something though, does anyone know where the ruby API is documented?
=20
If not, there are two specific questions that need answering. First, how=
would I retrieve a class name into a variable using rb_const_get(VALUE, =
ID)? I tried something like VALUE StringClass =3D rb_const_get(rb_cObjec=
t, rb_intern("MyClass")), but I kept getting compile errors like "initial=
izer is not a constant." Second, how exactly should you use rb_define_me=
thod with an arg count of -1? I tried making a function like func(VALUE =
argc, VALUE *argv, VALUE), but when I call it from ruby like func(1, 1, 1=
, 1), I get an arg count of 2. It seems that the arg count is getting a =
count of only half the actual number arguments rounded down. The args ar=
e still getting passed into argv, but it would be nice to be able to chec=
k the arg count without being off by one. One final thing (I guess you c=
ould call this a third question). What is wrong with the line rb_require=
("myfile")? It says there should be a ')' before the string as well as a=
'{'. There is also an '<Unkown>' error and
another misplaced '(' error. Thanks a ton for any help; I really wish t=
his API were actually documented. At all.
=09
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
Well, it turns out writing C extensions wasn't as easy as I had originall=
y thought, and for only one reason: poor documentation. Maybe I'm missin=
g something though, does anyone know where the ruby API is documented?
=20
If not, there are two specific questions that need answering. First, how=
would I retrieve a class name into a variable using rb_const_get(VALUE, =
ID)? I tried something like VALUE StringClass =3D rb_const_get(rb_cObjec=
t, rb_intern("MyClass")), but I kept getting compile errors like "initial=
izer is not a constant." Second, how exactly should you use rb_define_me=
thod with an arg count of -1? I tried making a function like func(VALUE =
argc, VALUE *argv, VALUE), but when I call it from ruby like func(1, 1, 1=
, 1), I get an arg count of 2. It seems that the arg count is getting a =
count of only half the actual number arguments rounded down. The args ar=
e still getting passed into argv, but it would be nice to be able to chec=
k the arg count without being off by one. One final thing (I guess you c=
ould call this a third question). What is wrong with the line rb_require=
("myfile")? It says there should be a ')' before the string as well as a=
'{'. There is also an '<Unkown>' error and
another misplaced '(' error. Thanks a ton for any help; I really wish t=
his API were actually documented. At all.
=09