module BinData

def trace_message # :nodoc:

:nodoc:
def trace_message # :nodoc:
  yield @tracer
end

def trace_reading(io = STDERR)

This is useful for debugging a BinData declaration.
If +block+ is given then the tracing only occurs for that block.
Turn on trace information when reading a BinData object.
def trace_reading(io = STDERR)
  @tracer = Tracer.new(io)
  [BasePrimitive, Choice].each(&:turn_on_tracing)
  if block_given?
    begin
      yield
    ensure
      [BasePrimitive, Choice].each(&:turn_off_tracing)
      @tracer = nil
    end
  end
end