From 07308c4d30b8c5260e5366c8eed2abf054d86fe7 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Fri, 31 Oct 2014 21:13:09 +0000 Subject: * ext/dl/*: remove DL as it is replaced by Fiddle. [Feature #5458] Thanks to Jonan Scheffler for this patch * test/dl/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/win32/extconf.rb | 2 +- ext/win32/lib/Win32API.rb | 18 ++++++++++++------ ext/win32/lib/win32/importer.rb | 10 ++-------- 3 files changed, 15 insertions(+), 15 deletions(-) (limited to 'ext/win32') 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 -- cgit v1.2.3