Hi folks,
I’m trying to figure out how to call a ruby method from C while passing
in a block. I read the ruby-talk [27774] thread from way back; it was
sort of useful, but it wasn’t clear when I read that how it applies to
what I want to do: I have no problem getting and using a block passed
into a C extension FROM ruby; going the other way seems a little more
arcane–rb_iterate doesn’t seem to do what I want, but maybe somebody
can convince me otherwise.
Basically, I have:
VALUE obj = … some ruby object …;
VALUE proc = … some ruby proc object …;
ID method = … some ruby method id …;
Now, I just want to do the equivelent of:
obj.method(&proc)
Something like this imaginary function:
rb_funcall2_with_block(obj, method, 0, 0, proc);
···
–
Wesley J. Landaker - wjl@icecavern.net
OpenPGP FP: C99E DF40 54F6 B625 FD48 B509 A3DE 8D79 541F F830
Hi,
with_block.c (1.44 KB)
test.rb (210 Bytes)
block_pass.diff (2.13 KB)
···
At Mon, 9 Jun 2003 06:25:59 +0900, Wesley J Landaker wrote:
VALUE obj = … some ruby object …;
VALUE proc = … some ruby proc object …;
ID method = … some ruby method id …;
Now, I just want to do the equivelent of:
obj.method(&proc)
Something like this imaginary function:
rb_funcall2_with_block(obj, method, 0, 0, proc);
It’s not impossible, but I guess a new function would be
necessary, considering about avalue/svalue.
Thanks for the response. =) I worked around it by using rb_eval_string,
but I’ll try using the patches you posted and see what I can get
working here!
···
On Sunday 08 June 2003 8:01 pm, nobu.nokada@softhome.net wrote:
Hi,
At Mon, 9 Jun 2003 06:25:59 +0900, > > Wesley J Landaker wrote:
VALUE obj = … some ruby object …;
VALUE proc = … some ruby proc object …;
ID method = … some ruby method id …;
Now, I just want to do the equivelent of:
obj.method(&proc)
Something like this imaginary function:
rb_funcall2_with_block(obj, method, 0, 0, proc);
It’s not impossible, but I guess a new function would be
necessary, considering about avalue/svalue.
–
Wesley J. Landaker - wjl@icecavern.net
OpenPGP FP: C99E DF40 54F6 B625 FD48 B509 A3DE 8D79 541F F830