class.cpp 547 B

12345678910111213141516171819202122232425262728
  1. // Distributed under the Boost Software License, Version 1.0. (See
  2. // accompanying file LICENSE_1_0.txt or copy at
  3. // http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/python/module.hpp>
  5. #include <boost/python/def.hpp>
  6. #include <boost/python/object.hpp>
  7. #include <boost/python/class.hpp>
  8. using namespace boost::python;
  9. struct X
  10. {
  11. int x;
  12. X(int n) : x(n) { }
  13. };
  14. int x_function(X& x)
  15. { return x.x;
  16. }
  17. BOOST_PYTHON_MODULE(class_ext)
  18. {
  19. class_<X>("X", init<int>());
  20. def("x_function", x_function);
  21. }
  22. #include "module_tail.cpp"