зеркало из https://github.com/github/ruby.git
* ext/dl/lib/dl/win32.rb: compatibility improvement.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
d15f5e8d55
Коммит
3074716cad
|
@ -1,3 +1,7 @@
|
||||||
|
Sat Jan 11 22:50:47 2003 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/dl/lib/dl/win32.rb: compatibility improvement.
|
||||||
|
|
||||||
Sat Jan 11 01:44:16 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Sat Jan 11 01:44:16 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* configure.in (RUBY_CHECK_IO_NEED): added more tests.
|
* configure.in (RUBY_CHECK_IO_NEED): added more tests.
|
||||||
|
|
|
@ -3,24 +3,27 @@
|
||||||
require 'dl'
|
require 'dl'
|
||||||
|
|
||||||
class Win32API
|
class Win32API
|
||||||
LIBRARY = {}
|
DLL = {}
|
||||||
|
|
||||||
attr_reader :val, :args
|
def initialize(dllname, func, import, export = "0")
|
||||||
|
prototype = (export + import.to_s).tr("VPpNnLlIi", "0SSI")
|
||||||
def initialize(lib, func, args, ret)
|
handle = DLL[dllname] ||= DL::Handle.new(dllname)
|
||||||
LIBRARY[lib] ||= DL.dlopen(lib)
|
begin
|
||||||
ty = (ret + args).tr('V','0')
|
@sym = handle.sym(func, prototype)
|
||||||
@sym = LIBRARY[lib].sym(func, ty)
|
rescue RuntimeError
|
||||||
@__dll__ = LIBRARY[lib].to_i
|
@sym = handle.sym(func + "A", prototype)
|
||||||
@__dllname__ = lib
|
end
|
||||||
@__proc__ = @sym.to_i
|
|
||||||
@val = nil
|
|
||||||
@args = []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(*args)
|
def call(*args)
|
||||||
@val,@args = @sym.call(*args)
|
import = @sym.proto[1..-1] || ""
|
||||||
return @val
|
args.each_with_index do |x, i|
|
||||||
|
args[i] = nil if x == 0 and import[i] == ?S
|
||||||
|
args[i], = [x].pack("I").unpack("i") if import[i] == ?I
|
||||||
|
end
|
||||||
|
ret, = @sym.call(*args)
|
||||||
|
return ret || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
alias Call call
|
alias Call call
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче