class FFIDB::Library

Attributes

dlopen[R]
headers[R]
name[R]
objects[R]
packages[R]
path[R]
source[R]
summary[R]
version[R]
website[R]

Public Class Methods

new(name, version, path) click to toggle source

@param [String, to_s] name @param [String, to_s] version @param [Pathname, to_s] path

# File lib/ffidb/library.rb, line 36
def initialize(name, version, path)
  @name, @version = name.to_s.freeze, (version || :stable).to_s.freeze
  @path = Pathname(path).freeze
  if (metadata_path = @path.join('library.yaml')).exist?
    metadata  = YAML.load(metadata_path.read).transform_keys(&:to_sym)
    metadata.delete(:name)
    @summary  = metadata.delete(:summary).freeze
    @website  = metadata.delete(:website).freeze
    @source   = metadata.delete(:source).freeze
    @packages = metadata.delete(:packages).transform_keys(&:to_sym).freeze
    dlopen    = metadata.delete(:dlopen).freeze
    @dlopen   = dlopen.is_a?(Array) ? dlopen : [dlopen]
    @objects  = (metadata.delete(:objects) || []).freeze
    @headers  = (metadata.delete(:headers) || []).freeze
  end
end

Public Instance Methods

<=>(other) click to toggle source

@param [Library] other @return [Integer]

# File lib/ffidb/library.rb, line 30
def <=>(other) self.name <=> other&.name end
each_enum(&block) click to toggle source

@yield [enum] @yieldparam [enum] Enum @return [Enumerator]

# File lib/ffidb/library.rb, line 79
def each_enum(&block)
  return self.to_enum(:each_enum) unless block_given?
  self.each_symbol.filter { |symbol| symbol.enum? }.each(&block)
end
each_function(&block) click to toggle source

@yield [function] @yieldparam [function] Function @return [Enumerator]

# File lib/ffidb/library.rb, line 106
def each_function(&block)
  return self.to_enum(:each_function) unless block_given?
  self.each_symbol.filter { |symbol| symbol.function? }.each(&block)
end
each_release(&block) click to toggle source

@yield [release] @yieldparam [release] Release @return [Enumerator]

# File lib/ffidb/library.rb, line 61
def each_release(&block)
  return self.to_enum(:each_release) unless block_given?
  # TODO
end
each_struct(&block) click to toggle source

@yield [struct] @yieldparam [struct] Struct @return [Enumerator]

# File lib/ffidb/library.rb, line 88
def each_struct(&block)
  return self.to_enum(:each_struct) unless block_given?
  self.each_symbol.filter { |symbol| symbol.struct? }.each(&block)
end
each_symbol(&block) click to toggle source

@yield [symbol] @yieldparam [symbol] Symbolic @return [Enumerator]

# File lib/ffidb/library.rb, line 115
def each_symbol(&block)
  return self.to_enum(:each_symbol) unless block_given?
  LibraryParser.new(self.path.join(self.version)).each_symbol(&block)
end
each_typedef(&block) click to toggle source

@yield [typedef] @yieldparam [symbol] Symbolic @return [Enumerator]

# File lib/ffidb/library.rb, line 70
def each_typedef(&block)
  return self.to_enum(:each_typedef) unless block_given?
  self.each_symbol.filter { |symbol| symbol.typedef? }.each(&block)
end
each_union(&block) click to toggle source

@yield [union] @yieldparam [union] Union @return [Enumerator]

# File lib/ffidb/library.rb, line 97
def each_union(&block)
  return self.to_enum(:each_union) unless block_given?
  self.each_symbol.filter { |symbol| symbol.union? }.each(&block)
end
soname() click to toggle source

@return [String]

# File lib/ffidb/library.rb, line 55
def soname() self.objects&.first end