summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-30 03:21:51 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-30 03:21:51 +0000
commit446bb33fa30f6339b3c20a36db0280315621dfd1 (patch)
tree27918189b034b20e66cb814aaca5a498e295f499 /proc.c
parente561fc44a4cc28984ad5b8f484214df5a7b02ca3 (diff)
merge revision(s) 54909,55531: [Backport #12531]
proc.c: passed_block * proc.c (passed_block): extract conversion from passed proc value to rb_block_t pointer. * proc.c (passed_block): convert passed block symbol to proc. based on the patch by Daisuke Sato in [ruby-dev:49695]. [Bug #12531] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/proc.c b/proc.c
index 018b6709d1..5387298692 100644
--- a/proc.c
+++ b/proc.c
@@ -809,6 +809,20 @@ check_argc(long argc)
#define check_argc(argc) (argc)
#endif
+static rb_block_t *
+passed_block(VALUE pass_procval)
+{
+ if (!NIL_P(pass_procval)) {
+ rb_proc_t *pass_proc;
+ if (SYMBOL_P(pass_procval)) {
+ pass_procval = sym_proc_new(rb_cProc, pass_procval);
+ }
+ GetProcPtr(pass_procval, pass_proc);
+ return &pass_proc->block;
+ }
+ return 0;
+}
+
VALUE
rb_proc_call(VALUE self, VALUE args)
{
@@ -829,12 +843,7 @@ rb_proc_call_with_block(VALUE self, int argc, const VALUE *argv, VALUE pass_proc
rb_block_t *block = 0;
GetProcPtr(self, proc);
- if (!NIL_P(pass_procval)) {
- rb_proc_t *pass_proc;
- GetProcPtr(pass_procval, pass_proc);
- block = &pass_proc->block;
- }
-
+ block = passed_block(pass_procval);
vret = rb_vm_invoke_proc(GET_THREAD(), proc, argc, argv, block);
RB_GC_GUARD(self);
RB_GC_GUARD(pass_procval);
@@ -1981,15 +1990,8 @@ rb_method_call_with_block(int argc, const VALUE *argv, VALUE method, VALUE pass_
}
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;
- }
- th->passed_block = block;
+ th->passed_block = passed_block(pass_procval);
VAR_INITIALIZED(data);
result = rb_vm_call(th, data->recv, data->me->called_id, argc, argv, method_callable_method_entry(data));
}