ruby-changes:1747
From: ko1@a...
Date: 23 Aug 2007 16:57:11 +0900
Subject: [ruby-changes:1747] nobu - Ruby:r13238 (trunk): * enumerator.c (sym_call): initialize first.
nobu 2007-08-23 16:57:03 +0900 (Thu, 23 Aug 2007) New Revision: 13238 Modified files: trunk/ChangeLog trunk/enumerator.c Log: * enumerator.c (sym_call): initialize first. * enumerator.c (enum_iter): typedefed. * enumerator.c (next_i): suppress a warning. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13238&r2=13237 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enumerator.c?r1=13238&r2=13237 Index: ChangeLog =================================================================== --- ChangeLog (revision 13237) +++ ChangeLog (revision 13238) @@ -1,4 +1,4 @@ -Thu Aug 23 16:55:35 2007 Nobuyoshi Nakada <nobu@r...> +Thu Aug 23 16:57:01 2007 Nobuyoshi Nakada <nobu@r...> * cont.c (rb_cont_call, fiber_switch, rb_fiber_resume, rb_fiber_yield): suppress warnings. @@ -6,6 +6,12 @@ * cont.c (rb_fiber_start): change on non-volatile variable between setjmp and longjmp may not has an effect. + * enumerator.c (sym_call): initialize first. + + * enumerator.c (enum_iter): typedefed. + + * enumerator.c (next_i): suppress a warning. + Thu Aug 23 16:04:11 2007 Koichi Sasada <ko1@a...> * compile.c, insns.def, parse.y: fix massign order. This change Index: enumerator.c =================================================================== --- enumerator.c (revision 13237) +++ enumerator.c (revision 13238) @@ -22,7 +22,7 @@ * object. */ static VALUE rb_cEnumerator; -static VALUE sym_each, sym_each_with_index, sym_each_slice, sym_each_cons; +static VALUE sym_each, sym_each_with_index, sym_each_slice, sym_each_cons, sym_call; VALUE rb_eStopIteration; @@ -35,11 +35,14 @@ return rb_proc_call(proc, args); } +struct enumerator; +typedef VALUE enum_iter(VALUE, struct enumerator *); + struct enumerator { VALUE method; VALUE proc; VALUE args; - VALUE (*iter)(VALUE, struct enumerator *); + enum_iter *iter; VALUE fib; VALUE next; VALUE dst; @@ -154,7 +157,7 @@ args[0] = rb_ary_new2(size); args[1] = (VALUE)size; - rb_block_call(obj, rb_intern("each"), 0, 0, each_slice_i, (VALUE)args); + rb_block_call(obj, SYM2ID(sym_each), 0, 0, each_slice_i, (VALUE)args); ary = args[0]; if (RARRAY_LEN(ary) > 0) rb_yield(ary); @@ -210,7 +213,7 @@ args[0] = rb_ary_new2(size); args[1] = (VALUE)size; - rb_block_call(obj, rb_intern("each"), 0, 0, each_cons_i, (VALUE)args); + rb_block_call(obj, SYM2ID(sym_each), 0, 0, each_cons_i, (VALUE)args); return Qnil; } @@ -234,7 +237,7 @@ ptr->iter = enumerator_iter_i; } else { - ptr->iter = (VALUE (*)(VALUE, struct enumerator *))rb_yield; + ptr->iter = (enum_iter *)rb_yield; } if (argc) ptr->args = rb_ary_new4(argc, argv); ptr->fib = 0; @@ -317,7 +320,7 @@ argc = RARRAY_LEN(e->args); argv = RARRAY_PTR(e->args); } - return rb_block_call(e->method, rb_intern("call"), argc, argv, e->iter, (VALUE)e); + return rb_block_call(e->method, SYM2ID(sym_call), argc, argv, e->iter, (VALUE)e); } static VALUE @@ -349,7 +352,7 @@ argc = RARRAY_LEN(e->args); argv = RARRAY_PTR(e->args); } - return rb_block_call(e->method, rb_intern("call"), argc, argv, + return rb_block_call(e->method, SYM2ID(sym_call), argc, argv, enumerator_with_index_i, (VALUE)&memo); } @@ -388,7 +391,7 @@ rb_block_call(obj, rb_intern("each"), 0, 0, next_ii, obj); e->has_next = Qfalse; - rb_fiber_yield(1, &e->next); + return rb_fiber_yield(1, &e->next); } static void @@ -498,6 +501,7 @@ sym_each_with_index = ID2SYM(rb_intern("each_with_index")); sym_each_slice = ID2SYM(rb_intern("each_slice")); sym_each_cons = ID2SYM(rb_intern("each_cons")); + sym_call = ID2SYM(rb_intern("call")); rb_provide("enumerator.so"); /* for backward compatibility */ } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml