Class: FFI::BitStruct
Direct Known Subclasses
Class Attribute Summary collapse
-
.bit_fields_hash_table ⇒ Object
readonly
Returns the value of attribute bit_fields_hash_table.
Class Method Summary collapse
Methods inherited from Struct
Class Attribute Details
.bit_fields_hash_table ⇒ Object (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 |