Project

General

Profile

Actions

Bug #6389

closed

Should be able to `return' and `break' from callback method of plain DL?

Added by usa (Usaku NAKAMURA) over 12 years ago. Updated over 12 years ago.

Status:
Closed
Target version:
ruby -v:
-
Backport:
[ruby-dev:45604]

Description

IRCで笹田さんと話をしていて発見したのですが、fiddleありだと
DLのコールバックメソッドからreturnやbreakが可能ですが、なしだと
LocalJumpErrorが発生します。

私の見解としては、returnできた方がうれしい気がしています。
が、いずれにせよ、挙動を揃えた方がいいのではないかと思います。
どう思いますか?>Aaronさん

以下、素のDLでもreturnできるようにするパッチです。

Index: ext/dl/lib/dl/func.rb

--- ext/dl/lib/dl/func.rb (リビジョン 35505)
+++ ext/dl/lib/dl/func.rb (作業コピー)
@@ -90,6 +90,9 @@ module DL
if( !block )
raise(RuntimeError, "block must be given.")
end

  •    unless block.lambda?
    
  •      block = Class.new{define_method(:call, block)}.new.method(:call)
    
  •    end
       if( @cfunc.ptr == 0 )
         cb = Proc.new{|*args|
           ary = @stack.unpack(args)
    
Actions #1

Updated by usa (Usaku NAKAMURA) over 12 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36718.
Usaku, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/dl/lib/dl/func.rb (DL::Function#bind): allow to return/break from
    the callback method. (Fiddle already allows it.)
    [Bug #6389] [ruby-dev:45604]
Actions

Also available in: Atom PDF

Like0
Like0