debugging ruby extensions

  • Thread starter Elias Athanasopoulos
  • Start date
E

Elias Athanasopoulos

Hello!

Is there a handy function to display messages to stdout/sterr inside
a ruby extension.

I thougth that:

if ((RARRAY(x) == NULL) || (RARRAY(y) == NULL))
{
rb_warn ("2nd and 3rd parameter must be arrays!\n");
return Qnil;
}

Would do such a thing.

BTW, is this a nice way to determine if an argument to a method
is an array of objects?

Regards,
 
E

Elias Athanasopoulos

Hello!

I would probably use the Check_Type() macro:

Check_Type(obj, T_ARRAY);

which raises a TypeError exception if obj is not an Array. If you want
more control over how the error is reported, instead do something like:

if (TYPE(obj) != T_ARRAY) {
/* report error here */
}

Thank you. It is what I wanted. I just found Check_Type()
function.

Sorry for the noise.

Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top