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

ruby-changes:57306

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 27 Aug 2019 15:54:10 +0900 (JST)
Subject: [ruby-changes:57306] 卜部昌平: 7329b3339a (master): #define RB_BLOCK_CALL_FUNC_STRICT 1

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

From 7329b3339adab12092056bd8159513645d4f9e8a 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 13:30:04 +0900
Subject: #define RB_BLOCK_CALL_FUNC_STRICT 1

After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is
dangerous and should be extinct.  Let's start from making
rb_block_call_func_t strict, and apply RB_BLOCK_CALL_FUNC_ARGLIST liberally.

diff --git a/enum.c b/enum.c
index bae32cb..665c97f 100644
--- a/enum.c
+++ b/enum.c
@@ -1535,7 +1535,7 @@ nmin_filter(struct nmin_data *data) https://github.com/ruby/ruby/blob/trunk/enum.c#L1535
 }
 
 static VALUE
-nmin_i(VALUE i, VALUE *_data, int argc, VALUE *argv)
+nmin_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, _data))
 {
     struct nmin_data *data = (struct nmin_data *)_data;
     VALUE cmpv;
@@ -1595,7 +1595,7 @@ rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary) https://github.com/ruby/ruby/blob/trunk/enum.c#L1595
 	for (i = 0; i < RARRAY_LEN(obj); i++) {
 	    VALUE args[1];
 	    args[0] = RARRAY_AREF(obj, i);
-	    nmin_i(obj, (VALUE*)&data, 1, args);
+            nmin_i(obj, (VALUE)&data, 1, args, Qundef);
 	}
     }
     else {
diff --git a/enumerator.c b/enumerator.c
index 6a2443f..beea1c7 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -1567,7 +1567,7 @@ lazy_init_block_i(RB_BLOCK_CALL_FUNC_ARGLIST(val, m)) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1567
 #define LAZY_MEMO_RESET_PACKED(memo) ((memo)->memo_flags &= ~LAZY_MEMO_PACKED)
 
 static VALUE
-lazy_init_yielder(VALUE val, VALUE m, int argc, VALUE *argv)
+lazy_init_yielder(RB_BLOCK_CALL_FUNC_ARGLIST(_, m))
 {
     VALUE yielder = RARRAY_AREF(m, 0);
     VALUE procs_array = RARRAY_AREF(m, 1);
@@ -1598,7 +1598,7 @@ lazy_init_yielder(VALUE val, VALUE m, int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1598
 }
 
 static VALUE
-lazy_init_block(VALUE val, VALUE m, int argc, VALUE *argv)
+lazy_init_block(RB_BLOCK_CALL_FUNC_ARGLIST(val, m))
 {
     VALUE procs = RARRAY_AREF(m, 1);
 
@@ -2860,7 +2860,7 @@ enum_chain_enum_size(VALUE obj, VALUE args, VALUE eobj) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L2860
 }
 
 static VALUE
-enum_chain_yield_block(VALUE arg, VALUE block, int argc, VALUE *argv)
+enum_chain_yield_block(RB_BLOCK_CALL_FUNC_ARGLIST(_, block))
 {
     return rb_funcallv(block, id_call, argc, argv);
 }
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 1bb4671..cf065e9 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1949,16 +1949,12 @@ PRINTF_ARGS(void rb_sys_warning(const char*, ...), 1, 2); https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1949
 COLDFUNC PRINTF_ARGS(void rb_warn(const char*, ...), 1, 2);
 PRINTF_ARGS(void rb_compile_warn(const char *, int, const char*, ...), 3, 4);
 
+#define RB_BLOCK_CALL_FUNC_STRICT 1
 #define RUBY_BLOCK_CALL_FUNC_TAKES_BLOCKARG 1
 #define RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg) \
     VALUE yielded_arg, VALUE callback_arg, int argc, const VALUE *argv, VALUE blockarg
 typedef VALUE rb_block_call_func(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg));
-
-#if defined RB_BLOCK_CALL_FUNC_STRICT && RB_BLOCK_CALL_FUNC_STRICT
 typedef rb_block_call_func *rb_block_call_func_t;
-#else
-typedef VALUE (*rb_block_call_func_t)(ANYARGS);
-#endif
 
 VALUE rb_each(VALUE);
 VALUE rb_yield(VALUE);
-- 
cgit v0.10.2


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

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