From: Simon Krahnke Date: 2008-04-24T21:35:04+09:00 Subject: Re: Calling C functions from Embedded Ruby Interpreter * Mohit Sindhwani (13:06) schrieb: > I know the subject line is quite a mouthful! Sorry about that. I don't see anything wrong in the subject line. > I've managed to embed a Ruby interpreter into my application and I can > call Ruby functions from the code in my application. It works fine and > returns results to me as expected. I can also ask it to run a script > for me. Grats. > set_default_color(0x00ff0000) > set_screen_size(800,600) > ..and so on. > > Now, as I understand it, in my application, I need to these C functions > in it: > VALUE set_default_color (VALUE color) > VALUE set_screen_size (VALUE w, VALUE h) > .. and so on. > > I just don't know what to do next! Well, the Pickaxe has a chapter on this stuff. Try rb_define_global_function("set_default_color", &set_default_color, 1) There also is rb_define_module_function(VALUE model, char *name, VALUE(*func)(), int argc) and rb_define_singleton_method taking the same arguments. I never tried any of these, and don't quit know how to tell a module function from a singleton function from a system function. (The last one is in Kernel, the other two can be in any module or class.) mfg, simon .... l