88#include < boost/python/class.hpp>
99#include < boost/ref.hpp>
1010#include < boost/python/ptr.hpp>
11+ #include < boost/python/return_value_policy.hpp>
12+ #include < boost/python/reference_existing_object.hpp>
1113
1214using namespace boost ::python;
1315
@@ -48,6 +50,16 @@ void apply_void_X_ref(PyObject* f, X& x)
4850 returning<void >::call (f, boost::ref (x));
4951}
5052
53+ X& apply_X_ref_pyobject (PyObject* f, PyObject* obj)
54+ {
55+ return returning<X&>::call (f, obj);
56+ }
57+
58+ X* apply_X_ptr_pyobject (PyObject* f, PyObject* obj)
59+ {
60+ return returning<X*>::call (f, obj);
61+ }
62+
5163void apply_void_X_cref (PyObject* f, X const & x)
5264{
5365 returning<void >::call (f, boost::cref (x));
@@ -63,6 +75,21 @@ void apply_void_X_deep_ptr(PyObject* f, X* x)
6375 returning<void >::call (f, x);
6476}
6577
78+ char const * apply_cstring_cstring (PyObject* f, char const * s)
79+ {
80+ return returning <char const *>::call (f, s);
81+ }
82+
83+ char const * apply_cstring_pyobject (PyObject* f, PyObject* s)
84+ {
85+ return returning <char const *>::call (f, s);
86+ }
87+
88+ char apply_char_char (PyObject* f, char c)
89+ {
90+ return returning <char >::call (f, c);
91+ }
92+
6693int X::counter;
6794
6895BOOST_PYTHON_MODULE_INIT (callbacks_ext)
@@ -75,6 +102,17 @@ BOOST_PYTHON_MODULE_INIT(callbacks_ext)
75102 .def (" apply_void_X_cref" , apply_void_X_cref)
76103 .def (" apply_void_X_ptr" , apply_void_X_ptr)
77104 .def (" apply_void_X_deep_ptr" , apply_void_X_deep_ptr)
105+
106+ .def (" apply_X_ptr_pyobject" , apply_X_ptr_pyobject
107+ , return_value_policy<reference_existing_object>())
108+
109+ .def (" apply_X_ref_pyobject" , apply_X_ref_pyobject
110+ , return_value_policy<reference_existing_object>())
111+
112+ .def (" apply_cstring_cstring" , apply_cstring_cstring)
113+ .def (" apply_cstring_pyobject" , apply_cstring_pyobject)
114+ .def (" apply_char_char" , apply_char_char)
115+
78116 .add (
79117 class_<X>(" X" )
80118 .def_init (args<int >())
0 commit comments