summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-25 00:21:22 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-25 00:21:22 +0000
commitf1e4b10a84d43ec15424f86a692957f3f94cb860 (patch)
treea1a0bb9f6668d658c38bd5a34abe4cbcff0b684e
parent6adef5abe5c37f5b3626383b12d569df78a0c3df (diff)
* 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
-rw-r--r--ChangeLog8
-rw-r--r--enumerator.c45
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 <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.
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);