22 #ifndef BOOST_PYTHON_INDEXING_SLICE_HANDLER_HPP 23 #define BOOST_PYTHON_INDEXING_SLICE_HANDLER_HPP 25 #include <boost/python/handle.hpp> 26 #include <boost/python/object.hpp> 27 #include <boost/python/list.hpp> 28 #include <boost/python/extract.hpp> 29 #include <boost/python/make_function.hpp> 30 #include <boost/mpl/apply.hpp> 33 #include <indexing_suite/slice.hpp> 34 #include <indexing_suite/python_iterator.hpp> 36 namespace boost {
namespace python {
namespace indexing {
37 template<
class Algorithms,
class Policy>
40 static boost::python::object make_getitem (Policy
const &);
41 static boost::python::object make_setitem (Policy
const &);
42 static boost::python::object make_delitem (Policy
const &);
43 static boost::python::object make_extend (Policy
const &);
46 typedef typename Algorithms::container container;
47 typedef typename Algorithms::reference reference;
48 typedef typename Algorithms::slice_helper slice_helper;
50 static boost::python::list get_slice (container &,
slice);
51 static void set_slice (container &,
slice, boost::python::object);
52 static void del_slice (container &,
slice);
53 static void extend (container &, boost::python::object);
57 template<
typename Policy>
67 typedef boost::python::default_result_converter result_converter;
68 typedef typename Policy::argument_package argument_package;
75 bool precall (PyObject *args);
76 PyObject* postcall (PyObject *args, PyObject *result);
87 template<
class Algorithms,
class Policy>
93 boost::python::make_function(
101 template<
class Algorithms,
class Policy>
102 boost::python::object
107 return boost::python::make_function (set_slice, policy);
114 template<
class Algorithms,
class Policy>
115 boost::python::object
120 return boost::python::make_function (del_slice, policy);
127 template<
class Algorithms,
class Policy>
128 boost::python::object
133 return boost::python::make_function (extend, policy);
141 template<
class Policy>
151 template<
class Policy>
154 return m_base.precall (args);
161 template<
class Policy>
165 int size = PyList_Size (result);
167 for (
int count = 0; count < size; ++count)
169 m_base.postcall (args, PyList_GetItem (result, count));
180 template<
class Algorithms,
class Policy>
185 typedef typename Policy::result_converter converter_type;
186 typedef typename Algorithms::reference reference;
188 typename boost::mpl::apply1<converter_type, reference>::type
191 boost::python::list result;
193 slice_helper helper (Algorithms::make_slice_helper (c, sl));
195 while (helper.next())
200 result.append (boost::python::handle<> (converter (helper.current())));
210 template<
class Algorithms,
class Policy>
221 typedef boost::python::extract<
222 BOOST_DEDUCED_TYPENAME Algorithms::value_param> extractor1;
224 typedef boost::python::extract<
225 BOOST_DEDUCED_TYPENAME Algorithms::value_type> extractor2;
234 slice_helper write_helper (Algorithms::make_slice_helper (c, sl));
237 while (value_iter.next())
239 extractor1 ex1 (value_iter.current());
243 write_helper.write (ex1);
248 write_helper.write (extractor2 (value_iter.current()));
252 if (write_helper.next())
256 write_helper.erase_remaining();
264 template<
class Algorithms,
class Policy>
269 slice_helper helper (Algorithms::make_slice_helper (c, sl));
273 helper.erase_remaining();
281 template<
class Algorithms,
class Policy>
284 ::extend (container &c, boost::python::object values)
289 boost::python::object length
290 ((boost::python::handle<>
291 (PyLong_FromLong (Algorithms::size (c)))));
294 ((boost::python::handle<>
297 boost::python::object().ptr(),
298 boost::python::object().ptr()))));
300 set_slice (c, sl, values);
304 #endif // BOOST_PYTHON_INDEXING_SLICE_HANDLER_HPP Definition: python_CEGUI.h:9
Definition: python_iterator.hpp:33
Definition: slice_handler.hpp:58
Definition: slice_handler.hpp:38