[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

debugging ruby extensions

Elias Athanasopoulos

11/10/2003 6:08:00 PM

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,
--
University of Athens I bet the human brain
Physics Department is a kludge --Marvin Minsky



2 Answers

Lyle Johnson

11/10/2003 6:15:00 PM

0

Elias Athanasopoulos wrote:

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

How about fprintf()? ;)

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

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 */
}

Hope this helps,

Lyle

Elias Athanasopoulos

11/10/2003 6:19:00 PM

0

Hello!

On Mon, Nov 10, 2003 at 12:14:36PM -0600, Lyle Johnson wrote:
> 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,
--
University of Athens I bet the human brain
Physics Department is a kludge --Marvin Minsky