modernize use nullptr (python binding) (#896)

This commit is contained in:
Arvid Norberg 2016-07-09 22:36:14 -04:00 committed by GitHub
parent e782783814
commit 48298e1670
6 changed files with 13 additions and 13 deletions

View File

@ -346,7 +346,7 @@ void bind_alert()
; ;
class_<read_piece_alert, bases<torrent_alert>, noncopyable>( class_<read_piece_alert, bases<torrent_alert>, noncopyable>(
"read_piece_alert", 0, no_init) "read_piece_alert", nullptr, no_init)
.add_property("buffer", get_buffer) .add_property("buffer", get_buffer)
.def_readonly("piece", &read_piece_alert::piece) .def_readonly("piece", &read_piece_alert::piece)
.def_readonly("size", &read_piece_alert::size) .def_readonly("size", &read_piece_alert::size)

View File

@ -33,15 +33,15 @@ struct tuple_to_endpoint
static void* convertible(PyObject* x) static void* convertible(PyObject* x)
{ {
if (!PyTuple_Check(x)) return NULL; if (!PyTuple_Check(x)) return nullptr;
if (PyTuple_Size(x) != 2) return NULL; if (PyTuple_Size(x) != 2) return nullptr;
extract<std::string> ip(object(borrowed(PyTuple_GetItem(x, 0)))); extract<std::string> ip(object(borrowed(PyTuple_GetItem(x, 0))));
if (!ip.check()) return NULL; if (!ip.check()) return nullptr;
extract<int> port(object(borrowed(PyTuple_GetItem(x, 1)))); extract<int> port(object(borrowed(PyTuple_GetItem(x, 1))));
if (!port.check()) return NULL; if (!port.check()) return nullptr;
lt::error_code ec; lt::error_code ec;
lt::address::from_string(ip, ec); lt::address::from_string(ip, ec);
if (ec) return NULL; if (ec) return nullptr;
return x; return x;
} }
@ -78,7 +78,7 @@ struct tuple_to_pair
static void* convertible(PyObject* x) static void* convertible(PyObject* x)
{ {
return (PyTuple_Check(x) && PyTuple_Size(x) == 2) ? x: NULL; return (PyTuple_Check(x) && PyTuple_Size(x) == 2) ? x: nullptr;
} }
static void construct(PyObject* x, converter::rvalue_from_python_stage1_data* data) static void construct(PyObject* x, converter::rvalue_from_python_stage1_data* data)
@ -121,7 +121,7 @@ struct list_to_vector
static void* convertible(PyObject* x) static void* convertible(PyObject* x)
{ {
return PyList_Check(x) ? x: 0; return PyList_Check(x) ? x: nullptr;
} }
static void construct(PyObject* x, converter::rvalue_from_python_stage1_data* data) static void construct(PyObject* x, converter::rvalue_from_python_stage1_data* data)

View File

@ -76,7 +76,7 @@ namespace
FileIter(file_storage const& fs, int i) : m_fs(&fs), m_i(i) {} FileIter(file_storage const& fs, int i) : m_fs(&fs), m_i(i) {}
FileIter(FileIter const& fi) : m_fs(fi.m_fs), m_i(fi.m_i) {} FileIter(FileIter const& fi) : m_fs(fi.m_fs), m_i(fi.m_i) {}
FileIter() : m_fs(NULL), m_i(0) {} FileIter() : m_fs(nullptr), m_i(0) {}
libtorrent::file_entry operator*() const libtorrent::file_entry operator*() const
{ return m_fs->at(m_i); } { return m_fs->at(m_i); }

View File

@ -794,7 +794,7 @@ void bind_session()
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
.def( .def(
"listen_on", &listen_on "listen_on", &listen_on
, (arg("min"), "max", arg("interface") = (char const*)0, arg("flags") = 0) , (arg("min"), "max", arg("interface") = (char const*)nullptr, arg("flags") = 0)
) )
#ifndef TORRENT_DISABLE_DHT #ifndef TORRENT_DISABLE_DHT
.def("start_dht", allow_threads(start_dht0)) .def("start_dht", allow_threads(start_dht0))

View File

@ -21,7 +21,7 @@ struct unicode_from_python
#if PY_VERSION_HEX >= 0x03020000 #if PY_VERSION_HEX >= 0x03020000
return PyBytes_Check(x) ? x : PyUnicode_Check(x) ? x : 0; return PyBytes_Check(x) ? x : PyUnicode_Check(x) ? x : 0;
#else #else
return PyString_Check(x) ? x : PyUnicode_Check(x) ? x : 0; return PyString_Check(x) ? x : PyUnicode_Check(x) ? x : nullptr;
#endif #endif
} }
@ -33,7 +33,7 @@ struct unicode_from_python
if (PyUnicode_Check(x)) if (PyUnicode_Check(x))
{ {
PyObject* utf8 = PyUnicode_AsUTF8String(x); PyObject* utf8 = PyUnicode_AsUTF8String(x);
if (utf8 == NULL) if (utf8 == nullptr)
{ {
new (storage) std::string(); new (storage) std::string();
} }

View File

@ -42,7 +42,7 @@ struct bytes_from_python
#if PY_MAJOR_VERSION >= 3 #if PY_MAJOR_VERSION >= 3
return PyBytes_Check(x) ? x : NULL; return PyBytes_Check(x) ? x : NULL;
#else #else
return PyString_Check(x) ? x : NULL; return PyString_Check(x) ? x : nullptr;
#endif #endif
} }