Hi. I’m working on a Ruby C++ extension, I have the following function, in which “self” object is either of structure type or of Exception type.
VALUE myFunction(VALUE self, VALUE args)
{
// Some functon call and process on args argument
}
Now in the above function I need to know the exact type of object “self” (i.e. rb_eException or rb_cStruct),
I tried using the following API,
if(Qtrue == rb_obj_is_kind_of(self, rb_eException))
{
std::cout<<"self is of rb_eException type "<<std::endl;
}
like above for rb_cStruct, rb_cClass etc but I’m getting only Qtrue for “rb_cClass” type.
How can I get the exact type of “self” object (i.e rb_cStruct or rb_eException)?
Thanks in advance.
You can get the class with
rb_obj_classwhich would be the appropriateVALUE.