88
99# include < boost/python/converter/find_from_python.hpp>
1010# include < boost/python/detail/wrap_python.hpp>
11- # include < boost/python/detail/destroy.hpp>
1211# include < boost/type_traits/transform_traits.hpp>
1312# include < boost/type_traits/cv_traits.hpp>
1413# include < boost/python/converter/pointer_type_id.hpp>
1514# include < boost/python/converter/from_python_data.hpp>
1615# include < boost/mpl/select_type.hpp>
1716# include < boost/python/converter/registry.hpp>
17+ # include < boost/python/converter/lvalue_from_python_chain.hpp>
18+ # include < boost/python/converter/rvalue_from_python_chain.hpp>
1819
1920namespace boost { namespace python { namespace converter {
2021
@@ -42,8 +43,6 @@ struct pointer_const_reference_from_python
4243
4344 private:
4445 typename detail::referent_storage<T>::type m_result;
45-
46- static lvalue_from_python_registration*& chain;
4746};
4847
4948// Used when T == U*
@@ -52,8 +51,6 @@ struct pointer_from_python : from_python_base
5251{
5352 pointer_from_python (PyObject*);
5453 T operator ()(PyObject*) const ;
55-
56- static lvalue_from_python_registration*& chain;
5754};
5855
5956// Used when T == U& and (T != V const& or T == W volatile&)
@@ -62,8 +59,6 @@ struct reference_from_python : from_python_base
6259{
6360 reference_from_python (PyObject*);
6461 T operator ()(PyObject*) const ;
65-
66- static lvalue_from_python_registration*& chain;
6762};
6863
6964// ------- rvalue converters ---------
@@ -79,14 +74,12 @@ class rvalue_from_python
7974
8075 public:
8176 rvalue_from_python (PyObject*);
82- ~rvalue_from_python ();
8377 bool convertible () const ;
8478
8579 result_type operator ()(PyObject*);
8680
8781 private:
8882 rvalue_data<result_type> m_data;
89- static rvalue_from_python_registration*& chain;
9083};
9184
9285template <class T >
@@ -191,7 +184,7 @@ inline pointer_const_reference_from_python<T>::pointer_const_reference_from_pyth
191184{
192185 detail::write_void_ptr_reference (
193186 m_result.bytes
194- , p == Py_None ? p : find (p, chain )
187+ , p == Py_None ? p : find (p, lvalue_from_python_chain<T>::value )
195188 , (T (*)())0 );
196189}
197190
@@ -208,15 +201,11 @@ inline T pointer_const_reference_from_python<T>::operator()(PyObject* p) const
208201 : detail::void_ptr_to_reference (m_result.bytes , (T (*)())0 );
209202}
210203
211- template <class T >
212- lvalue_from_python_registration*& pointer_const_reference_from_python<T>::chain
213- = registry::lvalue_converters(pointer_type_id<T>());
214-
215204// --------
216205
217206template <class T >
218207inline pointer_from_python<T>::pointer_from_python(PyObject* p)
219- : from_python_base(p == Py_None ? p : find(p, chain ))
208+ : from_python_base(p == Py_None ? p : find(p, lvalue_from_python_chain<T>::value ))
220209{
221210}
222211
@@ -226,15 +215,11 @@ inline T pointer_from_python<T>::operator()(PyObject* p) const
226215 return (p == Py_None) ? 0 : T (result ());
227216}
228217
229- template <class T >
230- lvalue_from_python_registration*& pointer_from_python<T>::chain
231- = registry::lvalue_converters(pointer_type_id<T>());
232-
233218// --------
234219
235220template <class T >
236221inline reference_from_python<T>::reference_from_python(PyObject* p)
237- : from_python_base(find(p,chain ))
222+ : from_python_base(find(p,lvalue_from_python_chain<T>::value ))
238223{
239224}
240225
@@ -244,23 +229,12 @@ inline T reference_from_python<T>::operator()(PyObject*) const
244229 return detail::void_ptr_to_reference (result (), (T (*)())0 );
245230}
246231
247- template <class T >
248- lvalue_from_python_registration*& reference_from_python<T>::chain
249- = registry::lvalue_converters(undecorated_type_id<T>());
250-
251232// -------
252233
253234template <class T >
254235inline rvalue_from_python<T>::rvalue_from_python(PyObject* obj)
236+ : m_data(find(obj, rvalue_from_python_chain<T>::value))
255237{
256- find (obj, chain, m_data.stage1 );
257- }
258-
259- template <class T >
260- inline rvalue_from_python<T>::~rvalue_from_python ()
261- {
262- if (m_data.stage1 .convertible == m_data.storage .bytes )
263- python::detail::destroy_reference<result_type>(m_data.storage .bytes );
264238}
265239
266240template <class T >
@@ -279,10 +253,6 @@ rvalue_from_python<T>::operator()(PyObject* p)
279253 return detail::void_ptr_to_reference (m_data.stage1 .convertible , (result_type (*)())0 );
280254}
281255
282- template <class T >
283- rvalue_from_python_registration*& rvalue_from_python<T>::chain
284- = registry::rvalue_converters(undecorated_type_id<T>());
285-
286256}}} // namespace boost::python::converter
287257
288258#endif // FROM_PYTHON_DWA2002127_HPP
0 commit comments