diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-08-26 15:35:28 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-08-27 15:52:26 +0900 |
commit | bc3e7924bc66d3ef77b219c72f3e59cc154550a3 (patch) | |
tree | 44aed5a94d9d16dee2af0f92ed4653d6e2deb198 | |
parent | af5e2566405e4808a6d0a29c5b7d305d6fc0aada (diff) |
rb_proc_new / rb_fiber_new now free from ANYARGS
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is
dangerous and should be extinct. This commit deletes ANYARGS from
rb_proc_new / rb_fiber_new, and applies RB_BLOCK_CALL_FUNC_ARGLIST
wherever necessary.
-rw-r--r-- | cont.c | 2 | ||||
-rw-r--r-- | enumerator.c | 2 | ||||
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | include/ruby/intern.h | 4 | ||||
-rw-r--r-- | proc.c | 16 |
5 files changed, 13 insertions, 13 deletions
@@ -1770,7 +1770,7 @@ rb_fiber_initialize(int argc, VALUE* argv, VALUE self) } VALUE -rb_fiber_new(VALUE (*func)(ANYARGS), VALUE obj) +rb_fiber_new(rb_block_call_func_t func, VALUE obj) { return fiber_initialize(fiber_alloc(rb_cFiber), rb_proc_new(func, obj), &shared_fiber_pool); } diff --git a/enumerator.c b/enumerator.c index afc9ed94fa..96daad2b4b 100644 --- a/enumerator.c +++ b/enumerator.c @@ -713,7 +713,7 @@ next_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, obj)) } static VALUE -next_i(VALUE curr, VALUE obj) +next_i(RB_BLOCK_CALL_FUNC_ARGLIST(_, obj)) { struct enumerator *e = enumerator_ptr(obj); VALUE nil = Qnil; @@ -8867,7 +8867,7 @@ compat_key(VALUE key) } static VALUE -default_proc_for_compat_func(VALUE hash, VALUE dmy, int argc, VALUE *argv) +default_proc_for_compat_func(RB_BLOCK_CALL_FUNC_ARGLIST(hash, _)) { VALUE key, new_key; diff --git a/include/ruby/intern.h b/include/ruby/intern.h index 0aaeb82fb6..f3d3c29fbc 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -238,7 +238,7 @@ VALUE rb_singleton_class(VALUE); int rb_cmpint(VALUE, VALUE, VALUE); NORETURN(void rb_cmperr(VALUE, VALUE)); /* cont.c */ -VALUE rb_fiber_new(VALUE (*)(ANYARGS), VALUE); +VALUE rb_fiber_new(rb_block_call_func_t, VALUE); VALUE rb_fiber_resume(VALUE fib, int argc, const VALUE *argv); VALUE rb_fiber_yield(int argc, const VALUE *argv); VALUE rb_fiber_current(void); @@ -446,7 +446,7 @@ void rb_obj_call_init(VALUE, int, const VALUE*); VALUE rb_class_new_instance(int, const VALUE*, VALUE); VALUE rb_block_proc(void); VALUE rb_block_lambda(void); -VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE); +VALUE rb_proc_new(rb_block_call_func_t, VALUE); VALUE rb_obj_is_proc(VALUE); VALUE rb_proc_call(VALUE, VALUE); VALUE rb_proc_call_with_block(VALUE, int argc, const VALUE *argv, VALUE); @@ -2790,7 +2790,7 @@ bmcall(RB_BLOCK_CALL_FUNC_ARGLIST(args, method)) VALUE rb_proc_new( - VALUE (*func)(ANYARGS), /* VALUE yieldarg[, VALUE procarg] */ + rb_block_call_func_t func, VALUE val) { VALUE procval = rb_iterate(mproc, 0, func, val); @@ -2987,7 +2987,7 @@ proc_binding(VALUE self) return bindval; } -static VALUE curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc); +static rb_block_call_func curry; static VALUE make_curry_proc(VALUE proc, VALUE passed, VALUE arity) @@ -3007,7 +3007,7 @@ make_curry_proc(VALUE proc, VALUE passed, VALUE arity) } static VALUE -curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) +curry(RB_BLOCK_CALL_FUNC_ARGLIST(_, args)) { VALUE proc, passed, arity; proc = RARRAY_AREF(args, 0); @@ -3018,14 +3018,14 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) rb_ary_freeze(passed); if (RARRAY_LEN(passed) < FIX2INT(arity)) { - if (!NIL_P(passed_proc)) { + if (!NIL_P(blockarg)) { rb_warn("given block not used"); } arity = make_curry_proc(proc, passed, arity); return arity; } else { - return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_CONST_PTR(passed), passed_proc); + return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_CONST_PTR(passed), blockarg); } } @@ -3130,16 +3130,16 @@ rb_method_curry(int argc, const VALUE *argv, VALUE self) } static VALUE -compose(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) +compose(RB_BLOCK_CALL_FUNC_ARGLIST(_, args)) { VALUE f, g, fargs; f = RARRAY_AREF(args, 0); g = RARRAY_AREF(args, 1); if (rb_obj_is_proc(g)) - fargs = rb_proc_call_with_block(g, argc, argv, passed_proc); + fargs = rb_proc_call_with_block(g, argc, argv, blockarg); else - fargs = rb_funcall_with_block(g, idCall, argc, argv, passed_proc); + fargs = rb_funcall_with_block(g, idCall, argc, argv, blockarg); if (rb_obj_is_proc(f)) return rb_proc_call(f, rb_ary_new3(1, fargs)); |