зеркало из https://github.com/github/ruby.git
* enumerator.c (enum_each_slice, enum_each_cons): returns
Enumerable::Enumerator if no block is given. [ruby-dev:29246] * enumerator.c: remove methods: enum_with_index, enum_slice, enum_cons. [ruby-dev:29246] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6adef5abe5
Коммит
f1e4b10a84
|
@ -7,6 +7,14 @@ Wed Oct 25 00:58:19 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
* win32/mkexports.rb, win32/resource.rb: use unique variable names.
|
||||
|
||||
Tue Oct 24 18:56:13 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* enumerator.c (enum_each_slice, enum_each_cons): returns
|
||||
Enumerable::Enumerator if no block is given. [ruby-dev:29246]
|
||||
|
||||
* enumerator.c: remove methods: enum_with_index, enum_slice,
|
||||
enum_cons. [ruby-dev:29246]
|
||||
|
||||
Tue Oct 24 18:51:27 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* enum.c (enum_zip): add RETURN_ENUMERATOR() to zip method.
|
||||
|
|
45
enumerator.c
45
enumerator.c
|
@ -101,19 +101,6 @@ obj_to_enum(int argc, VALUE *argv, VALUE obj)
|
|||
return rb_enumeratorize(obj, meth, argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* enum_with_index
|
||||
*
|
||||
* Returns Enumerable::Enumerator.new(self, :each_with_index).
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
enumerator_enum_with_index(VALUE obj)
|
||||
{
|
||||
return rb_enumeratorize(obj, sym_each_with_index, 0, 0);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
each_slice_i(VALUE val, VALUE *memo)
|
||||
{
|
||||
|
@ -152,7 +139,7 @@ enum_each_slice(VALUE obj, VALUE n)
|
|||
VALUE args[2], ary;
|
||||
|
||||
if (size <= 0) rb_raise(rb_eArgError, "invalid slice size");
|
||||
|
||||
RETURN_ENUMERATOR(obj, 1, &n);
|
||||
args[0] = rb_ary_new2(size);
|
||||
args[1] = (VALUE)size;
|
||||
|
||||
|
@ -164,19 +151,6 @@ enum_each_slice(VALUE obj, VALUE n)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* e.enum_slice(n)
|
||||
*
|
||||
* Returns Enumerable::Enumerator.new(self, :each_slice, n).
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
enumerator_enum_slice(VALUE obj, VALUE n)
|
||||
{
|
||||
return rb_enumeratorize(obj, sym_each_slice, 1, &n);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
each_cons_i(VALUE val, VALUE *memo)
|
||||
{
|
||||
|
@ -219,6 +193,7 @@ enum_each_cons(VALUE obj, VALUE n)
|
|||
long size = NUM2LONG(n);
|
||||
VALUE args[2];
|
||||
|
||||
RETURN_ENUMERATOR(obj, 1, &n);
|
||||
if (size <= 0) rb_raise(rb_eArgError, "invalid size");
|
||||
args[0] = rb_ary_new2(size);
|
||||
args[1] = (VALUE)size;
|
||||
|
@ -228,19 +203,6 @@ enum_each_cons(VALUE obj, VALUE n)
|
|||
return Qnil;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* e.enum_cons(n)
|
||||
*
|
||||
* Returns Enumerable::Enumerator.new(self, :each_cons, n).
|
||||
*
|
||||
*/
|
||||
static VALUE
|
||||
enumerator_enum_cons(VALUE obj, VALUE n)
|
||||
{
|
||||
return rb_enumeratorize(obj, sym_each_cons, 1, &n);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
enumerator_allocate(VALUE klass)
|
||||
{
|
||||
|
@ -378,11 +340,8 @@ Init_Enumerator(void)
|
|||
rb_define_method(rb_mKernel, "to_enum", obj_to_enum, -1);
|
||||
rb_define_method(rb_mKernel, "enum_for", obj_to_enum, -1);
|
||||
|
||||
rb_define_method(rb_mEnumerable, "enum_with_index", enumerator_enum_with_index, 0);
|
||||
rb_define_method(rb_mEnumerable, "each_slice", enum_each_slice, 1);
|
||||
rb_define_method(rb_mEnumerable, "enum_slice", enumerator_enum_slice, 1);
|
||||
rb_define_method(rb_mEnumerable, "each_cons", enum_each_cons, 1);
|
||||
rb_define_method(rb_mEnumerable, "enum_cons", enumerator_enum_cons, 1);
|
||||
|
||||
rb_cEnumerator = rb_define_class_under(rb_mEnumerable, "Enumerator", rb_cObject);
|
||||
rb_include_module(rb_cEnumerator, rb_mEnumerable);
|
||||
|
|
Загрузка…
Ссылка в новой задаче