Project

General

Profile

Backport #8341 » 8341.patch

ktsj (Kazuki Tsujimoto), 06/16/2013 03:29 AM

View differences:

include/ruby/intern.h
VALUE rb_obj_method(VALUE, VALUE);
VALUE rb_obj_is_method(VALUE);
VALUE rb_method_call(int, VALUE*, VALUE);
VALUE rb_method_call_with_block(int, VALUE *, VALUE, VALUE);
int rb_mod_method_arity(VALUE, ID);
int rb_obj_method_arity(VALUE, ID);
VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*);
proc.c
VALUE rb_cBinding;
VALUE rb_cProc;
static VALUE bmcall(VALUE, VALUE);
static VALUE bmcall(VALUE, VALUE, int, VALUE *, VALUE);
static int method_arity(VALUE);
static int method_min_max_arity(VALUE, int *max);
#define attached id__attached__
......
VALUE
rb_method_call(int argc, VALUE *argv, VALUE method)
{
VALUE proc = rb_block_given_p() ? rb_block_proc() : Qnil;
return rb_method_call_with_block(argc, argv, method, proc);
}
VALUE
rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procval)
{
VALUE result = Qnil; /* OK */
struct METHOD *data;
int state;
......
}
if ((state = EXEC_TAG()) == 0) {
rb_thread_t *th = GET_THREAD();
rb_block_t *block = 0;
if (!NIL_P(pass_procval)) {
rb_proc_t *pass_proc;
GetProcPtr(pass_procval, pass_proc);
block = &pass_proc->block;
}
PASS_PASSED_BLOCK_TH(th);
th->passed_block = block;
result = rb_vm_call(th, data->recv, data->id, argc, argv, data->me, data->defined_class);
}
POP_TAG();
......
}
static VALUE
bmcall(VALUE args, VALUE method)
bmcall(VALUE args, VALUE method, int argc, VALUE *argv, VALUE passed_proc)
{
volatile VALUE a;
VALUE ret;
int argc;
if (CLASS_OF(args) != rb_cArray) {
args = rb_ary_new3(1, args);
......
else {
argc = check_argc(RARRAY_LEN(args));
}
ret = rb_method_call(argc, RARRAY_PTR(args), method);
ret = rb_method_call_with_block(argc, RARRAY_PTR(args), method, passed_proc);
RB_GC_GUARD(a) = args;
return ret;
}
(2-2/2)