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

* enumerator.c (lazy_initialize, enumerable_lazy): no additional

arguments.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-03-08 15:35:05 +00:00
parent 0b2c4f43d2
commit e7d4e659a0
2 changed files with 14 additions and 22 deletions

View file

@ -1,3 +1,8 @@
Fri Mar 9 00:35:03 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enumerator.c (lazy_initialize, enumerable_lazy): no additional
arguments.
Fri Mar 9 00:30:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enumerator.c: add Enumerable#lazy. based on the patch by

View file

@ -1231,20 +1231,17 @@ lazy_init_block(VALUE val, VALUE m, int argc, VALUE *argv)
}
static VALUE
lazy_initialize(int argc, VALUE *argv, VALUE obj)
lazy_initialize(VALUE self, VALUE obj)
{
VALUE generator, arg;
VALUE generator;
if (argc < 1) rb_raise(rb_eArgError, "wrong number of arguments(%d for 1+)", argc);
--argc;
arg = *argv++;
generator = generator_allocate(rb_cGenerator);
rb_block_call(generator, id_initialize, 0, 0,
(rb_block_given_p() ? lazy_init_block_i: lazy_init_block),
arg);
enumerator_init(obj, generator, sym_each, argc, argv);
obj);
enumerator_init(self, generator, sym_each, 0, 0);
return obj;
return self;
}
/*
@ -1252,20 +1249,10 @@ lazy_initialize(int argc, VALUE *argv, VALUE obj)
* e.lazy -> lazy_enumerator
*/
static VALUE
enumerable_lazy(int argc, VALUE *argv, VALUE obj)
enumerable_lazy(VALUE obj)
{
if (argc > 0) {
VALUE ret, buff, *args = ALLOCV_N(VALUE, buff, argc + 1);
args[0] = obj;
MEMCPY(args + 1, argv, VALUE, argc);
ret = rb_class_new_instance(argc + 1, args, rb_cLazy);
ALLOCV_END(buff);
return ret;
}
else {
return rb_class_new_instance(1, &obj, rb_cLazy);
}
}
static VALUE
lazy_map_func(VALUE val, VALUE m, int argc, VALUE *argv)
@ -1387,8 +1374,8 @@ Init_Enumerator(void)
/* Enumerable::Lazy */
rb_cLazy = rb_define_class_under(rb_mEnumerable, "Lazy", rb_cEnumerator);
rb_define_method(rb_mEnumerable, "lazy", enumerable_lazy, -1);
rb_define_method(rb_cLazy, "initialize", lazy_initialize, -1);
rb_define_method(rb_mEnumerable, "lazy", enumerable_lazy, 0);
rb_define_method(rb_cLazy, "initialize", lazy_initialize, 1);
rb_define_method(rb_cLazy, "map", lazy_map, 0);
rb_define_method(rb_cLazy, "select", lazy_select, 0);
rb_define_method(rb_cLazy, "reject", lazy_reject, 0);