88# include < boost/python/detail/wrap_python.hpp>
99# include < boost/python/detail/none.hpp>
1010# include < boost/python/reference.hpp>
11+ # include < boost/python/converter/callback_to_python_base.hpp>
1112# include < string>
1213# include < complex>
1314
@@ -33,40 +34,37 @@ namespace converter
3334 BOOST_PYTHON_DECL PyObject* do_callback_to_python (PyObject*);
3435}
3536
36- # define BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE (T, expr ) \
37- template <> struct to_python_value <T&> \
38- : detail::builtin_to_python \
39- { \
40- PyObject* operator ()(T const & x) const \
41- { \
42- return (expr); \
43- } \
44- }; \
45- template <> struct to_python_value <T const &> \
46- : detail::builtin_to_python \
47- { \
48- PyObject* operator ()(T const & x) const \
49- { \
50- return (expr); \
51- } \
37+ # define BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE (T, expr ) \
38+ template <> struct to_python_value <T&> \
39+ : detail::builtin_to_python \
40+ { \
41+ PyObject* operator ()(T const & x) const \
42+ { \
43+ return (expr); \
44+ } \
45+ }; \
46+ template <> struct to_python_value <T const &> \
47+ : detail::builtin_to_python \
48+ { \
49+ PyObject* operator ()(T const & x) const \
50+ { \
51+ return (expr); \
52+ } \
5253 };
5354
54- # define BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE (T, expr ) \
55- namespace converter \
56- { \
57- template <> struct callback_to_python < T > \
58- { \
59- callback_to_python (T const & x) \
60- : m_held(expr) {} \
61- PyObject* get () const \
62- { return m_held.get (); } \
63- private: \
64- ref m_held; \
65- }; \
55+ # define BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE (T, expr ) \
56+ namespace converter \
57+ { \
58+ template <> struct callback_to_python < T > \
59+ : detail::callback_to_python_holder \
60+ { \
61+ callback_to_python (T const & x) \
62+ : detail::callback_to_python_holder(expr) {} \
63+ }; \
6664 }
6765
68- # define BOOST_PYTHON_TO_PYTHON_BY_VALUE (T, expr ) \
69- BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE (T,expr) \
66+ # define BOOST_PYTHON_TO_PYTHON_BY_VALUE (T, expr ) \
67+ BOOST_PYTHON_CALL_TO_PYTHON_BY_VALUE (T,expr) \
7068 BOOST_PYTHON_CALLBACK_TO_PYTHON_BY_VALUE (T,expr)
7169
7270# define BOOST_PYTHON_TO_INT (T ) \
0 commit comments