ruby function calling c

J

Justin Turney

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
 
E

Eric Hodel

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.
 
L

Laurent Sansonetti

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top