summaryrefslogtreecommitdiff
path: root/ext/dl/lib/dl
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-11 15:24:31 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-11 15:24:31 +0000
commit1fcde7c2e2bd780fc3bf4bf98fad7054177de5aa (patch)
tree5197f7212f58ded52d4c355e9643d870bf2854e9 /ext/dl/lib/dl
parent80e1f46ff07436b3c95624046f50667dde6b7da6 (diff)
* ext/dl/lib/dl/func.rb (DL::Function#unbind, #bound?): suppress NoMethodError when Fiddle is available. [ruby-core:50756] [Bug #7543]
* test/dl/test_func.rb (test_bound*, test_unbind*): tests for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/lib/dl')
-rw-r--r--ext/dl/lib/dl/func.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/dl/lib/dl/func.rb b/ext/dl/lib/dl/func.rb
index 434f1bc868..a2e503835f 100644
--- a/ext/dl/lib/dl/func.rb
+++ b/ext/dl/lib/dl/func.rb
@@ -36,6 +36,9 @@ module DL
def name
@name
end
+ def ptr
+ to_i
+ end
end
private_constant :FiddleClosureCFunc
@@ -157,6 +160,25 @@ module DL
end
def unbind()
+ if DL.fiddle? then
+ if @cfunc.kind_of?(Fiddle::Closure) and @cfunc.ptr != 0 then
+ call_type = case abi
+ when CALL_TYPE_TO_ABI[nil]
+ nil
+ when CALL_TYPE_TO_ABI[:stdcall]
+ :stdcall
+ else
+ raise(RuntimeError, "unsupported abi: #{abi}")
+ end
+ @cfunc = CFunc.new(0, @cfunc.ctype, name, call_type)
+ return 0
+ elsif @cfunc.ptr != 0 then
+ @cfunc.ptr = 0
+ return 0
+ else
+ return nil
+ end
+ end
if( @cfunc.ptr != 0 )
case @cfunc.calltype
when :cdecl