def _SimpleDecoder(wire_type, decode_value):
def SpecificDecoder(field_number, is_repeated, is_packed, key, new_default):<EOL><INDENT>if is_packed:<EOL><INDENT>local_DecodeVarint = _DecodeVarint<EOL>def DecodePackedField(buffer, pos, end, message, field_dict):<EOL><INDENT>value = field_dict.get(key)<EOL>if value is None:<EOL><INDENT>value = field_dict.setdefault(key, new_default(message))<EOL><DEDENT>(endpoint, pos) = local_DecodeVarint(buffer, pos)<EOL>endpoint += pos<EOL>if endpoint > end:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>while pos < endpoint:<EOL><INDENT>(element, pos) = decode_value(buffer, pos)<EOL>value.append(element)<EOL><DEDENT>if pos > endpoint:<EOL><INDENT>del value[-<NUM_LIT:1>]   <EOL>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>return pos<EOL><DEDENT>return DecodePackedField<EOL><DEDENT>elif is_repeated:<EOL><INDENT>tag_bytes = encoder.TagBytes(field_number, wire_type)<EOL>tag_len = len(tag_bytes)<EOL>def DecodeRepeatedField(buffer, pos, end, message, field_dict):<EOL><INDENT>value = field_dict.get(key)<EOL>if value is None:<EOL><INDENT>value = field_dict.setdefault(key, new_default(message))<EOL><DEDENT>while <NUM_LIT:1>:<EOL><INDENT>(element, new_pos) = decode_value(buffer, pos)<EOL>value.append(element)<EOL>pos = new_pos + tag_len<EOL>if buffer[new_pos:pos] != tag_bytes or new_pos >= end:<EOL><INDENT>if new_pos > end:<EOL><INDENT>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>return new_pos<EOL><DEDENT><DEDENT><DEDENT>return DecodeRepeatedField<EOL><DEDENT>else:<EOL><INDENT>def DecodeField(buffer, pos, end, message, field_dict):<EOL><INDENT>(field_dict[key], pos) = decode_value(buffer, pos)<EOL>if pos > end:<EOL><INDENT>del field_dict[key]  <EOL>raise _DecodeError('<STR_LIT>')<EOL><DEDENT>return pos<EOL><DEDENT>return DecodeField<EOL><DEDENT><DEDENT>return SpecificDecoder<EOL>
Return a constructor for a decoder for fields of a particular type.

    Args:
        wire_type:  The field's wire type.
        decode_value:  A function which decodes an individual value, e.g.
          _DecodeVarint()