shared_ptr -> std::shared_ptr
This is one of the first commits in a plan to remove all `using namespace std;` lines in the entire codebase as it is considered anti-pattern today.
This commit is contained in:
@@ -16,12 +16,12 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
// You'll see shared_ptr mentioned in this header because we need to
|
||||
// You'll see std::shared_ptr mentioned in this header because we need to
|
||||
// note which types are shared_ptrs in their registrations, to
|
||||
// implement special shared_ptr handling for rvalue conversions.
|
||||
template <class T> class shared_ptr;
|
||||
// implement special std::shared_ptr handling for rvalue conversions.
|
||||
template <class T> class std::shared_ptr;
|
||||
|
||||
namespace python { namespace converter {
|
||||
namespace python { namespace converter {
|
||||
|
||||
struct registration;
|
||||
|
||||
@@ -64,23 +64,23 @@ namespace detail
|
||||
register_shared_ptr0(...)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
register_shared_ptr0(shared_ptr<T>*)
|
||||
register_shared_ptr0(std::shared_ptr<T>*)
|
||||
{
|
||||
registry::lookup_shared_ptr(type_id<shared_ptr<T> >());
|
||||
registry::lookup_shared_ptr(type_id<std::shared_ptr<T> >());
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline void
|
||||
register_shared_ptr1(T const volatile*)
|
||||
{
|
||||
detail::register_shared_ptr0((T*)0);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline registration const&
|
||||
inline registration const&
|
||||
registry_lookup2(T&(*)())
|
||||
{
|
||||
detail::register_shared_ptr1((T*)0);
|
||||
@@ -88,13 +88,13 @@ namespace detail
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline registration const&
|
||||
inline registration const&
|
||||
registry_lookup1(type<T>)
|
||||
{
|
||||
return registry_lookup2((T(*)())0);
|
||||
}
|
||||
|
||||
inline registration const&
|
||||
inline registration const&
|
||||
registry_lookup1(type<const volatile void>)
|
||||
{
|
||||
detail::register_shared_ptr1((void*)0);
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
# include <boost/detail/workaround.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
struct lvalue_from_python_chain
|
||||
{
|
||||
@@ -36,7 +36,7 @@ struct BOOST_PYTHON_DECL registration
|
||||
public: // member functions
|
||||
explicit registration(type_info target, bool is_shared_ptr = false);
|
||||
~registration();
|
||||
|
||||
|
||||
// Convert the appropriately-typed data to Python
|
||||
PyObject* to_python(void const volatile*) const;
|
||||
|
||||
@@ -44,7 +44,7 @@ struct BOOST_PYTHON_DECL registration
|
||||
// exception if no class has been registered.
|
||||
PyTypeObject* get_class_object() const;
|
||||
|
||||
// Return common denominator of the python class objects,
|
||||
// Return common denominator of the python class objects,
|
||||
// convertable to target. Inspects the m_class_object and the value_chains.
|
||||
PyTypeObject const* expected_from_python_type() const;
|
||||
PyTypeObject const* to_python_target_type() const;
|
||||
@@ -57,7 +57,7 @@ struct BOOST_PYTHON_DECL registration
|
||||
|
||||
// The chain of eligible from_python converters when an rvalue is acceptable
|
||||
rvalue_from_python_chain* rvalue_chain;
|
||||
|
||||
|
||||
// The class object associated with this type
|
||||
PyTypeObject* m_class_object;
|
||||
|
||||
@@ -66,14 +66,14 @@ struct BOOST_PYTHON_DECL registration
|
||||
PyTypeObject const* (*m_to_python_target_type)();
|
||||
|
||||
|
||||
// True iff this type is a shared_ptr. Needed for special rvalue
|
||||
// True iff this type is a std::shared_ptr. Needed for special rvalue
|
||||
// from_python handling.
|
||||
const bool is_shared_ptr;
|
||||
|
||||
# if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
||||
private:
|
||||
void operator=(registration); // This is not defined, and just keeps MWCW happy.
|
||||
# endif
|
||||
# endif
|
||||
};
|
||||
|
||||
//
|
||||
|
||||
@@ -21,12 +21,12 @@ namespace registry
|
||||
BOOST_PYTHON_DECL registration const& lookup(type_info);
|
||||
|
||||
// Get the registration corresponding to the type, creating it if
|
||||
// necessary. Use this first when the type is a shared_ptr.
|
||||
// necessary. Use this first when the type is a std::shared_ptr.
|
||||
BOOST_PYTHON_DECL registration const& lookup_shared_ptr(type_info);
|
||||
|
||||
// Return a pointer to the corresponding registration, if one exists
|
||||
BOOST_PYTHON_DECL registration const* query(type_info);
|
||||
|
||||
|
||||
BOOST_PYTHON_DECL void insert(to_python_function_t, type_info, PyTypeObject const* (*to_python_target_type)() = 0);
|
||||
|
||||
// Insert an lvalue from_python converter
|
||||
@@ -39,7 +39,7 @@ namespace registry
|
||||
, type_info
|
||||
, PyTypeObject const* (*expected_pytype)() = 0
|
||||
);
|
||||
|
||||
|
||||
// Insert an rvalue from_python converter at the tail of the
|
||||
// chain. Used for implicit conversions
|
||||
BOOST_PYTHON_DECL void push_back(
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
# include <boost/python/converter/pytype_function.hpp>
|
||||
#endif
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/std::shared_ptr.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
template <class T>
|
||||
struct shared_ptr_from_python
|
||||
{
|
||||
shared_ptr_from_python()
|
||||
{
|
||||
converter::registry::insert(&convertible, &construct, type_id<shared_ptr<T> >()
|
||||
converter::registry::insert(&convertible, &construct, type_id<std::shared_ptr<T> >()
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
, &converter::expected_from_python_type_direct<T>::get_pytype
|
||||
#endif
|
||||
@@ -34,26 +34,26 @@ struct shared_ptr_from_python
|
||||
{
|
||||
if (p == Py_None)
|
||||
return p;
|
||||
|
||||
|
||||
return converter::get_lvalue_from_python(p, registered<T>::converters);
|
||||
}
|
||||
|
||||
|
||||
static void construct(PyObject* source, rvalue_from_python_stage1_data* data)
|
||||
{
|
||||
void* const storage = ((converter::rvalue_from_python_storage<shared_ptr<T> >*)data)->storage.bytes;
|
||||
void* const storage = ((converter::rvalue_from_python_storage<std::shared_ptr<T> >*)data)->storage.bytes;
|
||||
// Deal with the "None" case.
|
||||
if (data->convertible == source)
|
||||
new (storage) shared_ptr<T>();
|
||||
new (storage) std::shared_ptr<T>();
|
||||
else
|
||||
{
|
||||
boost::shared_ptr<void> hold_convertible_ref_count(
|
||||
boost::std::shared_ptr<void> hold_convertible_ref_count(
|
||||
(void*)0, shared_ptr_deleter(handle<>(borrowed(source))) );
|
||||
// use aliasing constructor
|
||||
new (storage) shared_ptr<T>(
|
||||
new (storage) std::shared_ptr<T>(
|
||||
hold_convertible_ref_count,
|
||||
static_cast<T*>(data->convertible));
|
||||
}
|
||||
|
||||
|
||||
data->convertible = storage;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,20 +7,20 @@
|
||||
|
||||
# include <boost/python/refcount.hpp>
|
||||
# include <boost/python/converter/shared_ptr_deleter.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/std::shared_ptr.hpp>
|
||||
# include <boost/get_pointer.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace converter {
|
||||
namespace boost { namespace python { namespace converter {
|
||||
|
||||
template <class T>
|
||||
PyObject* shared_ptr_to_python(shared_ptr<T> const& x)
|
||||
PyObject* shared_ptr_to_python(std::shared_ptr<T> const& x)
|
||||
{
|
||||
if (!x)
|
||||
return python::detail::none();
|
||||
else if (shared_ptr_deleter* d = boost::get_deleter<shared_ptr_deleter>(x))
|
||||
return incref( get_pointer( d->owner ) );
|
||||
else
|
||||
return converter::registered<shared_ptr<T> const&>::converters.to_python(&x);
|
||||
return converter::registered<std::shared_ptr<T> const&>::converters.to_python(&x);
|
||||
}
|
||||
|
||||
}}} // namespace boost::python::converter
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
# define IS_SHARED_PTR_DWA2003224_HPP
|
||||
|
||||
# include <boost/python/detail/is_xxx.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/std::shared_ptr.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
BOOST_PYTHON_IS_XXX_DEF(std::shared_ptr, std::shared_ptr, 1)
|
||||
|
||||
BOOST_PYTHON_IS_XXX_DEF(shared_ptr, shared_ptr, 1)
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
#endif // IS_SHARED_PTR_DWA2003224_HPP
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
# define VALUE_IS_SHARED_PTR_DWA2003224_HPP
|
||||
|
||||
# include <boost/python/detail/value_is_xxx.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/std::shared_ptr.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace detail {
|
||||
namespace boost { namespace python { namespace detail {
|
||||
|
||||
BOOST_PYTHON_VALUE_IS_XXX_DEF(std::shared_ptr, std::shared_ptr, 1)
|
||||
|
||||
BOOST_PYTHON_VALUE_IS_XXX_DEF(shared_ptr, shared_ptr, 1)
|
||||
|
||||
}}} // namespace boost::python::detail
|
||||
|
||||
#endif // VALUE_IS_SHARED_PTR_DWA2003224_HPP
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <cstddef>
|
||||
|
||||
namespace boost { namespace python {
|
||||
namespace boost { namespace python {
|
||||
|
||||
// Base class for all holders
|
||||
struct BOOST_PYTHON_DECL instance_holder : private noncopyable
|
||||
@@ -19,13 +19,13 @@ struct BOOST_PYTHON_DECL instance_holder : private noncopyable
|
||||
public:
|
||||
instance_holder();
|
||||
virtual ~instance_holder();
|
||||
|
||||
|
||||
// return the next holder in a chain
|
||||
instance_holder* next() const;
|
||||
|
||||
// When the derived holder actually holds by [smart] pointer and
|
||||
// null_ptr_only is set, only report that the type is held when
|
||||
// the pointer is null. This is needed for proper shared_ptr
|
||||
// the pointer is null. This is needed for proper std::shared_ptr
|
||||
// support, to prevent holding shared_ptrs from being found when
|
||||
// converting from python so that we can use the conversion method
|
||||
// that always holds the Python object.
|
||||
@@ -34,7 +34,7 @@ struct BOOST_PYTHON_DECL instance_holder : private noncopyable
|
||||
void install(PyObject* inst) throw();
|
||||
|
||||
// These functions should probably be located elsewhere.
|
||||
|
||||
|
||||
// Allocate storage for an object of the given size at the given
|
||||
// offset in the Python instance<> object if bytes are available
|
||||
// there. Otherwise allocate size bytes of heap memory.
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
|
||||
namespace boost { namespace python { namespace objects {
|
||||
namespace boost { namespace python { namespace objects {
|
||||
|
||||
// Given a type_id, find the instance data which corresponds to it, or
|
||||
// return 0 in case no such type is held. If null_shared_ptr_only is
|
||||
// true and the type being sought is a shared_ptr, only find an
|
||||
// instance if it turns out to be NULL. Needed for shared_ptr rvalue
|
||||
// true and the type being sought is a std::shared_ptr, only find an
|
||||
// instance if it turns out to be NULL. Needed for std::shared_ptr rvalue
|
||||
// from_python support.
|
||||
BOOST_PYTHON_DECL void* find_instance_impl(PyObject*, type_info, bool null_shared_ptr_only = false);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# define INHERITANCE_DWA200216_HPP
|
||||
|
||||
# include <boost/python/type_id.hpp>
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# include <boost/std::shared_ptr.hpp>
|
||||
# include <boost/mpl/if.hpp>
|
||||
# include <boost/type_traits/is_polymorphic.hpp>
|
||||
# include <boost/type_traits/is_base_and_derived.hpp>
|
||||
@@ -88,7 +88,7 @@ struct dynamic_cast_generator
|
||||
return dynamic_cast<Target*>(
|
||||
static_cast<Source*>(source));
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
template <class Source, class Target>
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
# include <boost/mpl/bool.hpp>
|
||||
|
||||
# if defined(__ICL) && __ICL < 600
|
||||
# include <boost/shared_ptr.hpp>
|
||||
# else
|
||||
# if defined(__ICL) && __ICL < 600
|
||||
# include <boost/std::shared_ptr.hpp>
|
||||
# else
|
||||
# include <memory>
|
||||
# endif
|
||||
|
||||
@@ -57,7 +57,7 @@ struct to_python_indirect
|
||||
else
|
||||
return this->execute(*ptr, mpl::false_());
|
||||
}
|
||||
|
||||
|
||||
template <class U>
|
||||
inline PyObject* execute(U const& x, mpl::false_) const
|
||||
{
|
||||
@@ -84,9 +84,9 @@ namespace detail
|
||||
// can't use auto_ptr with Intel 5 and VC6 Dinkum library
|
||||
// for some reason. We get link errors against the auto_ptr
|
||||
// copy constructor.
|
||||
# if defined(__ICL) && __ICL < 600
|
||||
typedef boost::shared_ptr<T> smart_pointer;
|
||||
# else
|
||||
# if defined(__ICL) && __ICL < 600
|
||||
typedef boost::std::shared_ptr<T> smart_pointer;
|
||||
# else
|
||||
typedef std::auto_ptr<T> smart_pointer;
|
||||
# endif
|
||||
typedef objects::pointer_holder<smart_pointer, T> holder_t;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
# include <boost/mpl/or.hpp>
|
||||
# include <boost/type_traits/is_const.hpp>
|
||||
|
||||
namespace boost { namespace python {
|
||||
namespace boost { namespace python {
|
||||
|
||||
namespace detail
|
||||
{
|
||||
@@ -58,7 +58,7 @@ struct object_manager_get_pytype<true>
|
||||
struct object_manager_to_python_value
|
||||
{
|
||||
typedef typename value_arg<T>::type argument_type;
|
||||
|
||||
|
||||
PyObject* operator()(argument_type) const;
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
typedef boost::mpl::bool_<is_handle<T>::value> is_t_handle;
|
||||
@@ -68,13 +68,13 @@ struct object_manager_get_pytype<true>
|
||||
}
|
||||
|
||||
inline static PyTypeObject const* get_pytype_aux(mpl::true_*) {return converter::object_manager_traits<T>::get_pytype();}
|
||||
|
||||
inline static PyTypeObject const* get_pytype_aux(mpl::false_* )
|
||||
|
||||
inline static PyTypeObject const* get_pytype_aux(mpl::false_* )
|
||||
{
|
||||
return object_manager_get_pytype<is_t_const::value>::get((T(*)())0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// This information helps make_getter() decide whether to try to
|
||||
// return an internal reference or not. I don't like it much,
|
||||
@@ -82,12 +82,12 @@ struct object_manager_get_pytype<true>
|
||||
BOOST_STATIC_CONSTANT(bool, uses_registry = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class T>
|
||||
struct registry_to_python_value
|
||||
{
|
||||
typedef typename value_arg<T>::type argument_type;
|
||||
|
||||
|
||||
PyObject* operator()(argument_type) const;
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
PyTypeObject const* get_pytype() const {return converter::registered<T>::converters.to_python_target_type();}
|
||||
@@ -103,11 +103,11 @@ struct object_manager_get_pytype<true>
|
||||
struct shared_ptr_to_python_value
|
||||
{
|
||||
typedef typename value_arg<T>::type argument_type;
|
||||
|
||||
|
||||
PyObject* operator()(argument_type) const;
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
PyTypeObject const* get_pytype() const {return get_pytype((boost::type<argument_type>*)0);}
|
||||
#endif
|
||||
#endif
|
||||
// This information helps make_getter() decide whether to try to
|
||||
// return an internal reference or not. I don't like it much,
|
||||
// but it will have to serve for now.
|
||||
@@ -115,9 +115,9 @@ struct object_manager_get_pytype<true>
|
||||
private:
|
||||
#ifndef BOOST_PYTHON_NO_PY_SIGNATURES
|
||||
template <class U>
|
||||
PyTypeObject const* get_pytype(boost::type<shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
|
||||
PyTypeObject const* get_pytype(boost::type<std::shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
|
||||
template <class U>
|
||||
PyTypeObject const* get_pytype(boost::type<const shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
|
||||
PyTypeObject const* get_pytype(boost::type<const std::shared_ptr<U> &> *) const {return converter::registered<U>::converters.to_python_target_type();}
|
||||
#endif
|
||||
};
|
||||
}
|
||||
@@ -140,7 +140,7 @@ struct to_python_value
|
||||
};
|
||||
|
||||
//
|
||||
// implementation
|
||||
// implementation
|
||||
//
|
||||
namespace detail
|
||||
{
|
||||
@@ -151,7 +151,7 @@ namespace detail
|
||||
# if BOOST_WORKAROUND(__GNUC__, < 3)
|
||||
// suppresses an ICE, somehow
|
||||
(void)r::converters;
|
||||
# endif
|
||||
# endif
|
||||
return converter::registered<argument_type>::converters.to_python(&x);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user