[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

what is the ruby C API equivalent of this...

jrmair

8/9/2008 11:42:00 AM

Hello friends,

I'm having a hard time implementing the equivalent of this in the ruby
C API:

module M
module_function
def run(&block)
module_eval(&block)
end
end


How is the &block operation implemented in the C API? im looking for
something to convert a proc to a
block. i've scanned many of the .c files and have found nothing.
Anyone have any ideas?

cheers

John
1 Answer

Tim Pease

8/9/2008 2:51:00 PM

0

On Aug 9, 2008, at 5:43 AM, jrmair@gmail.com wrote:

> Hello friends,
>

Hi!

> I'm having a hard time implementing the equivalent of this in the ruby
> C API:
>
> module M
> module_function
> def run(&block)
> module_eval(&block)
> end
> end
>
>
> How is the &block operation implemented in the C API? im looking for
> something to convert a proc to a
> block. i've scanned many of the .c files and have found nothing.
> Anyone have any ideas?
>

static VALUE
m_run( VALUE module )
{
if (rb_block_given_p()) {
rb_mod_module_eval(0, 0, module);
}
return Qnil;
}


VALUE module = rb_define_module("M");
rb_define_module_function( module, "run", m_run, 0 );



Blessings,
TwP