From d873aec9e6b36cce62b3d9b7775865e9569e27ee Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 29 Sep 2002 19:15:53 +0000 Subject: [PATCH] doc update [SVN r15557] --- doc/v2/call_method.html | 2 +- doc/v2/implicit.html | 4 +- doc/v2/lvalue_from_pytype.html | 216 ++++++++++++++++++--------------- 3 files changed, 118 insertions(+), 104 deletions(-) diff --git a/doc/v2/call_method.html b/doc/v2/call_method.html index 5323ab07..e5cf7e6b 100644 --- a/doc/v2/call_method.html +++ b/doc/v2/call_method.html @@ -121,7 +121,7 @@ class Base_callback : public Base using namespace boost::python; BOOST_PYTHON_MODULE_INIT(my_module) { - def("is_base", is_base) + def("is_base", is_base); class_<Base,Base_callback, noncopyable>("Base") .def("class_name", &Base_callback::Base_name) diff --git a/doc/v2/implicit.html b/doc/v2/implicit.html index 03832566..aebe2b52 100644 --- a/doc/v2/implicit.html +++ b/doc/v2/implicit.html @@ -123,8 +123,8 @@ X make_x(int n) { return X(n); } BOOST_PYTHON_MODULE_INIT(implicit_ext) { - def("x_value", x_value) - def("make_x", make_x) + def("x_value", x_value); + def("make_x", make_x); class_<X>("X", init<int>()) diff --git a/doc/v2/lvalue_from_pytype.html b/doc/v2/lvalue_from_pytype.html index 8b3cb49e..57997b3a 100755 --- a/doc/v2/lvalue_from_pytype.html +++ b/doc/v2/lvalue_from_pytype.html @@ -1,128 +1,145 @@ - + + + + Boost.Python - <boost/python/lvalue_from_python.hpp> + + +
-

-

+

C++ Boost

+

Boost.Python

-

Header <boost/python/lvalue_from_pytype.hpp>

+

Header + <boost/python/lvalue_from_pytype.hpp>

+

Contents

-
Introduction +
Introduction
- -
Classes +
Classes
-
Class Template lvalue_from_pytype +
Class Template + lvalue_from_pytype
-
Class Template - lvalue_from_pytype synopsis + lvalue_from_pytype synopsis
Class Template - lvalue_from_pytype constructor + lvalue_from_pytype constructor
+
-
Class Template extract_identity +
Class Template + extract_identity
+
-
Class Template - extract_identity synopsis + extract_identity synopsis
Class Template - extract_identity static functions + extract_identity static functions
-
Class Template extract_member +
+ +
Class Template + extract_member
+
-
Class Template - extract_member synopsis + extract_member synopsis
Class Template - extract_member static functions + extract_member static functions
+
+ -
Example +
Example

Introduction

- - <boost/python/lvalue_from_pytype.hpp> supplies - a facility for extracting C++ objects from within Python instances - of a given type. This is typically useful for dealing with - "traditional" Python extension types. + <boost/python/lvalue_from_pytype.hpp> supplies a + facility for extracting C++ objects from within Python instances of a + given type. This is typically useful for dealing with "traditional" + Python extension types.

Classes

-

Class template lvalue_from_pytype

+

Class template + lvalue_from_pytype

Class template lvalue_from_pytype will register - from_python converters which, given an object of the given Python - type, can extract references and pointers to a particular C++ - type. Its template arguments are: - -

- + from_python converters which, given an object of the given Python type, + can extract references and pointers to a particular C++ type. Its + template arguments are:

- - - - - + - - - + + + + + + + +
lvalue_from_pytype Requirements
- - In the table below, x denotes an object of type PythonObject& - + In the table below, x denotes an object of type + PythonObject&
Parameter - - Requirements - - Semantics
Extractor + Parametera model of Extractor whose - execute function returns a reference type. + RequirementsExtracts the lvalue from the Python object once its type has been confirmed + Semantics
python_type + ExtractorA compile-time constant PyTypeObject* + a model of Extractor whose execute + function returns a reference type.The Python type of instances convertible by this - converter. Python subtypes are also convertible. + Extracts the lvalue from the Python object once its type has been + confirmed
python_typeA compile-time constant PyTypeObject*The Python type of instances convertible by this converter. + Python subtypes are also convertible.
-

Class template lvalue_from_pytype synopsis

+

Class template + lvalue_from_pytype synopsis

 namespace boost { namespace python
 {
@@ -134,25 +151,25 @@ namespace boost { namespace python
 }}
 
-

Class template lvalue_from_pytype constructor

+

Class template + lvalue_from_pytype constructor

 lvalue_from_pytype();
 
- -
Effects: Registers converters which can convert - Python objects of the given type to lvalues of the type returned - by Extractor::execute. - +
Effects: Registers converters which can convert Python + objects of the given type to lvalues of the type returned by + Extractor::execute.
-

Class template extract_identity

+

Class template + extract_identity

-

extract_identity is a model of Extractor which can be - used in the common case where the C++ type to be extracted is the - same as the Python object type. +

extract_identity is a model of Extractor which can be used in the + common case where the C++ type to be extracted is the same as the Python + object type.

Class template extract_identity synopsis

@@ -167,26 +184,26 @@ namespace boost { namespace python }} -

Class template extract_identity static functions

+

Class template + extract_identity static functions

 InstanceType& execute(InstanceType& c);
 
- -
Returns: c - +
Returns: c
+

Class template + extract_member

-

Class template extract_member

+

extract_member is a model of Extractor which can be used in the + common case in the common case where the C++ type to be extracted is a + member of the Python object.

-

extract_member is a model of Extractor which can be - used in the common case in the common case where the C++ - type to be extracted is a member of the Python object. - -

Class template extract_member synopsis

+

Class template + extract_member synopsis

 namespace boost { namespace python
 {
@@ -198,34 +215,31 @@ namespace boost { namespace python
 }}
 
-

Class template extract_member static functions

+

Class template + extract_member static functions

 static MemberType& execute(InstanceType& c);
 
- -
Returns: c.*member - +
Returns: c.*member

Example

+ This example presumes that someone has implemented the standard noddy example + module from the Python documentation, and we want to build a module + which manipulates Noddys. Since + noddy_NoddyObject is so simple that it carries no + interesting information, the example is a bit contrived: it assumes you + want to keep track of one particular object for some reason. This module + would have to be dynamically linked to the module which defines + noddy_NoddyType. -This example presumes that someone has implemented the standard noddy -example module from the Python documentation, and we want to build -a module which manipulates Noddys. Since -noddy_NoddyObject is so simple that it carries no -interesting information, the example is a bit contrived: it assumes -you want to keep track of one particular object for some reason. This -module would have to be dynamically linked to the module which defines -noddy_NoddyType. - -

C++ module definition

- +

C++ module definition

 #include <boost/python/reference.hpp>
-#include <boost/python/module.hpp>
+#include <boost/python/module_init.hpp>
 
 // definition lifted from the Python docs
 typedef struct {
@@ -247,18 +261,15 @@ void set_cache(noddy_NoddyObject* x)
 
 BOOST_PYTHON_MODULE_INIT(noddy_cache)
 {
-   module noddy_cache("noddy_cache")
-      .def("is_cached", is_cached)
-      .def("set_cache", set_cache)
-      ;
+   def("is_cached", is_cached);
+   def("set_cache", set_cache);
 
    // register Noddy lvalue converter
    lvalue_from_pytype<extract_identity<noddy_NoddyObject>,&noddy_NoddyType>();
 }
 
-

Python code

- +

Python code

 >>> import noddy
 >>> n = noddy.new_noddy()
@@ -274,10 +285,13 @@ BOOST_PYTHON_MODULE_INIT(noddy_cache)
 
     

Revised - 05 November, 2001 + 29 September, 2001 +

- -

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

© Copyright Dave Abrahams 2002. All Rights + Reserved.

+ +