1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

rb_proc_new / rb_fiber_new now free from ANYARGS

After 5e86b005c0, 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.
This commit is contained in:
卜部昌平 2019-08-26 15:35:28 +09:00
parent af5e256640
commit bc3e7924bc
5 changed files with 13 additions and 13 deletions

2
cont.c
View file

@ -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);
}

View file

@ -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;

2
gc.c
View file

@ -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;

View file

@ -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);

16
proc.c
View file

@ -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));