cleanup of ABI breaking configuration options. TORRENT_DEBUG is believed to no longer affect the ABI of libtorrent. introduce a warning in gen_reference_doc.py for when defines are used in public structs. fix build with deprecated functions off

This commit is contained in:
Arvid Norberg 2013-11-17 22:38:37 +00:00
parent 907e7b7415
commit fe414878b2
8 changed files with 55 additions and 77 deletions

View File

@ -254,7 +254,7 @@ def parse_class(lno, lines, filename):
continue
if l.startswith('#'):
lno = consume_ifdef(lno - 1, lines)
lno = consume_ifdef(lno - 1, lines, True)
continue
if 'TORRENT_DEFINE_ALERT' in l:
@ -438,7 +438,7 @@ def consume_comment(lno, lines):
return lno
def consume_ifdef(lno, lines):
def consume_ifdef(lno, lines, warn_on_ifdefs = False):
l = lines[lno].strip()
lno += 1
@ -447,6 +447,19 @@ def consume_ifdef(lno, lines):
if verbose: print 'prep %s' % l
if warn_on_ifdefs and ('TORRENT_DEBUG' in l or 'TORRENT_DISABLE_FULL_STATS' in l):
print '***\nWARNING: possible ABI breakage in public struct!\n %s:%d\n***' % \
(filename, lno)
if warn_on_ifdefs and '#if' in l:
define = l.replace('#ifndef', '').replace('#ifdef', '') \
.replace('#if', '').replace('defined', '') \
.replace('TORRENT_USE_IPV6', '').replace('TORRENT_NO_DEPRECATE', '') \
.replace('||', '').replace('&&', '').replace('(', '').replace(')','') \
.replace('!', '').strip()
if define != '':
print 'sensitive define in public struct: "%s"\n %s:%d' % (define, filename, lno)
if l == '#ifndef TORRENT_NO_DEPRECATE' or \
l == '#ifdef TORRENT_DEBUG' or \
l == '#ifdef TORRENT_ASIO_DEBUGGING' or \

View File

@ -48,6 +48,10 @@ POSSIBILITY OF SUCH DAMAGE.
namespace libtorrent
{
class torrent_info;
#ifdef TORRENT_DISABLE_EXTENSIONS
struct torrent;
struct torrent_plugin;
#endif
// The add_torrent_params is a parameter pack for adding torrents to a session.
// The key fields when adding a torrent are:
@ -330,15 +334,14 @@ namespace libtorrent
int upload_limit;
int download_limit;
#ifndef TORRENT_DISABLE_EXTENSIONS
// torrent extension construction functions can be added to this
// vector to have them be added immediately when the torrent is
// constructed. This may be desired over the torrent_handle::add_extension()
// in order to avoid race conditions. For instance it may be important
// to have the plugin catch events that happen very early on after
// the torrent is created.
std::vector<boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> > extensions;
#endif
std::vector<boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> >
extensions;
};
}

View File

@ -37,12 +37,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/stringize.hpp>
#ifdef TORRENT_DEBUG
#define TORRENT_CFG_DEBUG dbg_
#else
#define TORRENT_CFG_DEBUG rel_
#endif
#if TORRENT_USE_BOOST_DATE_TIME
#define TORRENT_CFG_TIME boosttime_
#elif TORRENT_USE_ABSOLUTE_TIME
@ -63,29 +57,16 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_CFG_IPV6 noipv_-
#endif
#ifdef _UNICODE
#define TORRENT_CFG_UNICODE unicode_
#else
#define TORRENT_CFG_UNICODE ansi_
#endif
#ifdef TORRENT_NO_DEPRECATE
#define TORRENT_CFG_DEPR nodeprecate_
#else
#define TORRENT_CFG_DEPR deprecated_
#endif
#ifdef TORRENT_DISABLE_FULL_STATS
#define TORRENT_CFG_STATS partialstats_
#else
#define TORRENT_CFG_STATS fullstats_
#endif
#define TORRENT_CFG \
BOOST_PP_CAT(TORRENT_CFG_DEBUG, \
BOOST_PP_CAT(TORRENT_CFG_TIME, \
BOOST_PP_CAT(TORRENT_CFG_LOG, \
TORRENT_CFG_DEPR)))
TORRENT_CFG_DEPR))
#define TORRENT_CFG_STRING BOOST_PP_STRINGIZE(TORRENT_CFG)

View File

@ -272,14 +272,12 @@ namespace libtorrent
// __ http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
char country[2];
#ifndef TORRENT_DISABLE_GEO_IP
// the name of the AS this peer is located in. This might be
// an empty string if there is no name in the geo ip database.
std::string inet_as_name;
// the AS number the peer is located in.
int inet_as;
#endif
// a measurement of the balancing of free download (that we get)
// and free upload that we give. Every peer gets a certain amount of free upload, but

View File

@ -299,10 +299,6 @@ namespace libtorrent
{
public:
#ifdef TORRENT_DEBUG
void check_invariant() const;
#endif
// The constructor that takes an info-hash will initialize the info-hash to the given value,
// but leave all other fields empty. This is used internally when downloading torrents without
// the metadata. The metadata will be created by libtorrent as soon as it has been downloaded
@ -527,15 +523,7 @@ namespace libtorrent
// Returns the SSL root certificate for the torrent, if it is an SSL
// torrent. Otherwise returns an empty string. The certificate is
// the the public certificate in x509 format.
#ifdef TORRENT_USE_OPENSSL
std::string const& ssl_cert() const { return m_ssl_root_cert; }
#else
std::string ssl_cert() const
{
if (m_info_dict.type() != lazy_entry::dict_t) return "";
return m_info_dict.dict_find_string_value("ssl-cert");
}
#endif
std::string ssl_cert() const;
// returns true if this torrent_info object has a torrent loaded.
// This is primarily used to determine if a magnet link has had its
@ -673,6 +661,11 @@ namespace libtorrent
private:
#endif
#ifdef TORRENT_DEBUG
friend class invariant_access;
void check_invariant() const;
#endif
// not assignable
torrent_info const& operator=(torrent_info const&);
@ -717,13 +710,6 @@ namespace libtorrent
// to create the torrent file
std::string m_created_by;
#ifdef TORRENT_USE_OPENSSL
// for ssl-torrens, this contains the root
// certificate, in .pem format (i.e. ascii
// base64 encoded with head and tails)
std::string m_ssl_root_cert;
#endif
// the info section parsed. points into m_info_section
// parsed lazily
mutable lazy_entry m_info_dict;

View File

@ -137,8 +137,8 @@ namespace libtorrent
internal_file_entry::internal_file_entry(internal_file_entry const& fe)
: name(0)
, offset(fe.offset)
, symlink_index(fe.symlink_index)
, size(fe.size)
, symlink_index(fe.symlink_index)
, name_len(fe.name_len)
, pad_file(fe.pad_file)
, hidden_attribute(fe.hidden_attribute)
@ -518,7 +518,22 @@ namespace libtorrent
{
TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
internal_file_entry const& fe = m_files[index];
return file_path(fe, save_path);
// -2 means this is an absolute path filename
if (fe.path_index == -2) return fe.filename();
// -1 means no path
if (fe.path_index == -1) return combine_path(save_path, fe.filename());
if (fe.no_root_dir)
return combine_path(save_path
, combine_path(m_paths[fe.path_index]
, fe.filename()));
return combine_path(save_path
, combine_path(m_name
, combine_path(m_paths[fe.path_index]
, fe.filename())));
}
std::string file_storage::file_name(int index) const
@ -601,22 +616,8 @@ namespace libtorrent
std::string file_storage::file_path(internal_file_entry const& fe
, std::string const& save_path) const
{
TORRENT_ASSERT(fe.path_index >= -2 && fe.path_index < int(m_paths.size()));
// -2 means this is an absolute path filename
if (fe.path_index == -2) return fe.filename();
// -1 means no path
if (fe.path_index == -1) return combine_path(save_path, fe.filename());
if (fe.no_root_dir)
return combine_path(save_path
, combine_path(m_paths[fe.path_index]
, fe.filename()));
return combine_path(save_path
, combine_path(m_name
, combine_path(m_paths[fe.path_index]
, fe.filename())));
int index = &fe - &m_files[0];
return file_path(index);
}
std::string file_storage::file_name(internal_file_entry const& fe) const

View File

@ -3862,6 +3862,8 @@ namespace libtorrent
p.flags |= pi->optimistically_unchoked ? peer_info::optimistic_unchoke : 0;
#ifndef TORRENT_DISABLE_GEO_IP
p.inet_as = pi->inet_as ? pi->inet_as->first : 0xffff;
#else
p.inet_as = 0xffff;
#endif
}
else
@ -3869,9 +3871,7 @@ namespace libtorrent
p.source = 0;
p.failcount = 0;
p.num_hashfails = 0;
#ifndef TORRENT_DISABLE_GEO_IP
p.inet_as = 0xffff;
#endif
}
p.remote_dl_rate = m_remote_dl_rate;

View File

@ -576,9 +576,6 @@ namespace libtorrent
, m_piece_hashes(t.m_piece_hashes)
, m_comment(t.m_comment)
, m_created_by(t.m_created_by)
#ifdef TORRENT_USE_OPENSSL
, m_ssl_root_cert(t.m_ssl_root_cert)
#endif
, m_creation_date(t.m_creation_date)
, m_info_hash(t.m_info_hash)
, m_info_section_size(t.m_info_section_size)
@ -884,9 +881,6 @@ namespace libtorrent
swap(m_creation_date, ti.m_creation_date);
m_comment.swap(ti.m_comment);
m_created_by.swap(ti.m_created_by);
#ifdef TORRENT_USE_OPENSSL
m_ssl_root_cert.swap(ti.m_ssl_root_cert);
#endif
boost::uint32_t tmp;
SWAP(m_multifile, ti.m_multifile);
SWAP(m_private, ti.m_private);
@ -901,6 +895,12 @@ namespace libtorrent
#undef SWAP
std::string torrent_info::ssl_cert() const
{
if (m_info_dict.type() != lazy_entry::dict_t) return "";
return m_info_dict.dict_find_string_value("ssl-cert");
}
bool torrent_info::parse_info_section(lazy_entry const& info, error_code& ec, int flags)
{
if (info.type() != lazy_entry::dict_t)
@ -1064,10 +1064,6 @@ namespace libtorrent
m_private = info.dict_find_int_value("private", 0);
#ifdef TORRENT_USE_OPENSSL
m_ssl_root_cert = info.dict_find_string_value("ssl-cert");
#endif
return true;
}