Skip to content

Commit e6fd78c

Browse files
committed
Fixes for auto_ptr handling
[SVN r22490]
1 parent aeed5f0 commit e6fd78c

File tree

8 files changed

+39
-52
lines changed

8 files changed

+39
-52
lines changed

include/boost/python/data_members.hpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
# include <boost/python/detail/indirect_traits.hpp>
2121
# include <boost/python/detail/not_specified.hpp>
22+
# include <boost/python/detail/value_arg.hpp>
2223

2324
# include <boost/type_traits/add_const.hpp>
2425
# include <boost/type_traits/add_reference.hpp>
@@ -51,10 +52,6 @@ namespace detail
5152
template <class Data, class Class>
5253
struct member
5354
{
54-
private:
55-
typedef typename add_const<Data>::type data_const;
56-
typedef typename add_reference<data_const>::type data_cref;
57-
5855
public:
5956
member(Data Class::*which) : m_which(which) {}
6057

@@ -63,7 +60,7 @@ namespace detail
6360
return c.*m_which;
6461
}
6562

66-
void operator()(Class& c, data_cref d) const
63+
void operator()(Class& c, typename value_arg<Data>::type d) const
6764
{
6865
c.*m_which = d;
6966
}
@@ -76,10 +73,6 @@ namespace detail
7673
template <class Data>
7774
struct datum
7875
{
79-
private:
80-
typedef typename add_const<Data>::type data_const;
81-
typedef typename add_reference<data_const>::type data_cref;
82-
8376
public:
8477
datum(Data *which) : m_which(which) {}
8578

@@ -88,7 +81,7 @@ namespace detail
8881
return *m_which;
8982
}
9083

91-
void operator()(data_cref d) const
84+
void operator()(typename value_arg<Data>::type d) const
9285
{
9386
*m_which = d;
9487
}
@@ -112,11 +105,11 @@ namespace detail
112105
: mpl::and_<
113106
mpl::bool_<
114107
to_python_value<
115-
typename add_reference<typename add_const<T>::type>::type
108+
typename value_arg<T>::type
116109
>::uses_registry
117110
>
118111
, is_reference_to_class<
119-
typename add_reference<typename add_const<T>::type>::type
112+
typename value_arg<T>::type
120113
>
121114
>
122115
{

include/boost/python/default_call_policies.hpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
# include <boost/python/detail/prefix.hpp>
1010
# include <boost/mpl/if.hpp>
1111
# include <boost/python/to_python_value.hpp>
12+
# include <boost/python/detail/value_arg.hpp>
1213
# include <boost/type_traits/transform_traits.hpp>
14+
# include <boost/type_traits/is_pointer.hpp>
15+
# include <boost/type_traits/is_reference.hpp>
16+
# include <boost/mpl/or.hpp>
1317

1418
namespace boost { namespace python {
1519

@@ -53,14 +57,12 @@ struct default_result_converter
5357
template <class R>
5458
struct apply
5559
{
56-
BOOST_STATIC_CONSTANT(bool, is_illegal = is_reference<R>::value || is_pointer<R>::value);
57-
58-
typedef typename mpl::if_c<
59-
is_illegal
60-
, detail::specify_a_return_value_policy_to_wrap_functions_returning<R>
61-
, boost::python::to_python_value<
62-
typename add_reference<typename add_const<R>::type>::type
63-
>
60+
typedef typename mpl::if_<
61+
mpl::or_<is_pointer<R>, is_reference<R> >
62+
, detail::specify_a_return_value_policy_to_wrap_functions_returning<R>
63+
, boost::python::to_python_value<
64+
typename detail::value_arg<R>::type
65+
>
6466
>::type type;
6567
};
6668
};

include/boost/python/object/forward.hpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
# include <boost/type_traits/add_const.hpp>
1212
# include <boost/type_traits/add_reference.hpp>
1313
# include <boost/ref.hpp>
14+
# include <boost/python/detail/value_arg.hpp>
15+
# include <boost/python/detail/copy_ctor_mutates_rhs.hpp>
1416
# if BOOST_WORKAROUND(BOOST_MSVC, == 1200)
1517
# include <boost/type_traits/is_enum.hpp>
1618
# include <boost/mpl/and.hpp>
1719
# include <boost/mpl/not.hpp>
20+
# else
21+
# include <boost/mpl/or.hpp>
1822
# endif
1923

2024
namespace boost { namespace python { namespace objects {
@@ -48,7 +52,7 @@ struct forward
4852
>
4953
>
5054
# else
51-
is_scalar<T>
55+
mpl::or_<python::detail::copy_ctor_mutates_rhs<T>, is_scalar<T> >
5256
# endif
5357
, T
5458
, reference_to_value<T>
@@ -71,10 +75,8 @@ struct unforward<reference_to_value<T> >
7175

7276
template <typename T>
7377
struct unforward_cref
74-
: add_reference<
75-
typename add_const<
76-
typename unwrap_reference<T>::type
77-
>::type
78+
: python::detail::value_arg<
79+
typename unwrap_reference<T>::type
7880
>
7981
{
8082
};
@@ -122,10 +124,8 @@ namespace detail
122124
{
123125
template <class T>
124126
struct apply
125-
: add_reference<
126-
typename add_const<
127-
typename unwrap_reference<T>::type
128-
>::type
127+
: python::detail::value_arg<
128+
typename unwrap_reference<T>::type
129129
>
130130
{
131131
};
@@ -136,11 +136,9 @@ namespace detail
136136
{
137137
template <class T>
138138
struct apply
139-
: add_reference<
140-
typename add_const<
141-
typename T::reference
142-
>::type
143-
>
139+
: python::detail::value_arg<
140+
typename T::reference
141+
>
144142
{
145143
};
146144
};

include/boost/python/object_core.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ namespace api
176176
# endif
177177

178178
private: // def visitation for adding callable objects as class methods
179+
using def_visitor<U>::visit;
180+
179181
template <class ClassT, class DocStringT>
180182
void visit(ClassT& cl, char const* name, python::detail::def_helper<DocStringT> const& helper) const
181183
{

include/boost/python/return_arg.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# define RETURN_ARG_DWA2003719_HPP
88
# include <boost/python/default_call_policies.hpp>
99
# include <boost/python/detail/none.hpp>
10+
# include <boost/python/detail/value_arg.hpp>
1011

1112
# include <boost/type_traits/add_reference.hpp>
1213
# include <boost/type_traits/add_const.hpp>
@@ -40,11 +41,7 @@ namespace detail
4041
return true;
4142
}
4243

43-
PyObject *operator()(
44-
typename add_reference<
45-
typename add_const<T>::type
46-
>::type
47-
) const
44+
PyObject *operator()( typename value_arg<T>::type ) const
4845
{
4946
return none();
5047
}

include/boost/python/return_by_value.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# include <boost/type_traits/add_reference.hpp>
1313
# include <boost/type_traits/add_const.hpp>
1414

15+
# include <boost/python/detail/value_arg.hpp>
16+
1517
namespace boost { namespace python {
1618

1719
struct return_by_value
@@ -20,9 +22,7 @@ struct return_by_value
2022
struct apply
2123
{
2224
typedef to_python_value<
23-
typename add_reference<
24-
typename add_const<R>::type
25-
>::type
25+
typename detail::value_arg<R>::type
2626
> type;
2727
};
2828
};

include/boost/python/to_python_value.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# include <boost/python/converter/shared_ptr_to_python.hpp>
2020

2121
# include <boost/python/detail/value_is_shared_ptr.hpp>
22+
# include <boost/python/detail/value_arg.hpp>
2223

2324
# include <boost/type_traits/transform_traits.hpp>
2425

@@ -32,9 +33,7 @@ namespace detail
3233
template <class T>
3334
struct object_manager_to_python_value
3435
{
35-
typedef typename add_reference<
36-
typename add_const<T>::type
37-
>::type argument_type;
36+
typedef typename value_arg<T>::type argument_type;
3837

3938
PyObject* operator()(argument_type) const;
4039

@@ -48,9 +47,7 @@ namespace detail
4847
template <class T>
4948
struct registry_to_python_value
5049
{
51-
typedef typename add_reference<
52-
typename add_const<T>::type
53-
>::type argument_type;
50+
typedef typename value_arg<T>::type argument_type;
5451

5552
PyObject* operator()(argument_type) const;
5653

@@ -63,9 +60,7 @@ namespace detail
6360
template <class T>
6461
struct shared_ptr_to_python_value
6562
{
66-
typedef typename add_reference<
67-
typename add_const<T>::type
68-
>::type argument_type;
63+
typedef typename value_arg<T>::type argument_type;
6964

7065
PyObject* operator()(argument_type) const;
7166

test/as_to_python_function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// "as is" without express or implied warranty, and with no claim as
55
// to its suitability for any purpose.
66

7-
#include <boost/python/converter/to_python_function_type.hpp>
7+
#include <boost/python/converter/as_to_python_function.hpp>
88

99
struct hopefully_illegal
1010
{

0 commit comments

Comments
 (0)