From e791259e005e35069af7d701366f11c320eb31f2 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 21 Dec 2007 07:33:31 +0000 Subject: * enumerator.c (enumerator_iter_i): adjusted for rb_block_call_func. * include/ruby/ruby.h (rb_block_call_func): function to be called back as block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- enumerator.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'enumerator.c') diff --git a/enumerator.c b/enumerator.c index 2217ed648e..25c9ece24c 100644 --- a/enumerator.c +++ b/enumerator.c @@ -35,14 +35,11 @@ proc_call(VALUE proc, VALUE args) return rb_proc_call(proc, args); } -struct enumerator; -typedef VALUE enum_iter(VALUE, struct enumerator *, VALUE); - struct enumerator { VALUE method; VALUE proc; VALUE args; - enum_iter *iter; + rb_block_call_func *iter; VALUE fib; VALUE dst; VALUE no_next; @@ -77,8 +74,9 @@ enumerator_ptr(VALUE obj) } static VALUE -enumerator_iter_i(VALUE i, struct enumerator *e, VALUE argc) +enumerator_iter_i(VALUE i, VALUE enum_obj, int argc, VALUE *argv) { + struct enumerator *e = (struct enumerator *)enum_obj; return rb_yield(proc_call(e->proc, i)); } @@ -241,7 +239,7 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv) ptr->iter = enumerator_iter_i; } else { - ptr->iter = (enum_iter *)enumerator_each_i; + ptr->iter = enumerator_each_i; } if (argc) ptr->args = rb_ary_new4(argc, argv); ptr->fib = 0; @@ -369,7 +367,6 @@ enumerator_with_index(VALUE obj) static VALUE next_ii(VALUE i, VALUE obj) { - struct enumerator *e = enumerator_ptr(obj); rb_fiber_yield(1, &i); return Qnil; } -- cgit v1.2.3