mirror of
https://github.com/boostorg/python.git
synced 2026-01-29 19:52:16 +00:00
Initial speedup for EDG for the stub functions. The init<...> stuff is more involved...
[SVN r15097]
This commit is contained in:
@@ -15,9 +15,9 @@
|
||||
#include <boost/python/detail/defaults_gen.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/mpl/int_t.hpp>
|
||||
#include <boost/mpl/size.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
#include <boost/python/detail/type_list_utils.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace python {
|
||||
@@ -134,7 +134,7 @@ struct define_stub_function {};
|
||||
SigT sig,
|
||||
char const* doc)
|
||||
{
|
||||
typedef typename mpl::at<0, SigT>::type nth_type;
|
||||
typedef typename boost::python::detail::type_at<0, SigT>::type nth_type;
|
||||
typedef typename StubsT::v_type v_type;
|
||||
typedef typename StubsT::nv_type nv_type;
|
||||
|
||||
@@ -145,7 +145,8 @@ struct define_stub_function {};
|
||||
>::type stubs_type;
|
||||
|
||||
BOOST_STATIC_ASSERT(
|
||||
(stubs_type::max_args + 1) <= boost::mpl::size<SigT>::value);
|
||||
(stubs_type::max_args + 1) <=
|
||||
boost::python::detail::type_list_size<SigT>::value);
|
||||
|
||||
typedef typename stubs_type::template gen<SigT> gen_type;
|
||||
define_with_defaults_helper<stubs_type::n_funcs-1>::def
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <boost/preprocessor/inc.hpp>
|
||||
#include <boost/preprocessor/empty.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/python/detail/type_list_utils.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
@@ -44,7 +45,7 @@ struct func_stubs_base {};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define BPL_IMPL_TYPEDEF_GEN(INDEX, DATA) \
|
||||
typedef typename boost::mpl::at \
|
||||
typedef typename boost::python::detail::type_at \
|
||||
< \
|
||||
BOOST_PP_ADD(INDEX, DATA), \
|
||||
SigT \
|
||||
@@ -84,7 +85,7 @@ struct func_stubs_base {};
|
||||
template <typename SigT> \
|
||||
struct gen { \
|
||||
\
|
||||
typedef typename boost::mpl::at<0, SigT>::type RT; \
|
||||
typedef typename boost::python::detail::type_at<0, SigT>::type RT; \
|
||||
\
|
||||
BOOST_PP_FIX_REPEAT_2ND \
|
||||
( \
|
||||
@@ -135,8 +136,8 @@ struct func_stubs_base {};
|
||||
template <typename SigT> \
|
||||
struct gen { \
|
||||
\
|
||||
typedef typename boost::mpl::at<0, SigT>::type RT; \
|
||||
typedef typename boost::mpl::at<1, SigT>::type ClassT; \
|
||||
typedef typename boost::python::detail::type_at<0, SigT>::type RT; \
|
||||
typedef typename boost::python::detail::type_at<1, SigT>::type ClassT;\
|
||||
\
|
||||
BOOST_PP_FIX_REPEAT_2ND \
|
||||
( \
|
||||
|
||||
115
include/boost/python/detail/type_list_utils.hpp
Normal file
115
include/boost/python/detail/type_list_utils.hpp
Normal file
@@ -0,0 +1,115 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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
|
||||
|
||||
# include <boost/mpl/at.hpp>
|
||||
# include <boost/mpl/size.hpp>
|
||||
//# include <boost/mpl/pop_front.hpp>
|
||||
//# include <boost/mpl/pop_back.hpp>
|
||||
|
||||
# include <boost/preprocessor/enum_params.hpp>
|
||||
# include <boost/preprocessor/enum_shifted_params.hpp>
|
||||
# include <boost/preprocessor/cat.hpp>
|
||||
# include <boost/preprocessor/iterate.hpp>
|
||||
# include <boost/preprocessor/dec.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
# if (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 245) \
|
||||
&& (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600)
|
||||
|
||||
template <int N, class L>
|
||||
struct type_at : public boost::mpl::at<N, L> {};
|
||||
|
||||
template <class L>
|
||||
struct type_list_size : public boost::mpl::size<L> {};
|
||||
|
||||
// template <class L>
|
||||
// struct pop_front : public boost::mpl::pop_front<L> {};
|
||||
//
|
||||
// template <class L>
|
||||
// struct pop_back : public boost::mpl::pop_back<L> {};
|
||||
|
||||
# else
|
||||
|
||||
template <int N, class L>
|
||||
struct type_at {};
|
||||
|
||||
template <class L>
|
||||
struct type_list_size {};
|
||||
|
||||
// template <class L>
|
||||
// struct pop_front {};
|
||||
//
|
||||
// template <class L>
|
||||
// struct pop_back {};
|
||||
|
||||
// template <class L, class T>
|
||||
// struct push_back {};
|
||||
|
||||
# define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3, (0, BOOST_PYTHON_MAX_ARITY, <boost/python/detail/type_list_utils.hpp>))
|
||||
# include BOOST_PP_ITERATE()
|
||||
|
||||
# endif
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
#endif // TYPE_LIST_UTILS_JDG20020826_HPP
|
||||
|
||||
#else // defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
# define N BOOST_PP_ITERATION()
|
||||
# define MAX BOOST_PYTHON_MAX_ARITY
|
||||
|
||||
# if (N < MAX-1)
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(MAX, class A)>
|
||||
struct type_at<N, boost::mpl::type_list<BOOST_PP_ENUM_PARAMS(MAX, A)> >
|
||||
{
|
||||
typedef BOOST_PP_CAT(A, N) type;
|
||||
};
|
||||
|
||||
// template <BOOST_PP_ENUM_PARAMS(N, class A) BOOST_PP_COMMA_IF(N) class T>
|
||||
// struct push_back<boost::mpl::type_list<BOOST_PP_ENUM_PARAMS(N, A)>, T>
|
||||
// {
|
||||
// typedef boost::mpl::type_list<BOOST_PP_ENUM_PARAMS(N, A) BOOST_PP_COMMA_IF(N) T> sequence;
|
||||
// };
|
||||
|
||||
# if (N > 0)
|
||||
|
||||
// template <BOOST_PP_ENUM_PARAMS(N, class A)>
|
||||
// struct pop_front<boost::mpl::type_list<BOOST_PP_ENUM_PARAMS(N, A)> >
|
||||
// {
|
||||
// typedef boost::mpl::type_list<BOOST_PP_ENUM_SHIFTED_PARAMS(N, A)> sequence;
|
||||
// };
|
||||
//
|
||||
// template <BOOST_PP_ENUM_PARAMS(N, class A)>
|
||||
// struct pop_back<boost::mpl::type_list<BOOST_PP_ENUM_PARAMS(N, A)> >
|
||||
// {
|
||||
// typedef boost::mpl::type_list<BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(N), A)> sequence;
|
||||
// };
|
||||
|
||||
# endif
|
||||
# endif
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(N, class A)>
|
||||
struct type_list_size<boost::mpl::type_list<BOOST_PP_ENUM_PARAMS(N, A)> >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(long, value = N);
|
||||
};
|
||||
|
||||
# undef N
|
||||
# undef MAX
|
||||
|
||||
#endif // !defined(BOOST_PP_IS_ITERATING)
|
||||
@@ -121,8 +121,14 @@ BOOST_PYTHON_MODULE_INIT(defaults_ext)
|
||||
;
|
||||
|
||||
class_<X>("X")
|
||||
|
||||
# if (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 245) \
|
||||
&& (!defined(BOOST_INTEL_CXX_VERSION) || BOOST_INTEL_CXX_VERSION > 600)
|
||||
.def(init<int, optional<char, std::string, double> >())
|
||||
.def("get_state", &X::get_state)
|
||||
#endif
|
||||
|
||||
|
||||
.def("get_state", &X::get_state)
|
||||
.def("bar", &X::bar, X_bar_stubs())
|
||||
.def("foo", (object(X::*)(std::string, bool) const)0, X_foo_2_stubs())
|
||||
.def("foo", (object(X::*)(int, bool) const)0, X_foo_2_stubs())
|
||||
|
||||
Reference in New Issue
Block a user