ruby function calling c

Discussion in 'Ruby' started by Justin Turney, Nov 21, 2007.

  1. 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-forum.com/.
     
    Justin Turney, Nov 21, 2007
    #1
    1. Advertisements

  2. Justin Turney

    Eric Hodel Guest

    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
     
    Eric Hodel, Nov 21, 2007
    #2
    1. Advertisements

  3. On Nov 21, 2007 3:49 PM, 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=?
    >


    See rb_frame_last_func().

    Laurent
     
    Laurent Sansonetti, Nov 21, 2007
    #3
  4. Justin Turney, Nov 21, 2007
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    728
  2. Andreas Lagemann
    Replies:
    8
    Views:
    754
    Mike Wahler
    Jan 10, 2005
  3. tiwy
    Replies:
    0
    Views:
    614
  4. NoWonder
    Replies:
    2
    Views:
    385
    Matthias Kaeppler
    Apr 9, 2005
  5. Satish Chimakurthi

    Function calling another function

    Satish Chimakurthi, Mar 1, 2004, in forum: Python
    Replies:
    2
    Views:
    484
    Satish Chimakurthi
    Mar 1, 2004
  6. Pyenos
    Replies:
    5
    Views:
    579
    Bruno Desthuilliers
    Dec 23, 2006
  7. Deniz Bahar
    Replies:
    43
    Views:
    1,234
    Gordon Burditt
    Mar 2, 2005
  8. anne001
    Replies:
    1
    Views:
    980
Loading...