summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2021-07-06 18:52:29 +0200
committerBenoit Daloze <eregontp@gmail.com>2021-07-16 12:11:24 +0200
commitfd0df9c4fb36597e5e3f500670b29dbd77a14eca (patch)
tree5efd7ac323cc17519fbfd04104c1fc3be034fe5a
parent301d194ee3b49e6b078eccb999dd538e9bfa8c7c (diff)
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]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4629
-rw-r--r--include/ruby/internal/iterator.h1
-rw-r--r--proc.c16
-rw-r--r--vm_eval.c17
3 files changed, 15 insertions, 19 deletions
diff --git a/include/ruby/internal/iterator.h b/include/ruby/internal/iterator.h
index 99c0831b13..a2aee15d31 100644
--- a/include/ruby/internal/iterator.h
+++ b/include/ruby/internal/iterator.h
@@ -45,6 +45,7 @@ int rb_keyword_given_p(void);
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 6e1572847b..78b671a785 100644
--- a/proc.c
+++ b/proc.c
@@ -3153,18 +3153,6 @@ method_inspect(VALUE method)
}
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(
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)
* 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 bf5581cacf..bc40c15b6c 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1557,15 +1557,22 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
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,
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,
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