Skip to content

Commit a9baa51

Browse files
committed
Extract implemented
[SVN r14510]
1 parent a6c859c commit a9baa51

File tree

14 files changed

+568
-109
lines changed

14 files changed

+568
-109
lines changed

include/boost/python/converter/always_extract_object_manager.hpp

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

include/boost/python/converter/from_python.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ BOOST_PYTHON_DECL rvalue_from_python_chain const* implicit_conversion_chain(
2424
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* source, rvalue_from_python_stage1_data&, registration const&);
29+
2730
BOOST_PYTHON_DECL void* rvalue_result_from_python(
2831
PyObject*, rvalue_from_python_stage1_data&);
2932

@@ -32,6 +35,8 @@ BOOST_PYTHON_DECL void* pointer_result_from_python(PyObject*, registration const
3235

3336
BOOST_PYTHON_DECL void void_result_from_python(PyObject*);
3437

38+
BOOST_PYTHON_DECL void throw_no_pointer_from_python(PyObject*, registration const&);
39+
BOOST_PYTHON_DECL void throw_no_reference_from_python(PyObject*, registration const&);
3540

3641
}}} // namespace boost::python::converter
3742

include/boost/python/converter/obj_mgr_arg_from_python.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ inline object_manager_value_arg_from_python<T>::object_manager_value_arg_from_py
5757
template <class T>
5858
inline bool object_manager_value_arg_from_python<T>::convertible() const
5959
{
60-
return extract_object_manager<T>::check(m_source);
60+
return object_manager_traits<T>::check(m_source);
6161
}
6262

6363
template <class T>
@@ -83,7 +83,7 @@ namespace detail
8383
template <class T>
8484
inline bool object_manager_ref_check(T const& x)
8585
{
86-
return extract_object_manager<T>::check((get_managed_object)(x));
86+
return object_manager_traits<T>::check((get_managed_object)(x));
8787
}
8888
}
8989

include/boost/python/converter/object_manager.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ namespace boost { namespace python { namespace converter {
3939
//
4040
// X::is_specialized == true
4141
//
42-
// T(X::execute(p)) - constructs a T object from p, or throws a
43-
// TypeError exception if p doesn't have an appropriate type.
42+
// T(X::adopt(p)) - constructs a T object, stealing a reference to
43+
// p, or throws a TypeError exception if p doesn't have an
44+
// appropriate type.
4445
//
45-
// X::check(p), convertible to bool. True iff T(X::execute(p)) will
46+
// X::check(p), convertible to bool. True iff T(X::construct(p)) will
4647
// not throw.
48+
//
4749
template <class T>
48-
struct extract_object_manager
50+
struct object_manager_traits
4951
{
5052
BOOST_STATIC_CONSTANT(bool, is_specialized = false);
5153
};
@@ -58,9 +60,9 @@ struct is_object_manager
5860
// handle the cases that would otherwise require partial specialization
5961
BOOST_STATIC_CONSTANT(bool, hdl = is_handle<T>::value);
6062
BOOST_STATIC_CONSTANT(bool, borrowed = python::detail::is_borrowed_ptr<T>::value);
61-
BOOST_STATIC_CONSTANT(bool, extract_specialized = extract_object_manager<T>::is_specialized);
63+
BOOST_STATIC_CONSTANT(bool, traits_specialized = object_manager_traits<T>::is_specialized);
6264
public:
63-
BOOST_STATIC_CONSTANT(bool, value = (hdl | borrowed | extract_specialized));
65+
BOOST_STATIC_CONSTANT(bool, value = (hdl | borrowed | traits_specialized));
6466
};
6567

6668
# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION

include/boost/python/converter/pytype_extract_object_manager.hpp renamed to include/boost/python/converter/pytype_object_manager_traits.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
// copyright notice appears in all copies. This software is provided
44
// "as is" without express or implied warranty, and with no claim as
55
// to its suitability for any purpose.
6-
#ifndef PYTYPE_EXTRACT_OBJECT_MANAGER_DWA2002716_HPP
7-
# define PYTYPE_EXTRACT_OBJECT_MANAGER_DWA2002716_HPP
6+
#ifndef PYTYPE_OBJECT_MANAGER_TRAITS_DWA2002716_HPP
7+
# define PYTYPE_OBJECT_MANAGER_TRAITS_DWA2002716_HPP
88

99
# include <boost/python/converter/pytype_result_from_python.hpp>
1010
# include <boost/python/detail/raw_pyobject.hpp>
@@ -15,34 +15,34 @@ namespace boost { namespace python { namespace converter {
1515

1616
// Provide a forward declaration as a convenience for clients, who all
1717
// need it.
18-
template <class T> struct extract_object_manager;
18+
template <class T> struct object_manager_traits;
1919

20-
// Derive specializations of extract_object_manager from this class
20+
// Derive specializations of object_manager_traits from this class
2121
// when T is an object manager for a particular Python type hierarchy.
2222
//
2323
template <PyTypeObject* pytype, class T>
24-
struct pytype_extract_object_manager
24+
struct pytype_object_manager_traits
2525
{
2626
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
27-
static inline python::detail::new_reference execute(PyObject*);
27+
static inline python::detail::new_reference adopt(PyObject*);
2828
static inline bool check(PyObject* x);
2929
};
3030

3131
//
3232
// implementations
3333
//
3434
template <PyTypeObject* pytype, class T>
35-
inline python::detail::new_reference pytype_extract_object_manager<pytype,T>::execute(PyObject* x)
35+
inline python::detail::new_reference pytype_object_manager_traits<pytype,T>::adopt(PyObject* x)
3636
{
3737
return pytype_result_from_python(pytype, x);
3838
}
3939

4040
template <PyTypeObject* pytype, class T>
41-
inline bool pytype_extract_object_manager<pytype,T>::check(PyObject* x)
41+
inline bool pytype_object_manager_traits<pytype,T>::check(PyObject* x)
4242
{
4343
return ::PyObject_IsInstance(x, python::upcast<PyObject>(pytype));
4444
}
4545

4646
}}} // namespace boost::python::converter
4747

48-
#endif // PYTYPE_EXTRACT_OBJECT_MANAGER_DWA2002716_HPP
48+
#endif // PYTYPE_OBJECT_MANAGER_TRAITS_DWA2002716_HPP

include/boost/python/converter/return_from_python.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ namespace detail
140140
inline T return_object_manager_from_python<T>::operator()(PyObject* obj) const
141141
{
142142
return T(
143-
extract_object_manager<T>::execute(obj)
143+
object_manager_traits<T>::adopt(obj)
144144
);
145145
}
146146
}

0 commit comments

Comments
 (0)