File indexing completed on 2025-01-18 09:50:41
0001
0002
0003
0004
0005 #ifndef MAKE_FUNCTION_DWA20011221_HPP
0006 # define MAKE_FUNCTION_DWA20011221_HPP
0007
0008 # include <boost/python/detail/prefix.hpp>
0009
0010 # include <boost/python/default_call_policies.hpp>
0011 # include <boost/python/args.hpp>
0012 # include <boost/python/detail/caller.hpp>
0013
0014 # include <boost/python/object/function_object.hpp>
0015
0016 # include <boost/mpl/size.hpp>
0017 # include <boost/mpl/int.hpp>
0018
0019 namespace boost { namespace python {
0020
0021 namespace detail
0022 {
0023
0024
0025
0026
0027
0028
0029 template <class F, class CallPolicies, class Sig>
0030 object make_function_aux(
0031 F f
0032 , CallPolicies const& p
0033 , Sig const&
0034 )
0035 {
0036 return objects::function_object(
0037 detail::caller<F,CallPolicies,Sig>(f, p)
0038 );
0039 }
0040
0041
0042
0043
0044
0045 template <class F, class CallPolicies, class Sig, class NumKeywords>
0046 object make_function_aux(
0047 F f
0048 , CallPolicies const& p
0049 , Sig const&
0050 , detail::keyword_range const& kw
0051 , NumKeywords
0052 )
0053 {
0054 enum { arity = mpl::size<Sig>::value - 1 };
0055
0056 typedef typename detail::error::more_keywords_than_function_arguments<
0057 NumKeywords::value, arity
0058 >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED;
0059
0060 return objects::function_object(
0061 detail::caller<F,CallPolicies,Sig>(f, p)
0062 , kw);
0063 }
0064
0065
0066
0067
0068
0069
0070 template <class F, class CallPolicies, class Keywords>
0071 object make_function_dispatch(F f, CallPolicies const& policies, Keywords const& kw, mpl::true_)
0072 {
0073 return detail::make_function_aux(
0074 f
0075 , policies
0076 , detail::get_signature(f)
0077 , kw.range()
0078 , mpl::int_<Keywords::size>()
0079 );
0080 }
0081
0082 template <class F, class CallPolicies, class Signature>
0083 object make_function_dispatch(F f, CallPolicies const& policies, Signature const& sig, mpl::false_)
0084 {
0085 return detail::make_function_aux(
0086 f
0087 , policies
0088 , sig
0089 );
0090 }
0091
0092
0093 }
0094
0095
0096
0097
0098
0099
0100 template <class F>
0101 object make_function(F f)
0102 {
0103 return detail::make_function_aux(
0104 f,default_call_policies(), detail::get_signature(f));
0105 }
0106
0107 template <class F, class CallPolicies>
0108 object make_function(F f, CallPolicies const& policies)
0109 {
0110 return detail::make_function_aux(
0111 f, policies, detail::get_signature(f));
0112 }
0113
0114 template <class F, class CallPolicies, class KeywordsOrSignature>
0115 object make_function(
0116 F f
0117 , CallPolicies const& policies
0118 , KeywordsOrSignature const& keywords_or_signature)
0119 {
0120 typedef typename
0121 detail::is_reference_to_keywords<KeywordsOrSignature&>::type
0122 is_kw;
0123
0124 return detail::make_function_dispatch(
0125 f
0126 , policies
0127 , keywords_or_signature
0128 , is_kw()
0129 );
0130 }
0131
0132 template <class F, class CallPolicies, class Keywords, class Signature>
0133 object make_function(
0134 F f
0135 , CallPolicies const& policies
0136 , Keywords const& kw
0137 , Signature const& sig
0138 )
0139 {
0140 return detail::make_function_aux(
0141 f
0142 , policies
0143 , sig
0144 , kw.range()
0145 , mpl::int_<Keywords::size>()
0146 );
0147 }
0148
0149
0150 }}
0151
0152
0153 #endif