make alert types ABI compatible between builds with deprecated members enabled and without

This commit is contained in:
arvidn 2017-06-15 21:39:43 -04:00 committed by Arvid Norberg
parent 523313e72d
commit ff8703e862
2 changed files with 135 additions and 133 deletions

View File

@ -91,14 +91,15 @@ namespace libtorrent {
char const* torrent_name() const;
#ifndef TORRENT_NO_DEPRECATE
std::string TORRENT_DEPRECATED_MEMBER name;
#endif
protected:
std::reference_wrapper<aux::stack_allocator const> m_alloc;
private:
aux::allocation_slot m_name_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
std::string TORRENT_DEPRECATED_MEMBER name;
#endif
};
// The peer alert is a base class for alerts that refer to a specific peer. It includes all
@ -144,12 +145,13 @@ namespace libtorrent {
// returns a 0-terminated string of the tracker's URL
char const* tracker_url() const;
private:
aux::allocation_slot m_url_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// The tracker URL
std::string TORRENT_DEPRECATED_MEMBER url;
#endif
private:
aux::allocation_slot m_url_idx;
};
#define TORRENT_DEFINE_ALERT_IMPL(name, seq, prio) \
@ -268,9 +270,6 @@ namespace libtorrent {
static const int static_category = alert::storage_notification;
virtual std::string message() const override;
#ifndef TORRENT_NO_DEPRECATE
std::string TORRENT_DEPRECATED_MEMBER name;
#endif
char const* new_name() const;
@ -278,6 +277,10 @@ namespace libtorrent {
file_index_t const index;
private:
aux::allocation_slot m_name_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
std::string TORRENT_DEPRECATED_MEMBER name;
#endif
};
// This is posted as a response to a torrent_handle::rename_file() call, if the rename
@ -443,15 +446,16 @@ namespace libtorrent {
int const times_in_row;
int const status_code;
error_code const error;
#ifndef TORRENT_NO_DEPRECATE
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
// the message associated with this error
char const* error_message() const;
private:
aux::allocation_slot m_msg_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
};
// This alert is triggered if the tracker reply contains a warning field.
@ -468,16 +472,16 @@ namespace libtorrent {
static const int static_category = alert::tracker_notification | alert::error_notification;
virtual std::string message() const override;
#ifndef TORRENT_NO_DEPRECATE
// contains the warning message from the tracker.
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
// the message associated with this warning
char const* warning_message() const;
private:
aux::allocation_slot m_msg_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// contains the warning message from the tracker.
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
};
// This alert is generated when a scrape request succeeds.
@ -513,11 +517,6 @@ namespace libtorrent {
static const int static_category = alert::tracker_notification | alert::error_notification;
virtual std::string message() const override;
#ifndef TORRENT_NO_DEPRECATE
// contains a message describing the error.
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
// the error itself. This may indicate that the tracker sent an error
// message (``error::tracker_failure``), in which case it can be
// retrieved by calling ``error_message()``.
@ -529,6 +528,11 @@ namespace libtorrent {
private:
aux::allocation_slot m_msg_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// contains a message describing the error.
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
};
// This alert is only for informational purpose. It is generated when a tracker announce
@ -851,11 +855,11 @@ namespace libtorrent {
static const int static_category = alert::progress_notification;
virtual std::string message() const override;
int const block_index;
piece_index_t const piece_index;
#ifndef TORRENT_NO_DEPRECATE
char const* TORRENT_DEPRECATED_MEMBER peer_speedmsg;
#endif
int const block_index;
piece_index_t const piece_index;
};
// This alert is generated when a block is received that was not requested or
@ -890,15 +894,15 @@ namespace libtorrent {
static const int static_category = alert::storage_notification;
virtual std::string message() const override;
#ifndef TORRENT_NO_DEPRECATE
std::string TORRENT_DEPRECATED_MEMBER path;
#endif
// the path the torrent was moved to
char const* storage_path() const;
private:
aux::allocation_slot m_path_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
std::string TORRENT_DEPRECATED_MEMBER path;
#endif
};
// The ``storage_moved_failed_alert`` is generated when an attempt to move the storage,
@ -917,11 +921,6 @@ namespace libtorrent {
error_code const error;
#ifndef TORRENT_NO_DEPRECATE
// If the error happened for a specific file, ``file`` is its path.
std::string TORRENT_DEPRECATED_MEMBER file;
#endif
// If the error happened for a specific file, this returns its path.
char const* file_path() const;
@ -930,6 +929,11 @@ namespace libtorrent {
char const* operation;
private:
aux::allocation_slot m_file_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// If the error happened for a specific file, ``file`` is its path.
std::string TORRENT_DEPRECATED_MEMBER file;
#endif
};
// This alert is generated when a request to delete the files of a torrent complete.
@ -1081,14 +1085,6 @@ namespace libtorrent {
static const int static_category = alert::peer_notification | alert::error_notification;
virtual std::string message() const override;
#ifndef TORRENT_NO_DEPRECATE
// the HTTP seed that failed
std::string TORRENT_DEPRECATED_MEMBER url;
// the error message, potentially from the server
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
// the error the web seed encountered. If this is not set, the server
// sent an error message, call ``error_message()``.
error_code const error;
@ -1103,6 +1099,15 @@ namespace libtorrent {
private:
aux::allocation_slot m_url_idx;
aux::allocation_slot m_msg_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// the HTTP seed that failed
std::string TORRENT_DEPRECATED_MEMBER url;
// the error message, potentially from the server
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
};
// If the storage fails to read or write files that it needs access to, this alert is
@ -1120,11 +1125,6 @@ namespace libtorrent {
| alert::storage_notification;
virtual std::string message() const override;
#ifndef TORRENT_NO_DEPRECATE
// the path to the file that was accessed when the error occurred.
std::string TORRENT_DEPRECATED_MEMBER file;
#endif
// the error code describing the error.
error_code const error;
char const* operation;
@ -1132,11 +1132,14 @@ namespace libtorrent {
// the file that experienced the error
char const* filename() const;
#ifndef TORRENT_NO_DEPRECATE
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
private:
aux::allocation_slot m_file_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// the path to the file that was accessed when the error occurred.
std::string TORRENT_DEPRECATED_MEMBER file;
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
};
// This alert is generated when the metadata has been completely received and the info-hash
@ -1308,17 +1311,17 @@ namespace libtorrent {
// see alert's documentation for validity of this value
int const port;
#ifndef TORRENT_NO_DEPRECATE
// the address and port libtorrent attempted to listen on
aux::noexcept_movable<tcp::endpoint> endpoint;
// the type of listen socket this alert refers to.
socket_type_t sock_type;
#endif
private:
std::reference_wrapper<aux::stack_allocator const> m_alloc;
aux::allocation_slot m_interface_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// the address and port libtorrent attempted to listen on
aux::noexcept_movable<tcp::endpoint> TORRENT_DEPRECATED_MEMBER endpoint;
// the type of listen socket this alert refers to.
socket_type_t TORRENT_DEPRECATED_MEMBER sock_type;
#endif
};
// This alert is posted when the listen port succeeds to be opened on a
@ -1453,19 +1456,19 @@ namespace libtorrent {
int const map_type;
#ifndef TORRENT_NO_DEPRECATE
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
// the message associated with this log line
char const* log_message() const;
private:
// TODO: 2 should the alert baseclass have this object instead?
std::reference_wrapper<aux::stack_allocator const> m_alloc;
aux::allocation_slot m_log_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
};
// This alert is generated when a fastresume file has been passed to
@ -1493,13 +1496,14 @@ namespace libtorrent {
// the name of that operation. ``operation`` is nullptr otherwise.
char const* operation;
private:
aux::allocation_slot m_path_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// If the error happened to a specific file, ``file`` is the path to it.
std::string TORRENT_DEPRECATED_MEMBER file;
std::string TORRENT_DEPRECATED_MEMBER msg;
#endif
private:
aux::allocation_slot m_path_idx;
};
// This alert is posted when an incoming peer connection, or a peer that's about to be added
@ -1693,16 +1697,16 @@ namespace libtorrent {
static const int static_category = alert::status_notification;
virtual std::string message() const override;
#ifndef TORRENT_NO_DEPRECATE
// The tracker ID returned by the tracker
std::string TORRENT_DEPRECATED_MEMBER trackerid;
#endif
// The tracker ID returned by the tracker
char const* tracker_id() const;
private:
aux::allocation_slot m_tracker_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// The tracker ID returned by the tracker
std::string TORRENT_DEPRECATED_MEMBER trackerid;
#endif
};
// This alert is posted when the initial DHT bootstrap is done.
@ -1732,16 +1736,17 @@ namespace libtorrent {
// specifies which error the torrent encountered.
error_code const error;
#ifndef TORRENT_NO_DEPRECATE
// the filename (or object) the error occurred on.
std::string TORRENT_DEPRECATED_MEMBER error_file;
#endif
// the filename (or object) the error occurred on.
char const* filename() const;
private:
aux::allocation_slot m_file_idx;
#ifndef TORRENT_NO_DEPRECATE
public:
// the filename (or object) the error occurred on.
std::string TORRENT_DEPRECATED_MEMBER error_file;
#endif
};
// This is always posted for SSL torrents. This is a reminder to the client that
@ -1968,7 +1973,7 @@ namespace libtorrent {
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#endif
#endif // TORRENT_NO_DEPRECATE
// posted when something fails in the DHT. This is not necessarily a fatal
// error, but it could prevent proper operation
@ -2412,14 +2417,15 @@ namespace libtorrent {
// (depending on ``direction``).
aux::noexcept_movable<udp::endpoint> node;
#ifndef TORRENT_NO_DEPRECATE
direction_t TORRENT_DEPRECATED_MEMBER dir;
#endif
private:
std::reference_wrapper<aux::stack_allocator> m_alloc;
aux::allocation_slot m_msg_idx;
int const m_size;
#ifndef TORRENT_NO_DEPRECATE
public:
direction_t TORRENT_DEPRECATED_MEMBER dir;
#endif
};
struct TORRENT_EXPORT dht_get_peers_reply_alert final : alert
@ -2472,14 +2478,14 @@ namespace libtorrent {
bdecode_node response() const;
#ifndef TORRENT_NO_DEPRECATE
aux::noexcept_movable<udp::endpoint> TORRENT_DEPRECATED_MEMBER addr;
#endif
private:
std::reference_wrapper<aux::stack_allocator> m_alloc;
aux::allocation_slot m_response_idx;
int const m_response_size;
#ifndef TORRENT_NO_DEPRECATE
public:
aux::noexcept_movable<udp::endpoint> TORRENT_DEPRECATED_MEMBER addr;
#endif
};
// this is posted when one or more blocks are picked by the piece picker,

View File

@ -119,10 +119,10 @@ namespace libtorrent {
tracker_alert::tracker_alert(aux::stack_allocator& alloc
, torrent_handle const& h, string_view u)
: torrent_alert(alloc, h)
, m_url_idx(alloc.copy_string(u))
#ifndef TORRENT_NO_DEPRECATE
, url(u)
#endif
, m_url_idx(alloc.copy_string(u))
{}
char const* tracker_alert::tracker_url() const
@ -192,11 +192,11 @@ namespace libtorrent {
file_renamed_alert::file_renamed_alert(aux::stack_allocator& alloc
, torrent_handle const& h, string_view n, file_index_t const idx)
: torrent_alert(alloc, h)
, index(idx)
, m_name_idx(alloc.copy_string(n))
#ifndef TORRENT_NO_DEPRECATE
, name(n)
#endif
, index(idx)
, m_name_idx(alloc.copy_string(n))
{}
char const* file_renamed_alert::new_name() const
@ -290,10 +290,10 @@ namespace libtorrent {
, times_in_row(times)
, status_code(status)
, error(e)
, m_msg_idx(alloc.copy_string(m))
#ifndef TORRENT_NO_DEPRECATE
, msg(m)
#endif
, m_msg_idx(alloc.copy_string(m))
{
TORRENT_ASSERT(!u.empty());
}
@ -316,10 +316,10 @@ namespace libtorrent {
tracker_warning_alert::tracker_warning_alert(aux::stack_allocator& alloc
, torrent_handle const& h, string_view u, string_view m)
: tracker_alert(alloc, h, u)
, m_msg_idx(alloc.copy_string(m))
#ifndef TORRENT_NO_DEPRECATE
, msg(m)
#endif
, m_msg_idx(alloc.copy_string(m))
{
TORRENT_ASSERT(!u.empty());
}
@ -354,11 +354,11 @@ namespace libtorrent {
scrape_failed_alert::scrape_failed_alert(aux::stack_allocator& alloc
, torrent_handle const& h, string_view u, error_code const& e)
: tracker_alert(alloc, h, u)
, error(e)
, m_msg_idx()
#ifndef TORRENT_NO_DEPRECATE
, msg(convert_from_native(e.message()))
#endif
, error(e)
, m_msg_idx()
{
TORRENT_ASSERT(!u.empty());
}
@ -366,11 +366,11 @@ namespace libtorrent {
scrape_failed_alert::scrape_failed_alert(aux::stack_allocator& alloc
, torrent_handle const& h, string_view u, string_view m)
: tracker_alert(alloc, h, u)
, error(errors::tracker_failure)
, m_msg_idx(alloc.copy_string(m))
#ifndef TORRENT_NO_DEPRECATE
, msg(m)
#endif
, error(errors::tracker_failure)
, m_msg_idx(alloc.copy_string(m))
{
TORRENT_ASSERT(!u.empty());
}
@ -592,11 +592,11 @@ namespace libtorrent {
, tcp::endpoint const& ep
, peer_id const& peer_id, int block_num, piece_index_t piece_num)
: peer_alert(alloc, h, ep, peer_id)
, block_index(block_num)
, piece_index(piece_num)
#ifndef TORRENT_NO_DEPRECATE
, peer_speedmsg("")
#endif
, block_index(block_num)
, piece_index(piece_num)
{
TORRENT_ASSERT(block_index >= 0 && piece_index >= piece_index_t(0));
}
@ -630,10 +630,10 @@ namespace libtorrent {
storage_moved_alert::storage_moved_alert(aux::stack_allocator& alloc
, torrent_handle const& h, string_view p)
: torrent_alert(alloc, h)
, m_path_idx(alloc.copy_string(p))
#ifndef TORRENT_NO_DEPRECATE
, path(p)
#endif
, m_path_idx(alloc.copy_string(p))
{}
std::string storage_moved_alert::message() const
@ -652,11 +652,11 @@ namespace libtorrent {
, string_view f, char const* op)
: torrent_alert(alloc, h)
, error(e)
, operation(op)
, m_file_idx(alloc.copy_string(f))
#ifndef TORRENT_NO_DEPRECATE
, file(f)
#endif
, operation(op)
, m_file_idx(alloc.copy_string(f))
{}
char const* storage_moved_failed_alert::file_path() const
@ -687,10 +687,10 @@ namespace libtorrent {
: torrent_alert(alloc, h)
, error(e)
, info_hash(ih)
{
#ifndef TORRENT_NO_DEPRECATE
msg = convert_from_native(error.message());
, msg(convert_from_native(error.message()))
#endif
{
}
std::string torrent_delete_failed_alert::message() const
@ -704,10 +704,10 @@ namespace libtorrent {
, torrent_handle const& h)
: torrent_alert(alloc, h)
, params(std::move(p))
{
#ifndef TORRENT_NO_DEPRECATE
resume_data = std::make_shared<entry>(write_resume_data(params));
, resume_data(std::make_shared<entry>(write_resume_data(params)))
#endif
{
}
std::string save_resume_data_alert::message() const
@ -719,10 +719,10 @@ namespace libtorrent {
, torrent_handle const& h, error_code const& e)
: torrent_alert(alloc, h)
, error(e)
{
#ifndef TORRENT_NO_DEPRECATE
msg = convert_from_native(error.message());
, msg(convert_from_native(error.message()))
#endif
{
}
std::string save_resume_data_failed_alert::message() const
@ -810,12 +810,12 @@ namespace {
, socket_type(t)
, address(listen_addr)
, port(listen_port)
, m_alloc(alloc)
, m_interface_idx(alloc.copy_string(iface))
#ifndef TORRENT_NO_DEPRECATE
, endpoint(listen_addr, std::uint16_t(listen_port))
, sock_type(static_cast<socket_type_t>(sock_type_idx(t)))
#endif
, m_alloc(alloc)
, m_interface_idx(alloc.copy_string(iface))
{}
listen_failed_alert::listen_failed_alert(
@ -981,11 +981,10 @@ namespace {
portmap_error_alert::portmap_error_alert(aux::stack_allocator&
, int i, int t, error_code const& e)
: mapping(i), map_type(t), error(e)
{
#ifndef TORRENT_NO_DEPRECATE
msg = convert_from_native(error.message());
, msg(convert_from_native(error.message()))
#endif
}
{}
std::string portmap_error_alert::message() const
{
@ -1008,11 +1007,11 @@ namespace {
portmap_log_alert::portmap_log_alert(aux::stack_allocator& alloc, int t, const char* m)
: map_type(t)
, m_alloc(alloc)
, m_log_idx(alloc.copy_string(m))
#ifndef TORRENT_NO_DEPRECATE
, msg(m)
#endif
, m_alloc(alloc)
, m_log_idx(alloc.copy_string(m))
{}
char const* portmap_log_alert::log_message() const
@ -1037,11 +1036,11 @@ namespace {
: torrent_alert(alloc, h)
, error(ec)
, operation(op)
, m_path_idx(alloc.copy_string(f))
#ifndef TORRENT_NO_DEPRECATE
, file(f)
, msg(convert_from_native(error.message()))
#endif
, m_path_idx(alloc.copy_string(f))
{
}
@ -1213,10 +1212,10 @@ namespace {
, string_view u
, const std::string& id)
: tracker_alert(alloc, h, u)
, m_tracker_idx(alloc.copy_string(id))
#ifndef TORRENT_NO_DEPRECATE
, trackerid(id)
#endif
, m_tracker_idx(alloc.copy_string(id))
{}
char const* trackerid_alert::tracker_id() const
@ -1243,10 +1242,10 @@ namespace {
, error_code const& e, string_view f)
: torrent_alert(alloc, h)
, error(e)
, m_file_idx(alloc.copy_string(f))
#ifndef TORRENT_NO_DEPRECATE
, error_file(f)
#endif
, m_file_idx(alloc.copy_string(f))
{}
std::string torrent_error_alert::message() const
@ -1790,24 +1789,24 @@ namespace {
url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h
, string_view u, error_code const& e)
: torrent_alert(alloc, h)
, error(e)
, m_url_idx(alloc.copy_string(u))
, m_msg_idx()
#ifndef TORRENT_NO_DEPRECATE
, url(u)
, msg(convert_from_native(e.message()))
#endif
, error(e)
, m_url_idx(alloc.copy_string(u))
, m_msg_idx()
{}
url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h
, string_view u, string_view m)
: torrent_alert(alloc, h)
, m_url_idx(alloc.copy_string(u))
, m_msg_idx(alloc.copy_string(m))
#ifndef TORRENT_NO_DEPRECATE
, url(u)
, msg(m)
#endif
, m_url_idx(alloc.copy_string(u))
, m_msg_idx(alloc.copy_string(m))
{}
std::string url_seed_alert::message() const
@ -1831,17 +1830,14 @@ namespace {
, error_code const& ec, string_view f, char const* op
, torrent_handle const& h)
: torrent_alert(alloc, h)
#ifndef TORRENT_NO_DEPRECATE
, file(f)
#endif
, error(ec)
, operation(op)
, m_file_idx(alloc.copy_string(f))
{
#ifndef TORRENT_NO_DEPRECATE
msg = convert_from_native(error.message());
, file(f)
, msg(convert_from_native(error.message()))
#endif
}
{}
char const* file_error_alert::filename() const
{
@ -1905,12 +1901,12 @@ namespace {
, udp::endpoint const& ep)
: direction(d)
, node(std::move(ep))
#ifndef TORRENT_NO_DEPRECATE
, dir(d)
#endif
, m_alloc(alloc)
, m_msg_idx(alloc.copy_buffer(buf))
, m_size(int(buf.size()))
#ifndef TORRENT_NO_DEPRECATE
, dir(d)
#endif
{}
span<char const> dht_pkt_alert::pkt_buf() const
@ -2014,12 +2010,12 @@ namespace {
aux::stack_allocator& alloc, void* userdata_
, udp::endpoint const& addr_, bdecode_node const& response)
: userdata(userdata_), endpoint(addr_)
#ifndef TORRENT_NO_DEPRECATE
, addr(addr_)
#endif
, m_alloc(alloc)
, m_response_idx(alloc.copy_buffer(response.data_section()))
, m_response_size(int(response.data_section().size()))
#ifndef TORRENT_NO_DEPRECATE
, addr(addr_)
#endif
{}
dht_direct_response_alert::dht_direct_response_alert(
@ -2027,12 +2023,12 @@ namespace {
, void* userdata_
, udp::endpoint const& addr_)
: userdata(userdata_), endpoint(addr_)
#ifndef TORRENT_NO_DEPRECATE
, addr(addr_)
#endif
, m_alloc(alloc)
, m_response_idx()
, m_response_size(0)
#ifndef TORRENT_NO_DEPRECATE
, addr(addr_)
#endif
{}
std::string dht_direct_response_alert::message() const