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

rb_funcallv

* *.c: rename rb_funcall2 to rb_funcallv, except for extensions
  which are/will be/may be gems.  [Fix GH-1406]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-07-29 11:57:14 +00:00
parent 26de0b131e
commit c463366dfd
23 changed files with 53 additions and 48 deletions

View file

@ -1,3 +1,8 @@
Fri Jul 29 20:57:12 2016 chuanshuo <lilijreey@126.com>
* *.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 <ko1@atdot.net>
* proc.c (env_write): remove unused function.

View file

@ -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);
}
/*

2
dir.c
View file

@ -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;

View file

@ -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

2
eval.c
View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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: */

View file

@ -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);

View file

@ -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

View file

@ -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;
}

4
hash.c
View file

@ -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 {

14
io.c
View file

@ -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);

2
iseq.c
View file

@ -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;

View file

@ -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;

View file

@ -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);
}
/*

2
ruby.c
View file

@ -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;
}

View file

@ -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);
}

View file

@ -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

View file

@ -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 {

View file

@ -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:

View file

@ -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