Bug #6389

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

Added by Usaku NAKAMURA almost 2 years ago. Updated over 1 year ago.

[ruby-dev:45604]
Status:Closed
Priority:Normal
Assignee:Aaron Patterson
Category:ext
Target version:1.9.3
ruby -v:- Backport:

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)

Associated revisions

Revision 36718
Added by Usaku NAKAMURA over 1 year ago

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

History

#1 Updated by Usaku NAKAMURA over 1 year 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]

Also available in: Atom PDF