diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/ext/dl/lib/dl/callback.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/dl/lib/dl/callback.rb')
-rw-r--r-- | trunk/ext/dl/lib/dl/callback.rb | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/trunk/ext/dl/lib/dl/callback.rb b/trunk/ext/dl/lib/dl/callback.rb deleted file mode 100644 index d0b2c7a819..0000000000 --- a/trunk/ext/dl/lib/dl/callback.rb +++ /dev/null @@ -1,69 +0,0 @@ -require 'dl' -require 'thread' - -module DL - SEM = Mutex.new - - def set_callback_internal(proc_entry, addr_entry, argc, ty, &cbp) - if( argc < 0 ) - raise(ArgumentError, "arity should not be less than 0.") - end - addr = nil - SEM.synchronize{ - ary = proc_entry[ty] - (0...MAX_CALLBACK).each{|n| - idx = (n * DLSTACK_SIZE) + argc - if( ary[idx].nil? ) - ary[idx] = cbp - addr = addr_entry[ty][idx] - break - end - } - } - addr - end - - def set_cdecl_callback(ty, argc, &cbp) - set_callback_internal(CdeclCallbackProcs, CdeclCallbackAddrs, argc, ty, &cbp) - end - - def set_stdcall_callback(ty, argc, &cbp) - set_callback_internal(StdcallCallbackProcs, StdcallCallbackAddrs, argc, ty, &cbp) - end - - def remove_callback_internal(proc_entry, addr_entry, addr, ctype = nil) - index = nil - if( ctype ) - addr_entry[ctype].each_with_index{|xaddr, idx| - if( xaddr == addr ) - index = idx - end - } - else - addr_entry.each{|ty,entry| - entry.each_with_index{|xaddr, idx| - if( xaddr == addr ) - index = idx - end - } - } - end - if( proc_entry[ctype][index] ) - proc_entry[ctype][index] = nil - return true - else - return false - end - end - - def remove_cdecl_callback(addr, ctype = nil) - remove_callback_internal(CdeclCallbackProcs, CdeclCallbackAddrs, addr, ctype) - end - - def remove_stdcall_callback(addr, ctype = nil) - remove_callback_internal(StdcallCallbackProcs, StdcallCallbackAddrs, addr, ctype) - end - - alias set_callback set_cdecl_callback - alias remove_callback remove_cdecl_callback -end |