Calling a custom Ruby C extension method from other C extension

Hi, in my project I've created two Ruby C extensions:

  ext/my-exten/
  ext/string/

They create my-create.so and string.so.

string.so contains some custom methods I've added to class String
(i.e. String#headerize).
my-exten.so creates its own class and internally it needs to use the
String#headerize method by directly calling the C method in the string
extension (String_headerize).

So I suposse I must create a ext/string/string.h file declaring the C
function String_headerize, and use #include "../string/string.h"
within my-exten.c. This should work but, is there any other approach?
(note: I don't want to invoke a Ruby method from C code).

Thanks a lot.

···

--
Iñaki Baz Castillo
<ibc@aliax.net>

method 1:

in your my-exten use "extern String_headerize( args );"
and then you must require your string lib before yours

method 2:

if you not need the directly C method you chould use
rb_funcall(string,rb_intern(headerize),args ...);

···

--
Posted via http://www.ruby-forum.com/.

Thanks a lot. I prefer method 1 (as I expect is faster than method 2).

···

2011/4/20 Hans Mackowiak <hanmac@gmx.de>:

method 1:

in your my-exten use "extern String_headerize( args );"
and then you must require your string lib before yours

method 2:

if you not need the directly C method you chould use
rb_funcall(string,rb_intern(headerize),args ...);

--
Iñaki Baz Castillo
<ibc@aliax.net>