1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]
This commit is contained in:
Benoit Daloze 2021-07-06 18:52:29 +02:00
parent 301d194ee3
commit fd0df9c4fb
Notes: git 2021-07-16 19:11:52 +09:00
3 changed files with 15 additions and 19 deletions

View file

@ -45,6 +45,7 @@ int rb_keyword_given_p(void);
int rb_block_given_p(void); int rb_block_given_p(void);
void rb_need_block(void); void rb_need_block(void);
VALUE rb_iterate(VALUE(*)(VALUE),VALUE,rb_block_call_func_t,VALUE); 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(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_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); VALUE rb_rescue(VALUE(*)(VALUE),VALUE,VALUE(*)(VALUE,VALUE),VALUE);

16
proc.c
View file

@ -3152,18 +3152,6 @@ method_inspect(VALUE method)
return str; return str;
} }
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 static VALUE
bmcall(RB_BLOCK_CALL_FUNC_ARGLIST(args, method)) bmcall(RB_BLOCK_CALL_FUNC_ARGLIST(args, method))
{ {
@ -3175,7 +3163,7 @@ rb_proc_new(
rb_block_call_func_t func, rb_block_call_func_t func,
VALUE val) VALUE val)
{ {
VALUE procval = rb_iterate(mproc, 0, func, val); VALUE procval = rb_block_call(rb_mRubyVMFrozenCore, idProc, 0, 0, func, val);
return procval; return procval;
} }
@ -3201,7 +3189,7 @@ method_to_proc(VALUE method)
* end * end
* end * end
*/ */
procval = rb_iterate(mlambda, 0, bmcall, method); procval = rb_block_call(rb_mRubyVMFrozenCore, idLambda, 0, 0, bmcall, method);
GetProcPtr(procval, proc); GetProcPtr(procval, proc);
proc->is_from_method = 1; proc->is_from_method = 1;
return procval; return procval;

View file

@ -1557,15 +1557,22 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
return retval; return retval;
} }
VALUE static VALUE
rb_iterate(VALUE (* it_proc)(VALUE), VALUE data1, rb_iterate_internal(VALUE (* it_proc)(VALUE), VALUE data1,
rb_block_call_func_t bl_proc, VALUE data2) rb_block_call_func_t bl_proc, VALUE data2)
{ {
return rb_iterate0(it_proc, data1, return rb_iterate0(it_proc, data1,
bl_proc ? rb_vm_ifunc_proc_new(bl_proc, (void *)data2) : 0, bl_proc ? rb_vm_ifunc_proc_new(bl_proc, (void *)data2) : 0,
GET_EC()); 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 { struct iter_method_arg {
VALUE obj; VALUE obj;
ID mid; ID mid;
@ -1603,7 +1610,7 @@ rb_block_call_kw(VALUE obj, ID mid, int argc, const VALUE * argv,
arg.argc = argc; arg.argc = argc;
arg.argv = argv; arg.argv = argv;
arg.kw_splat = kw_splat; 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 VALUE
@ -1644,7 +1651,7 @@ rb_check_block_call(VALUE obj, ID mid, int argc, const VALUE *argv,
arg.argc = argc; arg.argc = argc;
arg.argv = argv; arg.argv = argv;
arg.kw_splat = 0; 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 VALUE