From: Robert Klemme Date: 2009-03-30T02:54:57+09:00 Subject: Re: Passing block in C On 29.03.2009 18:23, Peter Zotov wrote: > Quoting "Robert Klemme" : > >> On 29.03.2009 17:58, Peter Zotov wrote: >>> Quoting Phlip : >>> >>>> Peter Zotov wrote: >>>> >>>>> How can I call Ruby function from C with block? >>>>> E. g. >>>>> >>>>> VALUE block = rb_proc_new(...); >>>>> rb_funcall_with_block(cMyClass, rb_intern("initialize"), 0, block); >>>> Let me Google that for you! >>>> >>>> http://www.google.com/codesearch?q=rb_proc_new >>> Ehm. I meant 'what function must be in place of >>> rb_funcall_with_block'. I _know_ how do rb_proc_new work. >> I think that Phlip understood this. If you look at the results >> you'll find this >> >> http://www.google.com/codesearch/p?hl=de#X2brleciKjw/trunk/devel/RubyClass.cpp&q=rb_proc_new >> >> Which proves that his suggested search was indeed helpful. :-) > > It isn't. See RubyDoc: > > ObjectSpace.define_finalizer(obj, aProc=proc()) > Adds aProc as a finalizer, to be called after obj was destroyed. > > Notice the aProc is an argument, not block. > So that code is analogue for Ruby > method(object, proc { some_code }) > and I need > method(object) { some_code} Right, stupid me. Should have looked more closely. My apologies for the unnecessary noise. rb_iterate seems indeed the proper method: http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html#S8 Kind regards robert