Fix building bindings when TORRENT_NO_DEPRECATE is defined

Add 'performance_alert' to the bindings
This commit is contained in:
Andrew Resch 2008-10-28 06:29:30 +00:00
parent 5ab28ed37f
commit e9dd8ce050
4 changed files with 82 additions and 60 deletions

View File

@ -56,7 +56,9 @@ void bind_alert()
.def("message", &alert::message, alert_msg_doc)
.def("what", &alert::what)
.def("category", &alert::category)
#ifndef TORRENT_NO_DEPRECATE
.def("severity", &alert::severity, alert_severity_doc)
#endif
.def("__str__", &alert::message, alert_msg_doc)
;
@ -67,7 +69,7 @@ void bind_alert()
.value("critical", alert::critical)
.value("fatal", alert::fatal)
.value("none", alert::none)
;
;
enum_<alert::category_t>("category_t")
.value("error_notification", alert::error_notification)
@ -79,8 +81,10 @@ void bind_alert()
.value("status_notification", alert::status_notification)
.value("progress_notification", alert::progress_notification)
.value("ip_block_notification", alert::ip_block_notification)
.value("performance_warning", alert::performance_warning)
.value("all_categories", alert::all_categories)
;
;
}
class_<torrent_alert, bases<alert>, noncopyable>(
@ -153,20 +157,20 @@ void bind_alert()
class_<torrent_finished_alert, bases<torrent_alert>, noncopyable>(
"torrent_finished_alert", torrent_finished_alert_doc, no_init
);
class_<piece_finished_alert, bases<torrent_alert>, noncopyable>(
"piece_finished_alert", piece_finished_alert_doc, no_init
)
.def_readonly("piece_index", &piece_finished_alert::piece_index)
;
class_<block_finished_alert, bases<peer_alert>, noncopyable>(
"block_finished_alert", block_finished_alert_doc, no_init
)
.def_readonly("block_index", &block_finished_alert::block_index)
.def_readonly("piece_index", &block_finished_alert::piece_index)
;
class_<block_downloading_alert, bases<peer_alert>, noncopyable>(
"block_downloading_alert", block_downloading_alert_doc, no_init
)
@ -174,7 +178,7 @@ void bind_alert()
.def_readonly("block_index", &block_downloading_alert::block_index)
.def_readonly("piece_index", &block_downloading_alert::piece_index)
;
class_<storage_moved_alert, bases<torrent_alert>, noncopyable>(
"storage_moved_alert", storage_moved_alert_doc, no_init
);
@ -182,7 +186,7 @@ void bind_alert()
class_<torrent_deleted_alert, bases<torrent_alert>, noncopyable>(
"torrent_deleted_alert", torrent_deleted_alert_doc, no_init
);
class_<torrent_paused_alert, bases<torrent_alert>, noncopyable>(
"torrent_paused_alert", torrent_paused_alert_doc, no_init
);
@ -190,19 +194,19 @@ void bind_alert()
class_<torrent_checked_alert, bases<torrent_alert>, noncopyable>(
"torrent_checked_alert", torrent_checked_alert_doc, no_init
);
class_<url_seed_alert, bases<torrent_alert>, noncopyable>(
"url_seed_alert", url_seed_alert_doc, no_init
)
.def_readonly("url", &url_seed_alert::url)
;
class_<file_error_alert, bases<torrent_alert>, noncopyable>(
"file_error_alert", file_error_alert_doc, no_init
)
.def_readonly("file", &file_error_alert::file)
;
class_<metadata_failed_alert, bases<torrent_alert>, noncopyable>(
"metadata_failed_alert", metadata_failed_alert_doc, no_init
);
@ -214,20 +218,20 @@ void bind_alert()
class_<listen_failed_alert, bases<alert>, noncopyable>(
"listen_failed_alert", listen_failed_alert_doc, no_init
);
class_<listen_succeeded_alert, bases<alert>, noncopyable>(
"listen_succeeded_alert", listen_succeeded_alert_doc, no_init
)
.def_readonly("endpoint", &listen_succeeded_alert::endpoint)
;
class_<portmap_error_alert, bases<alert>, noncopyable>(
"portmap_error_alert", portmap_error_alert_doc, no_init
)
.def_readonly("mapping", &portmap_error_alert::mapping)
.def_readonly("type", &portmap_error_alert::type)
;
class_<portmap_alert, bases<alert>, noncopyable>(
"portmap_alert", portmap_alert_doc, no_init
)
@ -235,34 +239,34 @@ void bind_alert()
.def_readonly("external_port", &portmap_alert::external_port)
.def_readonly("type", &portmap_alert::type)
;
class_<fastresume_rejected_alert, bases<torrent_alert>, noncopyable>(
"fastresume_rejected_alert", fastresume_rejected_alert_doc, no_init
);
class_<peer_blocked_alert, bases<alert>, noncopyable>(
"peer_blocked_alert", peer_blocked_alert_doc, no_init
)
.def_readonly("ip", &peer_blocked_alert::ip)
;
class_<scrape_reply_alert, bases<tracker_alert>, noncopyable>(
"scrape_reply_alert", scrape_reply_alert_doc, no_init
)
.def_readonly("incomplete", &scrape_reply_alert::incomplete)
.def_readonly("complete", &scrape_reply_alert::complete)
;
class_<scrape_failed_alert, bases<tracker_alert>, noncopyable>(
"scrape_failed_alert", scrape_failed_alert_doc, no_init
);
class_<udp_error_alert, bases<alert>, noncopyable>(
"udp_error_alert", udp_error_alert_doc, no_init
)
.def_readonly("endpoint", &udp_error_alert::endpoint)
;
class_<external_ip_alert, bases<alert>, noncopyable>(
"external_ip_alert", external_ip_alert_doc, no_init
)
@ -288,11 +292,11 @@ void bind_alert()
.def_readonly("index", &file_rename_failed_alert::index)
.def_readonly("msg", &file_rename_failed_alert::msg)
;
class_<torrent_resumed_alert, bases<torrent_alert>, noncopyable>(
"torrent_resumed_alert", no_init
class_<torrent_resumed_alert, bases<torrent_alert>, noncopyable>(
"torrent_resumed_alert", no_init
);
class_<state_changed_alert, bases<torrent_alert>, noncopyable>(
"state_changed_alert", no_init
)
@ -304,50 +308,62 @@ void bind_alert()
)
.def_readonly("num_peers", &dht_reply_alert::num_peers)
;
class_<peer_unsnubbed_alert, bases<peer_alert>, noncopyable>(
"peer_unsnubbed_alert", no_init
);
class_<peer_snubbed_alert, bases<peer_alert>, noncopyable>(
"peer_snubbed_alert", no_init
);
class_<peer_connect_alert, bases<peer_alert>, noncopyable>(
"peer_connect_alert", no_init
);
class_<peer_disconnected_alert, bases<peer_alert>, noncopyable>(
"peer_disconnected_alert", no_init
);
class_<request_dropped_alert, bases<peer_alert>, noncopyable>(
"request_dropped_alert", no_init
)
.def_readonly("block_index", &request_dropped_alert::block_index)
.def_readonly("piece_index", &request_dropped_alert::piece_index)
;
class_<block_timeout_alert, bases<peer_alert>, noncopyable>(
"block_timeout_alert", no_init
)
.def_readonly("block_index", &block_timeout_alert::block_index)
.def_readonly("piece_index", &block_timeout_alert::piece_index)
;
class_<unwanted_block_alert, bases<peer_alert>, noncopyable>(
"unwanted_block_alert", no_init
)
.def_readonly("block_index", &unwanted_block_alert::block_index)
.def_readonly("piece_index", &unwanted_block_alert::piece_index)
;
class_<torrent_delete_failed_alert, bases<torrent_alert>, noncopyable>(
"torrent_delete_failed_alert", no_init
);
class_<save_resume_data_failed_alert, bases<torrent_alert>, noncopyable>(
"save_resume_data_failed_alert", no_init
);
class_<performance_alert, bases<torrent_alert>, noncopyable>(
"performance_alert", no_init
)
.def_readonly("warning_code", &performance_alert::warning_code)
;
enum_<performance_alert::performance_warning_t>("performance_warning_t")
.value("outstanding_disk_buffer_limit_reached", performance_alert::outstanding_disk_buffer_limit_reached)
.value("outstanding_request_limit_reached", performance_alert::outstanding_request_limit_reached)
;
}

View File

@ -49,7 +49,7 @@ extern char const* session_set_max_half_open_connections_doc;
extern char const* session_num_connections_doc;
extern char const* session_set_settings_doc;
extern char const* session_set_pe_settings_doc;
extern char const* session_get_pe_settings_doc;
extern char const* session_get_pe_settings_doc;
extern char const* session_set_severity_level_doc;
extern char const* session_pop_alert_doc;
extern char const* session_start_upnp_doc;
@ -106,11 +106,11 @@ namespace
}
#ifndef TORRENT_NO_DEPRECATE
torrent_handle add_torrent_depr(session& s, torrent_info const& ti
, boost::filesystem::path const& save, entry const& resume
, storage_mode_t storage_mode, bool paused)
torrent_handle add_torrent_depr(session& s, torrent_info const& ti
, boost::filesystem::path const& save, entry const& resume
, storage_mode_t storage_mode, bool paused)
{
allow_threading_guard guard;
allow_threading_guard guard;
return s.add_torrent(ti, save, resume, storage_mode, paused, default_storage_constructor);
}
#endif
@ -183,7 +183,7 @@ namespace
}
return ret;
}
#ifndef TORRENT_DISABLE_GEO_IP
bool load_asnum_db(session& s, std::string file)
{
@ -273,7 +273,7 @@ void bind_session()
.value("add_default_plugins", session::add_default_plugins)
.value("start_default_features", session::start_default_features)
;
class_<session, boost::noncopyable>("session", session_doc, no_init)
.def(
init<fingerprint, int>((
@ -305,11 +305,11 @@ void bind_session()
#ifndef TORRENT_NO_DEPRECATE
.def(
"add_torrent", &add_torrent_depr
, (
arg("resume_data") = entry(), arg("storage_mode") = storage_mode_sparse,
arg("paused") = false
)
, session_add_torrent_doc
, (
arg("resume_data") = entry(), arg("storage_mode") = storage_mode_sparse,
arg("paused") = false
)
, session_add_torrent_doc
)
#endif
.def("remove_torrent", allow_threads(&session::remove_torrent), arg("option") = session::none
@ -361,10 +361,12 @@ void bind_session()
#endif
.def("load_state", allow_threads(&session::load_state))
.def("state", allow_threads(&session::state))
#ifndef TORRENT_NO_DEPRECATE
.def(
"set_severity_level", allow_threads(&session::set_severity_level)
, session_set_severity_level_doc
)
#endif
.def("set_alert_mask", allow_threads(&session::set_alert_mask))
.def("pop_alert", allow_threads(&session::pop_alert), session_pop_alert_doc)
.def("add_extension", &add_extension)
@ -387,5 +389,3 @@ void bind_session()
register_ptr_to_python<std::auto_ptr<alert> >();
}

View File

@ -152,10 +152,10 @@ list file_priorities(torrent_handle& handle)
{
list ret;
std::vector<int> priorities = handle.file_priorities();
for (std::vector<int>::iterator i = priorities.begin(); i != priorities.end(); ++i)
ret.append(*i);
return ret;
}
@ -253,7 +253,7 @@ void bind_torrent_handle()
int (torrent_handle::*piece_priority0)(int) const = &torrent_handle::piece_priority;
void (torrent_handle::*piece_priority1)(int, int) const = &torrent_handle::piece_priority;
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
bool (torrent_handle::*resolve_countries0)() const = &torrent_handle::resolve_countries;
void (torrent_handle::*resolve_countries1)(bool) = &torrent_handle::resolve_countries;
#endif
@ -281,7 +281,7 @@ void bind_torrent_handle()
.def("pause", _(&torrent_handle::pause))
.def("resume", _(&torrent_handle::resume))
.def("clear_error", _(&torrent_handle::clear_error))
.def("is_auto_managed", _(&torrent_handle::is_auto_managed))
.def("auto_managed", _(&torrent_handle::auto_managed))
.def("queue_position", _(&torrent_handle::queue_position))
@ -289,15 +289,17 @@ void bind_torrent_handle()
.def("queue_position_down", _(&torrent_handle::queue_position_down))
.def("queue_position_top", _(&torrent_handle::queue_position_top))
.def("queue_position_bottom", _(&torrent_handle::queue_position_bottom))
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
.def("resolve_countries", _(resolve_countries0))
.def("resolve_countries", _(resolve_countries1))
#endif
// deprecated
#ifndef TORRENT_NO_DEPRECATE
.def("filter_piece", _(&torrent_handle::filter_piece))
.def("is_piece_filtered", _(&torrent_handle::is_piece_filtered))
.def("write_resume_data", _(&torrent_handle::write_resume_data))
#endif
.def("piece_availability", piece_availability)
.def("piece_priority", _(piece_priority0))
.def("piece_priority", _(piece_priority1))
@ -306,7 +308,6 @@ void bind_torrent_handle()
.def("prioritize_files", prioritize_files)
.def("file_priorities", file_priorities)
.def("use_interface", &torrent_handle::use_interface)
.def("write_resume_data", _(&torrent_handle::write_resume_data))
.def("save_resume_data", _(&torrent_handle::save_resume_data))
.def("force_reannounce", _(force_reannounce0))
.def("force_reannounce", force_reannounce)
@ -331,4 +332,3 @@ void bind_torrent_handle()
.def("rename_file", _(&torrent_handle::rename_file))
;
}

View File

@ -67,6 +67,10 @@ namespace
std::string result(ti.metadata().get(), ti.metadata_size());
return result;
}
torrent_info construct0(std::string path) {
return torrent_info(fs::path(path));
}
} // namespace unnamed
void bind_torrent_info()
@ -74,10 +78,13 @@ void bind_torrent_info()
return_value_policy<copy_const_reference> copy;
class_<torrent_info, boost::intrusive_ptr<torrent_info> >("torrent_info", no_init)
#ifndef TORRENT_NO_DEPRECATE
.def(init<entry const&>())
#endif
.def(init<sha1_hash const&>())
.def(init<char const*, int>())
.def(init<boost::filesystem::path>())
.def("add_tracker", &torrent_info::add_tracker, (arg("url"), arg("tier")=0))
.def("add_url_seed", &torrent_info::add_url_seed)
@ -87,8 +94,9 @@ void bind_torrent_info()
.def("total_size", &torrent_info::total_size)
.def("piece_length", &torrent_info::piece_length)
.def("num_pieces", &torrent_info::num_pieces)
#ifndef TORRENT_NO_DEPRECATE
.def("info_hash", &torrent_info::info_hash, copy)
#endif
.def("hash_for_piece", &torrent_info::hash_for_piece)
.def("piece_size", &torrent_info::piece_size)
@ -123,5 +131,3 @@ void bind_torrent_info()
.def_readwrite("tier", &announce_entry::tier)
;
}