From: "Iñaki Baz Castillo" Date: 2012-05-29T00:47:47+09:00 Subject: Re: [C exte] rb_protect() with more than a single parameters Really interesting your approach :) Thanks a lot to both. 2012/5/25 Ammar Ali : > On Thu, May 24, 2012 at 8:59 PM, Iñaki Baz Castillo wrote: >> >> Ok, so if from C I want to call a Ruby method passing N VALUE >> parameters, should I really create a Ruby Array and pass it as _data_ >> in rb_protect() ?? really? is there any other way? > > > I did not find another way after searching for a while, including the source > of all the extensions I could get my hands on. I was a little surprised too. > > I ended up writing my own wrappers around rb_funcall and rb_funcall2, using > rb_rescue2. Here's a gist: > >   https://gist.github.com/2787174 > > These come from a program that embeds ruby, not an extension, so they were > written to suit those needs. For example, rescuing rb_eException might be > too broad, and registering/unregistering args with the GC might not be > necessary for all applications. I think this is most probably the reason why > ruby does not provide such functions. > > In any event, I've been meaning to put these snippets out there in a related > thread in hope they might help someone. I hope they help you in some way. I > would be very interested in any feedback you might have. > > Regards, > Ammar > -- Iñaki Baz Castillo