module BinData::Struct::ByteAlignPlugin

def do_write(io)

def do_write(io)
  offset = 0
  instantiate_all_objs
  @field_objs.each do |f|
    next unless include_obj?(f)
    if align_obj?(f)
      nbytes = bytes_to_align(f, offset.ceil)
      offset = offset.ceil + nbytes
      io.writebytes("\x00" * nbytes)
    end
    f.do_write(io)
    nbytes = f.do_num_bytes
    offset = (nbytes.is_a?(Integer) ? offset.ceil : offset) + nbytes
  end
end