2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 18:12:43 +00:00

always use ref (counting) for safety

[SVN r12393]
This commit is contained in:
Dave Abrahams
2002-01-21 06:23:33 +00:00
parent 078585db28
commit 93501af046
3 changed files with 6 additions and 5 deletions

View File

@@ -38,8 +38,8 @@ struct BOOST_PYTHON_DECL class_base : noncopyable
// any bases.
);
// Retrieve a pointer to the underlying object
PyObject* object() const { return m_object.get(); }
// Retrieve the underlying object
ref object() const { return m_object; }
private:
ref m_object;
};

View File

@@ -9,6 +9,7 @@
# include <boost/python/converter/class.hpp>
# include <boost/python/object/class_wrapper.hpp>
# include <boost/mpl/for_each.hpp>
# include <boost/python/reference.hpp>
namespace boost { namespace python { namespace objects {
@@ -20,7 +21,7 @@ struct class_converters
{
public: // member functions
// Constructor takes the python class object associated with T
class_converters(PyObject* python_class);
class_converters(ref const& python_class);
private: // data members
converter::class_unwrapper<Derived> m_unwrapper;
@@ -86,7 +87,7 @@ struct register_base_of
};
template <class Derived, class Bases>
class_converters<Derived,Bases>::class_converters(PyObject* type_object)
class_converters<Derived,Bases>::class_converters(ref const& type_object)
: m_wrapper(type_object)
{
// register all up/downcasts here

View File

@@ -18,7 +18,7 @@ template <class T>
struct class_wrapper
: converter::wrapper<T const&>
{
class_wrapper(PyObject* type_)
class_wrapper(ref const& type_)
: m_class_object(type_)
{
# ifndef NDEBUG