register_ptr_to_python.hpp 769 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef REGISTER_PTR_TO_PYTHON_HPP
  6. #define REGISTER_PTR_TO_PYTHON_HPP
  7. #include <boost/python/pointee.hpp>
  8. #include <boost/python/object.hpp>
  9. #include <boost/python/object/class_wrapper.hpp>
  10. namespace boost { namespace python {
  11. template <class P>
  12. void register_ptr_to_python()
  13. {
  14. typedef typename boost::python::pointee<P>::type X;
  15. objects::class_value_wrapper<
  16. P
  17. , objects::make_ptr_instance<
  18. X
  19. , objects::pointer_holder<P,X>
  20. >
  21. >();
  22. }
  23. }} // namespace boost::python
  24. #endif // REGISTER_PTR_TO_PYTHON_HPP