2010-05-06 02:59:24 -04:00
|
|
|
require 'fiddle.so'
|
|
|
|
require 'fiddle/function'
|
|
|
|
require 'fiddle/closure'
|
|
|
|
|
|
|
|
module Fiddle
|
|
|
|
if WINDOWS
|
2011-08-15 19:48:59 -04:00
|
|
|
# Returns the last win32 +Error+ of the current executing +Thread+ or nil
|
|
|
|
# if none
|
2010-05-06 02:59:24 -04:00
|
|
|
def self.win32_last_error
|
|
|
|
Thread.current[:__FIDDLE_WIN32_LAST_ERROR__]
|
|
|
|
end
|
|
|
|
|
2011-08-15 19:48:59 -04:00
|
|
|
# Sets the last win32 +Error+ of the current executing +Thread+ to +error+
|
2010-05-06 02:59:24 -04:00
|
|
|
def self.win32_last_error= error
|
|
|
|
Thread.current[:__FIDDLE_WIN32_LAST_ERROR__] = error
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-08-15 19:48:59 -04:00
|
|
|
# Returns the last +Error+ of the current executing +Thread+ or nil if none
|
2010-05-06 02:59:24 -04:00
|
|
|
def self.last_error
|
|
|
|
Thread.current[:__FIDDLE_LAST_ERROR__]
|
|
|
|
end
|
|
|
|
|
2011-08-15 19:48:59 -04:00
|
|
|
# Sets the last +Error+ of the current executing +Thread+ to +error+
|
2010-05-06 02:59:24 -04:00
|
|
|
def self.last_error= error
|
|
|
|
Thread.current[:__DL2_LAST_ERROR__] = error
|
|
|
|
Thread.current[:__FIDDLE_LAST_ERROR__] = error
|
|
|
|
end
|
2012-11-26 20:38:41 -05:00
|
|
|
|
|
|
|
def dlopen library
|
|
|
|
Fiddle::Handle.new library
|
|
|
|
end
|
|
|
|
module_function :dlopen
|
|
|
|
|
|
|
|
# Add constants for backwards compat
|
|
|
|
|
|
|
|
RTLD_GLOBAL = Handle::RTLD_GLOBAL # :nodoc:
|
|
|
|
RTLD_LAZY = Handle::RTLD_LAZY # :nodoc:
|
|
|
|
RTLD_NOW = Handle::RTLD_NOW # :nodoc:
|
2010-05-06 02:59:24 -04:00
|
|
|
end
|