module Fiddler

Constants

LIBPATHS
LIBSUFFIX
LLONG
UCHAR
UINT
ULLONG
ULONG
USHORT
VERSION

Public Class Methods

included(base) click to toggle source
# File lib/fiddler.rb, line 73
def self.included(base)
  base.extend self
end

Public Instance Methods

[](val) click to toggle source
# File lib/fiddler.rb, line 65
def [](val)
  cdefs[val]
end
cdef(name, ret_type, args_types={}, options={}) click to toggle source
# File lib/fiddler.rb, line 45
  def cdef(name, ret_type, args_types={}, options={})
    address     = handler["#{@_prefix}#{name}"] || handler[name.to_s]
    options     = {name: name}.merge(options)
    call_type   = options.delete(:call_type) || Function::DEFAULT
    params      = args_types.keys.join(', ')
    values      = args_types.values
    cdefs[name] = Function.new(address, values, ret_type, call_type, options)

    module_eval <<-RB, __FILE__, __LINE__ + 1
    def #{name}(#{params})
      cdefs[#{name.inspect}].call(#{params})
    end
    module_function #{name.inspect}
    RB
  end
cdefs() click to toggle source
# File lib/fiddler.rb, line 61
def cdefs
  @_cdefs ||= {}
end
dlload(*libs) click to toggle source
Calls superclass method
# File lib/fiddler.rb, line 24
def dlload(*libs)
  libs.map! do |lib|
    LIBPATHS.map { |l| File.join(l, "#{lib}.#{LIBSUFFIX}") }.
    detect { |l| File.exist?(l) }
  end
  super(*libs)
end
prefix(value) click to toggle source
# File lib/fiddler.rb, line 69
def prefix(value)
  @_prefix = value
end