Class: FFI::BitStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/hts/ffi.rb

Direct Known Subclasses

HTS::FFI::Bcf1

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Struct

struct_layout, union_layout

Class Attribute Details

.bit_fields_hash_tableObject (readonly)

Returns the value of attribute bit_fields_hash_table.



49
50
51
# File 'lib/hts/ffi.rb', line 49

def bit_fields_hash_table
  @bit_fields_hash_table
end

Class Method Details

.bitfields(*args) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/hts/ffi.rb', line 51

def bitfields(*args)
  unless instance_variable_defined?(:@bit_fields_hash_table)
    @bit_fields_hash_table = {}
    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_hash_table[l] = [parent, s, w]
  end
end