diff options
author | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-31 21:13:09 +0000 |
---|---|---|
committer | tenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-10-31 21:13:09 +0000 |
commit | 07308c4d30b8c5260e5366c8eed2abf054d86fe7 (patch) | |
tree | 0444881bba7151db3ff7e6776404cfc1643a8383 /ext/win32/lib/Win32API.rb | |
parent | 88326272bc079cd0f47759e02e174f9ff1a73774 (diff) |
* ext/dl/*: remove DL as it is replaced by Fiddle.
[Feature #5458] Thanks to Jonan Scheffler <[email protected]>
for this patch
* test/dl/*: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32/lib/Win32API.rb')
-rw-r--r-- | ext/win32/lib/Win32API.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/win32/lib/Win32API.rb b/ext/win32/lib/Win32API.rb index 4d7d4887a5..24b33f1791 100644 --- a/ext/win32/lib/Win32API.rb +++ b/ext/win32/lib/Win32API.rb @@ -2,18 +2,24 @@ # for backward compatibility warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: Win32API is deprecated after Ruby 1.9.1; use dl directly instead" if $VERBOSE -require 'dl' +require 'fiddle' class Win32API DLL = {} - TYPEMAP = {"0" => DL::TYPE_VOID, "S" => DL::TYPE_VOIDP, "I" => DL::TYPE_LONG} - POINTER_TYPE = DL::SIZEOF_VOIDP == DL::SIZEOF_LONG_LONG ? 'q*' : 'l!*' + TYPEMAP = {"0" => Fiddle::TYPE_VOID, "S" => Fiddle::TYPE_VOIDP, "I" => Fiddle::TYPE_LONG} + POINTER_TYPE = Fiddle::SIZEOF_VOIDP == Fiddle::SIZEOF_LONG_LONG ? 'q*' : 'l!*' def initialize(dllname, func, import, export = "0", calltype = :stdcall) @proto = [import].join.tr("VPpNnLlIi", "0SSI").sub(/^(.)0*$/, '\1') - handle = DLL[dllname] ||= DL.dlopen(dllname) - @func = DL::CFunc.new(handle[func], TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], func, calltype) - rescue DL::DLError => e + handle = DLL[dllname] ||= Fiddle.dlopen(dllname) + + @func = Fiddle::Function.new( + handle[func], + import.map { |win_type| TYPEMAP[win_type.tr("VPpNnLlIi", "0SSI")] }, + TYPEMAP[export.tr("VPpNnLlIi", "0SSI")], + Fiddle::Importer::CALL_TYPE_TO_ABI[calltype] + ) + rescue Fiddle::DLError => e raise LoadError, e.message, e.backtrace end |