mirror of
https://github.com/boostorg/python.git
synced 2026-01-20 16:52:15 +00:00
+ Added Ralf's test code
+ Fixed defaults_gen MACRO generation + Fixed signature for const member functions [SVN r15047]
This commit is contained in:
@@ -88,7 +88,7 @@ struct func_stubs_base {};
|
||||
\
|
||||
BOOST_PP_FIX_REPEAT_2ND \
|
||||
( \
|
||||
BOOST_PP_INC(N_DFLTS), \
|
||||
N_ARGS, \
|
||||
BPL_IMPL_TYPEDEF_GEN, \
|
||||
1 \
|
||||
) \
|
||||
@@ -140,7 +140,7 @@ struct func_stubs_base {};
|
||||
\
|
||||
BOOST_PP_FIX_REPEAT_2ND \
|
||||
( \
|
||||
BOOST_PP_INC(N_DFLTS), \
|
||||
N_ARGS, \
|
||||
BPL_IMPL_TYPEDEF_GEN, \
|
||||
2 \
|
||||
) \
|
||||
|
||||
@@ -242,7 +242,7 @@ template
|
||||
>
|
||||
inline boost::mpl::type_list
|
||||
<
|
||||
RT, ClassT BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
RT, ClassT const BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
|
||||
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), T)
|
||||
>
|
||||
get_signature
|
||||
|
||||
@@ -89,9 +89,39 @@ struct X {
|
||||
abcd.append(d);
|
||||
return "int(%s); char(%s); string(%s); double(%s); " % tuple(abcd);
|
||||
}
|
||||
|
||||
object
|
||||
foo(int a, bool b=false) const
|
||||
{
|
||||
list ab;
|
||||
ab.append(a);
|
||||
ab.append(b);
|
||||
return "int(%s); bool(%s); " % tuple(ab);
|
||||
}
|
||||
|
||||
object
|
||||
foo(std::string a, bool b=false) const
|
||||
{
|
||||
list ab;
|
||||
ab.append(a);
|
||||
ab.append(b);
|
||||
return "string(%s); bool(%s); " % tuple(ab);
|
||||
}
|
||||
|
||||
object
|
||||
foo(list a, list b, bool c=false) const
|
||||
{
|
||||
list abc;
|
||||
abc.append(a);
|
||||
abc.append(b);
|
||||
abc.append(c);
|
||||
return "list(%s); list(%s); bool(%s); " % tuple(abc);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_PYTHON_MEM_FUN_GENERATOR(X_bar_stubs, bar, 1, 4)
|
||||
BOOST_PYTHON_MEM_FUN_GENERATOR(X_foo_2_stubs, foo, 1, 2)
|
||||
BOOST_PYTHON_MEM_FUN_GENERATOR(X_foo_3_stubs, foo, 2, 3)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -99,7 +129,7 @@ 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)
|
||||
@@ -109,7 +139,17 @@ BOOST_PYTHON_MODULE_INIT(defaults_ext)
|
||||
|
||||
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())
|
||||
;
|
||||
}
|
||||
|
||||
#include "module_tail.cpp"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user