tuple.cpp 882 B

123456789101112131415161718192021222324252627282930313233
  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. #include <boost/python/module.hpp>
  5. #include <boost/python/def.hpp>
  6. #include <boost/python/class.hpp>
  7. #include <boost/python/tuple.hpp>
  8. using namespace boost::python;
  9. object convert_to_tuple(object data)
  10. {
  11. return tuple(data);
  12. }
  13. void test_operators(tuple t1, tuple t2, object print)
  14. {
  15. print(t1 + t2);
  16. }
  17. tuple mktuple0() { return make_tuple(); }
  18. tuple mktuple1(int x) { return make_tuple(x); }
  19. tuple mktuple2(char const* a1, int x) { return make_tuple(a1, x); }
  20. BOOST_PYTHON_MODULE(tuple_ext)
  21. {
  22. def("convert_to_tuple",convert_to_tuple);
  23. def("test_operators",test_operators);
  24. def("make_tuple", mktuple0);
  25. def("make_tuple", mktuple1);
  26. def("make_tuple", mktuple2);
  27. }