def _SignedVarintEncoder():
  """Return an encoder for a basic signed varint value."""

  local_chr = chr
  def EncodeSignedVarint(write, value):
    if value < 0:
      value += (1 << 64)
    bits = value & 0x7f
    value >>= 7
    while value:
      write(0x80|bits)
      bits = value & 0x7f
      value >>= 7
    return write(bits)

  return EncodeSignedVarint
Return an encoder for a basic signed varint value.