long.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 LONG_DWA2002627_HPP
  6. # define LONG_DWA2002627_HPP
  7. # include <boost/python/detail/prefix.hpp>
  8. # include <boost/python/object.hpp>
  9. # include <boost/python/converter/pytype_object_mgr_traits.hpp>
  10. namespace boost { namespace python {
  11. namespace detail
  12. {
  13. struct BOOST_PYTHON_DECL long_base : object
  14. {
  15. protected:
  16. long_base(); // new long_
  17. explicit long_base(object_cref rhs);
  18. explicit long_base(object_cref rhs, object_cref base);
  19. BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(long_base, object)
  20. private:
  21. static detail::new_non_null_reference call(object const&);
  22. static detail::new_non_null_reference call(object const&, object const&);
  23. };
  24. }
  25. class long_ : public detail::long_base
  26. {
  27. typedef detail::long_base base;
  28. public:
  29. long_() {} // new long_
  30. template <class T>
  31. explicit long_(T const& rhs)
  32. : detail::long_base(object(rhs))
  33. {
  34. }
  35. template <class T, class U>
  36. explicit long_(T const& rhs, U const& base)
  37. : detail::long_base(object(rhs), object(base))
  38. {
  39. }
  40. public: // implementation detail -- for internal use only
  41. BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS(long_, base)
  42. };
  43. //
  44. // Converter Specializations
  45. //
  46. namespace converter
  47. {
  48. template <>
  49. struct object_manager_traits<long_>
  50. : pytype_object_manager_traits<&PyLong_Type,long_>
  51. {
  52. };
  53. }
  54. }} // namespace boost::python
  55. #endif // LONG_DWA2002627_HPP