[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

ruby function calling c

Justin Turney

11/21/2007 2:49:00 PM

In this simple example, if I assign two Ruby functions to call the same
C function:

rb_define_method(m_rbTask, "prefix=", RUBYCAST(rb_prefix_set), 1);
rb_define_method(m_rbTask, "scratch=", RUBYCAST(rb_prefix_set), 1);

is there a way in rb_prefix_set to determine if the user used prefix= or
scratch=?

Thanks,
Justin
--
Posted via http://www.ruby-....

3 Answers

Eric Hodel

11/21/2007 9:14:00 PM

0

On Nov 21, 2007, at 06:49 , Justin Turney wrote:
> In this simple example, if I assign two Ruby functions to call the
> same
> C function:
>
> rb_define_method(m_rbTask, "prefix=", RUBYCAST(rb_prefix_set), 1);
> rb_define_method(m_rbTask, "scratch=", RUBYCAST(rb_prefix_set), 1);
>
> is there a way in rb_prefix_set to determine if the user used
> prefix= or
> scratch=?

def my_caller
caller[0][/`(.*)'/, 1]
end

And use rb_funcall() to call my_caller.

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars



Laurent Sansonetti

11/21/2007 9:19:00 PM

0

On Nov 21, 2007 3:49 PM, Justin Turney <jturney@ccqc.uga.edu> wrote:
> In this simple example, if I assign two Ruby functions to call the same
> C function:
>
> rb_define_method(m_rbTask, "prefix=", RUBYCAST(rb_prefix_set), 1);
> rb_define_method(m_rbTask, "scratch=", RUBYCAST(rb_prefix_set), 1);
>
> is there a way in rb_prefix_set to determine if the user used prefix= or
> scratch=?
>

See rb_frame_last_func().

Laurent

Justin Turney

11/21/2007 10:47:00 PM

0

Thanks for your help. This is exactly what I needed.

Justin

--
Posted via http://www.ruby-....