Class: FFI::BitStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/minimap2/ffi_helper.rb

Direct Known Subclasses

Minimap2::FFI::Extra, Minimap2::FFI::Reg1

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.bit_fields_mapObject (readonly)

Returns the value of attribute bit_fields_map.



29
30
31
# File 'lib/minimap2/ffi_helper.rb', line 29

def bit_fields_map
  @bit_fields_map
end

Class Method Details

.bitfields(*args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/minimap2/ffi_helper.rb', line 31

def bitfields(*args)
  unless instance_variable_defined?(:@bit_fields)
    @bit_fields_map = {}
    prepend BitFieldsModule
  end

  parent = args.shift
  labels = []
  widths = []
  args.each_slice(2) do |l, w|
    labels << l
    widths << w
  end
  starts = widths.inject([0]) do |result, w|
    result << (result.last + w)
  end
  labels.zip(starts, widths).each do |l, s, w|
    @bit_fields_map[l] = [parent, s, w]
  end
end