/usr/include/boost/python
NameSizeModeActions
converter/-0755rm
detail/-0755rm
numpy/-0755rm
object/-0755rm
suite/-0755rm
args.hpp41940644editdlrm
args_fwd.hpp11860644editdlrm
arg_from_python.hpp20000644editdlrm
back_reference.hpp14630644editdlrm
bases.hpp14810644editdlrm
base_type_traits.hpp8780644editdlrm
borrowed.hpp5680644editdlrm
call.hpp27490644editdlrm
call_method.hpp28590644editdlrm
cast.hpp29540644editdlrm
class.hpp178660644editdlrm
class_fwd.hpp7720644editdlrm
copy_const_reference.hpp11010644editdlrm
copy_non_const_reference.hpp11410644editdlrm
data_members.hpp95930644editdlrm
def.hpp31870644editdlrm
default_call_policies.hpp22790644editdlrm
def_visitor.hpp24830644editdlrm
dict.hpp38660644editdlrm
docstring_options.hpp35050644editdlrm
enum.hpp29990644editdlrm
errors.hpp13970644editdlrm
exception_translator.hpp9390644editdlrm
exec.hpp17560644editdlrm
extract.hpp59880644editdlrm
handle.hpp45030644editdlrm
handle_fwd.hpp4550644editdlrm
has_back_reference.hpp6540644editdlrm
implicit.hpp11110644editdlrm
import.hpp4760644editdlrm
init.hpp114900644editdlrm
instance_holder.hpp20630644editdlrm
iterator.hpp43080644editdlrm
list.hpp36110644editdlrm
long.hpp16370644editdlrm
lvalue_from_pytype.hpp36140644editdlrm
make_constructor.hpp85790644editdlrm
make_function.hpp44820644editdlrm
manage_new_object.hpp10870644editdlrm
module.hpp4250644editdlrm
module_init.hpp21730644editdlrm
numpy.hpp11200644editdlrm
object.hpp8510644editdlrm
object_attributes.hpp30190644editdlrm
object_call.hpp8100644editdlrm
object_core.hpp133290644editdlrm
object_fwd.hpp4620644editdlrm
object_items.hpp19740644editdlrm
object_operators.hpp44940644editdlrm
object_protocol.hpp27300644editdlrm
object_protocol_core.hpp20800644editdlrm
object_slices.hpp40900644editdlrm
opaque_pointer_converter.hpp59290644editdlrm
operators.hpp142780644editdlrm
other.hpp9010644editdlrm
overloads.hpp4370644editdlrm
override.hpp35380644editdlrm
pointee.hpp8920644editdlrm
proxy.hpp26530644editdlrm
ptr.hpp12390644editdlrm
pure_virtual.hpp36550644editdlrm
raw_function.hpp14830644editdlrm
refcount.hpp9600644editdlrm
reference_existing_object.hpp13100644editdlrm
register_ptr_to_python.hpp7690644editdlrm
return_arg.hpp27990644editdlrm
return_by_value.hpp7240644editdlrm
return_internal_reference.hpp12850644editdlrm
return_opaque_pointer.hpp12900644editdlrm
return_value_policy.hpp6750644editdlrm
scope.hpp18780644editdlrm
self.hpp8890644editdlrm
signature.hpp75790644editdlrm
slice.hpp106430644editdlrm
slice_nil.hpp9120644editdlrm
ssize_t.hpp7350644editdlrm
stl_iterator.hpp13250644editdlrm
str.hpp107650644editdlrm
tag.hpp5380644editdlrm
to_python_converter.hpp24310644editdlrm
to_python_indirect.hpp29730644editdlrm
to_python_value.hpp55740644editdlrm
tuple.hpp17580644editdlrm
type_id.hpp52620644editdlrm
with_custodian_and_ward.hpp35460644editdlrm
wrapper.hpp10230644editdlrm
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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////////// #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 class init; // forward declaration template struct optional; // forward declaration namespace detail { namespace error { template struct more_keywords_than_init_arguments { typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1] BOOST_ATTRIBUTE_UNUSED; }; } // is_optional::value // // This metaprogram checks if T is an optional // template struct is_optional : mpl::false_ {}; template struct is_optional > : mpl::true_ {}; template struct define_class_init_helper; } // namespace detail template struct init_base : def_visitor { 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(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 > // // Defines: // // __init__(int, char, long, double) // __init__(int, char, long) // __init__(int, char) // __init__(int) template 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::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 init_with_call_policies : public init_base > { typedef init_base > 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 is the initial length(S) elements of S // namespace detail { template struct drop1 : mpl::iterator_range< typename mpl::begin::type , typename mpl::prior< typename mpl::end::type >::type > {}; } template class init : public init_base > { typedef init_base > base; public: typedef init self_t; init(char const* doc_ = 0) : base(doc_) { } template init(char const* doc_, detail::keywords 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 init(detail::keywords 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 init_with_call_policies operator[](CallPoliciesT const& policies) const { return init_with_call_policies( policies, this->doc_string(), this->keywords()); } typedef detail::type_list signature_; typedef detail::is_optional< typename mpl::eval_if< mpl::empty , mpl::false_ , mpl::back >::type > back_is_optional; typedef typename mpl::eval_if< back_is_optional , mpl::back , mpl::vector0<> >::type optional_args; typedef typename mpl::eval_if< back_is_optional , mpl::if_< mpl::empty , detail::drop1 , mpl::joint_view< detail::drop1 , 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 n_defaults; typedef mpl::size n_arguments; }; /////////////////////////////////////////////////////////////////////////////// // // optional // // optional::type returns a typelist. // /////////////////////////////////////////////////////////////////////////////// template struct optional : detail::type_list { }; namespace detail { template 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( policies , keywords_ , (typename ClassT::metadata::holder*)0 ) , doc ); } /////////////////////////////////////////////////////////////////////////////// // // define_class_init_helper::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::apply with one fewer argument (the // rightmost argument is shaved off) // /////////////////////////////////////////////////////////////////////////////// template struct define_class_init_helper { template 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::type next_nargs; define_class_init_helper::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 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