summaryrefslogtreecommitdiff
path: root/ext/win32
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-31 21:13:09 (GMT)
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-31 21:13:09 (GMT)
commit07308c4d30b8c5260e5366c8eed2abf054d86fe7 (patch)
tree0444881bba7151db3ff7e6776404cfc1643a8383 /ext/win32
parent88326272bc079cd0f47759e02e174f9ff1a73774 (diff)
* ext/dl/*: remove DL as it is replaced by Fiddle.
[Feature #5458] Thanks to Jonan Scheffler <jonanscheffler@gmail.com> 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')
-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 7aa2c93..c4efee8 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 4d7d488..24b33f1 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 5936bb6..7975cb7 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