module BinData::CheckOrAdjustOffsetPlugin::AdjustOffsetMixin

def adjust_offset(io)

def adjust_offset(io)
  actual_offset = io.offset
  expected = eval_parameter(:adjust_offset)
  if actual_offset != expected
    begin
      seek = expected - actual_offset
      io.seekbytes(seek)
      warn "adjusting stream position by #{seek} bytes" if $VERBOSE
    rescue
      raise ValidityError,
            "offset is '#{actual_offset}' but couldn't seek to " +
            "expected '#{expected}' for #{debug_name}"
    end
  end
end

def do_read(io) #:nodoc:

:nodoc:
def do_read(io) #:nodoc:
  adjust_offset(io)
  super(io)
end