diff --git a/doc/v2/has_back_reference.html b/doc/v2/has_back_reference.html index a31cf448..c6d752dc 100644 --- a/doc/v2/has_back_reference.html +++ b/doc/v2/has_back_reference.html @@ -1,77 +1,82 @@ - - + +
+ + -|
- |
Boost.PythonHeader <boost/python/has_back_reference.hpp>+ |
+
<boost/python/has_back_reference.hpp>
- defines the traits class template
- has_back_reference<>, which can be
- specialized by the user to indicate that a wrapped class
- instance holds a PyObject* corresponding to a
- Python object.
+
<boost/python/has_back_reference.hpp> defines the
+ traits class template has_back_reference<>, which can
+ be specialized by the user to indicate that a wrapped class instance
+ holds a PyObject* corresponding to a Python object.
has_back_referenceA unary metafunction whose value is true iff
- its argument is a pointer_wrapper<>.
+
A unary metafunction whose value is true iff its argument
+ is a pointer_wrapper<>.
has_back_reference synopsishas_back_reference synopsis
namespace boost { namespace python
{
@@ -82,36 +87,33 @@ namespace boost { namespace python
}}
- A "traits - class" which is inspected by Boost.Python to - determine how wrapped classes can be constructed. +
A "traits + class" which is inspected by Boost.Python to determine how wrapped + classes can be constructed.
value is an integral constant convertible
- to bool of unspecified type.
+ value is an integral constant convertible to bool of
+ unspecified type.true for value iff for each invocation of
- class_<WrappedClass>::def_init(args<type-sequence...>()),
- there exists a corresponding constructor
- WrappedClass::WrappedClass(PyObject*, type-sequence...). If
- such a specialization exists, the WrappedClass
- constructors will be called with a "back reference" pointer
- to the corresponding Python object whenever they are invoked from
- Python.
-
+ true for value iff for each invocation of
+ class_<WrappedClass>::def_init(args<type-sequence...
+ >()), there exists a corresponding constructor
+ WrappedClass::WrappedClass(PyObject*, type-sequence...
+ ). If such a specialization exists, the
+ WrappedClass constructors will be called with a "back
+ reference" pointer to the corresponding Python object whenever they are
+ invoked from Python.
#include <boost/python/class.hpp>
#include <boost/python/module.hpp>
#include <boost/python/has_back_reference.hpp>
+#include <boost/python/handle.hpp>
#include <boost/shared_ptr.hpp>
using namespace boost::python;
@@ -121,7 +123,7 @@ struct X
X(PyObject* self) : m_self(self), m_x(0) {}
X(PyObject* self, int x) : m_self(self), m_x(x) {}
- PyObject* self() { return m_self; }
+ handle<> self() { return handle<>(borrowed(m_self)); }
int get() { return m_x; }
void set(int x) { m_x = x; }
@@ -153,34 +155,27 @@ boost::shared_ptr<Y> Y_self(boost::shared_ptr<Y> self) const { retur
BOOST_PYTHON_MODULE_INIT(back_references)
{
- module("back_references")
- .add(
- class_<X>("X")
- .def_init()
- .def_init(args<int>())
- .def("self", &X::self)
- .def("get", &X::get)
- .def("set", &X::set)
- )
- .add(
- class_<Y, shared_ptr<Y> >("Y")
- .def_init()
- .def_init(args<int>())
- .def("get", &Y::get)
- .def("set", &Y::set)
- .def("self", Y_self)
- )
- ;
+ class_<X>("X")
+ .def(init<int>())
+ .def("self", &X::self)
+ .def("get", &X::get)
+ .def("set", &X::set)
+ ;
+
+ class_<Y, shared_ptr<Y> >("Y")
+ .def(init<int>())
+ .def("get", &Y::get)
+ .def("set", &Y::set)
+ .def("self", Y_self)
+ ;
}
+ The following Python session illustrates that x.self()
+ returns the same Python object on which it is invoked, while
+ y.self() must create a new Python object which refers to the
+ same Y instance.
-The following Python session illustrates that x.self()
-returns the same Python object on which it is invoked, while
-y.self() must create a new Python object which refers to
-the same Y instance.
-
-
>>> from back_references import *
>>> x = X(1)
@@ -207,11 +202,13 @@ the same Y instance.
Revised
- 07 May, 2002
+ 29 September, 2002
+
-
- © Copyright Dave Abrahams
- 2002. All Rights Reserved.
+
© Copyright Dave Abrahams 2002. All Rights
+ Reserved.
+
+