From: "David A. Black" Date: 2008-04-27T21:29:51+09:00 Subject: [OT] MFG (was: Re: Calling C functions from Embedded Ruby Interpreter) --1926193751-2068270783-1209299391=:27442 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-2068270783-1209299391=:27442" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-2068270783-1209299391=:27442 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Hi -- On Sun, 27 Apr 2008, Mohit Sindhwani wrote: > Hi Simon > > First, my apologies on the late response. Thanks for your email relating= to=20 > my request. > > Simon Krahnke wrote: >> * Mohit Sindhwani (13:06) schrieb >>> I know the subject line is quite a mouthful! Sorry about that. >>>=20 >>=20 >> I don't see anything wrong in the subject line. >>=20 > Haha, thanks for that! > >>> I've managed to embed a Ruby interpreter into my application and I can= =20 >>> call Ruby functions from the code in my application. It works fine and= =20 >>> returns results to me as expected. I can also ask it to run a script f= or=20 >>> me. >>>=20 >>=20 >> Grats. >> >>=20 >>> set_default_color(0x00ff0000) >>> set_screen_size(800,600) >>> ..and so on. >>>=20 >>> Now, as I understand it, in my application, I need to these C functions= in=20 >>> it: >>> VALUE set_default_color (VALUE color) >>> VALUE set_screen_size (VALUE w, VALUE h) >>> .. and so on. >>>=20 >>> I just don't know what to do next! >>>=20 >>=20 >> Well, the Pickaxe has a chapter on this stuff. >>=20 >> Try >>=20 >> rb_define_global_function("set_default_color", &set_default_color, 1) >>=20 >> 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.) >> >>=20 > > Ya, actually wisdom strikes soon after one requests for help. I did find= the=20 > necessary stuff in one of the links that I had been staring at for a whil= e...=20 > and after that, it was easy enough to connect up the dots to get things= =20 > moving. > > Thanks for the example. I followed the procedure for defining a module a= nd=20 > then creating the functions within it. Not sure if I eventually want it = to=20 > be that way but I know enough now to keep exploring. > >> mfg, simon .... l >>=20 > > Might I ask what "mfg" stands for? Mit freundlichen Gr=C3=BC=C3=9Fen (with friendly greetings -- more or less = like "Best wishes"). David --=20 Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates! --1926193751-2068270783-1209299391=:27442-- --1926193751-2068270783-1209299391=:27442--