forked from premiere/premiere-libtorrent
merged (python) fixes from RC_0_16
This commit is contained in:
parent
08454e518a
commit
5077c06c4a
|
@ -53,6 +53,7 @@ python-extension libtorrent
|
|||
src/session.cpp
|
||||
src/entry.cpp
|
||||
src/torrent_info.cpp
|
||||
src/string.cpp
|
||||
src/torrent_handle.cpp
|
||||
src/torrent_status.cpp
|
||||
src/session_settings.cpp
|
||||
|
|
|
@ -22,6 +22,7 @@ EXTRA_DIST = \
|
|||
src/peer_info.cpp \
|
||||
src/session.cpp \
|
||||
src/session_settings.cpp \
|
||||
src/string.cpp \
|
||||
src/torrent.cpp \
|
||||
src/torrent_handle.cpp \
|
||||
src/torrent_info.cpp \
|
||||
|
|
|
@ -14,6 +14,7 @@ void bind_big_number();
|
|||
void bind_session();
|
||||
void bind_entry();
|
||||
void bind_torrent_info();
|
||||
void bind_unicode_string_conversion();
|
||||
void bind_torrent_handle();
|
||||
void bind_torrent_status();
|
||||
void bind_session_settings();
|
||||
|
@ -40,6 +41,7 @@ BOOST_PYTHON_MODULE(libtorrent)
|
|||
bind_entry();
|
||||
bind_session();
|
||||
bind_torrent_info();
|
||||
bind_unicode_string_conversion();
|
||||
bind_torrent_handle();
|
||||
bind_torrent_status();
|
||||
bind_session_settings();
|
||||
|
|
|
@ -666,7 +666,9 @@ void bind_session()
|
|||
;
|
||||
|
||||
enum_<session::listen_on_flags_t>("listen_on_flags_t")
|
||||
#ifndef TORRENT_NO_DEPRECATE
|
||||
.value("listen_reuse_address", session::listen_reuse_address)
|
||||
#endif
|
||||
.value("listen_no_system_port", session::listen_no_system_port)
|
||||
;
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
// Copyright Daniel Wallin 2006. Use, modification and distribution is
|
||||
// subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/python.hpp>
|
||||
#include "libtorrent/utf8.hpp"
|
||||
#include <string>
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
struct unicode_from_python
|
||||
{
|
||||
unicode_from_python()
|
||||
{
|
||||
converter::registry::push_back(
|
||||
&convertible, &construct, type_id<std::string>()
|
||||
);
|
||||
}
|
||||
|
||||
static void* convertible(PyObject* x)
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03020000
|
||||
return PyBytes_Check(x) ? x : PyUnicode_Check(x) ? x : 0;
|
||||
#else
|
||||
return PyString_Check(x) ? x : PyUnicode_Check(x) ? x : 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void construct(PyObject* x, converter::rvalue_from_python_stage1_data* data)
|
||||
{
|
||||
using libtorrent::wchar_utf8;
|
||||
void* storage = ((converter::rvalue_from_python_storage<
|
||||
std::string>*)data)->storage.bytes;
|
||||
|
||||
if (PyUnicode_Check(x))
|
||||
{
|
||||
std::wstring str;
|
||||
str.resize(PyUnicode_GetSize(x) + 1, 0);
|
||||
#if PY_VERSION_HEX >= 0x03020000
|
||||
int len = PyUnicode_AsWideChar(x, &str[0], str.size());
|
||||
#else
|
||||
int len = PyUnicode_AsWideChar((PyUnicodeObject*)x, &str[0], str.size());
|
||||
#endif
|
||||
if (len > -1)
|
||||
{
|
||||
assert(len < str.size());
|
||||
str[len] = 0;
|
||||
}
|
||||
else str[str.size()-1] = 0;
|
||||
|
||||
std::string utf8;
|
||||
int ret = wchar_utf8(str, utf8);
|
||||
new (storage) std::string(utf8);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
new (storage) std::string(PyBytes_AsString(x));
|
||||
#else
|
||||
new (storage) std::string(PyString_AsString(x));
|
||||
#endif
|
||||
}
|
||||
data->convertible = storage;
|
||||
}
|
||||
};
|
||||
|
||||
void bind_unicode_string_conversion()
|
||||
{
|
||||
unicode_from_python();
|
||||
}
|
||||
|
18
configure.ac
18
configure.ac
|
@ -97,10 +97,24 @@ AS_ECHO "Checking for posix thread support:"
|
|||
AX_PTHREAD()
|
||||
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$PTHREAD_CFLAGS $CFLAGS -fvisibility=hidden"
|
||||
CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
|
||||
CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
|
||||
CC="$PTHREAD_CC"
|
||||
|
||||
AS_ECHO "Checking for visibility support:"
|
||||
AC_CACHE_CHECK([for __attribute__((visibility("hidden")))],
|
||||
ac_cv_hidden_visibility_attribute, [
|
||||
echo 'int __attribute__ ((visibility ("hidden"))) foo (void) { return 1; }' > visibility_conftest.c
|
||||
ac_cv_hidden_visibility_attribute=no
|
||||
if AC_TRY_COMMAND(${CC-cc} -fvisibility=hidden -S visibility_conftest.c -o visibility_conftest.s 1>&AS_MESSAGE_LOG_FD);
|
||||
then
|
||||
AS_ECHO "found"
|
||||
ac_cv_hidden_visibility_attribute=yes
|
||||
CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
|
||||
CFLAGS="$CFLAGS -fvisibility=hidden"
|
||||
fi
|
||||
rm -f visibility_conftest.*
|
||||
])
|
||||
|
||||
AS_ECHO
|
||||
AS_ECHO "Checking for boost libraries:"
|
||||
|
||||
|
|
Loading…
Reference in New Issue