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

rb_rescue / rb_rescue2 now free from ANYARGS

After 5e86b005c0, I now think ANYARGS is
dangerous and should be extinct.  This commit deletes ANYARGS from
rb_rescue / rb_rescue2, which revealed many arity / type mismatches.
This commit is contained in:
卜部昌平 2019-08-26 14:51:00 +09:00
parent 3cae73133c
commit 5c7c2d9951
8 changed files with 20 additions and 18 deletions

6
enum.c
View file

@ -2723,14 +2723,16 @@ zip_ary(RB_BLOCK_CALL_FUNC_ARGLIST(val, memoval))
} }
static VALUE static VALUE
call_next(VALUE *v) call_next(VALUE w)
{ {
VALUE *v = (VALUE *)w;
return v[0] = rb_funcallv(v[1], id_next, 0, 0); return v[0] = rb_funcallv(v[1], id_next, 0, 0);
} }
static VALUE static VALUE
call_stop(VALUE *v) call_stop(VALUE w, VALUE _)
{ {
VALUE *v = (VALUE *)w;
return v[0] = Qundef; return v[0] = Qundef;
} }

View file

@ -2231,7 +2231,7 @@ call_next(VALUE obj)
} }
static VALUE static VALUE
next_stopped(VALUE obj) next_stopped(VALUE obj, VALUE _)
{ {
return Qnil; return Qnil;
} }

8
eval.c
View file

@ -931,8 +931,8 @@ rb_need_block(void)
* \ingroup exception * \ingroup exception
*/ */
VALUE VALUE
rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1, rb_rescue2(VALUE (* b_proc) (VALUE), VALUE data1,
VALUE (* r_proc) (ANYARGS), VALUE data2, ...) VALUE (* r_proc) (VALUE, VALUE), VALUE data2, ...)
{ {
enum ruby_tag_type state; enum ruby_tag_type state;
rb_execution_context_t * volatile ec = GET_EC(); rb_execution_context_t * volatile ec = GET_EC();
@ -1003,8 +1003,8 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
* \ingroup exception * \ingroup exception
*/ */
VALUE VALUE
rb_rescue(VALUE (* b_proc)(ANYARGS), VALUE data1, rb_rescue(VALUE (* b_proc)(VALUE), VALUE data1,
VALUE (* r_proc)(ANYARGS), VALUE data2) VALUE (* r_proc)(VALUE, VALUE), VALUE data2)
{ {
return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError, return rb_rescue2(b_proc, data1, r_proc, data2, rb_eStandardError,
(VALUE)0); (VALUE)0);

View file

@ -140,7 +140,7 @@ static void gzfile_reset(struct gzfile*);
static void gzfile_close(struct gzfile*, int); static void gzfile_close(struct gzfile*, int);
static void gzfile_write_raw(struct gzfile*); static void gzfile_write_raw(struct gzfile*);
static VALUE gzfile_read_raw_partial(VALUE); static VALUE gzfile_read_raw_partial(VALUE);
static VALUE gzfile_read_raw_rescue(VALUE); static VALUE gzfile_read_raw_rescue(VALUE,VALUE);
static VALUE gzfile_read_raw(struct gzfile*, VALUE outbuf); static VALUE gzfile_read_raw(struct gzfile*, VALUE outbuf);
static int gzfile_read_raw_ensure(struct gzfile*, long, VALUE outbuf); static int gzfile_read_raw_ensure(struct gzfile*, long, VALUE outbuf);
static char *gzfile_read_raw_until_zero(struct gzfile*, long); static char *gzfile_read_raw_until_zero(struct gzfile*, long);
@ -2385,7 +2385,7 @@ gzfile_read_raw_partial(VALUE arg)
} }
static VALUE static VALUE
gzfile_read_raw_rescue(VALUE arg) gzfile_read_raw_rescue(VALUE arg, VALUE _)
{ {
struct read_raw_arg *ra = (struct read_raw_arg *)arg; struct read_raw_arg *ra = (struct read_raw_arg *)arg;
VALUE str = Qnil; VALUE str = Qnil;
@ -4888,5 +4888,3 @@ Init_zlib(void)
* Raised when the data length recorded in the gzip file footer is not equivalent * Raised when the data length recorded in the gzip file footer is not equivalent
* to the length of the actual uncompressed data. * to the length of the actual uncompressed data.
*/ */

View file

@ -1966,8 +1966,8 @@ int rb_block_given_p(void);
void rb_need_block(void); void rb_need_block(void);
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE); VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE);
VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE); VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE);
VALUE rb_rescue(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE); VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
VALUE rb_rescue2(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE,...); VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE); VALUE rb_ensure(VALUE(*)(ANYARGS),VALUE,VALUE(*)(ANYARGS),VALUE);
VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE); VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE);
VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE); VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE);

2
io.c
View file

@ -11457,7 +11457,7 @@ copy_stream_fallback(struct copy_stream_struct *stp)
rb_raise(rb_eArgError, "cannot specify src_offset for non-IO"); rb_raise(rb_eArgError, "cannot specify src_offset for non-IO");
} }
rb_rescue2(copy_stream_fallback_body, (VALUE)stp, rb_rescue2(copy_stream_fallback_body, (VALUE)stp,
(VALUE (*) (ANYARGS))0, (VALUE)0, (VALUE (*) (VALUE, VALUE))0, (VALUE)0,
rb_eEOFError, (VALUE)0); rb_eEOFError, (VALUE)0);
return Qnil; return Qnil;
} }

2
time.c
View file

@ -5204,7 +5204,7 @@ mload_zone(VALUE time, VALUE zone)
VALUE z, args[2]; VALUE z, args[2];
args[0] = time; args[0] = time;
args[1] = zone; args[1] = zone;
z = rb_rescue(mload_findzone, (VALUE)args, (VALUE (*)(ANYARGS))NULL, Qnil); z = rb_rescue(mload_findzone, (VALUE)args, 0, Qnil);
if (NIL_P(z)) return rb_fstring(zone); if (NIL_P(z)) return rb_fstring(zone);
if (RB_TYPE_P(z, T_STRING)) return rb_fstring(z); if (RB_TYPE_P(z, T_STRING)) return rb_fstring(z);
return z; return z;

View file

@ -322,16 +322,18 @@ struct rescue_funcall_args {
}; };
static VALUE static VALUE
check_funcall_exec(struct rescue_funcall_args *args) check_funcall_exec(VALUE v)
{ {
struct rescue_funcall_args *args = (void *)v;
return call_method_entry(args->ec, args->defined_class, return call_method_entry(args->ec, args->defined_class,
args->recv, idMethodMissing, args->recv, idMethodMissing,
args->me, args->argc, args->argv); args->me, args->argc, args->argv);
} }
static VALUE static VALUE
check_funcall_failed(struct rescue_funcall_args *args, VALUE e) check_funcall_failed(VALUE v, VALUE e)
{ {
struct rescue_funcall_args *args = (void *)v;
int ret = args->respond; int ret = args->respond;
if (!ret) { if (!ret) {
switch (rb_method_boundp(args->defined_class, args->mid, switch (rb_method_boundp(args->defined_class, args->mid,
@ -1075,7 +1077,7 @@ rb_yield_block(VALUE val, VALUE arg, int argc, const VALUE *argv, VALUE blockarg
} }
static VALUE static VALUE
loop_i(void) loop_i(VALUE _)
{ {
for (;;) { for (;;) {
rb_yield_0(0, 0); rb_yield_0(0, 0);