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

ruby-changes:57312

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:57312] 卜部昌平: bc3e7924bc (master): rb_proc_new / rb_fiber_new now free from ANYARGS

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

From bc3e7924bc66d3ef77b219c72f3e59cc154550a3 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:35:28 +0900
Subject: 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.

diff --git a/cont.c b/cont.c
index db422d9..ea21b32 100644
--- a/cont.c
+++ b/cont.c
@@ -1770,7 +1770,7 @@ rb_fiber_initialize(int argc, VALUE* argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/cont.c#L1770
 }
 
 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 afc9ed9..96daad2 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -713,7 +713,7 @@ next_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, obj)) https://github.com/ruby/ruby/blob/trunk/enumerator.c#L713
 }
 
 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;
diff --git a/gc.c b/gc.c
index 654a6c8..42559eb 100644
--- a/gc.c
+++ b/gc.c
@@ -8867,7 +8867,7 @@ compat_key(VALUE key) https://github.com/ruby/ruby/blob/trunk/gc.c#L8867
 }
 
 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 0aaeb82..f3d3c29 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -238,7 +238,7 @@ VALUE rb_singleton_class(VALUE); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L238
 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*); https://github.com/ruby/ruby/blob/trunk/include/ruby/intern.h#L446
 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);
diff --git a/proc.c b/proc.c
index 1c0a5df..1b8aa39 100644
--- a/proc.c
+++ b/proc.c
@@ -2790,7 +2790,7 @@ bmcall(RB_BLOCK_CALL_FUNC_ARGLIST(args, method)) https://github.com/ruby/ruby/blob/trunk/proc.c#L2790
 
 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) https://github.com/ruby/ruby/blob/trunk/proc.c#L2987
     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) https://github.com/ruby/ruby/blob/trunk/proc.c#L3007
 }
 
 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) https://github.com/ruby/ruby/blob/trunk/proc.c#L3018
     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) https://github.com/ruby/ruby/blob/trunk/proc.c#L3130
 }
 
 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));
-- 
cgit v0.10.2


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

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