def _SimpleEncoder(wire_type, encode_value, compute_value_size):
def SpecificEncoder(field_number, is_repeated, is_packed):<EOL><INDENT>if is_packed:<EOL><INDENT>tag_bytes = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)<EOL>local_EncodeVarint = _EncodeVarint<EOL>def EncodePackedField(write, value):<EOL><INDENT>write(tag_bytes)<EOL>size = <NUM_LIT:0><EOL>for element in value:<EOL><INDENT>size += compute_value_size(element)<EOL><DEDENT>local_EncodeVarint(write, size)<EOL>for element in value:<EOL><INDENT>encode_value(write, element)<EOL><DEDENT><DEDENT>return EncodePackedField<EOL><DEDENT>elif is_repeated:<EOL><INDENT>tag_bytes = TagBytes(field_number, wire_type)<EOL>def EncodeRepeatedField(write, value):<EOL><INDENT>for element in value:<EOL><INDENT>write(tag_bytes)<EOL>encode_value(write, element)<EOL><DEDENT><DEDENT>return EncodeRepeatedField<EOL><DEDENT>else:<EOL><INDENT>tag_bytes = TagBytes(field_number, wire_type)<EOL>def EncodeField(write, value):<EOL><INDENT>write(tag_bytes)<EOL>return encode_value(write, value)<EOL><DEDENT>return EncodeField<EOL><DEDENT><DEDENT>return SpecificEncoder<EOL>
Return a constructor for an encoder for fields of a particular type.

    Args:
        wire_type:  The field's wire type, for encoding tags.
        encode_value:  A function which encodes an individual value, e.g.
          _EncodeVarint().
        compute_value_size:  A function which computes the size of an individual
          value, e.g. _VarintSize().