Project

General

Profile

Feature #9602 ยป select-to-accept-args.patch

srawlins (Sam Rawlins), 03/07/2014 04:18 AM

View differences:

enum.c
}
static VALUE
find_all_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
find_all_iter_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
{
ENUM_WANT_SVALUE();
......
}
static VALUE
find_all_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, args))
{
NODE *memo = RNODE(args);
VALUE ary = memo->u1.value;
long j;
ENUM_WANT_SVALUE();
for (j=0; j<RARRAY_LEN(ary); j++) {
if (RTEST(rb_funcall(RARRAY_AREF(ary, j), id_eqq, 1, i))) {
rb_ary_push(memo->u2.value, i);
}
}
return Qnil;
}
static VALUE
enum_size(VALUE self, VALUE args, VALUE eobj)
{
VALUE r;
......
*/
static VALUE
enum_find_all(VALUE obj)
enum_find_all(int argc, VALUE *argv, VALUE obj)
{
VALUE ary;
NODE *memo;
VALUE items = Qnil;
RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
if (argc == 0) {
RETURN_SIZED_ENUMERATOR(obj, argc, argv, enum_size);
ary = rb_ary_new();
rb_block_call(obj, id_each, 0, 0, find_all_i, ary);
ary = rb_ary_new();
rb_block_call(obj, id_each, 0, 0, find_all_iter_i, ary);
} else {
rb_scan_args(argc, argv, "*", &items);
if (rb_block_given_p())
rb_warn("given block not used");
ary = rb_ary_new();
memo = NEW_MEMO(items, ary, 0);
rb_block_call(obj, id_each, 0, 0, find_all_i, (VALUE)memo);
}
return ary;
}
......
rb_define_method(rb_mEnumerable, "find", enum_find, -1);
rb_define_method(rb_mEnumerable, "detect", enum_find, -1);
rb_define_method(rb_mEnumerable, "find_index", enum_find_index, -1);
rb_define_method(rb_mEnumerable, "find_all", enum_find_all, 0);
rb_define_method(rb_mEnumerable, "select", enum_find_all, 0);
rb_define_method(rb_mEnumerable, "find_all", enum_find_all, -1);
rb_define_method(rb_mEnumerable, "select", enum_find_all, -1);
rb_define_method(rb_mEnumerable, "reject", enum_reject, 0);
rb_define_method(rb_mEnumerable, "collect", enum_collect, 0);
rb_define_method(rb_mEnumerable, "map", enum_collect, 0);
    (1-1/1)