module FFI::Library
Constants
- TypeMap
Public Class Methods
extended(mod)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 167 def self.extended(mod) FFI.exporter.mod = mod end
Public Instance Methods
attach_function(name, func, args, returns = nil, options = nil)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 171 def attach_function(name, func, args, returns = nil, options = nil) mname, a2, a3, a4, a5 = name, func, args, returns, options cname, arg_types, ret_type, opts = (a4 && (a2.is_a?(String) || a2.is_a?(Symbol))) ? [ a2, a3, a4, a5 ] : [ mname.to_s, a2, a3, a4 ] arg_types = arg_types.map { |e| find_type(e) } FFI.exporter.attach(mname, cname, find_type(ret_type), arg_types) end
callback(*args)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 182 def callback(*args) name, params, ret = if args.length == 3 args else [ nil, args[0], args[1] ] end native_params = params.map { |e| find_type(e) } cb = FFI::CallbackInfo.new(find_type(ret), native_params) FFI.exporter.callback(name, cb) if name end
ffi_lib(*args)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 178 def ffi_lib(*args) end
find_type(type)
click to toggle source
# File lib/ffi-compiler/fake_ffi/ffi.rb, line 194 def find_type(type) t = TypeMap[type] return t unless t.nil? if type.is_a?(Class) && type < Struct return TypeMap[type] = StructByReference.new(type) end TypeMap[type] = FFI.find_type(type) end