55// to its suitability for any purpose.
66#include < boost/python/module.hpp>
77#include < boost/python/class.hpp>
8+ #include < boost/python/tuple.hpp>
89#include < boost/python/list.hpp>
910
1011#if defined(_AIX) && defined(__EDG_VERSION__) && __EDG_VERSION__ < 245
1415using namespace boost ::python;
1516using namespace std ;
1617
18+ char const * const format = " int(%s); char(%s); string(%s); double(%s); " ;
19+
1720// /////////////////////////////////////////////////////////////////////////////
1821object
1922bar (int a, char b, std::string c, double d)
2023{
21- list abcd;
22- abcd.append (a);
23- abcd.append (b);
24- abcd.append (c);
25- abcd.append (d);
26- return " int(%s); char(%s); string(%s); double(%s); " % tuple (abcd);
24+ return format % make_tuple (a, b, c, d);
2725}
2826
2927object
3028bar (int a, char b, std::string c)
3129{
32- list abcd;
33- abcd.append (a);
34- abcd.append (b);
35- abcd.append (c);
36- abcd.append (0.0 );
37- return " int(%s); char(%s); string(%s); double(%s); " % tuple (abcd);
30+ return format % make_tuple (a, b, c, 0.0 );
3831}
3932
4033object
4134bar (int a, char b)
4235{
43- list abcd;
44- abcd.append (a);
45- abcd.append (b);
46- abcd.append (" default" );
47- abcd.append (0.0 );
48- return " int(%s); char(%s); string(%s); double(%s); " % tuple (abcd);
36+ return format % make_tuple (a, b, " default" , 0.0 );
4937}
5038
5139object
5240bar (int a)
5341{
54- list abcd;
55- abcd.append (a);
56- abcd.append (' D' );
57- abcd.append (" default" );
58- abcd.append (0.0 );
59- return " int(%s); char(%s); string(%s); double(%s); " % tuple (abcd);
42+ return format % make_tuple (a, ' D' , " default" , 0.0 );
6043}
6144
6245BOOST_PYTHON_FUNCTION_GENERATOR (bar_stubs, bar, 1 , 4 )
@@ -65,12 +48,7 @@ BOOST_PYTHON_FUNCTION_GENERATOR(bar_stubs, bar, 1, 4)
6548object
6649foo(int a, char b = ' D' , std::string c = " default" , double d = 0.0 )
6750{
68- list abcd;
69- abcd.append (a);
70- abcd.append (b);
71- abcd.append (c);
72- abcd.append (d);
73- return " int(%s); char(%s); string(%s); double(%s); " % tuple (abcd);
51+ return format % make_tuple (a, b, c, d);
7452}
7553
7654BOOST_PYTHON_FUNCTION_GENERATOR (foo_stubs, foo, 1 , 4 )
@@ -82,40 +60,25 @@ struct X {
8260 object
8361 bar (int a, char b = ' D' , std::string c = " default" , double d = 0.0 ) const
8462 {
85- list abcd;
86- abcd.append (a);
87- abcd.append (b);
88- abcd.append (c);
89- abcd.append (d);
90- return " int(%s); char(%s); string(%s); double(%s); " % tuple (abcd);
63+ return format % make_tuple (a, b, c, d);
9164 }
9265
9366 object
9467 foo (int a, bool b=false ) const
9568 {
96- list ab;
97- ab.append (a);
98- ab.append (b);
99- return " int(%s); bool(%s); " % tuple (ab);
69+ return " int(%s); bool(%s); " % make_tuple (a, b);
10070 }
10171
10272 object
10373 foo (std::string a, bool b=false ) const
10474 {
105- list ab;
106- ab.append (a);
107- ab.append (b);
108- return " string(%s); bool(%s); " % tuple (ab);
75+ return " string(%s); bool(%s); " % make_tuple (a, b);
10976 }
11077
11178 object
11279 foo (list a, list b, bool c=false ) const
11380 {
114- list abc;
115- abc.append (a);
116- abc.append (b);
117- abc.append (c);
118- return " list(%s); list(%s); bool(%s); " % tuple (abc);
81+ return " list(%s); list(%s); bool(%s); " % make_tuple (a, b, c);
11982 }
12083};
12184
0 commit comments