diff --git a/include/boost/python/args.hpp b/include/boost/python/args.hpp index dc00c96c..941529f0 100644 --- a/include/boost/python/args.hpp +++ b/include/boost/python/args.hpp @@ -1,5 +1,3 @@ -#if !defined(BOOST_PP_IS_ITERATING) - // Copyright David Abrahams 2002. Permission to copy, use, // modify, sell and distribute this software is granted provided this // copyright notice appears in all copies. This software is provided @@ -8,14 +6,8 @@ #ifndef ARGS_DWA2002323_HPP # define ARGS_DWA2002323_HPP # include - # include - -# include - -# include -# include -# include +# include namespace boost { namespace python { @@ -28,76 +20,15 @@ namespace detail } }} -# if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 245 - namespace boost { namespace python { // A type list for specifying arguments -template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, boost::mpl::null_argument) > +template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, mpl::void_) > struct args : detail::args_base > - , boost::mpl::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type + , detail::type_list< BOOST_PYTHON_UNARY_ENUM(BOOST_PYTHON_MAX_ARITY, A) >::type {}; }} // namespace boost::python -# else // slow template instantiators need this other version with - // explicit specializations of mpl::size<> and - // mpl::at<>. Eventually, however, inheritance from mpl::list - // *should* be eliminated and the two versions unified, just in - // order to get true arity independence - -namespace boost { namespace python { - -template < BOOST_PYTHON_ENUM_WITH_DEFAULT(BOOST_PYTHON_MAX_ARITY, typename A, boost::mpl::null_argument) > -struct args : detail::args_base > -{}; - -}} // namespace boost::python - -namespace boost { namespace mpl { - -template struct size; -template struct at; - -# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY, , 1)) -# include BOOST_PP_ITERATE() - -# define BOOST_PP_ITERATION_PARAMS_1 (4, (0, BOOST_PYTHON_MAX_ARITY - 1, , 2)) -# include BOOST_PP_ITERATE() - - -}} // namespace boost::mpl - -# endif // __EDG_VERSION__ # endif // ARGS_DWA2002323_HPP - -/* ---------- size ---------- */ -#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 1 -# line BOOST_PP_LINE(__LINE__, args.hpp(size)) - -# define N BOOST_PP_ITERATION() - -template -struct size > -{ - BOOST_STATIC_CONSTANT(long, value = N); -}; - -# undef N - -/* ---------- at ---------- */ -#elif BOOST_PP_ITERATION_DEPTH() == 1 && BOOST_PP_ITERATION_FLAGS() == 2 -# line BOOST_PP_LINE(__LINE__, args.hpp(at)) - -# define N BOOST_PP_ITERATION() - -template -struct at > -{ - typedef BOOST_PP_CAT(A, N) type; -}; - -# undef N - -#endif diff --git a/include/boost/python/bases.hpp b/include/boost/python/bases.hpp index 468c6744..ec03dfba 100644 --- a/include/boost/python/bases.hpp +++ b/include/boost/python/bases.hpp @@ -6,14 +6,16 @@ #ifndef BASES_DWA2002321_HPP # define BASES_DWA2002321_HPP # include -# include -# include -# include +# include +# include +# include +# include namespace boost { namespace python { + // A type list for specifying bases - template < BOOST_MPL_LIST_DEFAULT_PARAMETERS(typename B, ::boost::mpl::null_argument) > - struct bases : ::boost::mpl::type_list< BOOST_MPL_LIST_PARAMETERS(B) >::type + template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_BASES, typename B, mpl::void_) > + struct bases : detail::type_list< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) >::type {}; namespace detail @@ -23,14 +25,14 @@ namespace boost { namespace python { { BOOST_STATIC_CONSTANT(bool, value = false); }; - template < BOOST_MPL_LIST_PARAMETERS(class B) > - struct specifies_bases< bases< BOOST_MPL_LIST_PARAMETERS(B) > > + template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) > + struct specifies_bases< bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > > { BOOST_STATIC_CONSTANT(bool, value = true); }; # else - template < BOOST_MPL_LIST_PARAMETERS(class B) > - static char is_bases_helper(bases< BOOST_MPL_LIST_PARAMETERS(B) > const&); + template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class B) > + static char is_bases_helper(bases< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, B) > const&); static char (& is_bases_helper(...) )[256]; @@ -45,7 +47,7 @@ namespace boost { namespace python { # endif template > struct select_bases - : mpl::select_type< + : mpl::if_c< specifies_bases::value , T , Prev diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index cdc17104..7f769739 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -20,7 +20,7 @@ # include # include # include -# include +# include # include # include # include @@ -40,7 +40,22 @@ namespace boost { namespace python { namespace detail { - struct write_type_id; + // This function object is used with mpl::for_each to write the id + // of the type a pointer to which is passed as its 2nd compile-time + // argument. into the iterator pointed to by its runtime argument + struct write_type_id + { + write_type_id(type_info**p) : p(p) {} + + // Here's the runtime behavior + template + void operator()(T*) const + { + *(*p)++ = type_id(); + }; + + type_info** p; + }; template struct select_held_type; @@ -56,7 +71,7 @@ namespace detail // to the type of holder that must be created. The 3rd argument is a // reference to the Python type object to be created. template - static inline void register_copy_constructor(mpl::bool_t const&, SelectHolder const& , T* = 0) + static inline void register_copy_constructor(mpl::bool_c const&, SelectHolder const& , T* = 0) { typedef typename SelectHolder::type holder; force_instantiate(objects::class_wrapper >()); @@ -65,7 +80,7 @@ namespace detail // Tag dispatched to have no effect. template - static inline void register_copy_constructor(mpl::bool_t const&, SelectHolder const&, T* = 0) + static inline void register_copy_constructor(mpl::bool_c const&, SelectHolder const&, T* = 0) { SelectHolder::register_(); } @@ -126,7 +141,7 @@ class class_ : public objects::class_base // Write the rest of the elements into succeeding positions. type_info* p = ids + 1; - mpl::for_each::execute(&p); + mpl::for_each(detail::write_type_id(&p), (bases*)0, (add_pointer*)0); } BOOST_STATIC_CONSTANT( @@ -274,7 +289,7 @@ class class_ : public objects::class_base self& def_init() { detail::assert_default_constructible::check(); - this->def_init(mpl::type_list<>::type()); + this->def_init(mpl::list0<>::type()); return *this; } @@ -401,7 +416,7 @@ inline void class_::register_() const objects::register_class_from_python(); detail::register_copy_constructor( - mpl::bool_t() + mpl::bool_c() , holder_selector::execute((held_type*)0) ); } @@ -452,28 +467,6 @@ inline class_::class_(char const* name, char const* doc, no_init_t) namespace detail { - // This is an mpl BinaryMetaFunction object with a runtime behavior, - // which is to write the id of the type which is passed as its 2nd - // compile-time argument into the iterator pointed to by its runtime - // argument - struct write_type_id - { - // The first argument is Ignored because mpl::for_each is still - // currently an accumulate (reduce) implementation. - template struct apply - { - // also an artifact of accumulate-based for_each - typedef void type; - - // Here's the runtime behavior - static void execute(type_info** p) - { - *(*p)++ = type_id(); - } - }; - }; - - template struct has_noncopyable : type_traits::ice_or< @@ -485,7 +478,7 @@ namespace detail template struct select_held_type - : mpl::select_type< + : mpl::if_c< type_traits::ice_or< specifies_bases::value , is_same::value diff --git a/include/boost/python/converter/arg_from_python.hpp b/include/boost/python/converter/arg_from_python.hpp index 585a30eb..1e3dfa26 100755 --- a/include/boost/python/converter/arg_from_python.hpp +++ b/include/boost/python/converter/arg_from_python.hpp @@ -12,7 +12,7 @@ # include # include # include -# include +# include # include # include # include @@ -165,22 +165,22 @@ struct select_arg_from_python bool, back_ref = boost::python::is_back_reference::value); - typedef typename mpl::select_type< + typedef typename mpl::if_c< obj_mgr , object_manager_value_arg_from_python - , typename mpl::select_type< + , typename mpl::if_c< obj_mgr_ref , object_manager_ref_arg_from_python - , typename mpl::select_type< + , typename mpl::if_c< ptr , pointer_arg_from_python - , typename mpl::select_type< + , typename mpl::if_c< ptr_cref , pointer_cref_arg_from_python - , typename mpl::select_type< + , typename mpl::if_c< ref , reference_arg_from_python - , typename mpl::select_type< + , typename mpl::if_c< back_ref , back_reference_arg_from_python , arg_rvalue_from_python diff --git a/include/boost/python/converter/arg_to_python.hpp b/include/boost/python/converter/arg_to_python.hpp index 7abb274c..deab7964 100755 --- a/include/boost/python/converter/arg_to_python.hpp +++ b/include/boost/python/converter/arg_to_python.hpp @@ -109,22 +109,22 @@ namespace detail typedef typename unwrap_reference::type unwrapped_referent; typedef typename unwrap_pointer::type unwrapped_ptr; - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_string , arg_to_python - , typename mpl::select_type< + , typename mpl::if_c< function , function_arg_to_python - , typename mpl::select_type< + , typename mpl::if_c< manager , object_manager_arg_to_python - , typename mpl::select_type< + , typename mpl::if_c< ptr , pointer_deep_arg_to_python - , typename mpl::select_type< + , typename mpl::if_c< ptr_wrapper , pointer_shallow_arg_to_python - , typename mpl::select_type< + , typename mpl::if_c< ref_wrapper , reference_arg_to_python , value_arg_to_python diff --git a/include/boost/python/converter/object_manager.hpp b/include/boost/python/converter/object_manager.hpp index 431ef708..974c149b 100755 --- a/include/boost/python/converter/object_manager.hpp +++ b/include/boost/python/converter/object_manager.hpp @@ -10,7 +10,7 @@ # include # include # include -# include +# include # include // Facilities for dealing with types which always manage Python @@ -102,7 +102,7 @@ struct default_object_manager_traits template struct object_manager_traits - : mpl::select_type< + : mpl::if_c< is_handle::value , handle_object_manager_traits , default_object_manager_traits @@ -164,7 +164,7 @@ namespace detail template struct is_object_manager_help { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_object_manager::value , yes_reference_to_object_manager , no_reference_to_object_manager @@ -217,7 +217,7 @@ namespace detail template struct is_reference_to_object_manager { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_reference::value , detail::is_reference_to_object_manager_ref , detail::is_reference_to_object_manager_nonref diff --git a/include/boost/python/converter/return_from_python.hpp b/include/boost/python/converter/return_from_python.hpp index f02f01d9..58d182f0 100755 --- a/include/boost/python/converter/return_from_python.hpp +++ b/include/boost/python/converter/return_from_python.hpp @@ -63,13 +63,13 @@ namespace detail BOOST_STATIC_CONSTANT( bool, ref = is_reference::value); - typedef typename mpl::select_type< + typedef typename mpl::if_c< obj_mgr , return_object_manager_from_python - , typename mpl::select_type< + , typename mpl::if_c< ptr , return_pointer_from_python - , typename mpl::select_type< + , typename mpl::if_c< ref , return_reference_from_python , return_rvalue_from_python diff --git a/include/boost/python/converter/rvalue_from_python_data.hpp b/include/boost/python/converter/rvalue_from_python_data.hpp index 72ea7bd7..16c9d44b 100644 --- a/include/boost/python/converter/rvalue_from_python_data.hpp +++ b/include/boost/python/converter/rvalue_from_python_data.hpp @@ -10,6 +10,8 @@ # include # include # include +# include +# include # include // Data management for potential rvalue conversions from Python to C++ diff --git a/include/boost/python/copy_const_reference.hpp b/include/boost/python/copy_const_reference.hpp index b2fdd61f..8eecd2ce 100644 --- a/include/boost/python/copy_const_reference.hpp +++ b/include/boost/python/copy_const_reference.hpp @@ -6,7 +6,7 @@ #ifndef COPY_CONST_REFERENCE_DWA2002131_HPP # define COPY_CONST_REFERENCE_DWA2002131_HPP # include -# include +# include # include namespace boost { namespace python { @@ -28,7 +28,7 @@ struct copy_const_reference template struct apply { - typedef typename mpl::select_type< + typedef typename mpl::if_c< detail::is_reference_to_const::value , to_python_value , detail::copy_const_reference_expects_a_const_reference_return_type diff --git a/include/boost/python/copy_non_const_reference.hpp b/include/boost/python/copy_non_const_reference.hpp index 6f53fbdc..53c576e0 100644 --- a/include/boost/python/copy_non_const_reference.hpp +++ b/include/boost/python/copy_non_const_reference.hpp @@ -6,7 +6,7 @@ #ifndef COPY_NON_CONST_REFERENCE_DWA2002131_HPP # define COPY_NON_CONST_REFERENCE_DWA2002131_HPP # include -# include +# include # include namespace boost { namespace python { @@ -28,7 +28,7 @@ struct copy_non_const_reference template struct apply { - typedef typename mpl::select_type< + typedef typename mpl::if_c< boost::python::detail::is_reference_to_non_const::value , to_python_value , detail::copy_non_const_reference_expects_a_non_const_reference_return_type diff --git a/include/boost/python/default_call_policies.hpp b/include/boost/python/default_call_policies.hpp index f0b69255..f964990f 100644 --- a/include/boost/python/default_call_policies.hpp +++ b/include/boost/python/default_call_policies.hpp @@ -6,7 +6,7 @@ #ifndef DEFAULT_CALL_POLICIES_DWA2002131_HPP # define DEFAULT_CALL_POLICIES_DWA2002131_HPP # include -# include +# include # include # include @@ -50,7 +50,7 @@ struct default_result_converter { BOOST_STATIC_CONSTANT(bool, is_illegal = is_reference::value || is_pointer::value); - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_illegal , detail::specify_a_result_policy_to_wrap_functions_returning , boost::python::to_python_value< diff --git a/include/boost/python/detail/borrowed_ptr.hpp b/include/boost/python/detail/borrowed_ptr.hpp index dc50c634..6b35c862 100755 --- a/include/boost/python/detail/borrowed_ptr.hpp +++ b/include/boost/python/detail/borrowed_ptr.hpp @@ -8,7 +8,7 @@ # include # include -# include +# include # include # include # include @@ -77,7 +77,7 @@ typedef char (&no_borrowed_ptr_t)[2]; no_borrowed_ptr_t is_borrowed_ptr_test(...); template -typename mpl::select_type< +typename mpl::if_c< is_pointer::value , T , int diff --git a/include/boost/python/detail/caller.hpp b/include/boost/python/detail/caller.hpp index 322e1342..2ade2a11 100644 --- a/include/boost/python/detail/caller.hpp +++ b/include/boost/python/detail/caller.hpp @@ -21,8 +21,6 @@ # include # include -# // temp: include - # include # include # include diff --git a/include/boost/python/detail/convertible.hpp b/include/boost/python/detail/convertible.hpp index 4ab58d94..74440090 100755 --- a/include/boost/python/detail/convertible.hpp +++ b/include/boost/python/detail/convertible.hpp @@ -7,7 +7,7 @@ # define CONVERTIBLE_DWA2002614_HPP # if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 241 -# include +# include # include # endif @@ -26,7 +26,7 @@ struct convertible static inline yes_convertible check(Target) { return 0; } # else template - static inline typename mpl::select_type< + static inline typename mpl::if_c< is_convertible::value , yes_convertible , no_convertible diff --git a/include/boost/python/detail/defaults_def.hpp b/include/boost/python/detail/defaults_def.hpp index 7efbcb70..9c79d926 100644 --- a/include/boost/python/detail/defaults_def.hpp +++ b/include/boost/python/detail/defaults_def.hpp @@ -14,10 +14,10 @@ #include #include -#include +#include +#include #include #include -#include #include #include #include @@ -86,7 +86,7 @@ static void name_space_def( // template // inline void // define_stub_function( -// char const* name, StubsT s, NameSpaceT& name_space, boost::mpl::int_t) +// char const* name, StubsT s, NameSpaceT& name_space, mpl::int_c) // { // name_space.def(name, &StubsT::func_N); // } @@ -186,9 +186,9 @@ struct define_stub_function {}; // is a typelist that specifies the return type, the class (for member // functions, and the arguments. Here are some SigT examples: // -// int foo(int) mpl::type_list -// void bar(int, int) mpl::type_list -// void C::foo(int) mpl::type_list +// int foo(int) mpl::list +// void bar(int, int) mpl::list +// void C::foo(int) mpl::list // /////////////////////////////////////////////////////////////////////////////// template @@ -201,19 +201,18 @@ struct define_stub_function {}; SigT sig, char const* doc) { - typedef typename boost::python::detail::type_at<0, SigT>::type nth_type; + typedef typename mpl::front::type return_type; typedef typename StubsT::v_type v_type; typedef typename StubsT::nv_type nv_type; - typedef typename mpl::select_type< - boost::is_same::value + typedef typename mpl::if_c< + boost::is_same::value , v_type , nv_type >::type stubs_type; BOOST_STATIC_ASSERT( - (stubs_type::max_args) <= - boost::python::detail::type_list_size::value); + (stubs_type::max_args) <= mpl::size::value); typedef typename stubs_type::template gen gen_type; define_with_defaults_helper::def diff --git a/include/boost/python/detail/defaults_gen.hpp b/include/boost/python/detail/defaults_gen.hpp index 3198baa2..78808424 100644 --- a/include/boost/python/detail/defaults_gen.hpp +++ b/include/boost/python/detail/defaults_gen.hpp @@ -23,7 +23,8 @@ #include #include #include -#include +#include +#include namespace boost { namespace python { namespace detail { @@ -39,7 +40,7 @@ struct func_stubs_base {}; /////////////////////////////////////////////////////////////////////////////// #define BPL_IMPL_TYPEDEF_GEN(z, INDEX, DATA) \ - typedef typename boost::python::detail::type_at \ + typedef typename ::boost::mpl::at_c \ < \ BOOST_PP_ADD_D(1, INDEX, DATA), \ SigT \ @@ -70,7 +71,7 @@ struct func_stubs_base {}; template \ struct gen { \ \ - typedef typename boost::python::detail::type_at<0, SigT>::type RT; \ + typedef typename ::boost::mpl::front::type RT; \ \ BOOST_PP_REPEAT_2ND \ ( \ @@ -113,8 +114,8 @@ struct func_stubs_base {}; template \ struct gen { \ \ - typedef typename boost::python::detail::type_at<0, SigT>::type RT; \ - typedef typename boost::python::detail::type_at<1, SigT>::type ClassT; \ + typedef typename ::boost::mpl::front::type RT; \ + typedef typename ::boost::mpl::at_c<1, SigT>::type ClassT; \ \ BOOST_PP_REPEAT_2ND \ ( \ @@ -224,11 +225,11 @@ struct func_stubs_base {}; // template // struct gen { // -// typedef typename mpl::at<0, SigT>::type RT; -// typedef typename mpl::at<1, SigT>::type T0; -// typedef typename mpl::at<2, SigT>::type T1; -// typedef typename mpl::at<3, SigT>::type T2; -// typedef typename mpl::at<4, SigT>::type T3; +// typedef typename ::boost::mpl::at_c<0, SigT>::type RT; +// typedef typename ::boost::mpl::at_c<1, SigT>::type T0; +// typedef typename ::boost::mpl::at_c<2, SigT>::type T1; +// typedef typename ::boost::mpl::at_c<3, SigT>::type T2; +// typedef typename ::boost::mpl::at_c<4, SigT>::type T3; // // static RT func_0(T0 arg0) // { return foo(arg0); } diff --git a/include/boost/python/detail/destroy.hpp b/include/boost/python/detail/destroy.hpp index 89e82f73..7b107550 100644 --- a/include/boost/python/detail/destroy.hpp +++ b/include/boost/python/detail/destroy.hpp @@ -67,8 +67,8 @@ inline void destroy_referent_impl(void* p, T& (*)()) // note: cv-qualification needed for MSVC6 // must come *before* T for metrowerks value_destroyer< - (boost::is_array::value) - , (boost::has_trivial_destructor::value) + (boost::is_array::value) + ,(boost::has_trivial_destructor::value) >::execute((const volatile T*)p); } diff --git a/include/boost/python/detail/indirect_traits.hpp b/include/boost/python/detail/indirect_traits.hpp index faabecc2..c6f8bcc7 100644 --- a/include/boost/python/detail/indirect_traits.hpp +++ b/include/boost/python/detail/indirect_traits.hpp @@ -5,11 +5,17 @@ // to its suitability for any purpose. #ifndef INDIRECT_TRAITS_DWA2002131_HPP # define INDIRECT_TRAITS_DWA2002131_HPP -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include namespace boost { namespace python { namespace detail { @@ -184,7 +190,7 @@ typedef char (&outer_no_type)[1]; template struct is_const_help { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_const::value , inner_yes_type , inner_no_type @@ -194,7 +200,7 @@ struct is_const_help template struct is_volatile_help { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_volatile::value , inner_yes_type , inner_no_type @@ -204,7 +210,7 @@ struct is_volatile_help template struct is_pointer_help { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_pointer::value , inner_yes_type , inner_no_type @@ -214,7 +220,7 @@ struct is_pointer_help template struct is_class_help { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_class::value , inner_yes_type , inner_no_type @@ -228,7 +234,7 @@ struct is_reference_to_function static T t; BOOST_STATIC_CONSTANT( bool, value - = sizeof(::boost::detail::is_function_tester(t)) == sizeof(::boost::type_traits::yes_type)); + = sizeof(::boost::type_traits::is_function_ptr_tester(t)) == sizeof(::boost::type_traits::yes_type)); # endif template @@ -237,7 +243,7 @@ struct is_pointer_to_function static T t; BOOST_STATIC_CONSTANT( bool, value - = sizeof(::boost::detail::is_function_tester(t)) == sizeof(::boost::type_traits::yes_type)); + = sizeof(::boost::type_traits::is_function_ptr_tester(t)) == sizeof(::boost::type_traits::yes_type)); }; struct false_helper1 diff --git a/include/boost/python/detail/member_function_cast.hpp b/include/boost/python/detail/member_function_cast.hpp index 491e6711..f143abd0 100644 --- a/include/boost/python/detail/member_function_cast.hpp +++ b/include/boost/python/detail/member_function_cast.hpp @@ -11,7 +11,7 @@ # include -# include +# include # include # include @@ -71,7 +71,7 @@ struct member_function_cast # ifndef BOOST_NO_FUNCTION_TEMPLATE_ORDERING : member_function_cast_impl # else - : mpl::select_type< + : mpl::if_c< is_member_function_pointer::value , member_function_cast_impl , non_member_function_cast_impl diff --git a/include/boost/python/detail/msvc_typeinfo.hpp b/include/boost/python/detail/msvc_typeinfo.hpp index 21e47389..b50922b7 100644 --- a/include/boost/python/detail/msvc_typeinfo.hpp +++ b/include/boost/python/detail/msvc_typeinfo.hpp @@ -8,8 +8,10 @@ #include #include -#include -#include +#include +#include +#include +#include // // Fix for MSVC's broken typeid() implementation which doesn't strip // decoration. This fix doesn't handle cv-qualified array types. It diff --git a/include/boost/python/detail/preprocessor.hpp b/include/boost/python/detail/preprocessor.hpp index 89d1d26d..45e307d4 100644 --- a/include/boost/python/detail/preprocessor.hpp +++ b/include/boost/python/detail/preprocessor.hpp @@ -30,6 +30,10 @@ # define BOOST_PYTHON_MAX_ARITY 15 # endif +# ifndef BOOST_PYTHON_MAX_BASES +# define BOOST_PYTHON_MAX_BASES 10 +# endif + # define BOOST_PYTHON_CV_QUALIFIER(i) \ BOOST_PYTHON_APPLY( \ BOOST_PP_TUPLE_ELEM(4, i, BOOST_PYTHON_CV_QUALIFIER_I) \ diff --git a/include/boost/python/detail/referent_storage.hpp b/include/boost/python/detail/referent_storage.hpp index aebacf64..b93d888f 100644 --- a/include/boost/python/detail/referent_storage.hpp +++ b/include/boost/python/detail/referent_storage.hpp @@ -5,7 +5,7 @@ // to its suitability for any purpose. #ifndef REFERENT_STORAGE_DWA200278_HPP # define REFERENT_STORAGE_DWA200278_HPP -# include +# include # include namespace boost { namespace python { namespace detail { @@ -16,7 +16,7 @@ typedef int (alignment_dummy::*member_ptr); typedef int (alignment_dummy::*member_function_ptr)(); # define BOOST_PYTHON_ALIGNER(T, n) \ - typename mpl::select_type< \ + typename mpl::if_c< \ sizeof(T) <= size, T, char>::type t##n // Storage for size bytes, aligned to all fundamental types no larger than size diff --git a/include/boost/python/detail/result.hpp b/include/boost/python/detail/result.hpp index 84f6a554..6ec95fb7 100755 --- a/include/boost/python/detail/result.hpp +++ b/include/boost/python/detail/result.hpp @@ -14,7 +14,7 @@ # include # include -# include +# include # include # include @@ -60,7 +60,7 @@ struct void_type template struct result_result { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_class::value , get_result_type , void_type diff --git a/include/boost/python/detail/type_list.hpp b/include/boost/python/detail/type_list.hpp index 66ac3857..4a09c0be 100644 --- a/include/boost/python/detail/type_list.hpp +++ b/include/boost/python/detail/type_list.hpp @@ -3,14 +3,38 @@ // 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 TYPE_LIST_DWA200222_HPP -# define TYPE_LIST_DWA200222_HPP -# include +#ifndef TYPE_LIST_DWA2002913_HPP +# define TYPE_LIST_DWA2002913_HPP -namespace boost { namespace python { namespace detail { +# include +# include +# include -struct empty_list : boost::mpl::type_list<>::type {}; +# if BOOST_PYTHON_MAX_ARITY + 2 > BOOST_PYTHON_MAX_BASES +# define BOOST_PYTHON_LIST_SIZE BOOST_PP_INC(BOOST_PP_INC(BOOST_PYTHON_MAX_ARITY)) +# else +# define BOOST_PYTHON_BASE_LIST_SIZE BOOST_PYTHON_MAX_BASES +# endif -}}} // namespace boost::python::detail +// Compute the MPL list header to use for lists up to BOOST_PYTHON_LIST_SIZE in length +# if BOOST_PYTHON_LIST_SIZE > 48 +# error Arities above 48 not supported by Boost.Python due to MPL internal limit +# elif BOOST_PYTHON_LIST_SIZE > 38 +# include +# elif BOOST_PYTHON_LIST_SIZE > 28 +# include +# elif BOOST_PYTHON_LIST_SIZE > 18 +# include +# elif BOOST_PYTHON_LIST_SIZE > 8 +# include +# else +# include +# endif -#endif // TYPE_LIST_DWA200222_HPP +# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +# include +# else +# include +# endif + +#endif // TYPE_LIST_DWA2002913_HPP diff --git a/include/boost/python/detail/type_list_impl.hpp b/include/boost/python/detail/type_list_impl.hpp new file mode 100644 index 00000000..2a02851f --- /dev/null +++ b/include/boost/python/detail/type_list_impl.hpp @@ -0,0 +1,55 @@ +#ifndef BOOST_PP_IS_ITERATING +// Copyright David Abrahams 2002. 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 TYPE_LIST_IMPL_DWA2002913_HPP +# define TYPE_LIST_IMPL_DWA2002913_HPP + +# include +# include +# include +# include +# include +# include + +namespace boost { namespace python { namespace detail { + +template +struct type_list + : BOOST_PP_CAT(mpl::list,BOOST_PYTHON_LIST_SIZE) +{ +}; + +# define BOOST_PP_ITERATION_PARAMS_1 \ + (3, (0, BOOST_PP_DEC(BOOST_PYTHON_LIST_SIZE), )) +# include BOOST_PP_ITERATE() + + +}}} // namespace boost::python::detail + +# endif // TYPE_LIST_IMPL_DWA2002913_HPP + +#else // BOOST_PP_IS_ITERATING + +# define N BOOST_PP_ITERATION() +# define BOOST_PYTHON_VOID_ARGS BOOST_PP_SUB_D(1,BOOST_PYTHON_LIST_SIZE,N) + +template < + BOOST_PP_ENUM_PARAMS(N, class T) + > +struct type_list< + BOOST_PP_ENUM_PARAMS(N, T) + BOOST_PP_COMMA_IF(N) + BOOST_PP_ENUM( + BOOST_PYTHON_VOID_ARGS, BOOST_PYTHON_FIXED, mpl::void_) + > + : BOOST_PP_CAT(mpl::list,N) +{ +}; + +# undef BOOST_PYTHON_VOID_ARGS +# undef N + +#endif // BOOST_PP_IS_ITERATING diff --git a/include/boost/python/detail/type_list_impl_no_pts.hpp b/include/boost/python/detail/type_list_impl_no_pts.hpp new file mode 100644 index 00000000..1c4d392c --- /dev/null +++ b/include/boost/python/detail/type_list_impl_no_pts.hpp @@ -0,0 +1,101 @@ +#ifndef BOOST_PP_IS_ITERATING +// Copyright David Abrahams 2002. 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 TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP +# define TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP + +# include +# include +# include +# include +# include +# include +# include + +namespace boost { namespace python { namespace detail { + +template< typename T > +struct is_list_arg +{ + enum { value = true }; +}; + +template<> +struct is_list_arg +{ + enum { value = false }; +}; + +template struct type_list_impl_chooser; + +# define BOOST_PP_ITERATION_PARAMS_1 \ + (3, (0, BOOST_PYTHON_LIST_SIZE, )) +# include BOOST_PP_ITERATE() + +# define BOOST_PYTHON_PLUS() + +# define BOOST_PYTHON_IS_LIST_ARG(z, n, data) \ + BOOST_PP_IF(n, BOOST_PYTHON_PLUS, BOOST_PP_EMPTY)() \ + is_list_arg< BOOST_PP_CAT(T,n) >::value + +template< + BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE, class T) + > +struct type_list_count_args +{ + enum { value = + BOOST_PP_REPEAT_1(BOOST_PYTHON_LIST_SIZE, BOOST_PYTHON_IS_LIST_ARG, _) + }; +}; + +# undef BOOST_PYTHON_IS_LIST_ARG +# undef BOOST_PYTHON_PLUS + +template< + BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE, class T) + > +struct type_list_impl +{ + typedef type_list_count_args< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T) > arg_num_; + typedef typename detail::type_list_impl_chooser< arg_num_::value > + ::template result_< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T) >::type type; +}; + +template< + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_LIST_SIZE, class T, mpl::void_) + > +struct type_list + : detail::type_list_impl< BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T) >::type +{ + typedef typename detail::type_list_impl< + BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE,T) + >::type type; +}; + +}}} // namespace boost::python::detail + +# endif // TYPE_LIST_IMPL_NO_PTS_DWA2002913_HPP + +#else // BOOST_PP_IS_ITERATING + +# define N BOOST_PP_ITERATION() + +template<> +struct type_list_impl_chooser +{ + template< + BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_LIST_SIZE, class T) + > + struct result_ + { + typedef BOOST_PP_CAT(mpl::list,N)< + BOOST_PP_ENUM_PARAMS(N, T) + > type; + }; +}; + +# undef N + +#endif // BOOST_PP_IS_ITERATING diff --git a/include/boost/python/detail/type_list_utils.hpp b/include/boost/python/detail/type_list_utils.hpp index d03203b9..ebb5488b 100644 --- a/include/boost/python/detail/type_list_utils.hpp +++ b/include/boost/python/detail/type_list_utils.hpp @@ -1,116 +1,28 @@ -/////////////////////////////////////////////////////////////////////////////// -// +#error obsolete // Copyright David Abrahams 2002. 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. -// -/////////////////////////////////////////////////////////////////////////////// -#if !defined(BOOST_PP_IS_ITERATING) - #ifndef TYPE_LIST_UTILS_JDG20020826_HPP -#define TYPE_LIST_UTILS_JDG20020826_HPP +# define TYPE_LIST_UTILS_JDG20020826_HPP -# include -# include -//# include -//# include - -# include -# include -# include -# include -# include -# include - -# include +# ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION namespace boost { namespace python { namespace detail { -# if (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 245) \ - && (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600) +template< typename T > +struct is_list_arg +{ + enum { value = true }; +}; - template - struct type_at : public boost::mpl::at {}; - - template - struct type_list_size : public boost::mpl::size {}; - -// template -// struct pop_front : public boost::mpl::pop_front {}; -// -// template -// struct pop_back : public boost::mpl::pop_back {}; - -# else - - template - struct type_at {}; - - template - struct type_list_size {}; - -// template -// struct pop_front {}; -// -// template -// struct pop_back {}; - -// template -// struct push_back {}; - -# define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (0, BOOST_PYTHON_MAX_ARITY, )) -# include BOOST_PP_ITERATE() - -# endif - -}}} // namespace boost::python::detail +template<> +struct is_list_arg +{ + enum { value = false }; +}; +}}} +# endif #endif // TYPE_LIST_UTILS_JDG20020826_HPP - -#else // defined(BOOST_PP_IS_ITERATING) - -# define N BOOST_PP_ITERATION() - -# if (N < BOOST_PYTHON_MAX_ARITY-1) - - template - struct type_at > - { - typedef BOOST_PP_CAT(A, N) type; - }; - -// template -// struct push_back, T> -// { -// typedef boost::mpl::type_list sequence; -// }; - -# if (N > 0) - -// template -// struct pop_front > -// { -// typedef boost::mpl::type_list sequence; -// }; -// -// template -// struct pop_back > -// { -// typedef boost::mpl::type_list sequence; -// }; - -# endif -# endif - - template - struct type_list_size > - { - BOOST_STATIC_CONSTANT(long, value = N); - }; - -# undef N - -#endif // !defined(BOOST_PP_IS_ITERATING) diff --git a/include/boost/python/extract.hpp b/include/boost/python/extract.hpp index fdcaac28..598fe249 100644 --- a/include/boost/python/extract.hpp +++ b/include/boost/python/extract.hpp @@ -87,13 +87,13 @@ namespace converter BOOST_STATIC_CONSTANT( bool, ref = is_reference::value); - typedef typename mpl::select_type< + typedef typename mpl::if_c< obj_mgr , extract_object_manager - , typename mpl::select_type< + , typename mpl::if_c< ptr , extract_pointer - , typename mpl::select_type< + , typename mpl::if_c< ref , extract_reference , extract_rvalue diff --git a/include/boost/python/init.hpp b/include/boost/python/init.hpp index 567e480a..733973b1 100644 --- a/include/boost/python/init.hpp +++ b/include/boost/python/init.hpp @@ -10,21 +10,29 @@ #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 + +#include #include #include #include +#include #include -#include -#include -#include /////////////////////////////////////////////////////////////////////////////// #define BOOST_PYTHON_TEMPLATE_TYPES_WITH_DEFAULT \ @@ -32,7 +40,7 @@ ( \ BOOST_PYTHON_MAX_ARITY, \ class T, \ - boost::mpl::null_argument \ + mpl::void_ \ ) \ #define BOOST_PYTHON_TEMPLATE_TYPES \ @@ -61,16 +69,6 @@ struct optional; // forward declaration namespace detail { - /////////////////////////////////////////////////////////////////////////// - // - // is_nil::value - // - // This metaprogram checks if T is nil - // - /////////////////////////////////////////////////////////////////////////// - template - struct is_nil : public boost::is_same {}; - /////////////////////////////////////////////////////////////////////////// // // is_optional::value @@ -95,291 +93,159 @@ namespace detail { BOOST_STATIC_CONSTANT( bool, value = sizeof(f(t())) == sizeof(::boost::type_traits::yes_type)); + typedef mpl::bool_c type; + + BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_optional,(T)) // needed for MSVC & Borland }; /////////////////////////////////////// #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template - struct is_optional { + struct is_optional_impl { BOOST_STATIC_CONSTANT(bool, value = false); }; template - struct is_optional > { + struct is_optional_impl > { BOOST_STATIC_CONSTANT(bool, value = true); }; - #endif // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) - - /////////////////////////////////////////////////////////////////////////// - // - // append_to_init [ and helpers ] - // - // A metaprogram appends T to the initializer type list - // - /////////////////////////////////////////////////////////////////////////// - struct append_to_init_helper1 { - - // Case 1: default case, just push T to the back of ListT - - template - struct apply { - - typedef typename boost::mpl::push_back::sequence sequence; - }; - }; - - struct append_to_init_helper2 { - - template - struct apply { - - // Case 2: optional case, T is an optional, append all - // the contents of the optional T into back of ListT - - typedef typename boost::mpl::for_each - < - typename T::sequence, - ListT, - boost::mpl::push_back - >::state sequence; - }; - }; - - struct append_to_init_helper3 { - - // Case 3: nil case, we found a nil, do nothing - - template - struct apply { - - typedef ListT sequence; - }; - }; - - template - struct append_to_init { - - typedef typename boost::mpl::select_type - < - is_optional::value, // if - append_to_init_helper2, // then - typename boost::mpl::select_type // else - < - is_nil::value, // if - append_to_init_helper3, // then - append_to_init_helper1 // else - >::type - >::type helper; - - typedef typename helper::template apply::sequence sequence; - }; - - /////////////////////////////////////////////////////////////////////////// - // - // check_init_params [ and helpers ] - // - // Check the init template parameters. Detect illegal - // arguments such as: - // - // init, int> // BAD trailing int - // init, optional > // BAD optional used twice - // - /////////////////////////////////////////////////////////////////////////// - template - struct check_init_params_helper { - - template - struct apply { - - // case where size of sequence is not zero - - typedef typename boost::mpl::pop_front::sequence rest; - - enum { - - // if first is optional then there must be no more - // elements to its right. if not then recurse and check - // the rest of the type list - - first_is_optional = - is_optional::type>::value, - size_of_rest = boost::mpl::size::value, - rest_is_nil = (size_of_rest == 0), - is_ok = first_is_optional ? rest_is_nil : - check_init_params_helper - ::template apply::is_ok - }; - }; - }; - - template <> - struct check_init_params_helper<0> { - - // case where size of sequence is zero - - template - struct apply { - - enum { is_ok = true }; - }; - }; - - struct init_base {}; - - template - struct check_init_params : init_base { - - typedef boost::mpl::type_list params; - - BOOST_STATIC_ASSERT - ( - check_init_params_helper::value> - ::template apply::is_ok - ); - }; - - /////////////////////////////////////////////////////////////////////////// - // - // count_optional_types [ and helpers ] - // - // count_optional_types::value computes the number of - // optional types (see init and optional below). For example: - // - // init >::value == 3 - // - /////////////////////////////////////////////////////////////////////////// template - struct count_optionals1 { - - BOOST_STATIC_CONSTANT(int, value = 0); - }; - - template - struct count_optionals2 { - - BOOST_STATIC_CONSTANT( - int, value = boost::mpl::size::value + 1); - }; - - template - struct count_optionals - : boost::mpl::select_type - < - is_optional::value, // if - count_optionals2, // then - count_optionals1 // else - >::type + struct is_optional : is_optional_impl { + typedef mpl::bool_c::value> type; + BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_optional,(T)) // needed for MSVC & Borland }; - - template - struct count_optional_types { - - BOOST_STATIC_CONSTANT(int, value = - count_optionals::value + - count_optionals::value + - count_optionals::value - ); - }; + #endif // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) } // namespace detail -/////////////////////////////////////////////////////////////////////////////// -// -// init -// -// init::sequence returns a typelist. One of T0..TN -// mat be an optional<...> see below. There should be only one -// optional in the input types and an optional should be the -// last in the list. -// -/////////////////////////////////////////////////////////////////////////////// -#define BOOST_PYTHON_APPEND_TO_INIT(z, INDEX, D) \ - typedef typename detail::append_to_init \ - < \ - BOOST_PP_CAT(l, INDEX), \ - BOOST_PP_CAT(T, BOOST_PP_INC(INDEX)) \ - >::sequence BOOST_PP_CAT(l, BOOST_PP_INC(INDEX)); \ - template -struct init : detail::check_init_params +struct init //: detail::check_init_params { - typedef boost::mpl::type_list l0; - BOOST_PP_REPEAT_1ST( - BOOST_PP_DEC(BOOST_PYTHON_MAX_ARITY), BOOST_PYTHON_APPEND_TO_INIT, 0) + typedef detail::type_list signature_; + typedef typename mpl::end::type finish; - typedef BOOST_PP_CAT(l, BOOST_PP_DEC(BOOST_PYTHON_MAX_ARITY)) sequence; + // Find the optional<> element, if any + typedef typename mpl::find_if< + signature_, detail::is_optional + >::type opt; - BOOST_STATIC_CONSTANT(int, n_arguments = boost::mpl::size::value); - BOOST_STATIC_CONSTANT(int, n_defaults = - (detail::count_optional_types::value) - ); + // Check to make sure the optional<> element, if any, is the last one + typedef typename mpl::apply_if< + is_same + , mpl::identity + , mpl::next + >::type expected_finish; + BOOST_STATIC_ASSERT((is_same::value)); + + typedef typename mpl::apply_if< + is_same + , mpl::list0<> + , opt + >::type optional_args; + + // Count the number of default args + BOOST_STATIC_CONSTANT(int, n_defaults = mpl::size::value); + + typedef typename mpl::iterator_range< + typename mpl::begin::type + , opt + >::type required_args; + + // Build a reverse image of all the args, including optionals + typedef typename mpl::fold< + required_args + , mpl::list0<> + , mpl::push_front + >::type reversed_required; + + typedef typename mpl::fold< + optional_args + , reversed_required + , mpl::push_front + >::type reversed_args; + + // Count the maximum number of arguments + BOOST_STATIC_CONSTANT(int, n_arguments = mpl::size::value); }; /////////////////////////////////////////////////////////////////////////////// // // optional // -// optional::sequence returns a typelist. +// optional::type returns a typelist. // /////////////////////////////////////////////////////////////////////////////// template -struct optional { - - typedef boost::mpl::type_list sequence; +struct optional + : detail::type_list +{ }; -namespace detail { +namespace detail +{ + template + void def_init_reversed(ClassT& cl, ReversedArgs const&, CallPoliciesT const& policies, char const* doc) + { + typedef typename mpl::fold< + ReversedArgs + , mpl::list0<> + , mpl::push_front + >::type args; + + cl.def_init(args(), policies, 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 less arguments (the + // rightmost argument is shaved off) + // + /////////////////////////////////////////////////////////////////////////////// + template + struct define_class_init_helper { - /////////////////////////////////////////////////////////////////////////////// - // - // 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 less arguments (the - // rightmost argument is shaved off) - // - /////////////////////////////////////////////////////////////////////////////// - template - struct define_class_init_helper { + template + static void apply(ClassT& cl, CallPoliciesT const& policies, ReversedArgs const& args, char const* doc) + { + def_init_reversed(cl, args, policies, doc); - template - static void apply(ClassT& cl, CallPoliciesT const& policies, ArgsT const& args, char const* doc) - { - cl.def_init(args, policies, doc); - typename boost::mpl::pop_back::sequence next; - define_class_init_helper::apply(cl, policies, next, doc); - } - }; + typename mpl::pop_front::type next; + define_class_init_helper::apply(cl, policies, next, doc); + } + }; - /////////////////////////////////////////////////////////////////////////////// - // - // 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> { + /////////////////////////////////////////////////////////////////////////////// + // + // 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, ArgsT const& args, char const* doc) - { - cl.def_init(args, policies, doc); - } - }; + template + static void apply(ClassT& cl, CallPoliciesT const& policies, ReversedArgs const& args, char const* doc) + { + def_init_reversed(cl, args, policies, doc); + } + }; } /////////////////////////////////////////////////////////////////////////////// @@ -407,8 +273,8 @@ template void define_init(ClassT& cl, InitT const& i, CallPoliciesT const& policies, char const* doc) { - typedef typename InitT::sequence args_t; - detail::define_class_init_helper::apply(cl, policies, args_t(), doc); + typedef typename InitT::reversed_args reversed_args; + detail::define_class_init_helper::apply(cl, policies, reversed_args(), doc); } }} // namespace boost::python diff --git a/include/boost/python/manage_new_object.hpp b/include/boost/python/manage_new_object.hpp index e19035b7..0acbbec8 100644 --- a/include/boost/python/manage_new_object.hpp +++ b/include/boost/python/manage_new_object.hpp @@ -6,7 +6,7 @@ #ifndef MANAGE_NEW_OBJECT_DWA200222_HPP # define MANAGE_NEW_OBJECT_DWA200222_HPP # include -# include +# include # include # include @@ -27,7 +27,7 @@ struct manage_new_object template struct apply { - typedef typename mpl::select_type< + typedef typename mpl::if_c< boost::is_pointer::value , to_python_indirect , detail::manage_new_object_requires_a_pointer_return_type diff --git a/include/boost/python/object/class_converters.hpp b/include/boost/python/object/class_converters.hpp index 14e79a9d..79119ef7 100644 --- a/include/boost/python/object/class_converters.hpp +++ b/include/boost/python/object/class_converters.hpp @@ -13,6 +13,7 @@ # include # include # include +# include namespace boost { namespace python { namespace objects { @@ -45,29 +46,22 @@ struct do_nothing template struct register_base_of { - // Ignored is needed because mpl::for_each is still actually - // accumulate. We're not using any state so it just sits there. - template - struct apply + // Here's the runtime part: + template + void operator()(Base*) const { - typedef void type; // 'type' needs to be defined for the same reasons + // Register the Base class + register_dynamic_id(); + // Register the up-cast + register_conversion(false); - // Here's the runtime part: - static void execute() - { - // Register the Base class - register_dynamic_id(); - // Register the up-cast - register_conversion(false); - - // Register the down-cast, if appropriate. - mpl::select_type< - is_polymorphic::value - , register_downcast - , do_nothing - >::type::execute(); - } - }; + // Register the down-cast, if appropriate. + mpl::if_c< + is_polymorphic::value + , register_downcast + , do_nothing + >::type::execute(); + } }; // Brings into existence all converters associated with a class Bases @@ -82,7 +76,7 @@ inline void register_class_from_python(Derived* = 0, Bases* = 0) register_dynamic_id(); // register each base in the sequence - mpl::for_each >::execute(); + mpl::for_each(register_base_of(), (Bases*)0, (add_pointer*)0); } }}} // namespace boost::python::object diff --git a/include/boost/python/object/forward.hpp b/include/boost/python/object/forward.hpp index cc23e94c..93c1ed21 100644 --- a/include/boost/python/object/forward.hpp +++ b/include/boost/python/object/forward.hpp @@ -6,10 +6,11 @@ #ifndef FORWARD_DWA20011215_HPP # define FORWARD_DWA20011215_HPP -# include +# include # include # include # include +# include # include namespace boost { namespace python { namespace objects { @@ -30,7 +31,7 @@ struct reference_to_value // is T. template struct forward - : mpl::select_type< + : mpl::if_c< is_scalar::value , T , reference_to_value > diff --git a/include/boost/python/object/inheritance.hpp b/include/boost/python/object/inheritance.hpp index 5129e35e..88b556ff 100644 --- a/include/boost/python/object/inheritance.hpp +++ b/include/boost/python/object/inheritance.hpp @@ -8,7 +8,7 @@ # include # include -# include +# include # include namespace boost { namespace python { namespace objects { @@ -80,7 +80,7 @@ struct non_polymorphic_id_generator template struct dynamic_id_generator { - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_polymorphic::value , polymorphic_id_generator , non_polymorphic_id_generator >::type type; @@ -133,7 +133,7 @@ struct cast_generator is_base_and_derived::value )); - typedef typename mpl::select_type< + typedef typename mpl::if_c< is_upcast # if defined(__MWERKS__) && __MWERKS__ <= 0x2406 // grab a few more implicit_cast cases for CodeWarrior diff --git a/include/boost/python/object/make_holder.hpp b/include/boost/python/object/make_holder.hpp index 3073e83b..2a9e4e58 100644 --- a/include/boost/python/object/make_holder.hpp +++ b/include/boost/python/object/make_holder.hpp @@ -15,7 +15,9 @@ # include # include -# include +# include +# include +# include # include # include @@ -29,8 +31,10 @@ namespace boost { namespace python { namespace objects { template struct make_holder; # define BOOST_PYTHON_FORWARD_ARG(z, index, _) \ - typedef typename mpl::at::type t##index; \ - typedef typename forward::type f##index; + typedef typename iter##index::type t##index; \ + typedef typename forward::type f##index; \ + typedef typename mpl::next::type \ + BOOST_PP_CAT(iter,BOOST_PP_INC(index)); # define BOOST_PYTHON_DO_FORWARD_ARG(z, index, _) , f##index(a##index) @@ -56,6 +60,7 @@ struct make_holder template struct apply { + typedef typename mpl::begin::type iter0; BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_FORWARD_ARG, nil) static void execute( PyObject* p diff --git a/include/boost/python/object/pointer_holder.hpp b/include/boost/python/object/pointer_holder.hpp index 1fe20ef3..0dca4ae3 100644 --- a/include/boost/python/object/pointer_holder.hpp +++ b/include/boost/python/object/pointer_holder.hpp @@ -22,7 +22,7 @@ # include # include -# include +# include # include # include diff --git a/include/boost/python/object/select_holder.hpp b/include/boost/python/object/select_holder.hpp index 6902f68d..3535fd29 100644 --- a/include/boost/python/object/select_holder.hpp +++ b/include/boost/python/object/select_holder.hpp @@ -15,10 +15,10 @@ # include # include # include -# include +# include # include # include -# include +# include # include namespace boost { namespace python { namespace objects { @@ -30,7 +30,7 @@ namespace detail { BOOST_STATIC_CONSTANT(bool, selector = (!is_same::value) | has_back_reference::value); - typedef typename mpl::select_type< + typedef typename mpl::if_c< selector , value_holder_back_reference , value_holder @@ -38,18 +38,18 @@ namespace detail static inline void register_() { - select_value_holder::register_(mpl::bool_t()); + select_value_holder::register_(mpl::bool_c()); } static type* get() { return 0; } private: - static inline void register_(mpl::bool_t) + static inline void register_(mpl::bool_c) { python::detail::force_instantiate(instance_finder::registration); } - static inline void register_(mpl::bool_t) + static inline void register_(mpl::bool_c) { } }; @@ -60,7 +60,7 @@ namespace detail typedef typename python::pointee::type pointee; BOOST_STATIC_CONSTANT(bool, selector = (!is_same::value) | has_back_reference::value); - typedef typename mpl::select_type< + typedef typename mpl::if_c< selector , pointer_holder_back_reference , pointer_holder @@ -68,13 +68,13 @@ namespace detail static inline void register_() { - select_pointer_holder::register_(mpl::bool_t()); + select_pointer_holder::register_(mpl::bool_c()); } static type* get() { return 0; } private: - static inline void register_(mpl::bool_t) + static inline void register_(mpl::bool_c) { // not implemented at least until we solve the back // reference issue mentioned in pointer_holder.hpp. @@ -94,7 +94,7 @@ namespace detail } }; - static inline void register_(mpl::bool_t) + static inline void register_(mpl::bool_c) { python::detail::force_instantiate( objects::class_wrapper< diff --git a/include/boost/python/operators2.hpp b/include/boost/python/operators2.hpp index 8c56abf7..3f06eb46 100755 --- a/include/boost/python/operators2.hpp +++ b/include/boost/python/operators2.hpp @@ -11,7 +11,7 @@ # include # include # include -# include +# include # include # include # include @@ -120,15 +120,15 @@ namespace detail // self_t template struct operator_ - : mpl::select_type< - (is_same::value) - , typename mpl::select_type< - (is_same::value) + : mpl::if_< + is_same + , typename mpl::if_< + is_same , binary_op , binary_op_l::type> >::type - , typename mpl::select_type< - (is_same::value) + , typename mpl::if_< + is_same , unary_op , binary_op_r::type> >::type diff --git a/include/boost/python/pointee.hpp b/include/boost/python/pointee.hpp index 52d65d67..d62bab54 100644 --- a/include/boost/python/pointee.hpp +++ b/include/boost/python/pointee.hpp @@ -7,6 +7,7 @@ # define POINTEE_DWA2002323_HPP # include +# include namespace boost { namespace python { diff --git a/include/boost/python/reference_existing_object.hpp b/include/boost/python/reference_existing_object.hpp index 1f8a43d8..e16dcf18 100644 --- a/include/boost/python/reference_existing_object.hpp +++ b/include/boost/python/reference_existing_object.hpp @@ -6,7 +6,7 @@ #ifndef REFERENCE_EXISTING_OBJECT_DWA200222_HPP # define REFERENCE_EXISTING_OBJECT_DWA200222_HPP # include -# include +# include # include # include @@ -32,7 +32,7 @@ struct reference_existing_object BOOST_STATIC_CONSTANT( bool, ok = is_pointer::value || is_reference::value); - typedef typename mpl::select_type< + typedef typename mpl::if_c< ok , to_python_indirect , detail::reference_existing_object_requires_a_pointer_or_reference_return_type diff --git a/include/boost/python/return_internal_reference.hpp b/include/boost/python/return_internal_reference.hpp index 3a968f45..7e350d77 100644 --- a/include/boost/python/return_internal_reference.hpp +++ b/include/boost/python/return_internal_reference.hpp @@ -9,7 +9,7 @@ # include # include # include -# include +# include namespace boost { namespace python { @@ -30,7 +30,7 @@ struct return_internal_reference private: BOOST_STATIC_CONSTANT(bool, legal = owner_arg > 0); public: - typedef typename mpl::select_type< + typedef typename mpl::if_c< legal , reference_existing_object , detail::return_internal_reference_owner_arg_must_be_greater_than_zero diff --git a/include/boost/python/signature.hpp b/include/boost/python/signature.hpp index 3bef081e..bd4b26df 100644 --- a/include/boost/python/signature.hpp +++ b/include/boost/python/signature.hpp @@ -19,8 +19,19 @@ # include # include # include -# include +# include + # include +# include +# include +# include + +# define BOOST_PYTHON_FUNCTION_SIGNATURE_LIST(n) \ + BOOST_PP_CAT(mpl::list, BOOST_PP_INC(n)) + +# define BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(n) \ + BOOST_PP_CAT(mpl::list, BOOST_PP_INC(BOOST_PP_INC(n))) + /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace python { namespace detail { @@ -30,28 +41,28 @@ namespace boost { namespace python { namespace detail { // The following macros generate expansions for: // // template -// inline boost::mpl::type_list +// inline mpl::list // get_signature(RT(*)(T0...TN)) // { -// return boost::mpl::type_list(); +// return mpl::list(); // } // // template -// inline boost::mpl::type_list +// inline mpl::list // get_signature(RT(ClassT::*)(T0...TN))) // { -// return boost::mpl::type_list(); +// return mpl::list(); // } // // template -// inline boost::mpl::type_list +// inline mpl::list // get_signature(RT(ClassT::*)(T0...TN) const)) // { -// return boost::mpl::type_list(); +// return mpl::list(); // } // // These functions extract the return type, class (for member functions) -// and arguments of the input signature and stuffs them in an mpl::type_list. +// and arguments of the input signature and stuffs them in an mpl::list. // /////////////////////////////////////////////////////////////////////////////// @@ -65,6 +76,10 @@ namespace boost { namespace python { namespace detail { }} // namespace boost::python + +# undef BOOST_PYTHON_FUNCTION_SIGNATURE_LIST +# undef BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST + /////////////////////////////////////////////////////////////////////////////// # endif // SIGNATURE_JDG20020813_HPP @@ -73,47 +88,38 @@ namespace boost { namespace python { namespace detail { # define N BOOST_PP_ITERATION() template < - class RT BOOST_PP_COMMA_IF(N) - BOOST_PYTHON_UNARY_ENUM(N, class T)> -inline boost::mpl::type_list< - RT BOOST_PP_COMMA_IF(N) - BOOST_PP_ENUM_PARAMS(N, T)> + class RT BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)> +inline BOOST_PYTHON_FUNCTION_SIGNATURE_LIST(N)< + RT BOOST_PP_ENUM_TRAILING_PARAMS(N, T)> get_signature(RT(*)(BOOST_PP_ENUM_PARAMS(N, T))) { - return boost::mpl::type_list< - RT BOOST_PP_COMMA_IF(N) - BOOST_PP_ENUM_PARAMS(N, T)>(); + return BOOST_PYTHON_FUNCTION_SIGNATURE_LIST(N)< + RT BOOST_PP_ENUM_TRAILING_PARAMS(N, T) + >(); } /////////////////////////////////////////////////////////////////////////////// #if N <= (BOOST_PYTHON_MAX_ARITY - 2) template < - class RT, class ClassT BOOST_PP_COMMA_IF(N) - BOOST_PYTHON_UNARY_ENUM(N, class T)> -inline boost::mpl::type_list< - RT, ClassT BOOST_PP_COMMA_IF(N) - BOOST_PP_ENUM_PARAMS(N, T)> + class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)> +inline BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)< + RT, ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, T)> get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T))) { - return boost::mpl::type_list< - RT, ClassT BOOST_PP_COMMA_IF(N) - BOOST_PP_ENUM_PARAMS(N, T)>(); + return BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)< + RT, ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, T)>(); } /////////////////////////////////////// template < - class RT, class ClassT BOOST_PP_COMMA_IF(N) - BOOST_PYTHON_UNARY_ENUM(N, class T)> -inline boost::mpl::type_list< - RT, ClassT const BOOST_PP_COMMA_IF(N) - BOOST_PP_ENUM_PARAMS(N, T)> + class RT, class ClassT BOOST_PP_ENUM_TRAILING_PARAMS(N, class T)> +inline BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)< + RT, ClassT const BOOST_PP_ENUM_TRAILING_PARAMS(N, T)> get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(N, T)) const) { - return boost::mpl::type_list< - RT, ClassT const - BOOST_PP_COMMA_IF(N) - BOOST_PP_ENUM_PARAMS(N, T)>(); + return BOOST_PYTHON_MEMBER_FUNCTION_SIGNATURE_LIST(N)< + RT, ClassT const BOOST_PP_ENUM_TRAILING_PARAMS(N, T)>(); } #endif // N < (BOOST_PYTHON_MAX_ARITY - 2) diff --git a/include/boost/python/to_python_value.hpp b/include/boost/python/to_python_value.hpp index b85eaf68..3b9cd76c 100644 --- a/include/boost/python/to_python_value.hpp +++ b/include/boost/python/to_python_value.hpp @@ -11,7 +11,7 @@ # include # include # include -# include +# include # include # include # include @@ -46,7 +46,7 @@ namespace detail template struct to_python_value - : mpl::select_type< + : mpl::if_c< boost::type_traits::ice_or< converter::is_object_manager::value , converter::is_reference_to_object_manager::value