@@ -44,7 +44,7 @@ struct pointer_cref_arg_from_python
4444 typedef T result_type;
4545
4646 pointer_cref_arg_from_python (PyObject*);
47- T operator ()(PyObject* ) const ;
47+ T operator ()() const ;
4848 bool convertible () const ;
4949
5050 private: // storage for a U*
@@ -74,7 +74,7 @@ struct pointer_arg_from_python : arg_lvalue_from_python_base
7474 typedef T result_type;
7575
7676 pointer_arg_from_python (PyObject*);
77- T operator ()(PyObject* ) const ;
77+ T operator ()() const ;
7878};
7979
8080// Used when T == U& and (T != V const& or T == W volatile&)
@@ -84,7 +84,7 @@ struct reference_arg_from_python : arg_lvalue_from_python_base
8484 typedef T result_type;
8585
8686 reference_arg_from_python (PyObject*);
87- T operator ()(PyObject* ) const ;
87+ T operator ()() const ;
8888};
8989
9090// ===================
@@ -114,10 +114,11 @@ struct arg_rvalue_from_python
114114# if BOOST_MSVC < 1301 || _MSC_FULL_VER > 13102196
115115 typename arg_rvalue_from_python<T>::
116116# endif
117- result_type operator ()(PyObject* );
117+ result_type operator ()();
118118
119119 private:
120120 rvalue_from_python_data<result_type> m_data;
121+ PyObject* m_source;
121122};
122123
123124
@@ -132,9 +133,10 @@ struct back_reference_arg_from_python
132133 typedef T result_type;
133134
134135 back_reference_arg_from_python (PyObject*);
135- T operator ()(PyObject* );
136+ T operator ()();
136137 private:
137138 typedef boost::python::arg_from_python<typename T::type> base;
139+ PyObject* m_source;
138140};
139141
140142
@@ -259,9 +261,9 @@ inline bool pointer_cref_arg_from_python<T>::convertible() const
259261 return python::detail::void_ptr_to_reference (m_result.bytes , (T (*)())0 ) != 0 ;
260262}
261263template <class T >
262- inline T pointer_cref_arg_from_python<T>::operator ()(PyObject* p ) const
264+ inline T pointer_cref_arg_from_python<T>::operator ()() const
263265{
264- return (p == Py_None) // None ==> 0
266+ return (*( void **)m_result. bytes == Py_None) // None ==> 0
265267 ? detail::null_ptr_reference ((T (*)())0 )
266268 // Otherwise, return a U*const& to the m_result storage.
267269 : python::detail::void_ptr_to_reference (m_result.bytes , (T (*)())0 );
@@ -277,9 +279,9 @@ inline pointer_arg_from_python<T>::pointer_arg_from_python(PyObject* p)
277279}
278280
279281template <class T >
280- inline T pointer_arg_from_python<T>::operator ()(PyObject* p ) const
282+ inline T pointer_arg_from_python<T>::operator ()() const
281283{
282- return (p == Py_None) ? 0 : T (result ());
284+ return (result () == Py_None) ? 0 : T (result ());
283285}
284286
285287// reference_arg_from_python
@@ -291,7 +293,7 @@ inline reference_arg_from_python<T>::reference_arg_from_python(PyObject* p)
291293}
292294
293295template <class T >
294- inline T reference_arg_from_python<T>::operator ()(PyObject* ) const
296+ inline T reference_arg_from_python<T>::operator ()() const
295297{
296298 return python::detail::void_ptr_to_reference (result (), (T (*)())0 );
297299}
@@ -302,6 +304,7 @@ inline T reference_arg_from_python<T>::operator()(PyObject*) const
302304template <class T >
303305inline arg_rvalue_from_python<T>::arg_rvalue_from_python(PyObject* obj)
304306 : m_data(converter::rvalue_from_python_stage1(obj, registered<T>::converters))
307+ , m_source(obj)
305308{
306309}
307310
@@ -313,10 +316,10 @@ inline bool arg_rvalue_from_python<T>::convertible() const
313316
314317template <class T >
315318inline typename arg_rvalue_from_python<T>::result_type
316- arg_rvalue_from_python<T>::operator ()(PyObject* p )
319+ arg_rvalue_from_python<T>::operator ()()
317320{
318321 if (m_data.stage1 .construct != 0 )
319- m_data.stage1 .construct (p , &m_data.stage1 );
322+ m_data.stage1 .construct (m_source , &m_data.stage1 );
320323
321324 return python::detail::void_ptr_to_reference (m_data.stage1 .convertible , (result_type (*)())0 );
322325}
@@ -325,15 +328,15 @@ arg_rvalue_from_python<T>::operator()(PyObject* p)
325328//
326329template <class T >
327330back_reference_arg_from_python<T>::back_reference_arg_from_python(PyObject* x)
328- : base(x)
331+ : base(x), m_source (x)
329332{
330333}
331334
332335template <class T >
333336inline T
334- back_reference_arg_from_python<T>::operator ()(PyObject* x )
337+ back_reference_arg_from_python<T>::operator ()()
335338{
336- return T (x , base::operator ()(x ));
339+ return T (m_source , base::operator ()());
337340}
338341
339342}}} // namespace boost::python::converter
0 commit comments