[前][次][番号順一覧][スレッド一覧]

ruby-changes:9175

From: yugui <ko1@a...>
Date: Sat, 13 Dec 2008 11:00:00 +0900 (JST)
Subject: [ruby-changes:9175] Ruby:r20712 (ruby_1_9_1): merges r20607 from trunk into ruby_1_9_1.

yugui	2008-12-13 10:59:42 +0900 (Sat, 13 Dec 2008)

  New Revision: 20712

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20712

  Log:
    merges r20607 from trunk into ruby_1_9_1. [ruby-dev:37407]
    * enumerator.c (enumerator_rewind): If the enclosed object
      responds to a "rewind" method, call it; cf. [ruby-dev:37268]

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/enumerator.c

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 20711)
+++ ruby_1_9_1/ChangeLog	(revision 20712)
@@ -1,3 +1,8 @@
+Wed Dec 10 12:56:32 2008  Akinori MUSHA  <knu@i...>
+
+	* enumerator.c (enumerator_rewind): If the enclosed object
+	  responds to a "rewind" method, call it; cf. [ruby-dev:37268]
+
 Sat Dec 13 09:17:33 2008  Ryan Davis  <ryand-ruby@z...>
 
 	* lib/minitest/*.rb: Imported minitest 1.3.2 r4503.
Index: ruby_1_9_1/enumerator.c
===================================================================
--- ruby_1_9_1/enumerator.c	(revision 20711)
+++ ruby_1_9_1/enumerator.c	(revision 20712)
@@ -22,6 +22,7 @@
  */
 VALUE rb_cEnumerator;
 static VALUE sym_each;
+static ID id_rewind;
 
 VALUE rb_eStopIteration;
 
@@ -532,6 +533,8 @@
  *   e.rewind   => e
  *
  * Rewinds the enumeration sequence by the next method.
+ *
+ * If the enclosed object responds to a "rewind" method, it is called.
  */
 
 static VALUE
@@ -539,6 +542,9 @@
 {
     struct enumerator *e = enumerator_ptr(obj);
 
+    if (rb_respond_to(e->obj, id_rewind))
+	rb_funcall(e->obj, id_rewind, 0);
+
     e->fib = 0;
     e->dst = Qnil;
     e->no_next = Qfalse;
@@ -798,6 +804,7 @@
     rb_define_method(rb_cYielder, "<<", yielder_yield, -2);
 
     sym_each = ID2SYM(rb_intern("each"));
+    id_rewind = rb_intern("rewind");
 
     rb_provide("enumerator.so");	/* for backward compatibility */
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]