Project

General

Profile

Bug #6389

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

Added by usa (Usaku NAKAMURA) about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Target version:
[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)

Associated revisions

Revision 4a097d2e
Added by usa (Usaku NAKAMURA) almost 6 years ago

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 36718
Added by usa (Usaku NAKAMURA) almost 6 years ago

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

Revision 36718
Added by usa (Usaku NAKAMURA) almost 6 years ago

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

Revision 36718
Added by usa (Usaku NAKAMURA) almost 6 years ago

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

Revision 36718
Added by usa (Usaku NAKAMURA) almost 6 years ago

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

Revision 36718
Added by usa (Usaku NAKAMURA) almost 6 years 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 usa (Usaku NAKAMURA) almost 6 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]

Also available in: Atom PDF