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

Added make_tuple

[SVN r15052]
This commit is contained in:
Dave Abrahams
2002-08-22 13:20:58 +00:00
parent 68c8901c2a
commit e1099e9370
3 changed files with 48 additions and 49 deletions

View File

@@ -5,6 +5,7 @@
// to its suitability for any purpose.
#include <boost/python/module.hpp>
#include <boost/python/class.hpp>
#include <boost/python/tuple.hpp>
#include <boost/python/list.hpp>
#if defined(_AIX) && defined(__EDG_VERSION__) && __EDG_VERSION__ < 245
@@ -14,49 +15,31 @@
using namespace boost::python;
using namespace std;
char const* const format = "int(%s); char(%s); string(%s); double(%s); ";
///////////////////////////////////////////////////////////////////////////////
object
bar(int a, char b, std::string c, double d)
{
list abcd;
abcd.append(a);
abcd.append(b);
abcd.append(c);
abcd.append(d);
return "int(%s); char(%s); string(%s); double(%s); " % tuple(abcd);
return format % make_tuple(a, b, c, d);
}
object
bar(int a, char b, std::string c)
{
list abcd;
abcd.append(a);
abcd.append(b);
abcd.append(c);
abcd.append(0.0);
return "int(%s); char(%s); string(%s); double(%s); " % tuple(abcd);
return format % make_tuple(a, b, c, 0.0);
}
object
bar(int a, char b)
{
list abcd;
abcd.append(a);
abcd.append(b);
abcd.append("default");
abcd.append(0.0);
return "int(%s); char(%s); string(%s); double(%s); " % tuple(abcd);
return format % make_tuple(a, b, "default", 0.0);
}
object
bar(int a)
{
list abcd;
abcd.append(a);
abcd.append('D');
abcd.append("default");
abcd.append(0.0);
return "int(%s); char(%s); string(%s); double(%s); " % tuple(abcd);
return format % make_tuple(a, 'D', "default", 0.0);
}
BOOST_PYTHON_FUNCTION_GENERATOR(bar_stubs, bar, 1, 4)
@@ -65,12 +48,7 @@ BOOST_PYTHON_FUNCTION_GENERATOR(bar_stubs, bar, 1, 4)
object
foo(int a, char b = 'D', std::string c = "default", double d = 0.0)
{
list abcd;
abcd.append(a);
abcd.append(b);
abcd.append(c);
abcd.append(d);
return "int(%s); char(%s); string(%s); double(%s); " % tuple(abcd);
return format % make_tuple(a, b, c, d);
}
BOOST_PYTHON_FUNCTION_GENERATOR(foo_stubs, foo, 1, 4)
@@ -82,40 +60,25 @@ struct X {
object
bar(int a, char b = 'D', std::string c = "default", double d = 0.0) const
{
list abcd;
abcd.append(a);
abcd.append(b);
abcd.append(c);
abcd.append(d);
return "int(%s); char(%s); string(%s); double(%s); " % tuple(abcd);
return format % make_tuple(a, b, c, d);
}
object
foo(int a, bool b=false) const
{
list ab;
ab.append(a);
ab.append(b);
return "int(%s); bool(%s); " % tuple(ab);
return "int(%s); bool(%s); " % make_tuple(a, b);
}
object
foo(std::string a, bool b=false) const
{
list ab;
ab.append(a);
ab.append(b);
return "string(%s); bool(%s); " % tuple(ab);
return "string(%s); bool(%s); " % make_tuple(a, b);
}
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);
return "list(%s); list(%s); bool(%s); " % make_tuple(a, b, c);
}
};