Like _VarintDecoder() but decodes signed values.
326247
def _SignedVarintDecoder(mask):
  """"""


  def DecodeVarint(buffer, pos):
    result = 0
    shift = 0
    while 1:
      if pos > len(buffer) -1:
        raise NotEnoughDataException(  "Not enough data to decode varint" )
      b = local_ord(buffer[pos])
      result |= ((b & 0x7f) << shift)
      pos += 1
      if not (b & 0x80):
        if result > 0x7fffffffffffffff:
          result -= (1 << 64)
          result |= ~mask
        else:
          result &= mask
        return (result, pos)
      shift += 7
      if shift >= 64:
        raise _DecodeError('Too many bytes when decoding varint.')

  return DecodeVarint
284483
def readEncodedU32(self):
        
        self.reset_bits_pending();
        result = self.readUI8();
        if result & 0x80 != 0:
            result = (result & 0x7f) | (self.readUI8() << 7)
            if result & 0x4000 != 0:
                result = (result & 0x3fff) | (self.readUI8() << 14)
                if result & 0x200000 != 0:
                    result = (result & 0x1fffff) | (self.readUI8() << 21)
                    if result & 0x10000000 != 0:
                        result = (result & 0xfffffff) | (self.readUI8() << 28)
        return result
823904
def _parse_sid_iter(data):
    """"""
    limit = len(data)
    buf = BytesIO(data)
    while buf.tell() < limit:
        sid = _parse_var_int(buf, signed=False)
        yield SymbolToken(None, sid)
1142066
def _encode_bool(name, value, dummy0, dummy1):
    """"""
    return b"\x08" + name + (value and b"\x01" or b"\x00")
975953
def _decode(self):
        

        result = []
        idx = 0
        s = self._encoded_value

        while (idx < len(s)):
            # Get the idx'th character of s
            c = s[idx]

            if (c in CPEComponent2_2.NON_STANDARD_VALUES):
                # Escape character
                result.append("\\")
                result.append(c)
            else:
                # Do nothing
                result.append(c)

            idx += 1

        self._standard_value = "".join(result)
461469
private int readRawVarint32(ByteBuffer bytes) {
    byte tmp = bytes.get();
    if (tmp >= 0) {
      return tmp;
    }
    int result = tmp & 0x7f;
    if ((tmp = bytes.get()) >= 0) {
      result |= tmp << 7;
    } else {
      result |= (tmp & 0x7f) << 7;
      if ((tmp = bytes.get()) >= 0) {
        result |= tmp << 14;
      } else {
        result |= (tmp & 0x7f) << 14;
        if ((tmp = bytes.get()) >= 0) {
          result |= tmp << 21;
        } else {
          result |= (tmp & 0x7f) << 21;
          result |= (tmp = bytes.get()) << 28;
          if (tmp < 0) {
            // Discard upper 32 bits.
            for (int i = 0; i < 5; i++) {
              if (bytes.get() >= 0) {
                return result;
              }
            }
            connectionHandler.onException(new ScopeException("Error while reading raw int"));
          }
        }
      }
    }
    return result;
  }
828562
def _decode_hex(self, value):
		
		result = ''
		for i in range(0, len(value), 2):
			tmp = int(value[i:i + 2], 16)
			result += chr(tmp)
		return result
1144629
def _decode_var(cls, string):
        

        str_match = cls.quoted_string_regex.match(string)
        if str_match:
            return string.strip("'" if str_match.groups()[0] else '"')
        # NOTE: "¹".isdigit() results in True because they are idiots
        elif string.isdigit() and cls.is_digit_regex.match(string) is not None:
            return int(string)
        elif string.lower() in ("true", "false"):
            return string.lower() == "true"
        elif string.lstrip("-").isdigit():
            try:
                return int(string)
            except ValueError:
                # case where we mistake something like "--0" as a int
                return string
        elif "." in string.lstrip("-"):
            try:
                return float(string)
            except ValueError:
                # one off case where we mistake a single "." as a float
                return string
        else:
            return string
760237
function encodeVarInt(value) {
    var bytes = [], cursor, length, i;

    do {
        bytes.push(value & 0x7F);
        value >>= 7;
    } while (value > 0);

    length = bytes.length;
    cursor = new BufferCursor(new buffer.Buffer(length));

    for (i = length - 1; i >= 0; i -= 1) {
        if (i > 0) {
            bytes[i] |= 0x80;
        }

        cursor.writeUInt8(bytes[i]);
    }

    return cursor.buffer;
}
1052176
def signedVarintSize(value):
  """"""
  if value < 0: return 10
  if value <= 0x7f: return 1
  if value <= 0x3fff: return 2
  if value <= 0x1fffff: return 3
  if value <= 0xfffffff: return 4
  if value <= 0x7ffffffff: return 5
  if value <= 0x3ffffffffff: return 6
  if value <= 0x1ffffffffffff: return 7
  if value <= 0xffffffffffffff: return 8
  if value <= 0x7fffffffffffffff: return 9
  return 10
1339958
def decint(n, signed=False):  # pylint: disable=invalid-name,too-many-branches
    

    if isinstance(n, str):
        n = utils.to_string(n)

    if n is True:
        return 1

    if n is False:
        return 0

    if n is None:
        return 0

    if is_numeric(n):
        if signed:
            if not -TT255 <= n <= TT255 - 1:
                raise EncodingError('Number out of range: %r' % n)
        else:
            if not 0 <= n <= TT256 - 1:
                raise EncodingError('Number out of range: %r' % n)

        return n

    if is_string(n):
        if len(n) > 32:
            raise EncodingError('String too long: %r' % n)

        if len(n) == 40:
            int_bigendian = decode_hex(n)
        else:
            int_bigendian = n  # pylint: disable=redefined-variable-type

        result = big_endian_to_int(int_bigendian)
        if signed:
            if result >= TT255:
                result -= TT256

            if not -TT255 <= result <= TT255 - 1:
                raise EncodingError('Number out of range: %r' % n)
        else:
            if not 0 <= result <= TT256 - 1:
                raise EncodingError('Number out of range: %r' % n)

        return result

    raise EncodingError('Cannot decode integer: %r' % n)
794870
def _decode(value):
        
        if value.isdigit():
            return int(value)
        if isinstance(value, bytes):
            return value.decode('utf-8')
        else:
            return value
1116414
def encode(self, value):
        """"""
        if isinstance(value, bytes):
            return value
        elif isinstance(value, int):
            value = b(str(value))
        elif isinstance(value, float):
            value = b(repr(value))
        elif not isinstance(value, str):
            value = str(value)
        if isinstance(value, str):
            value = value.encode()
        return value
646928
def decode(self, integers):
    """"""
    integers = list(np.squeeze(integers))
    return self.encoders["inputs"].decode(integers)
417439
def _encode(self, value):
        ""
        if isinstance(value, bytes):
            return value
        elif isinstance(value, (int, long)):
            value = str(value).encode('utf-8')
        elif isinstance(value, float):
            value = repr(value).encode('utf-8')
        elif not isinstance(value, basestring):
            value = str(value).encode('utf-8')
        else:
            value = value.encode('utf-8', 'strict')
        return value
885648
function parseVarInt(cursor) {
    var result = 0, byte;

    do {
        byte = cursor.readUInt8();

        result <<= 7;
        result |= byte & 0x7F;
    } while (byte & 0x80);

    return result;
}
1292187
def _parse_decimal(buf):
    """"""
    exponent = _parse_var_int(buf, signed=True)
    sign_bit, coefficient = _parse_signed_int_components(buf)

    if coefficient == 0:
        # Handle the zero cases--especially negative zero
        value = Decimal((sign_bit, (0,), exponent))
    else:
        coefficient *= sign_bit and -1 or 1
        value = Decimal(coefficient).scaleb(exponent)

    return value