sl@0: // Copyright David Abrahams 2003. sl@0: // Distributed under the Boost Software License, Version 1.0. (See sl@0: // accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: #ifndef RAW_FUNCTION_DWA200336_HPP sl@0: # define RAW_FUNCTION_DWA200336_HPP sl@0: sl@0: # include sl@0: sl@0: # include sl@0: # include sl@0: # include sl@0: # include sl@0: sl@0: # include sl@0: # include sl@0: sl@0: namespace boost { namespace python { sl@0: sl@0: namespace detail sl@0: { sl@0: template sl@0: struct raw_dispatcher sl@0: { sl@0: raw_dispatcher(F f) : f(f) {} sl@0: sl@0: PyObject* operator()(PyObject* args, PyObject* keywords) sl@0: { sl@0: return incref( sl@0: object( sl@0: f( sl@0: tuple(borrowed_reference(args)) sl@0: , keywords ? dict(borrowed_reference(keywords)) : dict() sl@0: ) sl@0: ).ptr() sl@0: ); sl@0: } sl@0: sl@0: private: sl@0: F f; sl@0: }; sl@0: sl@0: object BOOST_PYTHON_DECL make_raw_function(objects::py_function); sl@0: } sl@0: sl@0: template sl@0: object raw_function(F f, std::size_t min_args = 0) sl@0: { sl@0: return detail::make_raw_function( sl@0: objects::py_function( sl@0: detail::raw_dispatcher(f) sl@0: , mpl::vector1() sl@0: , min_args sl@0: , (std::numeric_limits::max)() sl@0: ) sl@0: ); sl@0: } sl@0: sl@0: }} // namespace boost::python sl@0: sl@0: #endif // RAW_FUNCTION_DWA200336_HPP