summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-10 16:33:51 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-10 16:33:51 +0000
commited4139e39bb3ceda2985b2ea2ebd9a91479d25da (patch)
tree5d3dd4ee2335a7dc1fc437e8dd8fc01e4b22774d /proc.c
parent8b7a284b65cdc1ebb71cff34db473af1b17390d1 (diff)
* include/ruby/intern.h, proc.c: revert rb_proc_call() and
create rb_proc_call_with_block() instaed. * include/ruby/ruby.h, eval_jump.c, thread.c, vm_insnhelper.c: rb_blockptr should not be exposed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/proc.c b/proc.c
index 5446c82815..f681f46bc9 100644
--- a/proc.c
+++ b/proc.c
@@ -507,12 +507,26 @@ proc_call(int argc, VALUE *argv, VALUE procval)
}
VALUE
-rb_proc_call(VALUE self, VALUE args, rb_blockptr blockptr)
+rb_proc_call(VALUE self, VALUE args)
{
rb_proc_t *proc;
GetProcPtr(self, proc);
return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
- RARRAY_LEN(args), RARRAY_PTR(args), blockptr);
+ RARRAY_LEN(args), RARRAY_PTR(args), 0);
+}
+
+VALUE
+rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
+{
+ rb_proc_t *proc, *pass_proc = 0;
+ GetProcPtr(self, proc);
+
+ if (!NIL_P(pass_procval)) {
+ GetProcPtr(pass_procval, pass_proc);
+ }
+
+ return vm_invoke_proc(GET_THREAD(), proc, proc->block.self,
+ argc, argv, &pass_proc->block);
}
/*
@@ -1584,7 +1598,7 @@ proc_binding(VALUE self)
return bindval;
}
-static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr);
+static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc);
static VALUE
make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
@@ -1600,7 +1614,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity)
}
static VALUE
-curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)
+curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
{
VALUE proc, passed, arity;
proc = RARRAY_PTR(args)[0];
@@ -1609,15 +1623,17 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, rb_blockptr blockptr)
passed = rb_ary_plus(passed, rb_ary_new4(argc, argv));
rb_ary_freeze(passed);
+
if(RARRAY_LEN(passed) < FIX2INT(arity)) {
- if (blockptr) {
+ if (!NIL_P(passed_proc)) {
rb_warn("given block not used");
}
arity = make_curry_proc(proc, passed, arity);
return arity;
}
- arity = rb_proc_call(proc, passed, blockptr);
- return arity;
+ else {
+ return rb_proc_call_with_block(proc, RARRAY_LEN(passed), RARRAY_PTR(passed), passed_proc);
+ }
}
/*