From cb46d98caad5b49dd416c5909e4b10fe957ea876 Mon Sep 17 00:00:00 2001 From: mame Date: Mon, 13 Jul 2009 16:07:43 +0000 Subject: [PATCH] * enumerator.c (yielder_yield_i): use rb_proc_new instead of rb_iterate. [ruby-dev:38518] * README.EXT: rb_iterate is obsolete since 1.9; use rb_block_call instead. * README.EXT.ja: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ README.EXT | 13 ++++++++++++- README.EXT.ja | 13 ++++++++++++- enumerator.c | 8 +------- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 66027dbc72..0e4ca43040 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Jul 14 01:06:31 2009 Yusuke Endoh + + * enumerator.c (yielder_yield_i): use rb_proc_new instead of + rb_iterate. [ruby-dev:38518] + + * README.EXT: rb_iterate is obsolete since 1.9; use rb_block_call + instead. + + * README.EXT.ja: ditto. + Tue Jul 14 00:45:41 2009 Yuki Sonoda (Yugui) * test/ruby/test_case.rb (TestCase#test_deoptimization): diff --git a/README.EXT b/README.EXT index 667d551664..da0f6148f1 100644 --- a/README.EXT +++ b/README.EXT @@ -1159,12 +1159,23 @@ Sets the value of the instance variable. ** Control Structure - VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2) + VALUE rb_block_call(VALUE recv, ID mid, int argc, VALUE * argv, + VALUE (*func) (ANYARGS), VALUE data2) + +Calls a method on the recv, with the method name specified by the +symbol mid, supplying func as the block. func will receive the +value from yield as the first argument, data2 as the second, and +argc/argv as the third/fourth arguments. + + [OBSOLETE] VALUE rb_iterate(VALUE (*func1)(), void *arg1, VALUE (*func2)(), void *arg2) Calls the function func1, supplying func2 as the block. func1 will be called with the argument arg1. func2 receives the value from yield as the first argument, arg2 as the second argument. +When rb_iterate is used in 1.9, func1 has to call some Ruby-level method. +This function is obsolete since 1.9; use rb_block_call instead. + VALUE rb_yield(VALUE val) Evaluates the block with value val. diff --git a/README.EXT.ja b/README.EXT.ja index a07fddf09e..c6b5dfed9f 100644 --- a/README.EXT.ja +++ b/README.EXT.ja @@ -1258,12 +1258,23 @@ VALUE rb_iv_set(VALUE obj, const char *name, VALUE val) ** 制御構造 -VALUE rb_iterate(VALUE (*func1)(), VALUE arg1, VALUE (*func2)(), VALUE arg2) +VALUE rb_block_call(VALUE obj, ID mid, int argc, VALUE * argv, + VALUE (*func) (ANYARGS), VALUE data2) + + funcをブロックとして設定し, objをレシーバ, argcとargvを引 + 数としてmidメソッドを呼び出す. funcは第一引数にyieldされた + 値, 第二引数にdata2, 第三, 第四引数にargcとargvを受け取る. + +[OBSOLETE] VALUE rb_iterate(VALUE (*func1)(), VALUE arg1, VALUE (*func2)(), VALUE arg2) func2をブロックとして設定し, func1をイテレータとして呼ぶ. func1には arg1が引数として渡され, func2には第1引数にイテレー タから与えられた値, 第2引数にarg2が渡される. + 1.9でrb_iterateを使う場合は, func1の中でRubyレベルのメソッド + を呼び出さなければならない. + 1.9でobsoleteとなった. 代わりにrb_block_callが用意された. + VALUE rb_yield(VALUE val) valを値としてイテレータブロックを呼び出す. diff --git a/enumerator.c b/enumerator.c index 6723d72769..355a8f3948 100644 --- a/enumerator.c +++ b/enumerator.c @@ -717,12 +717,6 @@ yielder_yield(VALUE obj, VALUE args) return obj; } -static VALUE -yielder_new_i(VALUE dummy) -{ - return yielder_init(yielder_allocate(rb_cYielder), rb_block_proc()); -} - static VALUE yielder_yield_i(VALUE obj, VALUE memo, int argc, VALUE *argv) { @@ -732,7 +726,7 @@ yielder_yield_i(VALUE obj, VALUE memo, int argc, VALUE *argv) static VALUE yielder_new(void) { - return rb_iterate(yielder_new_i, (VALUE)0, yielder_yield_i, (VALUE)0); + return yielder_init(yielder_allocate(rb_cYielder), rb_proc_new(yielder_yield_i, 0)); } /*