python_type.hpp 936 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright Nikolay Mladenov 2007.
  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 BOOST_PYTHON_OBJECT_PYTHON_TYPE_H
  6. #define BOOST_PYTHON_OBJECT_PYTHON_TYPE_H
  7. #include <boost/python/converter/registered.hpp>
  8. namespace boost {namespace python {namespace detail{
  9. template <class T> struct python_class : PyObject
  10. {
  11. typedef python_class<T> this_type;
  12. typedef T type;
  13. static void *converter (PyObject *p){
  14. return p;
  15. }
  16. static void register_()
  17. {
  18. static bool first_time = true;
  19. if ( !first_time ) return;
  20. first_time = false;
  21. converter::registry::insert(&converter, boost::python::type_id<this_type>(), &converter::registered_pytype_direct<T>::get_pytype);
  22. }
  23. };
  24. }}} //namespace boost :: python :: detail
  25. #endif //BOOST_PYTHON_OBJECT_PYTHON_TYPE_H