123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- #include <boost/parameter.hpp>
- namespace boost { namespace python {
- BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
- BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
- BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
- BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
- }}
- namespace boost { namespace python {
- namespace detail {
- struct bases_base
- {
- };
- }
- template <typename A0 = void, typename A1 = void, typename A2 = void>
- struct bases : detail::bases_base
- {
- };
- }}
- #include <boost/mpl/bool.hpp>
- #include <boost/mpl/placeholders.hpp>
- #include <boost/mpl/if.hpp>
- #include <boost/mpl/eval_if.hpp>
- #include <boost/noncopyable.hpp>
- #include <boost/type_traits/is_same.hpp>
- #include <boost/type_traits/is_base_of.hpp>
- #include <boost/type_traits/is_class.hpp>
- #include <boost/config.hpp>
- #if !defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) || \
- !(1 == BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION)
- #include <boost/type_traits/is_scalar.hpp>
- #endif
- namespace boost { namespace python {
- typedef boost::parameter::parameters<
- boost::parameter::required<
- tag::class_type
- #if defined(BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION) && \
- (1 == BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION)
- , boost::mpl::if_<
- boost::is_class<boost::mpl::_>
- , boost::mpl::true_
- , boost::mpl::false_
- >
- #else
- , boost::mpl::if_<
- boost::is_scalar<boost::mpl::_>
- , boost::mpl::false_
- , boost::mpl::true_
- >
- #endif
- >
- , boost::parameter::optional<
- boost::parameter::deduced<tag::base_list>
- , boost::mpl::if_<
- boost::is_base_of<detail::bases_base,boost::mpl::_>
- , boost::mpl::true_
- , boost::mpl::false_
- >
- >
- , boost::parameter::optional<
- boost::parameter::deduced<tag::held_type>
- , boost::mpl::eval_if<
- boost::is_base_of<detail::bases_base,boost::mpl::_>
- , boost::mpl::false_
- , boost::mpl::if_<
- boost::is_same<boost::noncopyable,boost::mpl::_>
- , boost::mpl::false_
- , boost::mpl::true_
- >
- >
- >
- , boost::parameter::optional<
- boost::parameter::deduced<tag::copyable>
- , boost::mpl::if_<
- boost::is_same<boost::noncopyable,boost::mpl::_>
- , boost::mpl::true_
- , boost::mpl::false_
- >
- >
- > class_signature;
- template <
- typename A0
- , typename A1 = boost::parameter::void_
- , typename A2 = boost::parameter::void_
- , typename A3 = boost::parameter::void_
- >
- struct class_
- {
- // Create ArgumentPack
- typedef typename boost::python::class_signature::BOOST_NESTED_TEMPLATE
- bind<A0,A1,A2,A3>::type args;
- // Extract first logical parameter.
- typedef typename boost::parameter::value_type<
- args,boost::python::tag::class_type
- >::type class_type;
- typedef typename boost::parameter::value_type<
- args,boost::python::tag::base_list,boost::python::bases<>
- >::type base_list;
- typedef typename boost::parameter::value_type<
- args,boost::python::tag::held_type,class_type
- >::type held_type;
- typedef typename boost::parameter::value_type<
- args,boost::python::tag::copyable,void
- >::type copyable;
- };
- }}
- struct B
- {
- };
- struct D
- {
- };
- typedef boost::python::class_<B,boost::noncopyable> c1;
- #include <memory>
- #if defined(BOOST_NO_CXX11_SMART_PTR)
- typedef boost::python::class_<D,std::auto_ptr<D>,boost::python::bases<B> > c2;
- #else
- typedef boost::python::class_<
- D,std::unique_ptr<D>,boost::python::bases<B>
- > c2;
- #endif
- #include <boost/mpl/assert.hpp>
- #include <boost/mpl/aux_/test.hpp>
- MPL_TEST_CASE()
- {
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c1::class_type,B>
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c1::base_list,boost::python::bases<> >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c1::held_type,B>
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c1::copyable,boost::noncopyable>
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c2::class_type,D>
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c2::base_list,boost::python::bases<B> >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- #if defined(BOOST_NO_CXX11_SMART_PTR)
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c2::held_type,std::auto_ptr<D> >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- #else
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c2::held_type,std::unique_ptr<D> >
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- #endif // BOOST_NO_CXX11_SMART_PTR
- BOOST_MPL_ASSERT((
- boost::mpl::if_<
- boost::is_same<c2::copyable,void>
- , boost::mpl::true_
- , boost::mpl::false_
- >::type
- ));
- }
|