os/ossrv/ossrv_pub/boost_apis/boost/python/raw_function.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/python/raw_function.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,61 @@
     1.4 +// Copyright David Abrahams 2003.
     1.5 +// Distributed under the Boost Software License, Version 1.0. (See
     1.6 +// accompanying file LICENSE_1_0.txt or copy at
     1.7 +// http://www.boost.org/LICENSE_1_0.txt)
     1.8 +#ifndef RAW_FUNCTION_DWA200336_HPP
     1.9 +# define RAW_FUNCTION_DWA200336_HPP
    1.10 +
    1.11 +# include <boost/python/detail/prefix.hpp>
    1.12 +
    1.13 +# include <boost/python/tuple.hpp>
    1.14 +# include <boost/python/dict.hpp>
    1.15 +# include <boost/python/object/py_function.hpp>
    1.16 +# include <boost/mpl/vector/vector10.hpp>
    1.17 +
    1.18 +# include <boost/limits.hpp>
    1.19 +# include <cstddef>
    1.20 +
    1.21 +namespace boost { namespace python { 
    1.22 +
    1.23 +namespace detail
    1.24 +{
    1.25 +  template <class F>
    1.26 +  struct raw_dispatcher
    1.27 +  {
    1.28 +      raw_dispatcher(F f) : f(f) {}
    1.29 +      
    1.30 +      PyObject* operator()(PyObject* args, PyObject* keywords)
    1.31 +      {
    1.32 +          return incref(
    1.33 +              object(
    1.34 +                  f(
    1.35 +                      tuple(borrowed_reference(args))
    1.36 +                    , keywords ? dict(borrowed_reference(keywords)) : dict()
    1.37 +                  )
    1.38 +              ).ptr()
    1.39 +          );
    1.40 +      }
    1.41 +
    1.42 +   private:
    1.43 +      F f;
    1.44 +  };
    1.45 +
    1.46 +  object BOOST_PYTHON_DECL make_raw_function(objects::py_function);
    1.47 +}
    1.48 +
    1.49 +template <class F>
    1.50 +object raw_function(F f, std::size_t min_args = 0)
    1.51 +{
    1.52 +    return detail::make_raw_function(
    1.53 +        objects::py_function(
    1.54 +            detail::raw_dispatcher<F>(f)
    1.55 +          , mpl::vector1<PyObject*>()
    1.56 +          , min_args
    1.57 +          , (std::numeric_limits<unsigned>::max)()
    1.58 +        )
    1.59 +    );
    1.60 +}
    1.61 +    
    1.62 +}} // namespace boost::python
    1.63 +
    1.64 +#endif // RAW_FUNCTION_DWA200336_HPP