parameters: (extensions_by_number)
return_statement: return DecodeItem
docstring: Returns a decoder for a MessageSet item.
  
    The parameter is the _extensions_by_number map for the message class.
  
    The message set message looks like this:
      message MessageSet {
        repeated group Item = 1 {
          required int32 type_id = 2;
          required string message = 3;
        }
      }
docstring_summary: Returns a decoder for a MessageSet item.
docstring_tokens: Returns a decoder for a MessageSet item .
function: def MessageSetItemDecoder(extensions_by_number):
    """Returns a decoder for a MessageSet item.
  
    The parameter is the _extensions_by_number map for the message class.
  
    The message set message looks like this:
      message MessageSet {
        repeated group Item = 1 {
          required int32 type_id = 2;
          required string message = 3;
        }
      }
    """
  
    type_id_tag_bytes = encoder.TagBytes(2, wire_format.WIRETYPE_VARINT)
    message_tag_bytes = encoder.TagBytes(3, wire_format.WIRETYPE_LENGTH_DELIMITED)
    item_end_tag_bytes = encoder.TagBytes(1, wire_format.WIRETYPE_END_GROUP)
  
    local_ReadTag = ReadTag
    local_DecodeVarint = _DecodeVarint
    local_SkipField = SkipField
  
    def DecodeItem(buffer, pos, end, message, field_dict):
      type_id = -1
      message_start = -1
      message_end = -1
  
      # Technically, type_id and message can appear in any order, so we need
      # a little loop here.
      while 1:
        (tag_bytes, pos) = local_ReadTag(buffer, pos)
        if tag_bytes == type_id_tag_bytes:
          (type_id, pos) = local_DecodeVarint(buffer, pos)
        elif tag_bytes == message_tag_bytes:
          (size, message_start) = local_DecodeVarint(buffer, pos)
          pos = message_end = message_start + size
        elif tag_bytes == item_end_tag_bytes:
          break
        else:
          pos = SkipField(buffer, pos, end, tag_bytes)
          if pos == -1:
            raise _DecodeError('Missing group end tag.')
  
      if pos > end:
        raise _DecodeError('Truncated message.')
  
      if type_id == -1:
        raise _DecodeError('MessageSet item missing type_id.')
      if message_start == -1:
        raise _DecodeError('MessageSet item missing message.')
  
      extension = extensions_by_number.get(type_id)
      if extension is not None:
        value = field_dict.get(extension)
        if value is None:
          value = field_dict.setdefault(
              extension, extension.message_type._concrete_class())
        if value._InternalParse(buffer, message_start,message_end) != message_end:
          # The only reason _InternalParse would return early is if it encountered
          # an end-group tag.
          raise _DecodeError('Unexpected end-group tag.')
  
      return pos
  
    return DecodeItem
function_tokens: def MessageSetItemDecoder ( extensions_by_number ) : type_id_tag_bytes = encoder . TagBytes ( 2 , wire_format . WIRETYPE_VARINT ) message_tag_bytes = encoder . TagBytes ( 3 , wire_format . WIRETYPE_LENGTH_DELIMITED ) item_end_tag_bytes = encoder . TagBytes ( 1 , wire_format . WIRETYPE_END_GROUP ) local_ReadTag = ReadTag local_DecodeVarint = _DecodeVarint local_SkipField = SkipField def DecodeItem ( buffer , pos , end , message , field_dict ) : type_id = - 1 message_start = - 1 message_end = - 1 # Technically, type_id and message can appear in any order, so we need # a little loop here. while 1 : ( tag_bytes , pos ) = local_ReadTag ( buffer , pos ) if tag_bytes == type_id_tag_bytes : ( type_id , pos ) = local_DecodeVarint ( buffer , pos ) elif tag_bytes == message_tag_bytes : ( size , message_start ) = local_DecodeVarint ( buffer , pos ) pos = message_end = message_start + size elif tag_bytes == item_end_tag_bytes : break else : pos = SkipField ( buffer , pos , end , tag_bytes ) if pos == - 1 : raise _DecodeError ( 'Missing group end tag.' ) if pos > end : raise _DecodeError ( 'Truncated message.' ) if type_id == - 1 : raise _DecodeError ( 'MessageSet item missing type_id.' ) if message_start == - 1 : raise _DecodeError ( 'MessageSet item missing message.' ) extension = extensions_by_number . get ( type_id ) if extension is not None : value = field_dict . get ( extension ) if value is None : value = field_dict . setdefault ( extension , extension . message_type . _concrete_class ( ) ) if value . _InternalParse ( buffer , message_start , message_end ) != message_end : # The only reason _InternalParse would return early is if it encountered # an end-group tag. raise _DecodeError ( 'Unexpected end-group tag.' ) return pos return DecodeItem