[前][次][番号順一覧][スレッド一覧]

ruby-changes:57311

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 27 Aug 2019 16:18:38 +0900 (JST)
Subject: [ruby-changes:57311] 卜部昌平: af5e256640 (master): rb_catch now free from ANYARGS

https://git.ruby-lang.org/ruby.git/commit/?id=af5e256640

From af5e2566405e4808a6d0a29c5b7d305d6fc0aada Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Mon, 26 Aug 2019 15:27:48 +0900
Subject: rb_catch now free from ANYARGS

After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is
dangerous and should be extinct.  This commit deletes ANYARGS from
rb_catch, and fixes some bugs revealed by that.

diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
index cc0e865..ca74b80 100644
--- a/ext/racc/cparse/cparse.c
+++ b/ext/racc/cparse/cparse.c
@@ -212,7 +212,7 @@ static void extract_user_token _((struct cparse_params *v, https://github.com/ruby/ruby/blob/trunk/ext/racc/cparse/cparse.c#L212
                                   VALUE block_args, VALUE *tok, VALUE *val));
 static void shift _((struct cparse_params* v, long act, VALUE tok, VALUE val));
 static int reduce _((struct cparse_params* v, long act));
-static VALUE reduce0 _((VALUE block_args, VALUE data, VALUE self));
+static rb_block_call_func reduce0;
 
 #ifdef DEBUG
 # define D_puts(msg)        if (v->sys_debug) puts(msg)
@@ -708,7 +708,7 @@ reduce(struct cparse_params *v, long act) https://github.com/ruby/ruby/blob/trunk/ext/racc/cparse/cparse.c#L708
 }
 
 static VALUE
-reduce0(VALUE val, VALUE data, VALUE self)
+reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data))
 {
     struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
     VALUE reduce_to, reduce_len, method_id;
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index ae07322..86406ca 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1969,8 +1969,8 @@ VALUE rb_block_call(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1969
 VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);
 VALUE rb_rescue2(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE,...);
 VALUE rb_ensure(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE),VALUE);
-VALUE rb_catch(const char*,VALUE(*)(ANYARGS),VALUE);
-VALUE rb_catch_obj(VALUE,VALUE(*)(ANYARGS),VALUE);
+VALUE rb_catch(const char*,rb_block_call_func_t,VALUE);
+VALUE rb_catch_obj(VALUE,rb_block_call_func_t,VALUE);
 NORETURN(void rb_throw(const char*,VALUE));
 NORETURN(void rb_throw_obj(VALUE,VALUE));
 
diff --git a/vm_eval.c b/vm_eval.c
index e9045bb..8c7e01e 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1921,7 +1921,7 @@ rb_throw(const char *tag, VALUE val) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1921
 }
 
 static VALUE
-catch_i(VALUE tag, VALUE data)
+catch_i(RB_BLOCK_CALL_FUNC_ARGLIST(tag, _))
 {
     return rb_yield_0(1, &tag);
 }
@@ -1985,7 +1985,7 @@ rb_f_catch(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1985
 }
 
 VALUE
-rb_catch(const char *tag, VALUE (*func)(), VALUE data)
+rb_catch(const char *tag, rb_block_call_func_t func, VALUE data)
 {
     VALUE vtag = tag ? rb_sym_intern_ascii_cstr(tag) : rb_obj_alloc(rb_cObject);
     return rb_catch_obj(vtag, func, data);
@@ -2027,7 +2027,7 @@ rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_ty https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L2027
 }
 
 VALUE
-rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data)
+rb_catch_obj(VALUE t, rb_block_call_func_t func, VALUE data)
 {
     enum ruby_tag_type state;
     rb_execution_context_t *ec = GET_EC();
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]