mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 05:22:45 +00:00
removed signature<...> and updated defaults.cpp test
[SVN r15071]
This commit is contained in:
@@ -21,68 +21,27 @@
|
||||
#include <boost/mpl/type_list.hpp>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace boost { namespace python {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// signature
|
||||
//
|
||||
// This template struct acts as a type holder for the signature of a
|
||||
// function or member function. This struct is used to pass in the
|
||||
// return type, class (for member functions) and arguments of a
|
||||
// function or member function. Examples:
|
||||
//
|
||||
// signature<int(*)(int)> int foo(int)
|
||||
// signature<void(*)(int, int)> void foo(int, int)
|
||||
// signature<void(C::*)(int)> void C::foo(int, int)
|
||||
// signature<void(C::*)(int) const> void C::foo(int, int) const
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <typename T>
|
||||
struct signature {};
|
||||
|
||||
namespace detail {
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// The following macros generate expansions for:
|
||||
//
|
||||
// template <typename RT, typename T0... typename TN>
|
||||
// inline boost::mpl::type_list<RT, T0...TN>
|
||||
// get_signature(signature<RT(*)(T0...TN)>)
|
||||
// {
|
||||
// return boost::mpl::type_list<RT, T0...TN>();
|
||||
// }
|
||||
//
|
||||
// template <typename RT, typename T0... typename TN>
|
||||
// template <class RT, class T0... class TN>
|
||||
// inline boost::mpl::type_list<RT, T0...TN>
|
||||
// get_signature(RT(*)(T0...TN))
|
||||
// {
|
||||
// return boost::mpl::type_list<RT, T0...TN>();
|
||||
// }
|
||||
//
|
||||
// template <typename RT, typename ClassT, typename T0... typename TN>
|
||||
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
|
||||
// get_signature(signature<RT(ClassT::*)(T0...TN))>)
|
||||
// {
|
||||
// return boost::mpl::type_list<RT, ClassT, T0...TN>();
|
||||
// }
|
||||
//
|
||||
// template <typename RT, typename ClassT, typename T0... typename TN>
|
||||
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
|
||||
// get_signature(signature<RT(ClassT::*)(T0...TN) const)>)
|
||||
// {
|
||||
// return boost::mpl::type_list<RT, ClassT const, T0...TN>();
|
||||
// }
|
||||
//
|
||||
// template <typename RT, typename ClassT, typename T0... typename TN>
|
||||
// template <class RT, class ClassT, class T0... class TN>
|
||||
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
|
||||
// get_signature(RT(ClassT::*)(T0...TN)))
|
||||
// {
|
||||
// return boost::mpl::type_list<RT, ClassT, T0...TN>();
|
||||
// }
|
||||
//
|
||||
// template <typename RT, typename ClassT, typename T0... typename TN>
|
||||
// template <class RT, class ClassT, class T0... class TN>
|
||||
// inline boost::mpl::type_list<RT, ClassT, T0...TN>
|
||||
// get_signature(RT(ClassT::*)(T0...TN) const))
|
||||
// {
|
||||
@@ -93,14 +52,14 @@ namespace detail {
|
||||
// and arguments of the input signature and stuffs them in an mpl::type_list.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define BPL_IMPL_TEMPLATE_GEN(INDEX, DATA) typename BOOST_PP_CAT(T, INDEX)
|
||||
#define BOOST_PYTHON_TEMPLATE_GEN(INDEX, DATA) class BOOST_PP_CAT(T, INDEX)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define BOOST_PP_ITERATION_PARAMS_1 \
|
||||
(3, (0, BOOST_PYTHON_MAX_ARITY-1, <boost/python/signature.hpp>))
|
||||
|
||||
#include BOOST_PP_ITERATE()
|
||||
#undef BPL_IMPL_TEMPLATE_GEN
|
||||
#undef BOOST_PYTHON_TEMPLATE_GEN
|
||||
|
||||
}
|
||||
|
||||
@@ -109,218 +68,52 @@ namespace detail {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#endif // SIGNATURE_JDG20020813_HPP
|
||||
|
||||
|
||||
#else // defined(BOOST_PP_IS_ITERATING)
|
||||
// PP vertical iteration code
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
|
||||
|
||||
template
|
||||
<
|
||||
typename RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM
|
||||
(
|
||||
BOOST_PP_ITERATION(),
|
||||
BPL_IMPL_TEMPLATE_GEN,
|
||||
BOOST_PP_EMPTY
|
||||
)
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
template <
|
||||
class RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM(BOOST_PP_ITERATION(), BOOST_PYTHON_TEMPLATE_GEN, BOOST_PP_EMPTY)>
|
||||
inline boost::mpl::type_list<
|
||||
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature
|
||||
(signature<RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))>)
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
|
||||
get_signature(RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
|
||||
{
|
||||
return boost::mpl::type_list
|
||||
<
|
||||
return boost::mpl::type_list<
|
||||
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>();
|
||||
}
|
||||
|
||||
#endif // !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
|
||||
|
||||
///////////////////////////////////////
|
||||
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300))
|
||||
|
||||
# if defined(__MWERKS__) && __MWERKS__ <= 0x3002 && BOOST_PP_ITERATION() == 0
|
||||
template <typename RT>
|
||||
inline boost::mpl::type_list<RT>
|
||||
get_signature(signature<RT(void)>)
|
||||
{
|
||||
return boost::mpl::type_list<RT>();
|
||||
}
|
||||
# else
|
||||
template
|
||||
<
|
||||
typename RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM
|
||||
(
|
||||
BOOST_PP_ITERATION(),
|
||||
BPL_IMPL_TEMPLATE_GEN,
|
||||
BOOST_PP_EMPTY
|
||||
)
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature(
|
||||
signature<
|
||||
RT(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))
|
||||
>)
|
||||
{
|
||||
return boost::mpl::type_list
|
||||
<
|
||||
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>();
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif // !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1300))
|
||||
|
||||
///////////////////////////////////////
|
||||
template
|
||||
<
|
||||
typename RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM
|
||||
(
|
||||
BOOST_PP_ITERATION(),
|
||||
BPL_IMPL_TEMPLATE_GEN,
|
||||
BOOST_PP_EMPTY
|
||||
)
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature
|
||||
(RT(*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
|
||||
{
|
||||
return boost::mpl::type_list
|
||||
<
|
||||
RT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>();
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if BOOST_PP_ITERATION() <= (BOOST_PYTHON_MAX_ARITY - 2)
|
||||
|
||||
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
|
||||
|
||||
template
|
||||
<
|
||||
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM
|
||||
(
|
||||
BOOST_PP_ITERATION(),
|
||||
BPL_IMPL_TEMPLATE_GEN,
|
||||
BOOST_PP_EMPTY
|
||||
)
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
template <
|
||||
class RT, class ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM(BOOST_PP_ITERATION(), BOOST_PYTHON_TEMPLATE_GEN, BOOST_PP_EMPTY)>
|
||||
inline boost::mpl::type_list<
|
||||
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature
|
||||
(signature<RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T))>)
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
|
||||
get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
|
||||
{
|
||||
return boost::mpl::type_list
|
||||
<
|
||||
return boost::mpl::type_list<
|
||||
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
|
||||
();
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>();
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
template
|
||||
<
|
||||
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM
|
||||
(
|
||||
BOOST_PP_ITERATION(),
|
||||
BPL_IMPL_TEMPLATE_GEN,
|
||||
BOOST_PP_EMPTY
|
||||
)
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
template <
|
||||
class RT, class ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM(BOOST_PP_ITERATION(), BOOST_PYTHON_TEMPLATE_GEN, BOOST_PP_EMPTY)>
|
||||
inline boost::mpl::type_list<
|
||||
RT, ClassT const BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature
|
||||
(signature<RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const>)
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>
|
||||
get_signature(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const)
|
||||
{
|
||||
return boost::mpl::type_list
|
||||
<
|
||||
RT, ClassT const
|
||||
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>();
|
||||
}
|
||||
|
||||
#endif // !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
|
||||
|
||||
///////////////////////////////////////
|
||||
template
|
||||
<
|
||||
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM
|
||||
(
|
||||
BOOST_PP_ITERATION(),
|
||||
BPL_IMPL_TEMPLATE_GEN,
|
||||
BOOST_PP_EMPTY
|
||||
)
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature
|
||||
(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)))
|
||||
{
|
||||
return boost::mpl::type_list
|
||||
<
|
||||
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>();
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
template
|
||||
<
|
||||
typename RT, typename ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM
|
||||
(
|
||||
BOOST_PP_ITERATION(),
|
||||
BPL_IMPL_TEMPLATE_GEN,
|
||||
BOOST_PP_EMPTY
|
||||
)
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
RT, ClassT const
|
||||
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature
|
||||
(RT(ClassT::*)(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)) const)
|
||||
{
|
||||
return boost::mpl::type_list
|
||||
<
|
||||
RT, ClassT const
|
||||
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>();
|
||||
return boost::mpl::type_list<
|
||||
RT, ClassT const
|
||||
BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)>();
|
||||
}
|
||||
|
||||
#endif // BOOST_PP_ITERATION() < (BOOST_PYTHON_MAX_ARITY - 2)
|
||||
|
||||
@@ -17,6 +17,10 @@ using namespace std;
|
||||
|
||||
char const* const format = "int(%s); char(%s); string(%s); double(%s); ";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Overloaded functions
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
object
|
||||
bar(int a, char b, std::string c, double d)
|
||||
@@ -44,6 +48,10 @@ bar(int a)
|
||||
|
||||
BOOST_PYTHON_FUNCTION_GENERATOR(bar_stubs, bar, 1, 4)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Functions with default arguments
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
object
|
||||
foo(int a, char b = 'D', std::string c = "default", double d = 0.0)
|
||||
@@ -54,7 +62,10 @@ foo(int a, char b = 'D', std::string c = "default", double d = 0.0)
|
||||
BOOST_PYTHON_FUNCTION_GENERATOR(foo_stubs, foo, 1, 4)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Overloaded member functions with default arguments
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
struct X {
|
||||
|
||||
object
|
||||
@@ -92,24 +103,13 @@ BOOST_PYTHON_MODULE_INIT(defaults_ext)
|
||||
{
|
||||
module("defaults_ext")
|
||||
.def("foo", foo, foo_stubs())
|
||||
|
||||
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
|
||||
.def("bar", signature<object(*)(int, char, std::string, double)>(), bar_stubs())
|
||||
#else // signature does not work on VC6 only (VC7 is ok)
|
||||
.def("bar", (object(*)(int, char, std::string, double))0, bar_stubs())
|
||||
#endif
|
||||
;
|
||||
|
||||
class_<X>("X")
|
||||
.def("bar", &X::bar, X_bar_stubs())
|
||||
.def("foo", (object(X::*)(std::string, bool) const)0, X_foo_2_stubs())
|
||||
|
||||
#if !(defined(BOOST_MSVC) && (BOOST_MSVC <= 1200))
|
||||
.def("foo", signature<object(X::*)(int, bool) const>(), X_foo_2_stubs())
|
||||
#else // signature does not work on VC6 only (VC7 is ok)
|
||||
.def("foo", (object(X::*)(int, bool) const)0, X_foo_2_stubs())
|
||||
#endif
|
||||
|
||||
.def("foo", (object(X::*)(list, list, bool) const)0, X_foo_3_stubs())
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user