/
usr
/
include
/
boost
/
python
/
/usr/include/boost/python
mkdir
upload
Name
Size
Mode
Actions
converter/
-
0755
rm
detail/
-
0755
rm
numpy/
-
0755
rm
object/
-
0755
rm
suite/
-
0755
rm
args.hpp
4194
0644
edit
dl
rm
args_fwd.hpp
1186
0644
edit
dl
rm
arg_from_python.hpp
2000
0644
edit
dl
rm
back_reference.hpp
1463
0644
edit
dl
rm
bases.hpp
1481
0644
edit
dl
rm
base_type_traits.hpp
878
0644
edit
dl
rm
borrowed.hpp
568
0644
edit
dl
rm
call.hpp
2749
0644
edit
dl
rm
call_method.hpp
2859
0644
edit
dl
rm
cast.hpp
2954
0644
edit
dl
rm
class.hpp
17866
0644
edit
dl
rm
class_fwd.hpp
772
0644
edit
dl
rm
copy_const_reference.hpp
1101
0644
edit
dl
rm
copy_non_const_reference.hpp
1141
0644
edit
dl
rm
data_members.hpp
9593
0644
edit
dl
rm
def.hpp
3187
0644
edit
dl
rm
default_call_policies.hpp
2279
0644
edit
dl
rm
def_visitor.hpp
2483
0644
edit
dl
rm
dict.hpp
3866
0644
edit
dl
rm
docstring_options.hpp
3505
0644
edit
dl
rm
enum.hpp
2999
0644
edit
dl
rm
errors.hpp
1397
0644
edit
dl
rm
exception_translator.hpp
939
0644
edit
dl
rm
exec.hpp
1756
0644
edit
dl
rm
extract.hpp
5988
0644
edit
dl
rm
handle.hpp
4503
0644
edit
dl
rm
handle_fwd.hpp
455
0644
edit
dl
rm
has_back_reference.hpp
654
0644
edit
dl
rm
implicit.hpp
1111
0644
edit
dl
rm
import.hpp
476
0644
edit
dl
rm
init.hpp
11490
0644
edit
dl
rm
instance_holder.hpp
2063
0644
edit
dl
rm
iterator.hpp
4308
0644
edit
dl
rm
list.hpp
3611
0644
edit
dl
rm
long.hpp
1637
0644
edit
dl
rm
lvalue_from_pytype.hpp
3614
0644
edit
dl
rm
make_constructor.hpp
8579
0644
edit
dl
rm
make_function.hpp
4482
0644
edit
dl
rm
manage_new_object.hpp
1087
0644
edit
dl
rm
module.hpp
425
0644
edit
dl
rm
module_init.hpp
2173
0644
edit
dl
rm
numpy.hpp
1120
0644
edit
dl
rm
object.hpp
851
0644
edit
dl
rm
object_attributes.hpp
3019
0644
edit
dl
rm
object_call.hpp
810
0644
edit
dl
rm
object_core.hpp
13329
0644
edit
dl
rm
object_fwd.hpp
462
0644
edit
dl
rm
object_items.hpp
1974
0644
edit
dl
rm
object_operators.hpp
4494
0644
edit
dl
rm
object_protocol.hpp
2730
0644
edit
dl
rm
object_protocol_core.hpp
2080
0644
edit
dl
rm
object_slices.hpp
4090
0644
edit
dl
rm
opaque_pointer_converter.hpp
5929
0644
edit
dl
rm
operators.hpp
14278
0644
edit
dl
rm
other.hpp
901
0644
edit
dl
rm
overloads.hpp
437
0644
edit
dl
rm
override.hpp
3538
0644
edit
dl
rm
pointee.hpp
892
0644
edit
dl
rm
proxy.hpp
2653
0644
edit
dl
rm
ptr.hpp
1239
0644
edit
dl
rm
pure_virtual.hpp
3655
0644
edit
dl
rm
raw_function.hpp
1483
0644
edit
dl
rm
refcount.hpp
960
0644
edit
dl
rm
reference_existing_object.hpp
1310
0644
edit
dl
rm
register_ptr_to_python.hpp
769
0644
edit
dl
rm
return_arg.hpp
2799
0644
edit
dl
rm
return_by_value.hpp
724
0644
edit
dl
rm
return_internal_reference.hpp
1285
0644
edit
dl
rm
return_opaque_pointer.hpp
1290
0644
edit
dl
rm
return_value_policy.hpp
675
0644
edit
dl
rm
scope.hpp
1878
0644
edit
dl
rm
self.hpp
889
0644
edit
dl
rm
signature.hpp
7579
0644
edit
dl
rm
slice.hpp
10643
0644
edit
dl
rm
slice_nil.hpp
912
0644
edit
dl
rm
ssize_t.hpp
735
0644
edit
dl
rm
stl_iterator.hpp
1325
0644
edit
dl
rm
str.hpp
10765
0644
edit
dl
rm
tag.hpp
538
0644
edit
dl
rm
to_python_converter.hpp
2431
0644
edit
dl
rm
to_python_indirect.hpp
2973
0644
edit
dl
rm
to_python_value.hpp
5574
0644
edit
dl
rm
tuple.hpp
1758
0644
edit
dl
rm
type_id.hpp
5262
0644
edit
dl
rm
with_custodian_and_ward.hpp
3546
0644
edit
dl
rm
wrapper.hpp
1023
0644
edit
dl
rm
Edit:
/usr/include/boost/python/init.hpp
(11490B)
/////////////////////////////////////////////////////////////////////////////// // // Copyright David Abrahams 2002. // Copyright Joel de Guzman, 2002. // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // /////////////////////////////////////////////////////////////////////////////// #ifndef INIT_JDG20020820_HPP #define INIT_JDG20020820_HPP # include <boost/python/detail/prefix.hpp> #include <boost/python/detail/type_list.hpp> #include <boost/python/args_fwd.hpp> #include <boost/python/detail/make_keyword_range_fn.hpp> #include <boost/python/def_visitor.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/eval_if.hpp> #include <boost/mpl/size.hpp> #include <boost/mpl/iterator_range.hpp> #include <boost/mpl/empty.hpp> #include <boost/mpl/begin_end.hpp> #include <boost/mpl/bool.hpp> #include <boost/mpl/prior.hpp> #include <boost/mpl/joint_view.hpp> #include <boost/mpl/back.hpp> #include <boost/python/detail/type_traits.hpp> #include <boost/preprocessor/enum_params_with_a_default.hpp> #include <boost/preprocessor/enum_params.hpp> #include <utility> /////////////////////////////////////////////////////////////////////////////// #define BOOST_PYTHON_OVERLOAD_TYPES_WITH_DEFAULT \ BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( \ BOOST_PYTHON_MAX_ARITY, \ class T, \ mpl::void_) \ #define BOOST_PYTHON_OVERLOAD_TYPES \ BOOST_PP_ENUM_PARAMS_Z(1, \ BOOST_PYTHON_MAX_ARITY, \ class T) \ #define BOOST_PYTHON_OVERLOAD_ARGS \ BOOST_PP_ENUM_PARAMS_Z(1, \ BOOST_PYTHON_MAX_ARITY, \ T) \ /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace python { template <BOOST_PYTHON_OVERLOAD_TYPES_WITH_DEFAULT> class init; // forward declaration template <BOOST_PYTHON_OVERLOAD_TYPES_WITH_DEFAULT> struct optional; // forward declaration namespace detail { namespace error { template <int keywords, int init_args> struct more_keywords_than_init_arguments { typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1] BOOST_ATTRIBUTE_UNUSED; }; } // is_optional<T>::value // // This metaprogram checks if T is an optional // template <class T> struct is_optional : mpl::false_ {}; template <BOOST_PYTHON_OVERLOAD_TYPES> struct is_optional<optional<BOOST_PYTHON_OVERLOAD_ARGS> > : mpl::true_ {}; template <int NDefaults> struct define_class_init_helper; } // namespace detail template <class DerivedT> struct init_base : def_visitor<DerivedT> { init_base(char const* doc_, detail::keyword_range const& keywords_) : m_doc(doc_), m_keywords(keywords_) {} init_base(char const* doc_) : m_doc(doc_) {} DerivedT const& derived() const { return *static_cast<DerivedT const*>(this); } char const* doc_string() const { return m_doc; } detail::keyword_range const& keywords() const { return m_keywords; } static default_call_policies call_policies() { return default_call_policies(); } private: // visit // // Defines a set of n_defaults + 1 constructors for its // class_<...> argument. Each constructor after the first has // one less argument to its right. Example: // // init<int, optional<char, long, double> > // // Defines: // // __init__(int, char, long, double) // __init__(int, char, long) // __init__(int, char) // __init__(int) template <class classT> void visit(classT& cl) const { typedef typename DerivedT::signature signature; typedef typename DerivedT::n_arguments n_arguments; typedef typename DerivedT::n_defaults n_defaults; detail::define_class_init_helper<n_defaults::value>::apply( cl , derived().call_policies() , signature() , n_arguments() , derived().doc_string() , derived().keywords()); } friend class python::def_visitor_access; private: // data members char const* m_doc; detail::keyword_range m_keywords; }; template <class CallPoliciesT, class InitT> class init_with_call_policies : public init_base<init_with_call_policies<CallPoliciesT, InitT> > { typedef init_base<init_with_call_policies<CallPoliciesT, InitT> > base; public: typedef typename InitT::n_arguments n_arguments; typedef typename InitT::n_defaults n_defaults; typedef typename InitT::signature signature; init_with_call_policies( CallPoliciesT const& policies_ , char const* doc_ , detail::keyword_range const& keywords ) : base(doc_, keywords) , m_policies(policies_) {} CallPoliciesT const& call_policies() const { return this->m_policies; } private: // data members CallPoliciesT m_policies; }; // // drop1<S> is the initial length(S) elements of S // namespace detail { template <class S> struct drop1 : mpl::iterator_range< typename mpl::begin<S>::type , typename mpl::prior< typename mpl::end<S>::type >::type > {}; } template <BOOST_PYTHON_OVERLOAD_TYPES> class init : public init_base<init<BOOST_PYTHON_OVERLOAD_ARGS> > { typedef init_base<init<BOOST_PYTHON_OVERLOAD_ARGS> > base; public: typedef init<BOOST_PYTHON_OVERLOAD_ARGS> self_t; init(char const* doc_ = 0) : base(doc_) { } template <std::size_t N> init(char const* doc_, detail::keywords<N> const& kw) : base(doc_, kw.range()) { typedef typename detail::error::more_keywords_than_init_arguments< N, n_arguments::value + 1 >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; } template <std::size_t N> init(detail::keywords<N> const& kw, char const* doc_ = 0) : base(doc_, kw.range()) { typedef typename detail::error::more_keywords_than_init_arguments< N, n_arguments::value + 1 >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; } template <class CallPoliciesT> init_with_call_policies<CallPoliciesT, self_t> operator[](CallPoliciesT const& policies) const { return init_with_call_policies<CallPoliciesT, self_t>( policies, this->doc_string(), this->keywords()); } typedef detail::type_list<BOOST_PYTHON_OVERLOAD_ARGS> signature_; typedef detail::is_optional< typename mpl::eval_if< mpl::empty<signature_> , mpl::false_ , mpl::back<signature_> >::type > back_is_optional; typedef typename mpl::eval_if< back_is_optional , mpl::back<signature_> , mpl::vector0<> >::type optional_args; typedef typename mpl::eval_if< back_is_optional , mpl::if_< mpl::empty<optional_args> , detail::drop1<signature_> , mpl::joint_view< detail::drop1<signature_> , optional_args > > , signature_ >::type signature; // TODO: static assert to make sure there are no other optional elements // Count the number of default args typedef mpl::size<optional_args> n_defaults; typedef mpl::size<signature> n_arguments; }; /////////////////////////////////////////////////////////////////////////////// // // optional // // optional<T0...TN>::type returns a typelist. // /////////////////////////////////////////////////////////////////////////////// template <BOOST_PYTHON_OVERLOAD_TYPES> struct optional : detail::type_list<BOOST_PYTHON_OVERLOAD_ARGS> { }; namespace detail { template <class ClassT, class CallPoliciesT, class Signature, class NArgs> inline void def_init_aux( ClassT& cl , Signature const& , NArgs , CallPoliciesT const& policies , char const* doc , detail::keyword_range const& keywords_ ) { cl.def( "__init__" , detail::make_keyword_range_constructor<Signature,NArgs>( policies , keywords_ , (typename ClassT::metadata::holder*)0 ) , doc ); } /////////////////////////////////////////////////////////////////////////////// // // define_class_init_helper<N>::apply // // General case // // Accepts a class_ and an arguments list. Defines a constructor // for the class given the arguments and recursively calls // define_class_init_helper<N-1>::apply with one fewer argument (the // rightmost argument is shaved off) // /////////////////////////////////////////////////////////////////////////////// template <int NDefaults> struct define_class_init_helper { template <class ClassT, class CallPoliciesT, class Signature, class NArgs> static void apply( ClassT& cl , CallPoliciesT const& policies , Signature const& args , NArgs , char const* doc , detail::keyword_range keywords) { detail::def_init_aux(cl, args, NArgs(), policies, doc, keywords); if (keywords.second > keywords.first) --keywords.second; typedef typename mpl::prior<NArgs>::type next_nargs; define_class_init_helper<NDefaults-1>::apply( cl, policies, Signature(), next_nargs(), doc, keywords); } }; /////////////////////////////////////////////////////////////////////////////// // // define_class_init_helper<0>::apply // // Terminal case // // Accepts a class_ and an arguments list. Defines a constructor // for the class given the arguments. // /////////////////////////////////////////////////////////////////////////////// template <> struct define_class_init_helper<0> { template <class ClassT, class CallPoliciesT, class Signature, class NArgs> static void apply( ClassT& cl , CallPoliciesT const& policies , Signature const& args , NArgs , char const* doc , detail::keyword_range const& keywords) { detail::def_init_aux(cl, args, NArgs(), policies, doc, keywords); } }; } }} // namespace boost::python #undef BOOST_PYTHON_OVERLOAD_TYPES_WITH_DEFAULT #undef BOOST_PYTHON_OVERLOAD_TYPES #undef BOOST_PYTHON_OVERLOAD_ARGS #undef BOOST_PYTHON_IS_OPTIONAL_VALUE #undef BOOST_PYTHON_APPEND_TO_INIT /////////////////////////////////////////////////////////////////////////////// #endif // INIT_JDG20020820_HPP
Save
cmd:
run