From: Ryan Davis Date: 2007-07-17T11:29:01+09:00 Subject: Re: C library extension question On Jul 16, 2007, at 19:00 , Francis Cianfrocca wrote: > On 7/16/07, Oliver wrote: >> >> probably I didn't make myself clear: >> >> Under normal usage, the library expects user to supply some functions >> in C, such as func_a(), func_b(), through function pointers >> defined in >> above dispatch command structure. >> >> Now, from a wrapper stand point of view, I was hoping that the user- >> provided function func_a(), func_b() etc. can be done by ruby as well >> - it will be very awkward for a user to use partial c, partial ruby >> for the same library. I don't see why rb_funcall() can help in this >> case - in a sense, this case calls for a way to map ruby function >> into >> C function, for the sake of using the C library call. > > Write func_a, func_b, func_c as C functions that massage their > arguments > into Rubyland and call rb_funcall to hit the user-written Ruby > functions. > Similarly massage the return values from Ruby back into C values. Except that he wants the users to write func_[a-c] in ruby, to be invoked by C, via c function pointers. It is that last teeny requirement that I think blows this up.