2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-29 07:42:36 +00:00

Added return_by_value, enhanced data member support to handle constant members

[SVN r15935]
This commit is contained in:
Dave Abrahams
2002-10-15 15:46:34 +00:00
parent 2c7829f50e
commit c389e057b4
7 changed files with 241 additions and 20 deletions

View File

@@ -11,7 +11,7 @@
# include <boost/type_traits/transform_traits.hpp>
# include <boost/type_traits/cv_traits.hpp>
# include <boost/python/return_value_policy.hpp>
# include <boost/python/copy_non_const_reference.hpp>
# include <boost/python/return_by_value.hpp>
# include <boost/python/object/function_object.hpp>
# include <boost/python/arg_from_python.hpp>
# include <boost/bind.hpp>
@@ -65,7 +65,7 @@ namespace detail
template <class C, class D>
object make_getter(D C::*pm)
{
typedef return_value_policy<copy_non_const_reference> default_policy;
typedef return_value_policy<return_by_value> default_policy;
return objects::function_object(
::boost::bind(

View File

@@ -10,7 +10,7 @@
# include <boost/python/class.hpp>
# include <boost/python/object/class_detail.hpp>
# include <boost/python/return_value_policy.hpp>
# include <boost/python/copy_const_reference.hpp>
# include <boost/python/return_by_value.hpp>
# include <boost/python/object/function_object.hpp>
# include <boost/python/handle.hpp>
# include <boost/type.hpp>
@@ -29,18 +29,7 @@ namespace boost { namespace python { namespace objects {
// iterators are copied, so we just replace the result_converter from
// the default_iterator_call_policies with a permissive one which
// always copies the result.
struct default_iterator_call_policies
: default_call_policies
{
struct result_converter
{
template <class R>
struct apply
{
typedef to_python_value<R> type;
};
};
};
typedef return_value_policy<return_by_value> default_iterator_call_policies;
// Instantiations of these are wrapped to produce Python iterators.
template <class NextPolicies, class Iterator>

View File

@@ -0,0 +1,30 @@
// Copyright David Abrahams 2002. Permission to copy, use,
// modify, sell and distribute this software is granted provided this
// copyright notice appears in all copies. This software is provided
// "as is" without express or implied warranty, and with no claim as
// to its suitability for any purpose.
#ifndef BY_VALUE_DWA20021015_HPP
# define BY_VALUE_DWA20021015_HPP
# include <boost/python/to_python_value.hpp>
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/add_const.hpp>
namespace boost { namespace python {
struct return_by_value
{
template <class R>
struct apply
{
typedef to_python_value<
typename add_reference<
typename add_const<R>::type
>::type
> type;
};
};
}} // namespace boost::python
#endif // BY_VALUE_DWA20021015_HPP