I’m trying to wrap up a library, and one of its functions accepts a
callback function as an argument. What I want to do is to make the
function exported to ruby accept a block, and yield this block on the
callback function. So, to do that, I guess what I need is some way to do
the equivalent of
def foo(&block)
…
end
in C, ie, store the code block in a variable so I can pass it around.
I could make my code work using a Proc object explicitely as one of the
C function’s arguments, as in
static VALUE
my_func(…, VALUE block)
{
…
func_with_callback(…, my_callback, (void *)block);
…
}