8341.patch

Kazuki Tsujimoto, 06/16/2013 03:29 AM

Download (2.32 KB)

View differences:

include/ruby/intern.h
380 380
VALUE rb_obj_method(VALUE, VALUE);
381 381
VALUE rb_obj_is_method(VALUE);
382 382
VALUE rb_method_call(int, VALUE*, VALUE);
383
VALUE rb_method_call_with_block(int, VALUE *, VALUE, VALUE);
383 384
int rb_mod_method_arity(VALUE, ID);
384 385
int rb_obj_method_arity(VALUE, ID);
385 386
VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*);
proc.c
28 28
VALUE rb_cBinding;
29 29
VALUE rb_cProc;
30 30

  
31
static VALUE bmcall(VALUE, VALUE);
31
static VALUE bmcall(VALUE, VALUE, int, VALUE *, VALUE);
32 32
static int method_arity(VALUE);
33 33
static int method_min_max_arity(VALUE, int *max);
34 34
#define attached id__attached__
......
1593 1593
VALUE
1594 1594
rb_method_call(int argc, VALUE *argv, VALUE method)
1595 1595
{
1596
    VALUE proc = rb_block_given_p() ? rb_block_proc() : Qnil;
1597
    return rb_method_call_with_block(argc, argv, method, proc);
1598
}
1599

  
1600
VALUE
1601
rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procval)
1602
{
1596 1603
    VALUE result = Qnil;	/* OK */
1597 1604
    struct METHOD *data;
1598 1605
    int state;
......
1612 1619
    }
1613 1620
    if ((state = EXEC_TAG()) == 0) {
1614 1621
	rb_thread_t *th = GET_THREAD();
1622
	rb_block_t *block = 0;
1623

  
1624
	if (!NIL_P(pass_procval)) {
1625
	    rb_proc_t *pass_proc;
1626
	    GetProcPtr(pass_procval, pass_proc);
1627
	    block = &pass_proc->block;
1628
	}
1615 1629

  
1616
	PASS_PASSED_BLOCK_TH(th);
1630
	th->passed_block = block;
1617 1631
	result = rb_vm_call(th, data->recv, data->id,  argc, argv, data->me, data->defined_class);
1618 1632
    }
1619 1633
    POP_TAG();
......
2062 2076
}
2063 2077

  
2064 2078
static VALUE
2065
bmcall(VALUE args, VALUE method)
2079
bmcall(VALUE args, VALUE method, int argc, VALUE *argv, VALUE passed_proc)
2066 2080
{
2067 2081
    volatile VALUE a;
2068 2082
    VALUE ret;
2069
    int argc;
2070 2083

  
2071 2084
    if (CLASS_OF(args) != rb_cArray) {
2072 2085
	args = rb_ary_new3(1, args);
......
2075 2088
    else {
2076 2089
	argc = check_argc(RARRAY_LEN(args));
2077 2090
    }
2078
    ret = rb_method_call(argc, RARRAY_PTR(args), method);
2091
    ret = rb_method_call_with_block(argc, RARRAY_PTR(args), method, passed_proc);
2079 2092
    RB_GC_GUARD(a) = args;
2080 2093
    return ret;
2081 2094
}