From f1e4b10a84d43ec15424f86a692957f3f94cb860 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 25 Oct 2006 00:21:22 +0000 Subject: * 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 --- ChangeLog | 8 ++++++++ enumerator.c | 45 ++------------------------------------------- 2 files changed, 10 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9158bc7f48..abcd37a2ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,14 @@ Wed Oct 25 00:58:19 2006 Nobuyoshi Nakada * win32/mkexports.rb, win32/resource.rb: use unique variable names. +Tue Oct 24 18:56:13 2006 Yukihiro Matsumoto + + * 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 * enum.c (enum_zip): add RETURN_ENUMERATOR() to zip method. diff --git a/enumerator.c b/enumerator.c index 727990f652..51ebb2c2b1 100644 --- a/enumerator.c +++ b/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); -- cgit v1.2.3