1 // Copyright David Abrahams 2002. 2 // Distributed under the Boost Software License, Version 1.0. (See 3 // accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 #include <boost/python/object/iterator_core.hpp> 7 #include <boost/python/object/function_object.hpp> 8 #include <boost/bind.hpp> 9 #include <boost/mpl/vector/vector10.hpp> 10 11 namespace boost { namespace python { namespace objects { 12 13 namespace 14 { identity(PyObject * args_,PyObject *)15 PyObject* identity(PyObject* args_, PyObject*) 16 { 17 PyObject* x = PyTuple_GET_ITEM(args_,0); 18 Py_INCREF(x); 19 return x; 20 } 21 } 22 identity_function()23BOOST_PYTHON_DECL object const& identity_function() 24 { 25 static object result( 26 function_object( 27 py_function(&identity, mpl::vector2<PyObject*,PyObject*>()) 28 ) 29 ); 30 return result; 31 } 32 stop_iteration_error()33void stop_iteration_error() 34 { 35 PyErr_SetObject(PyExc_StopIteration, Py_None); 36 throw_error_already_set(); 37 } 38 39 }}} // namespace boost::python::objects 40