ruby-changes:66818
From: Benoit <ko1@a...>
Date: Fri, 16 Jul 2021 19:11:52 +0900 (JST)
Subject: [ruby-changes:66818] fd0df9c4fb (master): Emit deprecatation warnings for rb_iterate()
https://git.ruby-lang.org/ruby.git/commit/?id=fd0df9c4fb From fd0df9c4fb36597e5e3f500670b29dbd77a14eca Mon Sep 17 00:00:00 2001 From: Benoit Daloze <eregontp@g...> Date: Tue, 6 Jul 2021 18:52:29 +0200 Subject: Emit deprecatation warnings for rb_iterate() * It is obsolete since 1.9, see https://github.com/ruby/ruby/blob/master/doc/extension.rdoc#label-Control+Structure and [Misc #18025] --- include/ruby/internal/iterator.h | 1 + proc.c | 16 ++-------------- vm_eval.c | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/include/ruby/internal/iterator.h b/include/ruby/internal/iterator.h index 99c0831..a2aee15 100644 --- a/include/ruby/internal/iterator.h +++ b/include/ruby/internal/iterator.h @@ -45,6 +45,7 @@ int rb_keyword_given_p(void); https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/iterator.h#L45 int rb_block_given_p(void); void rb_need_block(void); VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE); +DEPRECATED_BY(rb_block_call since 1.9, 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_kw(VALUE,ID,int,const VALUE*,rb_block_call_func_t,VALUE,int); VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE); diff --git a/proc.c b/proc.c index 6e15728..78b671a 100644 --- a/proc.c +++ b/proc.c @@ -3153,18 +3153,6 @@ method_inspect(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L3153 } static VALUE -mproc(VALUE method) -{ - return rb_funcallv(rb_mRubyVMFrozenCore, idProc, 0, 0); -} - -static VALUE -mlambda(VALUE method) -{ - return rb_funcallv(rb_mRubyVMFrozenCore, idLambda, 0, 0); -} - -static VALUE bmcall(RB_BLOCK_CALL_FUNC_ARGLIST(args, method)) { return rb_method_call_with_block_kw(argc, argv, method, blockarg, RB_PASS_CALLED_KEYWORDS); @@ -3175,7 +3163,7 @@ rb_proc_new( https://github.com/ruby/ruby/blob/trunk/proc.c#L3163 rb_block_call_func_t func, VALUE val) { - VALUE procval = rb_iterate(mproc, 0, func, val); + VALUE procval = rb_block_call(rb_mRubyVMFrozenCore, idProc, 0, 0, func, val); return procval; } @@ -3201,7 +3189,7 @@ method_to_proc(VALUE method) https://github.com/ruby/ruby/blob/trunk/proc.c#L3189 * end * end */ - procval = rb_iterate(mlambda, 0, bmcall, method); + procval = rb_block_call(rb_mRubyVMFrozenCore, idLambda, 0, 0, bmcall, method); GetProcPtr(procval, proc); proc->is_from_method = 1; return procval; diff --git a/vm_eval.c b/vm_eval.c index bf5581c..bc40c15 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1557,15 +1557,22 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1557 return retval; } -VALUE -rb_iterate(VALUE (* it_proc)(VALUE), VALUE data1, - rb_block_call_func_t bl_proc, VALUE data2) +static VALUE +rb_iterate_internal(VALUE (* it_proc)(VALUE), VALUE data1, + rb_block_call_func_t bl_proc, VALUE data2) { return rb_iterate0(it_proc, data1, bl_proc ? rb_vm_ifunc_proc_new(bl_proc, (void *)data2) : 0, GET_EC()); } +VALUE +rb_iterate(VALUE (* it_proc)(VALUE), VALUE data1, + rb_block_call_func_t bl_proc, VALUE data2) +{ + return rb_iterate_internal(it_proc, data1, bl_proc, data2); +} + struct iter_method_arg { VALUE obj; ID mid; @@ -1603,7 +1610,7 @@ rb_block_call_kw(VALUE obj, ID mid, int argc, const VALUE * argv, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1610 arg.argc = argc; arg.argv = argv; arg.kw_splat = kw_splat; - return rb_iterate(iterate_method, (VALUE)&arg, bl_proc, data2); + return rb_iterate_internal(iterate_method, (VALUE)&arg, bl_proc, data2); } VALUE @@ -1644,7 +1651,7 @@ rb_check_block_call(VALUE obj, ID mid, int argc, const VALUE *argv, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1651 arg.argc = argc; arg.argv = argv; arg.kw_splat = 0; - return rb_iterate(iterate_check_method, (VALUE)&arg, bl_proc, data2); + return rb_iterate_internal(iterate_check_method, (VALUE)&arg, bl_proc, data2); } VALUE -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/