Skip to content

Commit 149c60b

Browse files
committed
Still further rationalized conversion registry
[SVN r14462]
1 parent 9795a27 commit 149c60b

File tree

8 files changed

+167
-177
lines changed

8 files changed

+167
-177
lines changed

Jamfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ dll bpl
2727
src/module.cpp
2828
src/objects2.cpp
2929
src/converter/builtin_converters.cpp
30-
src/converter/callback.cpp
30+
src/converter/arg_to_python_base.cpp
3131
src/object/iterator.cpp
3232
src/object_protocol.cpp
3333
src/object_operators.cpp

include/boost/python/converter/arg_from_python.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef ARG_FROM_PYTHON_DWA2002127_HPP
77
# define ARG_FROM_PYTHON_DWA2002127_HPP
88

9-
# include <boost/python/converter/find_from_python.hpp>
9+
# include <boost/python/converter/from_python.hpp>
1010
# include <boost/python/detail/wrap_python.hpp>
1111
# include <boost/python/detail/indirect_traits.hpp>
1212
# include <boost/type_traits/transform_traits.hpp>

include/boost/python/converter/callback_from_python_base.hpp

Lines changed: 0 additions & 24 deletions
This file was deleted.

include/boost/python/converter/find_from_python.hpp renamed to include/boost/python/converter/from_python.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ struct rvalue_from_python_chain;
1818
BOOST_PYTHON_DECL void* get_lvalue_from_python(
1919
PyObject* source, registration const&);
2020

21-
BOOST_PYTHON_DECL rvalue_from_python_stage1_data rvalue_from_python_stage1(
21+
BOOST_PYTHON_DECL rvalue_from_python_chain const* implicit_conversion_chain(
2222
PyObject* source, registration const&);
2323

24-
BOOST_PYTHON_DECL rvalue_from_python_chain const* implicit_conversion_chain(
24+
BOOST_PYTHON_DECL rvalue_from_python_stage1_data rvalue_from_python_stage1(
2525
PyObject* source, registration const&);
2626

27+
BOOST_PYTHON_DECL void* rvalue_from_python_stage2(
28+
PyObject*, rvalue_from_python_stage1_data&, void* storage);
29+
30+
BOOST_PYTHON_DECL void* reference_from_python(PyObject*, registration const&);
31+
BOOST_PYTHON_DECL void* pointer_from_python(PyObject*, registration const&);
32+
33+
BOOST_PYTHON_DECL void void_from_python(PyObject*);
34+
35+
2736
}}} // namespace boost::python::converter
2837

2938
#endif // FIND_FROM_PYTHON_DWA2002223_HPP

include/boost/python/converter/return_from_python.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef RETURN_FROM_PYTHON_DWA200265_HPP
77
# define RETURN_FROM_PYTHON_DWA200265_HPP
88

9-
# include <boost/python/converter/callback_from_python_base.hpp>
9+
# include <boost/python/converter/from_python.hpp>
1010
# include <boost/python/converter/rvalue_from_python_data.hpp>
1111
# include <boost/python/converter/registered.hpp>
1212
# include <boost/python/converter/registered_pointee.hpp>
@@ -77,7 +77,7 @@ struct return_from_python<void>
7777

7878
result_type operator()(PyObject* x) const
7979
{
80-
converter::detail::absorb_result(x);
80+
converter::void_from_python(x);
8181
# ifdef BOOST_NO_VOID_RETURNS
8282
return result_type();
8383
# endif
@@ -101,21 +101,21 @@ namespace detail
101101
inline typename return_rvalue_from_python<T>::result_type
102102
return_rvalue_from_python<T>::operator()(PyObject* obj)
103103
{
104-
return *(T*)convert_rvalue(obj, m_data.stage1, m_data.storage.bytes);
104+
return *(T*)rvalue_from_python_stage2(obj, m_data.stage1, m_data.storage.bytes);
105105
}
106106

107107
template <class T>
108108
inline T return_reference_from_python<T>::operator()(PyObject* obj) const
109109
{
110110
return python::detail::void_ptr_to_reference(
111-
callback_convert_reference(obj, registered<T>::converters)
111+
reference_from_python(obj, registered<T>::converters)
112112
, (T(*)())0);
113113
}
114114

115115
template <class T>
116116
inline T return_pointer_from_python<T>::operator()(PyObject* obj) const
117117
{
118-
return T(callback_convert_pointer(obj, registered_pointee<T>::converters));
118+
return T(pointer_from_python(obj, registered_pointee<T>::converters));
119119
}
120120
}
121121

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright David Abrahams 2002. Permission to copy, use,
2+
// modify, sell and distribute this software is granted provided this
3+
// copyright notice appears in all copies. This software is provided
4+
// "as is" without express or implied warranty, and with no claim as
5+
// to its suitability for any purpose.
6+
7+
#include <boost/python/converter/arg_to_python_base.hpp>
8+
#include <boost/python/errors.hpp>
9+
#include <boost/python/converter/registrations.hpp>
10+
#include <boost/python/handle.hpp>
11+
#include <boost/python/refcount.hpp>
12+
13+
namespace boost { namespace python { namespace converter {
14+
15+
namespace
16+
{
17+
inline PyObject* convert_to_python(void const volatile* source, registration const& converters)
18+
{
19+
if (converters.to_python == 0)
20+
{
21+
handle<> msg(
22+
::PyString_FromFormat(
23+
"No to_python (by-value) converter found for C++ type: %s"
24+
, converters.target_type.name()));
25+
26+
PyErr_SetObject(PyExc_TypeError, msg.get());
27+
28+
throw_error_already_set();
29+
}
30+
31+
return source == 0
32+
? incref(Py_None)
33+
: converters.to_python(const_cast<void*>(source));
34+
}
35+
}
36+
37+
namespace detail
38+
{
39+
arg_to_python_base::arg_to_python_base(
40+
void const volatile* source, registration const& converters)
41+
# if !defined(BOOST_MSVC) || _MSC_FULL_VER != 13102140
42+
: handle<>(converter::convert_to_python(source, converters))
43+
# else
44+
: m_ptr(converter::convert_to_python(source, converters))
45+
# endif
46+
{
47+
}
48+
49+
BOOST_PYTHON_DECL void throw_no_class_registered()
50+
{
51+
PyErr_SetString(
52+
PyExc_TypeError
53+
, const_cast<char*>("class not registered for to_python type"));
54+
throw_error_already_set();
55+
}
56+
}
57+
58+
}}} // namespace boost::python::converter

src/converter/callback.cpp

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)