mirror of
https://github.com/boostorg/python.git
synced 2026-01-26 06:42:27 +00:00
Reduce indentation of parameter lists split across lines (fix "endline layout")
[SVN r20445]
This commit is contained in:
@@ -97,9 +97,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
static void visitor_helper (PythonClass &, Policy const &);
|
||||
|
||||
private:
|
||||
static size_type bounds_check (container &, index_param, char const *msg
|
||||
, bool one_past = false
|
||||
, bool truncate = false);
|
||||
static size_type bounds_check (
|
||||
container &, index_param, char const *msg
|
||||
, bool one_past = false
|
||||
, bool truncate = false);
|
||||
// Throws std::out_of_range if necessary. If one_past is set, then
|
||||
// indexes up to container.size() *inclusive* are allowed. If
|
||||
// truncate is set, then out of bounds values are reset to the
|
||||
@@ -240,11 +241,12 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
typename default_algorithms<ContainerTraits, Ovr>::size_type
|
||||
default_algorithms<ContainerTraits, Ovr>::bounds_check (container &c
|
||||
, index_param ix
|
||||
, char const *msg
|
||||
, bool one_past
|
||||
, bool truncate)
|
||||
default_algorithms<ContainerTraits, Ovr>::bounds_check (
|
||||
container &c
|
||||
, index_param ix
|
||||
, char const *msg
|
||||
, bool one_past
|
||||
, bool truncate)
|
||||
{
|
||||
size_type bound = most_derived::size(c) + (one_past ? 1 : 0);
|
||||
size_type result;
|
||||
@@ -296,8 +298,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
typename default_algorithms<ContainerTraits, Ovr>::iterator
|
||||
default_algorithms<ContainerTraits, Ovr>::find (container &c
|
||||
, key_param key)
|
||||
default_algorithms<ContainerTraits, Ovr>::find (
|
||||
container &c, key_param key)
|
||||
{
|
||||
return std::find (most_derived::begin(c), most_derived::end(c), key);
|
||||
}
|
||||
@@ -308,15 +310,15 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
typename default_algorithms<ContainerTraits, Ovr>::size_type
|
||||
default_algorithms<ContainerTraits, Ovr>::get_index (container &c
|
||||
, key_param key)
|
||||
default_algorithms<ContainerTraits, Ovr>::get_index (
|
||||
container &c, key_param key)
|
||||
{
|
||||
iterator temp (most_derived::find (c, key));
|
||||
|
||||
if (temp == most_derived::end(c))
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError
|
||||
, "get_index: element not found");
|
||||
PyErr_SetString (
|
||||
PyExc_ValueError, "get_index: element not found");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -330,8 +332,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
typename default_algorithms<ContainerTraits, Ovr>::size_type
|
||||
default_algorithms<ContainerTraits, Ovr>::count (container &c
|
||||
, key_param key)
|
||||
default_algorithms<ContainerTraits, Ovr>::count (
|
||||
container &c, key_param key)
|
||||
{
|
||||
return std::count (most_derived::begin(c), most_derived::end(c), key);
|
||||
}
|
||||
@@ -342,8 +344,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
bool
|
||||
default_algorithms<ContainerTraits, Ovr>::contains (container &c
|
||||
, key_param key)
|
||||
default_algorithms<ContainerTraits, Ovr>::contains (
|
||||
container &c, key_param key)
|
||||
{
|
||||
return most_derived::find (c, key) != most_derived::end(c);
|
||||
}
|
||||
@@ -354,8 +356,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
typename default_algorithms<ContainerTraits, Ovr>::reference
|
||||
default_algorithms<ContainerTraits, Ovr>::get (container &c
|
||||
, index_param ix)
|
||||
default_algorithms<ContainerTraits, Ovr>::get (
|
||||
container &c, index_param ix)
|
||||
{
|
||||
return c[most_derived::bounds_check (c, ix, "get")];
|
||||
}
|
||||
@@ -366,9 +368,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
default_algorithms<ContainerTraits, Ovr>::assign (container &c
|
||||
, index_param ix
|
||||
, value_param val)
|
||||
default_algorithms<ContainerTraits, Ovr>::assign (
|
||||
container &c, index_param ix, value_param val)
|
||||
{
|
||||
c[most_derived::bounds_check (c, ix, "assign")] = val;
|
||||
}
|
||||
@@ -379,8 +380,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
default_algorithms<ContainerTraits, Ovr>::push_back (container &c
|
||||
, value_param v)
|
||||
default_algorithms<ContainerTraits, Ovr>::push_back (
|
||||
container &c, value_param v)
|
||||
{
|
||||
c.push_back (v);
|
||||
}
|
||||
@@ -391,15 +392,14 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
default_algorithms<ContainerTraits, Ovr>::insert (container &c
|
||||
, index_param i
|
||||
, value_param v)
|
||||
default_algorithms<ContainerTraits, Ovr>::insert (
|
||||
container &c, index_param i, value_param v)
|
||||
{
|
||||
iterator insert_pos (most_derived::begin(c));
|
||||
|
||||
// Index may range up to c.size() inclusive to allow inserting at end
|
||||
std::advance (insert_pos
|
||||
, most_derived::bounds_check (c, i, "insert", true, true));
|
||||
std::advance (
|
||||
insert_pos, most_derived::bounds_check (c, i, "insert", true, true));
|
||||
|
||||
c.insert (insert_pos, v);
|
||||
}
|
||||
@@ -410,9 +410,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
default_algorithms<ContainerTraits, Ovr>::erase_range (container &c
|
||||
, index_param from
|
||||
, index_param to)
|
||||
default_algorithms<ContainerTraits, Ovr>::erase_range (
|
||||
container &c, index_param from, index_param to)
|
||||
{
|
||||
iterator start (most_derived::begin(c));
|
||||
iterator finish (most_derived::begin(c));
|
||||
@@ -434,8 +433,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
default_algorithms<ContainerTraits, Ovr>::erase_one (container &c
|
||||
, index_param ix)
|
||||
default_algorithms<ContainerTraits, Ovr>::erase_one (
|
||||
container &c, index_param ix)
|
||||
{
|
||||
iterator iter (most_derived::begin(c));
|
||||
std::advance (iter, most_derived::bounds_check (c, ix, "erase_one"));
|
||||
@@ -535,13 +534,13 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
assoc_algorithms<ContainerTraits, Ovr>::erase_one (container &c
|
||||
, key_param key)
|
||||
assoc_algorithms<ContainerTraits, Ovr>::erase_one (
|
||||
container &c, key_param key)
|
||||
{
|
||||
if (c.erase (key) == 0)
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError
|
||||
, "Container does not hold value to be erased");
|
||||
PyErr_SetString (
|
||||
PyExc_ValueError, "Container does not hold value to be erased");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -553,13 +552,13 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
set_algorithms<ContainerTraits, Ovr>::insert (container &c
|
||||
, index_param ix)
|
||||
set_algorithms<ContainerTraits, Ovr>::insert (
|
||||
container &c, index_param ix)
|
||||
{
|
||||
if (!c.insert (ix).second)
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError
|
||||
, "Set already holds value for insertion");
|
||||
PyErr_SetString (
|
||||
PyExc_ValueError, "Set already holds value for insertion");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -571,9 +570,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
map_algorithms<ContainerTraits, Ovr>::assign (container &c
|
||||
, index_param ix
|
||||
, value_param val)
|
||||
map_algorithms<ContainerTraits, Ovr>::assign (
|
||||
container &c, index_param ix, value_param val)
|
||||
{
|
||||
c[ix] = val; // Handles overwrite and insert
|
||||
}
|
||||
@@ -584,9 +582,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
void
|
||||
map_algorithms<ContainerTraits, Ovr>::insert (container &c
|
||||
, index_param ix
|
||||
, value_param val)
|
||||
map_algorithms<ContainerTraits, Ovr>::insert (
|
||||
container &c, index_param ix, value_param val)
|
||||
{
|
||||
typedef std::pair
|
||||
<typename self_type::container_traits::index_type
|
||||
@@ -597,8 +594,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
if (!c.insert (pair_type (ix, val)).second)
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError
|
||||
, "Map already holds value for insertion");
|
||||
PyErr_SetString (
|
||||
PyExc_ValueError, "Map already holds value for insertion");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -622,8 +619,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
bool
|
||||
assoc_algorithms<ContainerTraits, Ovr>::contains (container &c
|
||||
, key_param key)
|
||||
assoc_algorithms<ContainerTraits, Ovr>::contains (
|
||||
container &c, key_param key)
|
||||
{
|
||||
return most_derived::find (c, key) != most_derived::end(c);
|
||||
}
|
||||
@@ -635,15 +632,15 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
typename assoc_algorithms<ContainerTraits, Ovr>::iterator
|
||||
assoc_algorithms<ContainerTraits, Ovr>::find_or_throw (container &c
|
||||
, index_param ix)
|
||||
assoc_algorithms<ContainerTraits, Ovr>::find_or_throw (
|
||||
container &c, index_param ix)
|
||||
{
|
||||
iterator iter = most_derived::find (c, ix);
|
||||
|
||||
if (iter == most_derived::end(c))
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError
|
||||
, "associative container: key not found");
|
||||
PyErr_SetString (
|
||||
PyExc_ValueError, "associative container: key not found");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -657,8 +654,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<typename ContainerTraits, typename Ovr>
|
||||
typename assoc_algorithms<ContainerTraits, Ovr>::size_type
|
||||
assoc_algorithms<ContainerTraits, Ovr>::count (container &c
|
||||
, key_param key)
|
||||
assoc_algorithms<ContainerTraits, Ovr>::count (
|
||||
container &c, key_param key)
|
||||
{
|
||||
return c.count (key);
|
||||
}
|
||||
|
||||
@@ -358,8 +358,9 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
// Erase the elements from the real container
|
||||
raw_iterator result
|
||||
= raw_container().erase (raw_container().begin() + from.index
|
||||
, raw_container().begin() + to.index);
|
||||
= raw_container().erase (
|
||||
raw_container().begin() + from.index
|
||||
, raw_container().begin() + to.index);
|
||||
|
||||
return iterator (this, result);
|
||||
}
|
||||
@@ -373,9 +374,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
// Adjust indexes from iter.index onwards, since insert goes
|
||||
// before this element
|
||||
adjust_indexes_back (m_map.lower_bound (iter.index)
|
||||
, m_map.end()
|
||||
, 1);
|
||||
adjust_indexes_back (
|
||||
m_map.lower_bound (iter.index), m_map.end(), 1);
|
||||
|
||||
// Insert the element into the real container
|
||||
raw_iterator result
|
||||
@@ -407,9 +407,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
// Adjust indexes from iter.index onwanrds (insert goes before
|
||||
// this element)
|
||||
adjust_indexes_back (m_map.lower_bound (iter.index)
|
||||
, m_map.end()
|
||||
, std::distance (from, to));
|
||||
adjust_indexes_back (
|
||||
m_map.lower_bound (iter.index), m_map.end(), std::distance (from, to));
|
||||
|
||||
// Insert the element into the real container
|
||||
raw_container().insert (raw_container().begin() + iter.index, from, to);
|
||||
@@ -498,9 +497,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<class Container, class Holder>
|
||||
void
|
||||
container_proxy<Container, Holder>
|
||||
::adjust_indexes_front (map_iterator low_bound
|
||||
, map_iterator high_bound
|
||||
, difference_type offset)
|
||||
::adjust_indexes_front (
|
||||
map_iterator low_bound, map_iterator high_bound, difference_type offset)
|
||||
{
|
||||
// Adjust indexes in the given range of proxies by the given offset.
|
||||
// The adjustment is done by erasing and re-inserting the entries
|
||||
@@ -525,9 +523,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
template <class Container, class Holder>
|
||||
void
|
||||
container_proxy<Container, Holder>
|
||||
::adjust_indexes_back (map_iterator low_bound
|
||||
, map_iterator high_bound
|
||||
, difference_type offset)
|
||||
::adjust_indexes_back (
|
||||
map_iterator low_bound, map_iterator high_bound, difference_type offset)
|
||||
{
|
||||
if (low_bound != high_bound)
|
||||
{
|
||||
|
||||
@@ -116,12 +116,14 @@ namespace boost { namespace python { namespace indexing {
|
||||
namespace detail {
|
||||
template<bool doit> struct maybe_insert {
|
||||
template<class Algorithms>
|
||||
static void apply (typename Algorithms::container &
|
||||
, typename Algorithms::index_param
|
||||
, typename Algorithms::value_param)
|
||||
static void apply (
|
||||
typename Algorithms::container &
|
||||
, typename Algorithms::index_param
|
||||
, typename Algorithms::value_param)
|
||||
{
|
||||
PyErr_SetString (PyExc_TypeError
|
||||
, "container does not support insertion into slice");
|
||||
PyErr_SetString (
|
||||
PyExc_TypeError
|
||||
, "container does not support insertion into slice");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -129,9 +131,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<> struct maybe_insert<true> {
|
||||
template<class Algorithms>
|
||||
static void apply (typename Algorithms::container &c
|
||||
, typename Algorithms::index_param i
|
||||
, typename Algorithms::value_param v)
|
||||
static void apply (
|
||||
typename Algorithms::container &c
|
||||
, typename Algorithms::index_param i
|
||||
, typename Algorithms::value_param v)
|
||||
{
|
||||
Algorithms::insert (c, i, v);
|
||||
}
|
||||
@@ -143,8 +146,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
{
|
||||
if (m_slice.step() != 1)
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError
|
||||
, "attempt to insert via extended slice");
|
||||
PyErr_SetString (
|
||||
PyExc_ValueError, "attempt to insert via extended slice");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -161,12 +164,13 @@ namespace boost { namespace python { namespace indexing {
|
||||
namespace detail {
|
||||
template<bool doit> struct maybe_erase {
|
||||
template<class Algorithms>
|
||||
static void apply (typename Algorithms::container &
|
||||
, typename Algorithms::index_param
|
||||
, typename Algorithms::index_param)
|
||||
static void apply (
|
||||
typename Algorithms::container &
|
||||
, typename Algorithms::index_param
|
||||
, typename Algorithms::index_param)
|
||||
{
|
||||
PyErr_SetString (PyExc_TypeError
|
||||
, "container does not support item deletion");
|
||||
PyErr_SetString (
|
||||
PyExc_TypeError, "container does not support item deletion");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
@@ -174,9 +178,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
template<> struct maybe_erase<true> {
|
||||
template<class Algorithms>
|
||||
static void apply (typename Algorithms::container &c
|
||||
, typename Algorithms::index_param from
|
||||
, typename Algorithms::index_param to)
|
||||
static void apply (
|
||||
typename Algorithms::container &c
|
||||
, typename Algorithms::index_param from
|
||||
, typename Algorithms::index_param to)
|
||||
{
|
||||
Algorithms::erase_range (c, from, to);
|
||||
}
|
||||
@@ -188,8 +193,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
{
|
||||
if (m_slice.step() != 1)
|
||||
{
|
||||
PyErr_SetString (PyExc_ValueError
|
||||
, "attempt to delete via extended slice");
|
||||
PyErr_SetString (
|
||||
PyExc_ValueError, "attempt to delete via extended slice");
|
||||
|
||||
boost::python::throw_error_already_set ();
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
iterator_pair<Iterator>::iterator_pair (iterator_param begin
|
||||
, iterator_param end)
|
||||
iterator_pair<Iterator>::iterator_pair (
|
||||
iterator_param begin, iterator_param end)
|
||||
: m_begin (begin)
|
||||
, m_end (end)
|
||||
{
|
||||
|
||||
@@ -111,8 +111,9 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
namespace std {
|
||||
template<class C>
|
||||
void iter_swap (boost::python::indexing::proxy_iterator<C> const &first
|
||||
, boost::python::indexing::proxy_iterator<C> const &second)
|
||||
void iter_swap (
|
||||
boost::python::indexing::proxy_iterator<C> const &first
|
||||
, boost::python::indexing::proxy_iterator<C> const &second)
|
||||
{
|
||||
first.iter_swap (second);
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ boost::python::indexing::slice::slice (T const &ref)
|
||||
{
|
||||
if (!PySlice_Check (this->ptr()))
|
||||
{
|
||||
PyErr_SetString (PyExc_TypeError
|
||||
, "slice constructor: passed a non-slice object");
|
||||
PyErr_SetString (
|
||||
PyExc_TypeError, "slice constructor: passed a non-slice object");
|
||||
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
@@ -79,8 +79,8 @@ namespace boost { namespace python { namespace converter {
|
||||
// Specialized converter to handle PySlice_Type objects
|
||||
template<>
|
||||
struct object_manager_traits<boost::python::indexing::slice>
|
||||
: pytype_object_manager_traits<&PySlice_Type
|
||||
, ::boost::python::indexing::slice>
|
||||
: pytype_object_manager_traits <
|
||||
&PySlice_Type, ::boost::python::indexing::slice>
|
||||
{
|
||||
};
|
||||
}}}
|
||||
|
||||
@@ -204,8 +204,8 @@ namespace boost { namespace python { namespace indexing {
|
||||
|
||||
if (!read_ptr.get())
|
||||
{
|
||||
PyErr_SetString (PyExc_TypeError
|
||||
, "Type assigned to slice must be a sequence");
|
||||
PyErr_SetString (
|
||||
PyExc_TypeError, "Type assigned to slice must be a sequence");
|
||||
|
||||
boost::python::throw_error_already_set();
|
||||
}
|
||||
|
||||
@@ -62,9 +62,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_len<true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("__len__", &Algorithms::size, policy);
|
||||
}
|
||||
@@ -87,9 +88,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_getitem<index_style_nonlinear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("__getitem__", &Algorithms::get, policy);
|
||||
}
|
||||
@@ -102,13 +104,15 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_getitem<index_style_linear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("__getitem__", &Algorithms::get, policy);
|
||||
pyClass.def ("__getitem__"
|
||||
, slice_handler<Algorithms, Policy>::make_getitem (policy));
|
||||
pyClass.def (
|
||||
"__getitem__"
|
||||
, slice_handler<Algorithms, Policy>::make_getitem (policy));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -129,9 +133,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_setitem<true, index_style_nonlinear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("__setitem__", &Algorithms::assign, policy);
|
||||
}
|
||||
@@ -144,13 +149,15 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_setitem<true, index_style_linear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("__setitem__", &Algorithms::assign, policy);
|
||||
pyClass.def ("__setitem__"
|
||||
, slice_handler<Algorithms, Policy>::make_setitem (policy));
|
||||
pyClass.def (
|
||||
"__setitem__"
|
||||
, slice_handler<Algorithms, Policy>::make_setitem (policy));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -171,9 +178,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_delitem<true, index_style_nonlinear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("__delitem__", &Algorithms::erase_one, policy);
|
||||
}
|
||||
@@ -186,13 +194,15 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_delitem<true, index_style_linear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("__delitem__", &Algorithms::erase_one, policy);
|
||||
pyClass.def ("__delitem__"
|
||||
, slice_handler<Algorithms, Policy>::make_delitem (policy));
|
||||
pyClass.def (
|
||||
"__delitem__"
|
||||
, slice_handler<Algorithms, Policy>::make_delitem (policy));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -213,16 +223,19 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_iter<true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
// *FIXME* seperate precall and postcall portions of the
|
||||
// policy (precall when generating the range object, postcall
|
||||
// when returing from range.next())
|
||||
pyClass.def ("__iter__"
|
||||
, boost::python::range<Policy> (Algorithms::begin
|
||||
, Algorithms::end));
|
||||
pyClass.def (
|
||||
"__iter__"
|
||||
, boost::python::range<Policy> (
|
||||
Algorithms::begin
|
||||
, Algorithms::end));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -243,9 +256,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_sort<true, true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("sort", &Algorithms::sort, policy);
|
||||
}
|
||||
@@ -268,9 +282,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_reverse<true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("reverse", &Algorithms::reverse, policy);
|
||||
}
|
||||
@@ -293,9 +308,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_append<true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("append", &Algorithms::push_back, policy);
|
||||
}
|
||||
@@ -318,9 +334,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_insert<true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("insert", Algorithms::insert, policy);
|
||||
}
|
||||
@@ -343,12 +360,14 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_extend<true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("extend"
|
||||
, slice_handler<Algorithms, Policy>::make_extend (policy));
|
||||
pyClass.def (
|
||||
"extend"
|
||||
, slice_handler<Algorithms, Policy>::make_extend (policy));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -369,9 +388,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_index<true> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("index", Algorithms::get_index, policy);
|
||||
}
|
||||
@@ -394,9 +414,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_count<true, index_style_none> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
pyClass.def ("count", Algorithms::count, policy);
|
||||
pyClass.def ("contains", Algorithms::contains, policy);
|
||||
@@ -411,9 +432,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_count<true, index_style_linear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
// This is identical to the index_style_none version. Doing it
|
||||
// this way avoids using a partial specialization for
|
||||
@@ -430,9 +452,10 @@ namespace boost { namespace python { namespace indexing {
|
||||
template<>
|
||||
struct maybe_add_count<true, index_style_nonlinear> {
|
||||
template<class PythonClass, class Algorithms, class Policy>
|
||||
static void apply (PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
static void apply (
|
||||
PythonClass &pyClass
|
||||
, Algorithms const &
|
||||
, Policy const &policy)
|
||||
{
|
||||
// Nearest equivalent is has_key, since Python dictionaries
|
||||
// have at most one value for a key.
|
||||
@@ -484,12 +507,13 @@ namespace boost { namespace python { namespace indexing {
|
||||
maybe_add_delitem<traits::has_erase, traits::index_style>
|
||||
::apply (pyClass, algorithms(), m_policy);
|
||||
|
||||
maybe_add_iter<((traits::index_style != index_style_linear)
|
||||
&& traits::has_copyable_iter)>
|
||||
maybe_add_iter
|
||||
<(traits::index_style != index_style_linear)
|
||||
&& traits::has_copyable_iter>
|
||||
::apply (pyClass, algorithms(), m_policy);
|
||||
|
||||
maybe_add_sort<traits::is_reorderable
|
||||
, value_traits_::lessthan_comparable>
|
||||
maybe_add_sort
|
||||
<traits::is_reorderable, value_traits_::lessthan_comparable>
|
||||
::apply (pyClass, algorithms(), precallPolicy);
|
||||
|
||||
maybe_add_reverse<traits::is_reorderable>
|
||||
@@ -501,12 +525,12 @@ namespace boost { namespace python { namespace indexing {
|
||||
maybe_add_insert<traits::has_insert>
|
||||
::apply (pyClass, algorithms(), precallPolicy);
|
||||
|
||||
maybe_add_extend<(traits::has_insert
|
||||
&& traits::index_style == index_style_linear)>
|
||||
maybe_add_extend
|
||||
<traits::has_insert && traits::index_style == index_style_linear>
|
||||
::apply (pyClass, algorithms(), precallPolicy);
|
||||
|
||||
maybe_add_index<(traits::has_find
|
||||
&& (traits::index_style == index_style_linear))>
|
||||
maybe_add_index
|
||||
<traits::has_find && (traits::index_style == index_style_linear)>
|
||||
::apply (pyClass, algorithms(), precallPolicy);
|
||||
|
||||
maybe_add_count<traits::has_find, traits::index_style>
|
||||
|
||||
@@ -36,11 +36,12 @@ boost::python::indexing::integer_slice
|
||||
: m_slice (sl)
|
||||
// Leave index members uninitialized
|
||||
{
|
||||
PySlice_GetIndices (reinterpret_cast<PySliceObject *> (m_slice.ptr())
|
||||
, length
|
||||
, &m_start
|
||||
, &m_stop
|
||||
, &m_step);
|
||||
PySlice_GetIndices (
|
||||
reinterpret_cast<PySliceObject *> (m_slice.ptr())
|
||||
, length
|
||||
, &m_start
|
||||
, &m_stop
|
||||
, &m_step);
|
||||
|
||||
if (m_step == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user