mirror of
https://github.com/ruby/ruby.git
synced 2025-08-22 20:44:18 +02:00
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1ddbc7e70f
commit
dfe8fa1bbc
2 changed files with 12 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Dec 10 12:56:32 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* 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@zenspider.com>
|
Sat Dec 13 09:17:33 2008 Ryan Davis <ryand-ruby@zenspider.com>
|
||||||
|
|
||||||
* lib/minitest/*.rb: Imported minitest 1.3.2 r4503.
|
* lib/minitest/*.rb: Imported minitest 1.3.2 r4503.
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
*/
|
*/
|
||||||
VALUE rb_cEnumerator;
|
VALUE rb_cEnumerator;
|
||||||
static VALUE sym_each;
|
static VALUE sym_each;
|
||||||
|
static ID id_rewind;
|
||||||
|
|
||||||
VALUE rb_eStopIteration;
|
VALUE rb_eStopIteration;
|
||||||
|
|
||||||
|
@ -532,6 +533,8 @@ enumerator_next(VALUE obj)
|
||||||
* e.rewind => e
|
* e.rewind => e
|
||||||
*
|
*
|
||||||
* Rewinds the enumeration sequence by the next method.
|
* Rewinds the enumeration sequence by the next method.
|
||||||
|
*
|
||||||
|
* If the enclosed object responds to a "rewind" method, it is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -539,6 +542,9 @@ enumerator_rewind(VALUE obj)
|
||||||
{
|
{
|
||||||
struct enumerator *e = enumerator_ptr(obj);
|
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->fib = 0;
|
||||||
e->dst = Qnil;
|
e->dst = Qnil;
|
||||||
e->no_next = Qfalse;
|
e->no_next = Qfalse;
|
||||||
|
@ -798,6 +804,7 @@ Init_Enumerator(void)
|
||||||
rb_define_method(rb_cYielder, "<<", yielder_yield, -2);
|
rb_define_method(rb_cYielder, "<<", yielder_yield, -2);
|
||||||
|
|
||||||
sym_each = ID2SYM(rb_intern("each"));
|
sym_each = ID2SYM(rb_intern("each"));
|
||||||
|
id_rewind = rb_intern("rewind");
|
||||||
|
|
||||||
rb_provide("enumerator.so"); /* for backward compatibility */
|
rb_provide("enumerator.so"); /* for backward compatibility */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue