def _SignedVarintDecoder(mask, result_type):
def DecodeVarint(buffer, pos):<EOL><INDENT>result = <NUM_LIT:0><EOL>shift = <NUM_LIT:0><EOL>while <NUM_LIT:1>:<EOL><INDENT>b = six.indexbytes(buffer, pos)<EOL>result |= ((b & <NUM_LIT>) << shift)<EOL>pos += <NUM_LIT:1><EOL>if not (b & <NUM_LIT>):<EOL><INDENT>if result > <NUM_LIT>:<EOL><INDENT>result -= (<NUM_LIT:1> << <NUM_LIT:64>)<EOL>result |= ~mask<EOL><DEDENT>else:<EOL><INDENT>result &= mask<EOL><DEDENT>result = result_type(result)<EOL>return (result, pos)<EOL><DEDENT>shift += <NUM_LIT:7><EOL>if shift >= <NUM_LIT:64>:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT>return DecodeVarint<EOL>
Like _VarintDecoder() but decodes signed values.