diff --git a/ChangeLog b/ChangeLog index 4e0384458b..76fa8031e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 29 20:57:12 2016 chuanshuo + + * *.c: rename rb_funcall2 to rb_funcallv, except for extensions + which are/will be/may be gems. [Fix GH-1406] + Fri Jul 29 10:51:34 2016 Koichi Sasada * proc.c (env_write): remove unused function. diff --git a/complex.c b/complex.c index def0758276..7a9c56d667 100644 --- a/complex.c +++ b/complex.c @@ -468,7 +468,7 @@ f_complex_new2(VALUE klass, VALUE x, VALUE y) static VALUE nucomp_f_complex(int argc, VALUE *argv, VALUE klass) { - return rb_funcall2(rb_cComplex, id_convert, argc, argv); + return rb_funcallv(rb_cComplex, id_convert, argc, argv); } #define imp1(n) \ @@ -1582,7 +1582,7 @@ nucomp_rationalize(int argc, VALUE *argv, VALUE self) rb_raise(rb_eRangeError, "can't convert %"PRIsVALUE" into Rational", self); } - return rb_funcall2(dat->real, rb_intern("rationalize"), argc, argv); + return rb_funcallv(dat->real, rb_intern("rationalize"), argc, argv); } /* diff --git a/dir.c b/dir.c index d1bd2e4003..90fc1efed9 100644 --- a/dir.c +++ b/dir.c @@ -2364,7 +2364,7 @@ dir_s_glob(int argc, VALUE *argv, VALUE obj) static VALUE dir_open_dir(int argc, VALUE *argv) { - VALUE dir = rb_funcall2(rb_cDir, rb_intern("open"), argc, argv); + VALUE dir = rb_funcallv(rb_cDir, rb_intern("open"), argc, argv); rb_check_typeddata(dir, &dir_data_type); return dir; diff --git a/enumerator.c b/enumerator.c index 2d692e537f..7b83af4ade 100644 --- a/enumerator.c +++ b/enumerator.c @@ -1528,7 +1528,7 @@ lazy_map(VALUE obj) static VALUE lazy_flat_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, yielder)) { - return rb_funcall2(yielder, id_yield, argc, argv); + return rb_funcallv(yielder, id_yield, argc, argv); } static VALUE @@ -1830,7 +1830,7 @@ lazy_take_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, args)) memo = args; } - rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); + rb_funcallv(argv[0], id_yield, argc - 1, argv + 1); if ((remain = NUM2LONG(memo)-1) == 0) { return Qundef; } @@ -1875,7 +1875,7 @@ lazy_take_while_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, args)) { VALUE result = rb_yield_values2(argc - 1, &argv[1]); if (!RTEST(result)) return Qundef; - rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); + rb_funcallv(argv[0], id_yield, argc - 1, argv + 1); return Qnil; } @@ -1913,7 +1913,7 @@ lazy_drop_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, args)) memo = args; } if ((remain = NUM2LONG(memo)) == 0) { - rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); + rb_funcallv(argv[0], id_yield, argc - 1, argv + 1); } else { rb_ivar_set(argv[0], id_memo, LONG2NUM(--remain)); @@ -1942,7 +1942,7 @@ lazy_drop_while_func(RB_BLOCK_CALL_FUNC_ARGLIST(val, args)) rb_ivar_set(argv[0], id_memo, memo = Qtrue); } if (memo == Qtrue) { - rb_funcall2(argv[0], id_yield, argc - 1, argv + 1); + rb_funcallv(argv[0], id_yield, argc - 1, argv + 1); } return Qnil; } @@ -1963,7 +1963,7 @@ lazy_uniq_i(VALUE i, VALUE hash, int argc, const VALUE *argv, VALUE yielder) { if (rb_hash_add_new_element(hash, i, Qfalse)) return Qnil; - return rb_funcall2(yielder, id_yield, argc, argv); + return rb_funcallv(yielder, id_yield, argc, argv); } static VALUE diff --git a/eval.c b/eval.c index db7552c4d7..d0f14b0b5e 100644 --- a/eval.c +++ b/eval.c @@ -1315,7 +1315,7 @@ void rb_obj_call_init(VALUE obj, int argc, const VALUE *argv) { PASS_PASSED_BLOCK_HANDLER(); - rb_funcall2(obj, idInitialize, argc, argv); + rb_funcallv(obj, idInitialize, argc, argv); } void diff --git a/ext/-test-/funcall/passing_block.c b/ext/-test-/funcall/passing_block.c index 0200f80369..70cb210831 100644 --- a/ext/-test-/funcall/passing_block.c +++ b/ext/-test-/funcall/passing_block.c @@ -5,7 +5,7 @@ VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*); static VALUE with_funcall2(int argc, VALUE *argv, VALUE self) { - return rb_funcall2(self, rb_intern("target"), argc, argv); + return rb_funcallv(self, rb_intern("target"), argc, argv); } static VALUE diff --git a/ext/-test-/notimplement/bug.c b/ext/-test-/notimplement/bug.c index 34731bc2e6..8e9cae707a 100644 --- a/ext/-test-/notimplement/bug.c +++ b/ext/-test-/notimplement/bug.c @@ -4,7 +4,7 @@ static VALUE bug_funcall(int argc, VALUE *argv, VALUE self) { if (argc < 1) rb_raise(rb_eArgError, "not enough argument"); - return rb_funcall2(self, rb_to_id(*argv), argc-1, argv+1); + return rb_funcallv(self, rb_to_id(*argv), argc-1, argv+1); } void diff --git a/ext/digest/bubblebabble/bubblebabble.c b/ext/digest/bubblebabble/bubblebabble.c index 4b8263de5a..8f436908d3 100644 --- a/ext/digest/bubblebabble/bubblebabble.c +++ b/ext/digest/bubblebabble/bubblebabble.c @@ -101,7 +101,7 @@ rb_digest_s_bubblebabble(VALUE klass, VALUE str) static VALUE rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass) { - return bubblebabble_str_new(rb_funcall2(klass, id_digest, argc, argv)); + return bubblebabble_str_new(rb_funcallv(klass, id_digest, argc, argv)); } /* Document-method: Digest::Instance#bubblebabble diff --git a/ext/digest/digest.c b/ext/digest/digest.c index a02eb12cd6..012c0cc89d 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -486,7 +486,7 @@ rb_digest_class_s_digest(int argc, VALUE *argv, VALUE klass) static VALUE rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass) { - return hexencode_str_new(rb_funcall2(klass, id_digest, argc, argv)); + return hexencode_str_new(rb_funcallv(klass, id_digest, argc, argv)); } /* :nodoc: */ diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index d560e7356f..4fe8859353 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -202,7 +202,7 @@ path_sub(int argc, VALUE *argv, VALUE self) str = rb_block_call(str, rb_intern("sub"), argc, argv, 0, 0); } else { - str = rb_funcall2(str, rb_intern("sub"), argc, argv); + str = rb_funcallv(str, rb_intern("sub"), argc, argv); } return rb_class_new_instance(1, &str, rb_obj_class(self)); } @@ -299,7 +299,7 @@ path_each_line(int argc, VALUE *argv, VALUE self) return rb_block_call(rb_cIO, rb_intern("foreach"), 1+n, args, 0, 0); } else { - return rb_funcall2(rb_cIO, rb_intern("foreach"), 1+n, args); + return rb_funcallv(rb_cIO, rb_intern("foreach"), 1+n, args); } } @@ -321,7 +321,7 @@ path_read(int argc, VALUE *argv, VALUE self) args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); - return rb_funcall2(rb_cIO, rb_intern("read"), 1+n, args); + return rb_funcallv(rb_cIO, rb_intern("read"), 1+n, args); } /* @@ -341,7 +341,7 @@ path_binread(int argc, VALUE *argv, VALUE self) args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "02", &args[1], &args[2]); - return rb_funcall2(rb_cIO, rb_intern("binread"), 1+n, args); + return rb_funcallv(rb_cIO, rb_intern("binread"), 1+n, args); } /* @@ -362,7 +362,7 @@ path_write(int argc, VALUE *argv, VALUE self) args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); - return rb_funcall2(rb_cIO, rb_intern("write"), 1+n, args); + return rb_funcallv(rb_cIO, rb_intern("write"), 1+n, args); } /* @@ -383,7 +383,7 @@ path_binwrite(int argc, VALUE *argv, VALUE self) args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); - return rb_funcall2(rb_cIO, rb_intern("binwrite"), 1+n, args); + return rb_funcallv(rb_cIO, rb_intern("binwrite"), 1+n, args); } /* @@ -405,7 +405,7 @@ path_readlines(int argc, VALUE *argv, VALUE self) args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "03", &args[1], &args[2], &args[3]); - return rb_funcall2(rb_cIO, rb_intern("readlines"), 1+n, args); + return rb_funcallv(rb_cIO, rb_intern("readlines"), 1+n, args); } /* @@ -423,7 +423,7 @@ path_sysopen(int argc, VALUE *argv, VALUE self) args[0] = get_strpath(self); n = rb_scan_args(argc, argv, "02", &args[1], &args[2]); - return rb_funcall2(rb_cIO, rb_intern("sysopen"), 1+n, args); + return rb_funcallv(rb_cIO, rb_intern("sysopen"), 1+n, args); } /* @@ -608,7 +608,7 @@ path_open(int argc, VALUE *argv, VALUE self) return rb_block_call(rb_cFile, rb_intern("open"), 1+n, args, 0, 0); } else { - return rb_funcall2(rb_cFile, rb_intern("open"), 1+n, args); + return rb_funcallv(rb_cFile, rb_intern("open"), 1+n, args); } } @@ -1013,7 +1013,7 @@ path_s_glob(int argc, VALUE *argv, VALUE klass) else { VALUE ary; long i; - ary = rb_funcall2(rb_cDir, rb_intern("glob"), n, args); + ary = rb_funcallv(rb_cDir, rb_intern("glob"), n, args); ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary"); for (i = 0; i < RARRAY_LEN(ary); i++) { VALUE elt = RARRAY_AREF(ary, i); diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c index f73f12777c..d1cf1e2b2a 100644 --- a/ext/socket/unixsocket.c +++ b/ext/socket/unixsocket.c @@ -422,7 +422,7 @@ unix_recv_io(int argc, VALUE *argv, VALUE sock) ff_argc = mode == Qnil ? 1 : 2; ff_argv[0] = INT2FIX(fd); ff_argv[1] = mode; - return rb_funcall2(klass, for_fd, ff_argc, ff_argv); + return rb_funcallv(klass, for_fd, ff_argc, ff_argv); } } #else diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 4dcd22e6f0..229780d565 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -383,7 +383,7 @@ static /* [local] */ HRESULT ( STDMETHODCALLTYPE Invoke )( mid = rb_intern("value"); } } - v = rb_funcall2(p->obj, mid, args, parg); + v = rb_funcallv(p->obj, mid, args, parg); ole_val2variant(v, pVarResult); return S_OK; } diff --git a/hash.c b/hash.c index cab0b9eaa2..963d9aed3f 100644 --- a/hash.c +++ b/hash.c @@ -2588,10 +2588,10 @@ rb_hash_flatten(int argc, VALUE *argv, VALUE hash) rb_hash_foreach(hash, flatten_i, ary); if (level - 1 > 0) { *argv = INT2FIX(level - 1); - rb_funcall2(ary, id_flatten_bang, argc, argv); + rb_funcallv(ary, id_flatten_bang, argc, argv); } else if (level < 0) { - rb_funcall2(ary, id_flatten_bang, 0, 0); + rb_funcallv(ary, id_flatten_bang, 0, 0); } } else { diff --git a/io.c b/io.c index 19a0c9d426..fbd24f6046 100644 --- a/io.c +++ b/io.c @@ -6606,7 +6606,7 @@ rb_f_open(int argc, VALUE *argv) } } if (redirect) { - VALUE io = rb_funcall2(argv[0], to_open, argc-1, argv+1); + VALUE io = rb_funcallv(argv[0], to_open, argc-1, argv+1); if (rb_block_given_p()) { return rb_ensure(rb_yield, io, io_close, io); @@ -7079,7 +7079,7 @@ rb_f_putc(VALUE recv, VALUE ch) if (recv == rb_stdout) { return rb_io_putc(recv, ch); } - return rb_funcall2(rb_stdout, rb_intern("putc"), 1, &ch); + return rb_funcallv(rb_stdout, rb_intern("putc"), 1, &ch); } @@ -7184,7 +7184,7 @@ rb_f_puts(int argc, VALUE *argv, VALUE recv) if (recv == rb_stdout) { return rb_io_puts(argc, argv, recv); } - return rb_funcall2(rb_stdout, rb_intern("puts"), argc, argv); + return rb_funcallv(rb_stdout, rb_intern("puts"), argc, argv); } void @@ -8206,7 +8206,7 @@ rb_f_gets(int argc, VALUE *argv, VALUE recv) if (recv == argf) { return argf_gets(argc, argv, argf); } - return rb_funcall2(argf, idGets, argc, argv); + return rb_funcallv(argf, idGets, argc, argv); } /* @@ -8279,7 +8279,7 @@ rb_f_readline(int argc, VALUE *argv, VALUE recv) if (recv == argf) { return argf_readline(argc, argv, argf); } - return rb_funcall2(argf, rb_intern("readline"), argc, argv); + return rb_funcallv(argf, rb_intern("readline"), argc, argv); } @@ -8332,7 +8332,7 @@ rb_f_readlines(int argc, VALUE *argv, VALUE recv) if (recv == argf) { return argf_readlines(argc, argv, argf); } - return rb_funcall2(argf, rb_intern("readlines"), argc, argv); + return rb_funcallv(argf, rb_intern("readlines"), argc, argv); } /* @@ -10864,7 +10864,7 @@ rb_io_set_encoding(int argc, VALUE *argv, VALUE io) VALUE v1, v2, opt; if (!RB_TYPE_P(io, T_FILE)) { - return rb_funcall2(io, id_set_encoding, argc, argv); + return rb_funcallv(io, id_set_encoding, argc, argv); } argc = rb_scan_args(argc, argv, "11:", &v1, &v2, &opt); diff --git a/iseq.c b/iseq.c index 0f98107c7f..e4698f58f2 100644 --- a/iseq.c +++ b/iseq.c @@ -325,7 +325,7 @@ cleanup_iseq_build(rb_iseq_t *iseq) compile_data_free(data); if (RTEST(err)) { - rb_funcall2(err, rb_intern("set_backtrace"), 1, &iseq->body->location.path); + rb_funcallv(err, rb_intern("set_backtrace"), 1, &iseq->body->location.path); rb_exc_raise(err); } return Qtrue; diff --git a/random.c b/random.c index bc6474f864..ee91c533aa 100644 --- a/random.c +++ b/random.c @@ -957,7 +957,7 @@ rb_random_real(VALUE obj) { rb_random_t *rnd = try_get_rnd(obj); if (!rnd) { - VALUE v = rb_funcall2(obj, id_rand, 0, 0); + VALUE v = rb_funcallv(obj, id_rand, 0, 0); double d = NUM2DBL(v); if (d < 0.0) { rb_raise(rb_eRangeError, "random number too small %g", d); @@ -1018,7 +1018,7 @@ rb_random_ulong_limited(VALUE obj, unsigned long limit) rb_random_t *rnd = try_get_rnd(obj); if (!rnd) { VALUE lim = ulong_to_num_plus_1(limit); - VALUE v = rb_to_int(rb_funcall2(obj, id_rand, 1, &lim)); + VALUE v = rb_to_int(rb_funcallv(obj, id_rand, 1, &lim)); unsigned long r = NUM2ULONG(v); if (rb_num_negative_p(v)) { rb_raise(rb_eRangeError, "random number too small %ld", r); @@ -1121,7 +1121,7 @@ range_values(VALUE vmax, VALUE *begp, VALUE *endp, int *exclp) if (!rb_range_values(vmax, begp, &end, exclp)) return Qfalse; if (endp) *endp = end; if (!rb_respond_to(end, id_minus)) return Qfalse; - r = rb_funcall2(end, id_minus, 1, begp); + r = rb_funcallv(end, id_minus, 1, begp); if (NIL_P(r)) return Qfalse; return r; } @@ -1270,7 +1270,7 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range) } } default: - return rb_funcall2(beg, id_plus, 1, &v); + return rb_funcallv(beg, id_plus, 1, &v); } return v; diff --git a/rational.c b/rational.c index 1909536461..f0e8d56cbf 100644 --- a/rational.c +++ b/rational.c @@ -605,7 +605,7 @@ f_rational_new_no_reduce2(VALUE klass, VALUE x, VALUE y) static VALUE nurat_f_rational(int argc, VALUE *argv, VALUE klass) { - return rb_funcall2(rb_cRational, id_convert, argc, argv); + return rb_funcallv(rb_cRational, id_convert, argc, argv); } /* diff --git a/ruby.c b/ruby.c index 797fa79774..8f88339f84 100644 --- a/ruby.c +++ b/ruby.c @@ -634,7 +634,7 @@ require_libraries(VALUE *req_list) rb_enc_associate(feature, extenc); RBASIC_SET_CLASS_RAW(feature, rb_cString); OBJ_FREEZE(feature); - rb_funcall2(self, require, 1, &feature); + rb_funcallv(self, require, 1, &feature); } *req_list = 0; } diff --git a/string.c b/string.c index a5b1279084..26f2324b95 100644 --- a/string.c +++ b/string.c @@ -3526,7 +3526,7 @@ rb_str_match_m(int argc, VALUE *argv, VALUE str) rb_check_arity(argc, 1, 2); re = argv[0]; argv[0] = str; - result = rb_funcall2(get_pat(re), rb_intern("match"), argc, argv); + result = rb_funcallv(get_pat(re), rb_intern("match"), argc, argv); if (!NIL_P(result) && rb_block_given_p()) { return rb_yield(result); } diff --git a/thread_sync.c b/thread_sync.c index ed81a31d76..efa6208f5d 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -1157,7 +1157,7 @@ static VALUE do_sleep(VALUE args) { struct sleep_call *p = (struct sleep_call *)args; - return rb_funcall2(p->mutex, id_sleep, 1, &p->timeout); + return rb_funcallv(p->mutex, id_sleep, 1, &p->timeout); } static VALUE diff --git a/vm_eval.c b/vm_eval.c index 4ef4d6e582..264c0920a8 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -853,7 +853,7 @@ rb_funcallv(VALUE recv, ID mid, int argc, const VALUE *argv) /*! * Calls a method. * - * Same as rb_funcall2 but this function can call only public methods. + * Same as rb_funcallv but this function can call only public methods. * \param recv receiver of the method * \param mid an ID that represents the name of the method * \param argc the number of arguments @@ -1543,7 +1543,7 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level) rb_set_safe_level_force(level); if ((state = TH_EXEC_TAG()) == 0) { if (!RB_TYPE_P(cmd, T_STRING)) { - val = rb_funcall2(cmd, idCall, RARRAY_LENINT(arg), + val = rb_funcallv(cmd, idCall, RARRAY_LENINT(arg), RARRAY_CONST_PTR(arg)); } else { diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 9b29124709..1b4123412f 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1303,7 +1303,7 @@ check_match(VALUE pattern, VALUE target, enum vm_check_match_type type) } else { /* fallback to funcall (e.g. method_missing) */ - return rb_funcall2(pattern, idEqq, 1, &target); + return rb_funcallv(pattern, idEqq, 1, &target); } } default: diff --git a/vm_method.c b/vm_method.c index acdd976ff9..b5a6f538d0 100644 --- a/vm_method.c +++ b/vm_method.c @@ -610,7 +610,7 @@ rb_method_entry_make(VALUE klass, ID mid, VALUE defined_class, rb_method_visibil recv_class = rb_ivar_get((klass), attached); \ hook_id = singleton_##hook; \ } \ - rb_funcall2(recv_class, hook_id, 1, &arg); \ + rb_funcallv(recv_class, hook_id, 1, &arg); \ } while (0) static void