From 322d2ff58af0c0a745e516abffa207e759faec63 Mon Sep 17 00:00:00 2001 From: Brian Ford Date: Tue, 3 Jul 2012 16:31:06 -0700 Subject: [PATCH] Added rb_frame_this_func. --- vm/capi/18/include/ruby.h | 3 +++ vm/capi/19/include/ruby/ruby.h | 3 +++ vm/capi/module.cpp | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/vm/capi/18/include/ruby.h b/vm/capi/18/include/ruby.h index cbaee90622..41dc8f9755 100644 --- a/vm/capi/18/include/ruby.h +++ b/vm/capi/18/include/ruby.h @@ -1114,6 +1114,9 @@ VALUE rb_uint2big(unsigned long number); /** Return name of the function being called */ ID rb_frame_last_func(); + /** Return name of the current Ruby method */ + ID rb_frame_this_func(); + VALUE rb_exec_recursive(VALUE (*func)(VALUE, VALUE, int), VALUE obj, VALUE arg); diff --git a/vm/capi/19/include/ruby/ruby.h b/vm/capi/19/include/ruby/ruby.h index 3da4668db3..bf626a4a5e 100644 --- a/vm/capi/19/include/ruby/ruby.h +++ b/vm/capi/19/include/ruby/ruby.h @@ -1233,6 +1233,9 @@ VALUE rb_uint2big(unsigned long number); /** Return name of the function being called */ ID rb_frame_last_func(); + /** Return name of the current Ruby method */ + ID rb_frame_this_func(); + VALUE rb_exec_recursive(VALUE (*func)(VALUE, VALUE, int), VALUE obj, VALUE arg); diff --git a/vm/capi/module.cpp b/vm/capi/module.cpp index 6d9e3a4595..7e665ddf85 100644 --- a/vm/capi/module.cpp +++ b/vm/capi/module.cpp @@ -48,6 +48,14 @@ extern "C" { return env->get_handle(rcf->name()); } + ID rb_frame_this_func() { + NativeMethodEnvironment* env = NativeMethodEnvironment::get(); + + CallFrame* rcf = env->current_call_frame()->top_ruby_frame(); + + return env->get_handle(rcf->name()); + } + static VALUE const_missing(VALUE klass, ID id) { return rb_funcall(klass, rb_intern("const_missing"), 1, ID2SYM(id)); }