• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright David Abrahams 2005. Distributed under the Boost
2 // Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4 
5 #include <boost/python/module.hpp>
6 #include <boost/python/def.hpp>
7 #include <boost/python/class.hpp>
8 #include <boost/python/tuple.hpp>
9 
10 using namespace boost::python;
11 
convert_to_tuple(object data)12 object convert_to_tuple(object data)
13 {
14     return tuple(data);
15 }
16 
test_operators(tuple t1,tuple t2,object print)17 void test_operators(tuple t1, tuple t2, object print)
18 {
19     print(t1 + t2);
20 }
21 
mktuple0()22 tuple mktuple0() { return make_tuple(); }
mktuple1(int x)23 tuple mktuple1(int x) { return make_tuple(x); }
mktuple2(char const * a1,int x)24 tuple mktuple2(char const* a1, int x) { return make_tuple(a1, x); }
25 
BOOST_PYTHON_MODULE(tuple_ext)26 BOOST_PYTHON_MODULE(tuple_ext)
27 {
28     def("convert_to_tuple",convert_to_tuple);
29     def("test_operators",test_operators);
30     def("make_tuple", mktuple0);
31     def("make_tuple", mktuple1);
32     def("make_tuple", mktuple2);
33 }
34