Method: Fiddle::CUnionEntity.size

Defined in:
lib/fiddle/struct.rb

.size(types) ⇒ Object

Returns the size needed for the union with the given types.

Fiddle::CUnionEntity.size(
  [ Fiddle::TYPE_DOUBLE,
    Fiddle::TYPE_INT,
    Fiddle::TYPE_CHAR,
    Fiddle::TYPE_VOIDP ]) #=> 8


542
543
544
545
546
547
548
549
550
# File 'lib/fiddle/struct.rb', line 542

def CUnionEntity.size(types)
  types.map { |type, count = 1|
    if type.respond_to?(:entity_class)
      type.size * count
    else
      PackInfo::SIZE_MAP[type] * count
    end
  }.max
end