diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-06 06:59:24 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-06 06:59:24 +0000 |
commit | 4bada8b864e445b6eebe1a341e30cad94dbcaf84 (patch) | |
tree | bb7e4ed991aa16eda953d536265c6f9e5dc03a5d /ext/dl/lib/dl/import.rb | |
parent | ca3c007f058f17b2f0bf3c5ccc6701f3f6d49ca5 (diff) | |
download | ruby-4bada8b864e445b6eebe1a341e30cad94dbcaf84.tar.gz |
* ext/fiddle/*: Adding fiddle library to wrap libffi
* test/fiddle/*: testing fiddle extension
* ext/dl/lib/dl.rb: Requiring fiddle if it is available
* ext/dl/lib/dl/callback.rb: using Fiddle if it is available
* ext/dl/lib/dl/func.rb: ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/lib/dl/import.rb')
-rw-r--r-- | ext/dl/lib/dl/import.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb index 199354c18e..fd23bc9676 100644 --- a/ext/dl/lib/dl/import.rb +++ b/ext/dl/lib/dl/import.rb @@ -211,9 +211,17 @@ module DL end def bind_function(name, ctype, argtype, call_type = nil, &block) - f = Function.new(CFunc.new(0, ctype, name, call_type || :cdecl), argtype) - f.bind(&block) - f + if DL.fiddle? + closure = Class.new(Fiddle::Closure) { + define_method(:call, block) + }.new(ctype, argtype) + + Function.new(closure, argtype) + else + f = Function.new(CFunc.new(0, ctype, name, call_type || :cdecl), argtype) + f.bind(&block) + f + end end def create_temp_function(name, ctype, argtype, call_type = nil) |