Berger, Daniel
8/28/2006 7:49:00 PM
Daniel Berger wrote:
> Tilman Sauerbeck wrote:
>> Daniel Berger [2006-08-29 01:41]:
>>
>> Hi Daniel,
>> I never worked with blocks in a C extension like you do, but I noticed a
>> general problem in your code:
>>
>>> static VALUE foo_block(VALUE self){
>>> return rb_funcall(cFoo, rb_intern("new"), 0, rb_yield(self));
>> ^
>> You're passing one argument (the result of rb_yield()), yet you tell
>> ruby to expect zero arguments. So make that 0 a 1.
>>
>>
>>> static VALUE kernel_foo(VALUE self){
>>> VALUE v_proc = rb_proc_new(foo_block, self); /* Also tried Qnil */
>>> return rb_funcall(rb_cObject, rb_intern("instance_eval"), 0, v_proc);
>>
>> Some problem here.
>>
>> HTH,
>> Tilman
>
> Ok, fixing that I get "can't convert Proc into String (TypeError)".
>
> Maybe I'm supposed to be using rb_block_proc, but I'm not entirely
> certain how it works.
>
> Thanks,
>
> Dan
>
I guess I was over thinking it. This function works by itself:
static VALUE kernel_foo(VALUE self){
return rb_funcall(cFoo, rb_intern("new"), 1, rb_yield(rb_block_proc()));
}
Regards,
Dan
This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.