merged RC_1_1 into master

This commit is contained in:
arvidn 2017-04-13 07:42:32 -07:00
commit 645d658214
15 changed files with 528 additions and 24 deletions

View File

@ -66,6 +66,11 @@
* resume data no longer has timestamps of files
* require C++11 to build libtorrent
* forward declaring libtorrent types is discouraged. a new fwd.hpp header is provided
1.1.3 release
* removed (broken) support for incoming connections over socks5
* restore announce_entry's timestamp fields to posix time in python binding
* deprecate torrent_added_alert (in favor of add_torrent_alert)

View File

@ -143,8 +143,6 @@ def print_peer_info(console, peers):
id = 'waiting for handshake'
elif p.flags & lt.peer_info.connecting:
id = 'connecting to peer'
elif p.flags & lt.peer_info.queued:
id = 'queued'
else:
id = p.client

View File

@ -9,17 +9,16 @@
#include <libtorrent/error_code.hpp>
#include <libtorrent/ip_filter.hpp>
#include <libtorrent/disk_io_thread.hpp>
#include <libtorrent/aux_/session_settings.hpp>
#include <libtorrent/extensions.hpp>
#include <libtorrent/bdecode.hpp>
#include <libtorrent/bencode.hpp>
#include <libtorrent/read_resume_data.hpp>
#include <libtorrent/aux_/session_impl.hpp> // for settings_map()
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/kademlia/item.hpp> // for sign_mutable_item
#include <libtorrent/alert.hpp>
#include <libtorrent/time.hpp>
#include <libtorrent/session_stats.hpp>
#include <libtorrent/session_status.hpp>
#include <libtorrent/extensions/smart_ban.hpp>
#include <libtorrent/extensions/ut_metadata.hpp>

View File

@ -46,8 +46,15 @@ For a description on how to create torrent files, see create_torrent.
.. _make_torrent: make_torrent.html
things to keep in mind
======================
forward declarations
====================
Forward declaring types from the libtorrent namespace is discouraged as it may
break in future releases. Instead include ``libtorrent/fwd.hpp`` for forward
declarations of all public types in libtorrent.
trouble shooting
================
A common problem developers are facing is torrents stopping without explanation.
Here is a description on which conditions libtorrent will stop your torrents,
@ -73,6 +80,11 @@ from certain disk errors if the problem is resolved. If the torrent is not
auto managed, you have to call set_upload_mode() to turn
downloading back on again.
For a more detailed guide on how to trouble shoot performance issues, see
troubleshooting_
.. _troubleshooting: troubleshooting.html
network primitives
==================

View File

@ -10,9 +10,9 @@ libtorrent manual
:backlinks: none
The following troubleshooting chart may help in finding out why torrents fail
to download. It is not complete, please submit suggestions via mail to
arvid@libtorrent.org or to the `mailing list`_. Ideally in the form of patches
against ``docs/troubleshooting.dot``.
to download. It is not complete, please submit suggestions via pull requests at
https://github.com/arvidn/libtorrent or to the `mailing list`_. Ideally in the
form of patches against ``docs/troubleshooting.dot``.
.. _`mailing list`: http://lists.sourceforge.net/lists/listinfo/libtorrent-discuss

View File

@ -1,8 +1,44 @@
/*
Copyright (c) 2003-2017, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "session_view.hpp"
#include "print.hpp"
#include "libtorrent/session_stats.hpp"
#include "libtorrent/torrent_handle.hpp"
#include <algorithm> // for std::max
namespace lt = libtorrent;
session_view::session_view()
: m_position(0)
, m_print_utp_stats(false)

View File

@ -1,10 +1,40 @@
/*
Copyright (c) 2003-2017, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SESSION_VIEW_HPP_
#define SESSION_VIEW_HPP_
#include "libtorrent/session_stats.hpp"
#include <cstdint>
namespace lt = libtorrent;
#include <vector>
struct session_view
{

View File

@ -1,5 +1,38 @@
/*
Copyright (c) 2003-2017, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "torrent_view.hpp"
#include "print.hpp"
#include "libtorrent/torrent_handle.hpp"
#include "libtorrent/torrent_status.hpp"
const int header_size = 2;

View File

@ -1,3 +1,35 @@
/*
Copyright (c) 2003-2017, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_VIEW_HPP_
#define TORRENT_VIEW_HPP_
@ -5,7 +37,7 @@
#include <vector>
#include <unordered_set>
#include "libtorrent/torrent_handle.hpp"
#include "libtorrent/fwd.hpp"
#include "libtorrent/torrent_status.hpp"
namespace lt = libtorrent;

View File

@ -51,6 +51,7 @@ nobase_include_HEADERS = \
file_pool.hpp \
file_storage.hpp \
fingerprint.hpp \
fwd.hpp \
gzip.hpp \
hasher.hpp \
hasher512.hpp \

View File

@ -1856,7 +1856,7 @@ namespace libtorrent {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
struct TORRENT_DEPRECATED TORRENT_EXPORT mmap_cache_alert final : alert
struct TORRENT_DEPRECATED_EXPORT mmap_cache_alert final : alert
{
mmap_cache_alert(aux::stack_allocator& alloc
, error_code const& ec);

262
include/libtorrent/fwd.hpp Normal file
View File

@ -0,0 +1,262 @@
/*
Copyright (c) 2017, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_FWD_HPP
#define TORRENT_FWD_HPP
#include "libtorrent/export.hpp"
namespace libtorrent {
// include/libtorrent/add_torrent_params.hpp
struct add_torrent_params;
// include/libtorrent/alert.hpp
class alert;
// include/libtorrent/alert_types.hpp
struct torrent_alert;
struct peer_alert;
struct tracker_alert;
struct torrent_removed_alert;
struct read_piece_alert;
struct file_completed_alert;
struct file_renamed_alert;
struct file_rename_failed_alert;
struct performance_alert;
struct state_changed_alert;
struct tracker_error_alert;
struct tracker_warning_alert;
struct scrape_reply_alert;
struct scrape_failed_alert;
struct tracker_reply_alert;
struct dht_reply_alert;
struct tracker_announce_alert;
struct hash_failed_alert;
struct peer_ban_alert;
struct peer_unsnubbed_alert;
struct peer_snubbed_alert;
struct peer_error_alert;
struct peer_connect_alert;
struct peer_disconnected_alert;
struct invalid_request_alert;
struct torrent_finished_alert;
struct piece_finished_alert;
struct request_dropped_alert;
struct block_timeout_alert;
struct block_finished_alert;
struct block_downloading_alert;
struct unwanted_block_alert;
struct storage_moved_alert;
struct storage_moved_failed_alert;
struct torrent_deleted_alert;
struct torrent_delete_failed_alert;
struct save_resume_data_alert;
struct save_resume_data_failed_alert;
struct torrent_paused_alert;
struct torrent_resumed_alert;
struct torrent_checked_alert;
struct url_seed_alert;
struct file_error_alert;
struct metadata_failed_alert;
struct metadata_received_alert;
struct udp_error_alert;
struct external_ip_alert;
struct listen_failed_alert;
struct listen_succeeded_alert;
struct portmap_error_alert;
struct portmap_alert;
struct portmap_log_alert;
struct fastresume_rejected_alert;
struct peer_blocked_alert;
struct dht_announce_alert;
struct dht_get_peers_alert;
struct stats_alert;
struct cache_flushed_alert;
struct anonymous_mode_alert;
struct lsd_peer_alert;
struct trackerid_alert;
struct dht_bootstrap_alert;
struct torrent_error_alert;
struct torrent_need_cert_alert;
struct incoming_connection_alert;
struct add_torrent_alert;
struct state_update_alert;
struct session_stats_alert;
struct dht_error_alert;
struct dht_immutable_item_alert;
struct dht_mutable_item_alert;
struct dht_put_alert;
struct i2p_alert;
struct dht_outgoing_get_peers_alert;
struct log_alert;
struct torrent_log_alert;
struct peer_log_alert;
struct lsd_error_alert;
struct dht_lookup;
struct dht_routing_bucket;
struct dht_stats_alert;
struct incoming_request_alert;
struct dht_log_alert;
struct dht_pkt_alert;
struct dht_get_peers_reply_alert;
struct dht_direct_response_alert;
struct picker_log_alert;
struct session_error_alert;
struct dht_live_nodes_alert;
struct session_stats_header_alert;
// include/libtorrent/announce_entry.hpp
struct announce_entry;
// include/libtorrent/bdecode.hpp
struct bdecode_node;
// include/libtorrent/bitfield.hpp
struct bitfield;
// include/libtorrent/create_torrent.hpp
struct create_torrent;
// include/libtorrent/disk_interface.hpp
struct open_file_state;
// include/libtorrent/disk_io_thread.hpp
struct cache_status;
// include/libtorrent/entry.hpp
class entry;
// include/libtorrent/error_code.hpp
struct storage_error;
// include/libtorrent/extensions.hpp
struct plugin;
struct torrent_plugin;
struct peer_plugin;
struct crypto_plugin;
// include/libtorrent/file_pool.hpp
struct file_pool;
// include/libtorrent/file_storage.hpp
struct file_slice;
class file_storage;
// include/libtorrent/hasher.hpp
class hasher;
// include/libtorrent/hasher512.hpp
class hasher512;
// include/libtorrent/ip_filter.hpp
struct ip_filter;
class port_filter;
// include/libtorrent/kademlia/dht_state.hpp
struct dht_state;
// include/libtorrent/kademlia/dht_storage.hpp
struct dht_storage_counters;
struct dht_storage_interface;
// include/libtorrent/peer_connection_handle.hpp
struct peer_connection_handle;
struct bt_peer_connection_handle;
// include/libtorrent/peer_info.hpp
struct peer_info;
// include/libtorrent/peer_request.hpp
struct peer_request;
// include/libtorrent/session.hpp
class session_proxy;
struct session_params;
class session;
// include/libtorrent/session_handle.hpp
struct session_handle;
// include/libtorrent/session_settings.hpp
struct dht_settings;
struct pe_settings;
// include/libtorrent/session_stats.hpp
struct stats_metric;
// include/libtorrent/session_status.hpp
struct utp_status;
struct session_status;
// include/libtorrent/settings_pack.hpp
struct settings_pack;
// include/libtorrent/storage.hpp
struct storage_interface;
class default_storage;
// include/libtorrent/storage_defs.hpp
struct storage_interface;
struct storage_params;
// include/libtorrent/torrent_handle.hpp
struct block_info;
struct partial_piece_info;
struct torrent_handle;
// include/libtorrent/torrent_info.hpp
struct web_seed_entry;
class torrent_info;
// include/libtorrent/torrent_status.hpp
struct torrent_status;
#ifndef TORRENT_NO_DEPRECATE
// include/libtorrent/alert_types.hpp
struct torrent_added_alert;
struct mmap_cache_alert;
// include/libtorrent/file_storage.hpp
struct file_entry;
struct internal_file_entry;
// include/libtorrent/lazy_entry.hpp
struct pascal_string;
struct lazy_entry;
#endif // TORRENT_NO_DEPRECATE
}
#endif // TORRENT_FWD_HPP

View File

@ -49,14 +49,14 @@ namespace libtorrent {
//
// For more information about magnet links, see magnet-links_.
//
std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle);
std::string TORRENT_EXPORT make_magnet_uri(torrent_info const& info);
TORRENT_EXPORT std::string make_magnet_uri(torrent_handle const& handle);
TORRENT_EXPORT std::string make_magnet_uri(torrent_info const& info);
#ifndef TORRENT_NO_DEPRECATE
#ifndef BOOST_NO_EXCEPTIONS
// deprecated in 0.14
TORRENT_DEPRECATED
torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri
TORRENT_DEPRECATED_EXPORT
torrent_handle add_magnet_uri(session& ses, std::string const& uri
, std::string const& save_path
, storage_mode_t storage_mode = storage_mode_sparse
, bool paused = false
@ -64,14 +64,14 @@ namespace libtorrent {
, void* userdata = 0);
// deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url
TORRENT_DEPRECATED
torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri
TORRENT_DEPRECATED_EXPORT
torrent_handle add_magnet_uri(session& ses, std::string const& uri
, add_torrent_params p);
#endif
// deprecated in 0.16. Instead, pass in the magnet link as add_torrent_params::url
TORRENT_DEPRECATED
torrent_handle TORRENT_EXPORT add_magnet_uri(session& ses, std::string const& uri
TORRENT_DEPRECATED_EXPORT
torrent_handle add_magnet_uri(session& ses, std::string const& uri
, add_torrent_params p, error_code& ec);
#endif

View File

@ -69,7 +69,7 @@ TORRENT_TEST(close_file_interval)
}
torrent_handle h = ses.get_torrents().front();
std::vector<pool_file_status> const file_status = h.file_status();
std::vector<open_file_state> const file_status = h.file_status();
printf("%d: %d files\n", ticks, int(file_status.size()));
if (ticks > 0 && ticks < 19)
{
@ -124,7 +124,7 @@ TORRENT_TEST(file_pool_size)
return true;
}
std::vector<pool_file_status> const status = ses.get_torrents().at(0).file_status();
std::vector<open_file_state> const status = ses.get_torrents().at(0).file_status();
printf("open files: %d\n", int(status.size()));
max_files = std::max(max_files, int(status.size()));
if (!is_seed(ses)) return false;

96
tools/gen_fwd.py Normal file
View File

@ -0,0 +1,96 @@
#!/usr/bin/env python
import os
import sys
file_header ='''/*
Copyright (c) 2017, Arvid Norberg
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_FWD_HPP
#define TORRENT_FWD_HPP
#include "libtorrent/export.hpp"
namespace libtorrent {
'''
file_footer = '''
}
#endif // TORRENT_FWD_HPP
'''
classes = os.popen('git grep TORRENT_EXPORT').read().split('\n')
deprecated_classes = os.popen('git grep TORRENT_DEPRECATED_EXPORT').read().split('\n')
def filter_classes(classes, keyword):
current_file = ''
ret = ''
for c in classes:
line = c.split(':', 1)
if not line[0].endswith('.hpp'): continue
# ignore the forward header itself, that's the one we're generating
if line[0].endswith('/fwd.hpp'): continue
# don't provide forward declarations of internal types
if '/aux_/' in line[0]: continue
this_file = line[0].strip()
decl = ':'.join(line[1:]).strip().split(' ')
if decl[0].strip() not in ['struct', 'class']: continue
# TODO: support TORRENT_DEPRECATED_EXPORT
if decl[1].strip() != keyword: continue
if this_file != current_file:
ret += '\n// ' + this_file + '\n'
current_file = this_file;
decl = decl[0] + ' ' + decl[2]
if not decl.endswith(';'): decl += ';'
ret += decl + '\n'
return ret
os.remove('include/libtorrent/fwd.hpp')
with open('include/libtorrent/fwd.hpp', 'w+') as f:
f.write(file_header)
f.write(filter_classes(classes, 'TORRENT_EXPORT'));
f.write('\n#ifndef TORRENT_NO_DEPRECATE\n')
f.write(filter_classes(deprecated_classes, 'TORRENT_DEPRECATED_EXPORT'));
f.write('\n#endif // TORRENT_NO_DEPRECATE')
f.write(file_footer)