From a15f7d5bf35a67c89ed47f547500d2d76162ee8f Mon Sep 17 00:00:00 2001 From: nobody Date: Sat, 8 Mar 2003 03:53:20 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'RC_1_30_0'. [SVN r17778] --- include/boost/python/raw_function.hpp | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 include/boost/python/raw_function.hpp diff --git a/include/boost/python/raw_function.hpp b/include/boost/python/raw_function.hpp new file mode 100755 index 00000000..3a28d127 --- /dev/null +++ b/include/boost/python/raw_function.hpp @@ -0,0 +1,47 @@ +// Copyright David Abrahams 2003. Permission to copy, use, +// modify, sell and distribute this software is granted provided this +// copyright notice appears in all copies. This software is provided +// "as is" without express or implied warranty, and with no claim as +// to its suitability for any purpose. +#ifndef RAW_FUNCTION_DWA200336_HPP +# define RAW_FUNCTION_DWA200336_HPP + +# include +# include +# include + +# include + +namespace boost { namespace python { + +namespace detail +{ + template + struct raw_dispatcher + { + raw_dispatcher(F f) : f(f) {} + + PyObject* operator()(PyObject* args, PyObject* keywords) + { + return incref( + object( + f(tuple(borrowed_reference(args)), dict(borrowed_reference(keywords))) + ).ptr() + ); + } + private: + F f; + }; + + object BOOST_PYTHON_DECL make_raw_function(objects::py_function, std::size_t min_args); +} + +template +object raw_function(F f, std::size_t min_args = 0) +{ + return detail::make_raw_function(detail::raw_dispatcher(f), min_args); +} + +}} // namespace boost::python + +#endif // RAW_FUNCTION_DWA200336_HPP