From 2f4e12916d8c1f7b801786c0ff68760efe1eff32 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 29 Sep 2002 16:26:04 +0000 Subject: [PATCH] doc update [SVN r15550] --- doc/v2/data_members.html | 121 +++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 56 deletions(-) diff --git a/doc/v2/data_members.html b/doc/v2/data_members.html index 820bb1d4..5ec6ff01 100644 --- a/doc/v2/data_members.html +++ b/doc/v2/data_members.html @@ -1,109 +1,118 @@ - + + + + Boost.Python - <boost/python/data_members.hpp> + + +
-

-

+

C++ Boost

+

Boost.Python

-

Header <boost/python/data_members.hpp>

+

Header + <boost/python/data_members.hpp>

+

Contents

-
Introduction +
Introduction
-
Functions +
Functions
-
make_getter +
make_getter
-
make_setter +
make_setter
+
-
Example +
Example

Introduction

make_getter() and - make_setter() are - the functions used internally by class_<>::make_setter() are the + functions used internally by class_<>::def_readonly and class_<>::def_readwrite to - produce Python callable objects which wrap C++ data members. + "class.html#class_-spec-modifiers">def_readwrite to produce + Python callable objects which wrap C++ data members.

Functions

-
 template <class C, class D>
-objects::function* make_getter(D C::*pm);
+object make_getter(D C::*pm);
 
 template <class C, class D, class Policies>
-objects::function* make_getter(D C::*pm, Policies const& policies);
+object make_getter(D C::*pm, Policies const& policies);
 
-
Requires: Policies is a model of CallPolicies. +
Requires: Policies is a model of CallPolicies.
-
Effects: Creates a Python callable object which - accepts a single argument that can be converted - from_python to C*, and returns the - corresponding member D member of the C - object, converted to_python. If - policies is supplied, it will be applied to the - function as described here. +
Effects: Creates a Python callable object which accepts a + single argument that can be converted from_python to + C*, and returns the corresponding member D + member of the C object, converted to_python. + If policies is supplied, it will be applied to the + function as described here.
-
Returns: A pointer convertible to PyObject* which - refers to the new Python callable object. +
Returns: An instance of object which holds the new Python + callable object.
 template <class C, class D>
-objects::function* make_setter(D C::*pm);
+object make_setter(D C::*pm);
 
 template <class C, class D, class Policies>
-objects::function* make_setter(D C::*pm, Policies const& policies);
+object make_setter(D C::*pm, Policies const& policies);
 
-
Requires: Policies is a model of CallPolicies. +
Requires: Policies is a model of CallPolicies.
-
Effects: Creates a Python callable object which, when - called from Python, expects two arguments which can be converted +
Effects: Creates a Python callable object which, when called + from Python, expects two arguments which can be converted from_python to C* and D const&, respectively, and sets the - corresponding D member of the C - object. If policies is supplied, it will be applied - to the function as described here. + corresponding D member of the C object. If + policies is supplied, it will be applied to the function + as described here.
-
Returns: A pointer convertible to - PyObject* which refers to the new Python callable - object. +
Returns: An instance of object which holds the new Python + callable object.

Example

-

The code below uses make_getter and make_setter to expose a - data member as functions: - +

The code below uses make_getter and make_setter to expose a data + member as functions:

 #include <boost/python/data_members.hpp>
 #include <boost/python/module.hpp>
@@ -119,14 +128,10 @@ using namespace boost::python;
 
 BOOST_PYTHON_MODULE_INIT(data_members_example)
 {
-    module("data_members_example")
-        .add(
-            class_<X>("X")
-               .def_init(args<int>())
-               .def("get", make_getter(&X::y))
-               .def("set", make_setter(&X::y))
-        )
-        ;
+    class_<X>("X", init<int>())
+       .def("get", make_getter(&X::y))
+       .def("set", make_setter(&X::y))
+       ;
 }
 
It can be used this way in Python: @@ -142,9 +147,13 @@ BOOST_PYTHON_MODULE_INIT(data_members_example)

- 8 May 2002 + 29 September 2002 + +

- -

© Copyright Dave - Abrahams 2002. All Rights Reserved. +

© Copyright Dave Abrahams 2002. All Rights + Reserved.

+ +