def METHOD_NAME(self, references, buffers):
    if not isinstance(self.msg_data, bytes):
        msg = MessageSent(
            kind=self.kind,
            msg_type=self.msg_type,
            msg_data=self.msg_data
        )
    else:
        msg = MessageSentBuffers(
            kind=self.kind,
            msg_type=self.msg_type
        )
        assert buffers is not None
        buffer_id = make_id()
        buf = (dict(id=buffer_id), self.msg_data)
        buffers.append(buf)
    return msg