fix python binding linking on msvc (#878)

This commit is contained in:
Arvid Norberg 2016-07-03 23:30:52 -04:00 committed by GitHub
parent 34a2a7f7d4
commit 66416963eb
5 changed files with 44 additions and 20 deletions

View File

@ -23,7 +23,6 @@ environment:
- variant: test_release
compiler: msvc-14.0
model: 64
python: 1
linkflags: '"/LIBPATH:C:\\openssl-1.0.1p-vs2015\\lib64"'
include: '"c:\\openssl-1.0.1p-vs2015\\include"'
- variant: test_debug

View File

@ -34,6 +34,17 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/bdecode.hpp>
#include <libtorrent/upnp.hpp>
#include <libtorrent/socks5_stream.hpp>
namespace boost
{
// this fixe mysterious link error on msvc
boost::system::error_category const volatile*
get_pointer(boost::system::error_category const volatile* p)
{
return p;
}
}
#include "boost_python.hpp"
using namespace boost::python;
@ -42,7 +53,9 @@ using boost::system::error_category;
void bind_error_code()
{
class_<boost::system::error_category, boost::noncopyable>("error_category", no_init)
using boost::noncopyable;
class_<boost::system::error_category, noncopyable>("error_category", no_init)
.def("name", &error_category::name)
.def("message", &error_category::message)
.def(self == self)
@ -56,34 +69,34 @@ void bind_error_code()
.def("value", &error_code::value)
.def("clear", &error_code::clear)
.def("category", &error_code::category
, return_internal_reference<>())
, return_value_policy<reference_existing_object>())
.def("assign", &error_code::assign)
;
def("get_libtorrent_category", &get_libtorrent_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
def("get_upnp_category", &get_upnp_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
def("get_http_category", &get_http_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
def("get_socks_category", &get_socks_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
#if TORRENT_USE_I2P
def("get_i2p_category", &get_i2p_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
#endif
def("get_bdecode_category", &get_bdecode_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
def("generic_category", &boost::system::generic_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
def("system_category", &boost::system::system_category
, return_internal_reference<>());
, return_value_policy<reference_existing_object>());
}

View File

@ -17,13 +17,23 @@
#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/extensions/lt_trackers.hpp>
#include <libtorrent/extensions/metadata_transfer.hpp>
#include <libtorrent/extensions/smart_ban.hpp>
#include <libtorrent/extensions/ut_metadata.hpp>
#include <libtorrent/extensions/ut_pex.hpp>
namespace boost
{
// this fixes mysterious link error on msvc
libtorrent::alert const volatile*
get_pointer(libtorrent::alert const volatile* p)
{
return p;
}
}
#include "gil.hpp"
#include "bytes.hpp"
@ -323,8 +333,11 @@ namespace
alert const*
wait_for_alert(lt::session& s, int ms)
{
allow_threading_guard guard;
alert const* a = s.wait_for_alert(milliseconds(ms));
alert const* a;
{
allow_threading_guard guard;
a = s.wait_for_alert(milliseconds(ms));
}
return a;
}
@ -415,10 +428,9 @@ namespace
}
list ret;
for (std::vector<alert*>::iterator i = alerts.begin()
, end(alerts.end()); i != end; ++i)
for (alert* a : alerts)
{
ret.append(boost::python::ptr(*i));
ret.append(boost::python::ptr(a));
}
return ret;
}
@ -759,8 +771,7 @@ void bind_session()
.def("load_state", &load_state, (arg("entry"), arg("flags") = 0xffffffff))
.def("save_state", &save_state, (arg("entry"), arg("flags") = 0xffffffff))
.def("pop_alerts", &pop_alerts)
.def("wait_for_alert", &wait_for_alert, return_internal_reference<>()
)
.def("wait_for_alert", &wait_for_alert, return_internal_reference<>())
.def("add_extension", &add_extension)
#ifndef TORRENT_NO_DEPRECATE
#if TORRENT_USE_I2P

View File

@ -16,6 +16,7 @@ project
<source>setup_dht.cpp
<source>create_torrent.cpp
<source>utils.cpp
<toolset>msvc:<cflags>/wd4275
: default-build
<threading>multi
<invariant-checks>full

@ -1 +1 @@
Subproject commit 0c796e3e0dea7ca05eef3ded2cf3806ef19a1413
Subproject commit 1df1d608358ed93cc5024ad731df7d047508554f