How to export classes from C extensions to Ruby?

Hi, I’ve coded a Ruby C extension in which some exception classes are
created. However, those classes are not visible in Ruby itself.

This is, if for example I do a “irb”:

irb> require “myexten.so”

Then the exception classes don’t exist. But the functions in the C
extension can make use of them, raise them and so.

I create the classes as follows:

void Init_utils() {

// Create a exception XDMSURLParsingError.
class_error = rb_define_class(“MyProjectError”, rb_eStandardError);
class_url_parsing_error = rb_define_class(“URLParsingError”,
class_error);
}

Should I do something special to export these classes to Ruby? Of
course a workaround would be creating these classes also in Ruby, but
seems a bit “dirty” :slight_smile:

Thanks.

2009/10/30 Iñaki Baz C. [email protected]:

void Init_utils() {
 …
 // Create a exception XDMSURLParsingError.
 class_error = rb_define_class(“MyProjectError”, rb_eStandardError);
 class_url_parsing_error = rb_define_class(“URLParsingError”, class_error);
}

Should I do something special to export these classes to Ruby? Of
course a workaround would be creating these classes also in Ruby, but
seems a bit “dirty” :slight_smile:

Sorry, my fault. The class is visible but it’s not in the module I’ve
created so I ddin’t capture the correct exception.