ruby-changes:12287
From: nobu <ko1@a...>
Date: Tue, 7 Jul 2009 13:37:07 +0900 (JST)
Subject: [ruby-changes:12287] Ruby:r23980 (trunk): * enum.c (DEFINE_ENUMFUNCS): included function signature.
nobu 2009-07-07 13:36:50 +0900 (Tue, 07 Jul 2009) New Revision: 23980 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23980 Log: * enum.c (DEFINE_ENUMFUNCS): included function signature. Modified files: trunk/ChangeLog trunk/enum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 23979) +++ ChangeLog (revision 23980) @@ -1,5 +1,7 @@ -Tue Jul 7 13:34:30 2009 Nobuyoshi Nakada <nobu@r...> +Tue Jul 7 13:36:46 2009 Nobuyoshi Nakada <nobu@r...> + * enum.c (DEFINE_ENUMFUNCS): included function signature. + * enum.c (rb_enum_join): non-nil separator must be convertible to String. [ruby-core:24172] Index: enum.c =================================================================== --- enum.c (revision 23979) +++ enum.c (revision 23980) @@ -823,7 +823,11 @@ return ary; } +#define ENUMFUNC(name) rb_block_given_p() ? name##_iter_i : name##_i + #define DEFINE_ENUMFUNCS(name) \ +static VALUE enum_##name##_func(VALUE result, VALUE *memo); \ +\ static VALUE \ name##_i(VALUE i, VALUE *memo, int argc, VALUE *argv) \ { \ @@ -834,10 +838,12 @@ name##_iter_i(VALUE i, VALUE *memo, int argc, VALUE *argv) \ { \ return enum_##name##_func(enum_yield(argc, argv), memo); \ -} +} \ +\ +static VALUE \ +enum_##name##_func(VALUE result, VALUE *memo) -static VALUE -enum_all_func(VALUE result, VALUE *memo) +DEFINE_ENUMFUNCS(all) { if (!RTEST(result)) { *memo = Qfalse; @@ -846,8 +852,6 @@ return Qnil; } -DEFINE_ENUMFUNCS(all) - /* * call-seq: * enum.all? [{|obj| block } ] => true or false @@ -870,12 +874,11 @@ { VALUE result = Qtrue; - rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? all_iter_i : all_i, (VALUE)&result); + rb_block_call(obj, id_each, 0, 0, ENUMFUNC(all), (VALUE)&result); return result; } -static VALUE -enum_any_func(VALUE result, VALUE *memo) +DEFINE_ENUMFUNCS(any) { if (RTEST(result)) { *memo = Qtrue; @@ -884,8 +887,6 @@ return Qnil; } -DEFINE_ENUMFUNCS(any) - /* * call-seq: * enum.any? [{|obj| block } ] => true or false @@ -909,12 +910,11 @@ { VALUE result = Qfalse; - rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? any_iter_i : any_i, (VALUE)&result); + rb_block_call(obj, id_each, 0, 0, ENUMFUNC(any), (VALUE)&result); return result; } -static VALUE -enum_one_func(VALUE result, VALUE *memo) +DEFINE_ENUMFUNCS(one) { if (RTEST(result)) { if (*memo == Qundef) { @@ -928,8 +928,6 @@ return Qnil; } -DEFINE_ENUMFUNCS(one) - /* * call-seq: * enum.one? [{|obj| block }] => true or false @@ -953,13 +951,12 @@ { VALUE result = Qundef; - rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? one_iter_i : one_i, (VALUE)&result); + rb_block_call(obj, id_each, 0, 0, ENUMFUNC(one), (VALUE)&result); if (result == Qundef) return Qfalse; return result; } -static VALUE -enum_none_func(VALUE result, VALUE *memo) +DEFINE_ENUMFUNCS(none) { if (RTEST(result)) { *memo = Qfalse; @@ -968,8 +965,6 @@ return Qnil; } -DEFINE_ENUMFUNCS(none) - /* * call-seq: * enum.none? [{|obj| block }] => true or false @@ -990,7 +985,7 @@ { VALUE result = Qtrue; - rb_block_call(obj, id_each, 0, 0, rb_block_given_p() ? none_iter_i : none_i, (VALUE)&result); + rb_block_call(obj, id_each, 0, 0, ENUMFUNC(none), (VALUE)&result); return result; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/