summaryrefslogtreecommitdiff
path: root/ext/win32
diff options
context:
space:
mode:
Diffstat (limited to 'ext/win32')
-rw-r--r--ext/win32/extconf.rb2
-rw-r--r--ext/win32/lib/Win32API.rb18
-rw-r--r--ext/win32/lib/win32/importer.rb10
3 files changed, 15 insertions, 15 deletions
diff --git a/ext/win32/extconf.rb b/ext/win32/extconf.rb
index 7aa2c93684..c4efee8149 100644
--- a/ext/win32/extconf.rb
+++ b/ext/win32/extconf.rb
@@ -1,3 +1,3 @@
-if (compiled?('dl') or compiled?('fiddle')) and $mswin||$mingw||$cygwin
+if compiled?('fiddle') and $mswin||$mingw||$cygwin
create_makefile('win32')
end
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
diff --git a/ext/win32/lib/win32/importer.rb b/ext/win32/lib/win32/importer.rb
index 5936bb6900..7975cb7f5d 100644
--- a/ext/win32/lib/win32/importer.rb
+++ b/ext/win32/lib/win32/importer.rb
@@ -1,14 +1,8 @@
-begin
- require 'fiddle/import'
- importer = Fiddle::Importer
-rescue LoadError
- require 'dl/import'
- importer = DL::Importer
-end
+require 'fiddle/import'
module Win32
end
Win32.module_eval do
- Importer = importer
+ Importer = Fiddle::Importer
end