class FFI::Struct

def layout(*spec)

def layout(*spec)
  return @layout if spec.size == 0
  builder = FFI::StructLayoutBuilder.new
  builder.union = self < Union
  if spec[0].kind_of?(Hash)
    hash_layout(builder, spec)
  else
    array_layout(builder, spec)
  end
  builder.size = @size if defined?(@size) && @size > builder.size
  cspec = builder.build
  @layout = cspec unless self == FFI::Struct
  @size = cspec.size
  return cspec
end