2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 18:12:43 +00:00

Replaced mpl::at with mpl iterators and changed some PP_ADD to PP_INC in the process.

[SVN r15350]
This commit is contained in:
Joel de Guzman
2002-09-16 00:25:27 +00:00
parent fcfd4dae07
commit 70e7f111e8
4 changed files with 35 additions and 101 deletions

View File

@@ -157,45 +157,24 @@ class class_ : public objects::class_base
// Construct with class name, docstring, and no init() function
class_(char const* name, char const* doc, no_init_t);
// template <class InitArgs>
// inline class_(char const* name, detail::args_base<InitArgs> const&)
// : base(name, id_vector::size, id_vector().ids)
// {
// this->register_();
// this->def_init(InitArgs());
// this->set_instance_size(holder_selector::additional_size());
// }
//
//
// template <class InitArgs>
// inline class_(char const* name, char const* doc, detail::args_base<InitArgs> const&, char const* initdoc = 0)
// : base(name, id_vector::size, id_vector().ids, doc)
// {
// this->register_();
// this->def_init(InitArgs(), initdoc);
// this->set_instance_size(holder_selector::additional_size());
// }
template <class DerivedT>
inline class_(char const* name, init_base<DerivedT> const& init)
inline class_(char const* name, init_base<DerivedT> const& i)
: base(name, id_vector::size, id_vector().ids)
{
this->register_();
define_init(*this, init.derived());
define_init(*this, i.derived());
this->set_instance_size(holder_selector::additional_size());
}
template <class DerivedT>
inline class_(char const* name, char const* doc, init_base<DerivedT> const& init)
inline class_(char const* name, char const* doc, init_base<DerivedT> const& i)
: base(name, id_vector::size, id_vector().ids, doc)
{
this->register_();
define_init(*this, init.derived());
define_init(*this, i.derived());
this->set_instance_size(holder_selector::additional_size());
}
// Wrap a member function or a non-member function which can take
// a T, T cv&, or T cv* as its first parameter, or a callable
// python object.
@@ -206,35 +185,13 @@ class class_ : public objects::class_base
return *this;
}
// template <BOOST_PYTHON_TEMPLATE_TYPES>
// self& def(init<BOOST_PYTHON_TEMPLATE_ARGS> const& i)
// {
// define_init(*this, i, default_call_policies());
// return *this;
// }
template <class DerivedT>
self& def(init_base<DerivedT> const& init)
self& def(init_base<DerivedT> const& i)
{
define_init(*this, init.derived());
define_init(*this, i.derived());
return *this;
}
// template <class CallPolicyOrDoc, BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_ARITY, class T)>
// self& def(
// init<BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_ARITY, T)> const& i,
// CallPolicyOrDoc const& policy_or_doc,
// char const* doc = 0)
// {
// typedef detail::def_helper<CallPolicyOrDoc> helper;
// define_init(*this, i,
// helper::get_policy(policy_or_doc),
// helper::get_doc(policy_or_doc, doc));
// return *this;
// }
template <class Arg1T, class Arg2T>
self& def(char const* name, Arg1T arg1, Arg2T const& arg2)
{
@@ -252,24 +209,12 @@ class class_ : public objects::class_base
self& def(char const* name, Arg1T arg1, Arg2T const& arg2, Arg3T const& arg3)
{
// The arguments are definitely:
// def(name, function, doc_string, policy)
// def(name, function, policy, doc_string) // TODO: exchange policy, doc_string position
dispatch_def(&arg2, name, arg1, arg2, arg3);
return *this;
}
// template <class Arg1T, class Arg2T, class Arg3T>
// self& def(char const* name, Arg1T arg1, Arg2T const& arg2, Arg3T const& arg3, char const* doc)
// {
// // The arguments are definitely:
// // arg1: signature
// // arg2: stubs
// // arg3: policy
//
// dispatch_def(&arg2, name, arg1, arg2, arg3, doc);
// return *this;
// }
template <detail::operator_id id, class L, class R>
self& def(detail::operator_<id,L,R> const& op)
{
@@ -435,26 +380,6 @@ inline void class_<T,X1,X2,X3>::register_() const
);
}
//template <class T, class X1, class X2, class X3>
//inline class_<T,X1,X2,X3>::class_()
// : base(typeid(T).name(), id_vector::size, id_vector().ids)
//{
// this->register_();
// detail::force_instantiate(sizeof(detail::assert_default_constructible(T())));
// this->def_init();
// this->set_instance_size(holder_selector::additional_size());
//}
//template <class T, class X1, class X2, class X3>
//inline class_<T,X1,X2,X3>::class_(no_init_t)
// : base(typeid(T).name(), id_vector::size, id_vector().ids)
//{
// this->register_();
// this->def_no_init();
//}
template <class T, class X1, class X2, class X3>
inline class_<T,X1,X2,X3>::class_(char const* name, char const* doc)
: base(name, id_vector::size, id_vector().ids, doc)

View File

@@ -73,7 +73,7 @@ template <class Arg1T, class Arg2T, class Arg3T>
void def(char const* name, Arg1T arg1, Arg2T const& arg2, Arg3T const& arg3)
{
// The arguments are definitely:
// def(name, function, doc_string, policy)
// def(name, function, policy, doc_string) // TODO: exchange policy, doc_string position
detail::dispatch_def(&arg2, name, arg1, arg2, arg3);
}

View File

@@ -61,13 +61,11 @@ struct func_stubs_with_call_policies
}} // namespace boost::python
///////////////////////////////////////////////////////////////////////////////
#define BOOST_PYTHON_TYPEDEF_GEN(z, index, data) \
typedef typename ::boost::mpl::at_c< \
BOOST_PP_ADD_D(1, index, data), \
SigT>::type BOOST_PP_CAT(T, index); \
typedef typename BOOST_PP_CAT(iter, index)::next \
BOOST_PP_CAT(iter, BOOST_PP_INC(index)); \
typedef typename BOOST_PP_CAT(iter, index)::type BOOST_PP_CAT(T, index); \
#define BOOST_PYTHON_FUNC_WRAPPER_GEN(z, index, data) \
static RT BOOST_PP_CAT(func_, index) ( \
@@ -90,12 +88,14 @@ struct func_stubs_with_call_policies
template <typename SigT> \
struct gen { \
\
typedef typename ::boost::mpl::front<SigT>::type RT; \
typedef typename ::boost::mpl::begin<SigT>::type rt_iter; \
typedef typename rt_iter::type RT; \
typedef typename rt_iter::next iter0; \
\
BOOST_PP_REPEAT_2ND( \
n_args, \
BOOST_PYTHON_TYPEDEF_GEN, \
1) \
0) \
\
BOOST_PP_REPEAT_2ND( \
BOOST_PP_INC(n_dflts), \
@@ -128,13 +128,17 @@ struct func_stubs_with_call_policies
template <typename SigT> \
struct gen { \
\
typedef typename ::boost::mpl::front<SigT>::type RT; \
typedef typename ::boost::mpl::at_c<1, SigT>::type ClassT; \
typedef typename ::boost::mpl::begin<SigT>::type rt_iter; \
typedef typename rt_iter::type RT; \
\
typedef typename rt_iter::next class_iter; \
typedef typename class_iter::type ClassT; \
typedef typename class_iter::next iter0; \
\
BOOST_PP_REPEAT_2ND( \
n_args, \
BOOST_PYTHON_TYPEDEF_GEN, \
2) \
0) \
\
BOOST_PP_REPEAT_2ND( \
BOOST_PP_INC(n_dflts), \
@@ -143,7 +147,6 @@ struct func_stubs_with_call_policies
}; \
};
///////////////////////////////////////////////////////////////////////////////
#if defined(BOOST_MSVC)
@@ -319,11 +322,17 @@ struct func_stubs_with_call_policies
// template <typename SigT>
// struct gen {
//
// 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;
// typedef typename ::boost::mpl::begin<SigT>::type rt_iter;
// typedef typename rt_iter::type RT;
// typedef typename rt_iter::next iter0;
// typedef typename iter0::type T0;
// typedef typename iter0::next iter1;
// typedef typename iter1::type T1;
// typedef typename iter1::next iter2;
// typedef typename iter2::type T2;
// typedef typename iter2::next iter3;
// typedef typename iter3::type T3;
// typedef typename iter3::next iter4;
//
// static RT func_0(T0 arg0)
// { return foo(arg0); }

View File

@@ -341,11 +341,11 @@ namespace detail
///////////////////////////////////////////////////////////////////////////////
template <class ClassT, class InitT>
void
define_init(ClassT& cl, InitT const& init)
define_init(ClassT& cl, InitT const& i)
{
typedef typename InitT::reversed_args reversed_args;
detail::define_class_init_helper<InitT::n_defaults>::apply(
cl, init.call_policies(), reversed_args(), init.doc_string());
cl, i.call_policies(), reversed_args(), i.doc_string());
}
}} // namespace boost::python