From 3fcd67b57407df2a0984c679d8ca742030dc1fb1 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 19 Jul 2013 16:30:26 +0000 Subject: [PATCH] minor rearranging and comments --- include/libtorrent/add_torrent_params.hpp | 2 +- include/libtorrent/assert.hpp | 16 ++++++++-------- include/libtorrent/entry.hpp | 6 +++--- include/libtorrent/file.hpp | 1 + include/libtorrent/file_storage.hpp | 1 + include/libtorrent/natpmp.hpp | 2 ++ include/libtorrent/peer_id.hpp | 1 + include/libtorrent/session.hpp | 3 +++ include/libtorrent/time.hpp | 2 ++ include/libtorrent/torrent_info.hpp | 4 ++-- include/libtorrent/upnp.hpp | 2 ++ 11 files changed, 26 insertions(+), 14 deletions(-) diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index 40424b7fa..16c334435 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -45,7 +45,7 @@ namespace libtorrent { class torrent_info; - struct add_torrent_params + struct TORRENT_EXPORT add_torrent_params { add_torrent_params(storage_constructor_type sc = default_storage_constructor) : version(LIBTORRENT_VERSION_NUM) diff --git a/include/libtorrent/assert.hpp b/include/libtorrent/assert.hpp index c69b2bece..1c5b05182 100644 --- a/include/libtorrent/assert.hpp +++ b/include/libtorrent/assert.hpp @@ -40,13 +40,8 @@ std::string demangle(char const* name); TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth = 0); #endif -#if (!defined TORRENT_DEBUG && !TORRENT_RELEASE_ASSERTS) \ - || TORRENT_NO_ASSERTS - -#define TORRENT_ASSERT(a) do {} while(false) -#define TORRENT_ASSERT_VAL(a, b) do {} while(false) - -#else +#if (defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS) \ + && !TORRENT_NO_ASSERTS #if TORRENT_PRODUCTION_ASSERTS extern char const* libtorrent_assert_log; @@ -74,7 +69,12 @@ TORRENT_EXPORT void assert_fail(const char* expr, int line, char const* file #define TORRENT_ASSERT_VAL(x, y) assert(x) #endif -#endif +#else // TORRENT_DEBUG || TORENT_RELEASE_ASSERTS && !TORRENT_NO_ASSERTS + +#define TORRENT_ASSERT(a) do {} while(false) +#define TORRENT_ASSERT_VAL(a, b) do {} while(false) + +#endif // TORRENT_DEBUG || TORENT_RELEASE_ASSERTS && !TORRENT_NO_ASSERTS #endif diff --git a/include/libtorrent/entry.hpp b/include/libtorrent/entry.hpp index 128082d12..4d3caec44 100644 --- a/include/libtorrent/entry.hpp +++ b/include/libtorrent/entry.hpp @@ -163,9 +163,7 @@ namespace libtorrent private: -#ifndef TORRENT_DEBUG - data_type m_type; -#else +#ifdef TORRENT_DEBUG // the bitfield is used so that the m_type_queried // field still fits, so that the ABI is the same for // debug builds and release builds. It appears to be @@ -182,6 +180,8 @@ namespace libtorrent // exceptions are used. mutable bool m_type_queried:1; protected: +#else + data_type m_type; #endif // TORRENT_DEBUG #if (defined(_MSC_VER) && _MSC_VER < 1310) || TORRENT_COMPLETE_TYPES_REQUIRED diff --git a/include/libtorrent/file.hpp b/include/libtorrent/file.hpp index 3d967be8d..0bc1d6292 100644 --- a/include/libtorrent/file.hpp +++ b/include/libtorrent/file.hpp @@ -108,6 +108,7 @@ namespace libtorrent int mode; }; + // TODO: why are all these functions exported? enum stat_flags_t { dont_follow_links = 1 }; TORRENT_EXPORT void stat_file(std::string f, file_status* s , error_code& ec, int flags = 0); diff --git a/include/libtorrent/file_storage.hpp b/include/libtorrent/file_storage.hpp index 2e3d6568a..325d0371a 100644 --- a/include/libtorrent/file_storage.hpp +++ b/include/libtorrent/file_storage.hpp @@ -71,6 +71,7 @@ namespace libtorrent // it's smaller and optimized for smaller memory // footprint, as opposed to file_entry, which is // optimized for convenience + // TODO: does this really need to be exported? struct TORRENT_EXPORT internal_file_entry { friend class file_storage; diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index 03d8a9a42..0b852e8d8 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -53,6 +53,8 @@ namespace libtorrent typedef boost::function portmap_callback_t; typedef boost::function log_callback_t; +// TODO: 3 should this really be a public symbol? +// also, make this a shared_ptr instead class TORRENT_EXPORT natpmp : public intrusive_ptr_base { public: diff --git a/include/libtorrent/peer_id.hpp b/include/libtorrent/peer_id.hpp index 18d19a9ef..670ad97f4 100644 --- a/include/libtorrent/peer_id.hpp +++ b/include/libtorrent/peer_id.hpp @@ -58,6 +58,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { + // TODO: 3 rename this to sha1_hash class TORRENT_EXPORT big_number { // the number of bytes of the number diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index 3fdd3760b..cbf904e27 100644 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -98,6 +98,7 @@ namespace libtorrent // workaround for microsofts // hardware exceptions that makes // it hard to debug stuff + // TODO: 3 make this an implementation detail #ifdef _MSC_VER struct TORRENT_EXPORT eh_initializer { @@ -128,6 +129,8 @@ namespace libtorrent #define TORRENT_LOGPATH_ARG_DEFAULT #endif + // Once it's created, the session object will spawn the main thread that will do all the work. + // The main thread will be idle as long it doesn't have any torrents to participate in. class TORRENT_EXPORT session: public boost::noncopyable, aux::eh_initializer { public: diff --git a/include/libtorrent/time.hpp b/include/libtorrent/time.hpp index dc36d1b6b..c521c732d 100644 --- a/include/libtorrent/time.hpp +++ b/include/libtorrent/time.hpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { + // TODO: 3 do these two really need to be exposed to users? TORRENT_EXPORT char const* time_now_string(); TORRENT_EXPORT std::string log_time(); @@ -64,6 +65,7 @@ namespace libtorrent namespace aux { + // TODO: 3 move these to time.cpp TORRENT_EXPORT boost::int64_t performance_counter_to_microseconds(boost::int64_t pc); TORRENT_EXPORT boost::int64_t microseconds_to_performance_counter(boost::int64_t ms); } diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 44415099c..232b9786a 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -235,6 +235,7 @@ namespace libtorrent typedef libtorrent_exception invalid_torrent_file; #endif + // TODO: 3 should this really be a public symbol? int TORRENT_EXPORT load_file(std::string const& filename , std::vector& v, error_code& ec, int limit = 8000000); @@ -420,8 +421,7 @@ namespace libtorrent bool is_merkle_torrent() const { return !m_merkle_tree.empty(); } // if we're logging member offsets, we need access to them -#if defined TORRENT_DEBUG \ - && !defined TORRENT_LOGGING \ +#if !defined TORRENT_LOGGING \ && !defined TORRENT_VERBOSE_LOGGING \ && !defined TORRENT_ERROR_LOGGING private: diff --git a/include/libtorrent/upnp.hpp b/include/libtorrent/upnp.hpp index b23875fa0..7e98b1e31 100644 --- a/include/libtorrent/upnp.hpp +++ b/include/libtorrent/upnp.hpp @@ -99,6 +99,8 @@ namespace libtorrent typedef boost::function portmap_callback_t; typedef boost::function log_callback_t; +// TODO: 3 should this really be a public symbol? +// also, make this a shared_ptr instead class TORRENT_EXPORT upnp : public intrusive_ptr_base { public: