diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-10 16:33:51 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-10 16:33:51 +0000 |
commit | ed4139e39bb3ceda2985b2ea2ebd9a91479d25da (patch) | |
tree | 5d3dd4ee2335a7dc1fc437e8dd8fc01e4b22774d | |
parent | 8b7a284b65cdc1ebb71cff34db473af1b17390d1 (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
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | eval_jump.c | 2 | ||||
-rw-r--r-- | include/ruby/intern.h | 3 | ||||
-rw-r--r-- | include/ruby/ruby.h | 2 | ||||
-rw-r--r-- | proc.c | 30 | ||||
-rw-r--r-- | thread.c | 15 | ||||
-rw-r--r-- | version.h | 6 | ||||
-rw-r--r-- | vm_insnhelper.c | 12 |
8 files changed, 56 insertions, 22 deletions
@@ -1,3 +1,11 @@ +Wed Jun 11 01:28:12 2008 Koichi Sasada <[email protected]> + + * 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. + Tue Jun 10 21:07:19 2008 Kazuhiro NISHIYAMA <[email protected]> * test/ruby/test_float.rb: add tests. [ruby-dev:35009] diff --git a/eval_jump.c b/eval_jump.c index 7d394f431d..f474844ba8 100644 --- a/eval_jump.c +++ b/eval_jump.c @@ -10,7 +10,7 @@ void rb_call_end_proc(VALUE data) { - rb_proc_call(data, rb_ary_new(), 0); + rb_proc_call(data, rb_ary_new()); } /* diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 18f6ac9e1d..9f8e444b04 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -272,7 +272,8 @@ VALUE rb_class_new_instance(int, VALUE*, VALUE); VALUE rb_block_proc(void); VALUE rb_f_lambda(void); VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE); -VALUE rb_proc_call(VALUE, VALUE, rb_blockptr); +VALUE rb_proc_call(VALUE, VALUE); +VALUE rb_proc_call_with_block(VALUE, int argc, VALUE *argv, VALUE); int rb_proc_arity(VALUE); VALUE rb_binding_new(void); VALUE rb_obj_method(VALUE, VALUE); diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 799fc1e712..5bae5d392d 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -824,8 +824,6 @@ PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2); PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2); PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4); -typedef struct rb_block_struct *rb_blockptr; - typedef VALUE rb_block_call_func(VALUE, VALUE, int, VALUE*); VALUE rb_each(VALUE); @@ -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); + } } /* @@ -3079,6 +3079,7 @@ call_trace_proc(VALUE args, int tracing) struct call_trace_func_args *p = (struct call_trace_func_args *)args; VALUE eventname = rb_str_new2(get_event_name(p->event)); VALUE filename = rb_str_new2(rb_sourcefile()); + VALUE argv[6]; int line = rb_sourceline(); ID id = 0; VALUE klass = 0; @@ -3101,11 +3102,15 @@ call_trace_proc(VALUE args, int tracing) klass = rb_iv_get(klass, "__attached__"); } } - return rb_proc_call(p->proc, rb_ary_new3(6, - eventname, filename, INT2FIX(line), - id ? ID2SYM(id) : Qnil, - p->self ? rb_binding_new() : Qnil, - klass ? klass : Qnil), 0); + + argv[0] = eventname; + argv[1] = filename; + argv[2] = INT2FIX(line); + argv[3] = id ? ID2SYM(id) : Qnil; + argv[4] = p->self ? rb_binding_new() : Qnil; + argv[5] = klass ? klass : Qnil; + + return rb_proc_call_with_block(p->proc, 6, argv, Qnil); } static void @@ -1,7 +1,7 @@ #define RUBY_VERSION "1.9.0" -#define RUBY_RELEASE_DATE "2008-06-10" +#define RUBY_RELEASE_DATE "2008-06-11" #define RUBY_VERSION_CODE 190 -#define RUBY_RELEASE_CODE 20080610 +#define RUBY_RELEASE_CODE 20080611 #define RUBY_PATCHLEVEL 0 #define RUBY_VERSION_MAJOR 1 @@ -9,7 +9,7 @@ #define RUBY_VERSION_TEENY 0 #define RUBY_RELEASE_YEAR 2008 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 10 +#define RUBY_RELEASE_DAY 11 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; diff --git a/vm_insnhelper.c b/vm_insnhelper.c index b7dbbd2fe4..05555427dc 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -655,8 +655,7 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block, const rb_block_t *blockptr) { NODE *ifunc = (NODE *) block->iseq; - VALUE val; - VALUE arg; + VALUE val, arg, blockarg; int lambda = block_proc_is_lambda(block->proc); if (lambda) { @@ -669,11 +668,18 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block, arg = argv[0]; } + if (blockptr) { + blockarg = vm_make_proc(th, th->cfp, blockptr); + } + else { + blockarg = Qnil; + } + vm_push_frame(th, 0, FRAME_MAGIC_IFUNC, self, (VALUE)block->dfp, 0, th->cfp->sp, block->lfp, 1); - val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockptr); + val = (*ifunc->nd_cfnc) (arg, ifunc->nd_tval, argc, argv, blockarg); th->cfp++; return val; |