Method: DL::CStructEntity#set_ctypes
- Defined in:
- lib/dl/struct.rb
#set_ctypes(types) ⇒ Object
Given types, calculate the offsets and sizes for the types in the struct.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/dl/struct.rb', line 127 def set_ctypes(types) @ctypes = types @offset = [] offset = 0 max_align = types.map { |type, count = 1| orig_offset = offset align = ALIGN_MAP[type] offset = PackInfo.align(orig_offset, align) @offset << offset offset += (SIZE_MAP[type] * count) align }.max @size = PackInfo.align(offset, max_align) end |