How to export classes from C extensions to Ruby?

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

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 =3D rb_define_class("MyProjectError", rb_eStandardError);
class_url_parsing_error =3D rb_define_class("URLParsingError", class_erro=
r);
}

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" :)

Thanks.



--=20
I=C3=B1aki Baz Castillo
<[email protected]>
 
I

Iñaki Baz Castillo

2009/10/30 I=C3=B1aki Baz Castillo said:
void Init_utils() {
=C2=A0...
=C2=A0// Create a exception XDMSURLParsingError.
=C2=A0class_error =3D rb_define_class("MyProjectError", rb_eStandardError= );
=C2=A0class_url_parsing_error =3D rb_define_class("URLParsingError", clas= s_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" :)

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.
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top