Skip to content

Commit 12c7981

Browse files
committed
*** empty log message ***
[SVN r12805]
1 parent 08c909f commit 12c7981

File tree

12 files changed

+331
-363
lines changed

12 files changed

+331
-363
lines changed

doc/v2/class.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,24 @@ <h3><a name="class_-spec">
7676
<table border="1" summary="class_ template parameters">
7777
<tr>
7878
<th>Parameter
79-
<th>Description
79+
<th>Requirements
8080
<th>Default
8181
<tr>
8282
<td><code>T</code>
83-
<td>The class being exposed to Python
83+
<td>A class type.
8484
<tr>
8585
<td><code>Bases</code>
86-
<td>An <a href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++ base classes
86+
87+
<td>An <a href="../../../mpl/doc/Sequences.html">MPL
88+
sequence</a> of C++ base classes of <code>T</code>.
89+
8790
<td>An unspecified empty sequence
91+
8892
<tr>
89-
<td><a href="HolderGenerator.html">HolderGenerator</a></code>
90-
<td>A type generator for the holder which
91-
maintains the C++ object inside the Python instance.
93+
<td><code>HolderGenerator</code>
94+
95+
<td>A model of <code><a href="HolderGenerator.html">HolderGenerator</a></code>.
96+
9297
<td><code>boost::python::objects::value_holder_generator</code>
9398
</table>
9499

doc/v2/errors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ <h2><a name="functions"></a>Functions</h2>
7878
<dl class="handle_exception-semantics">
7979
<dt><b>Requires:</b> The first form requires that the expression
8080
<code><a
81-
href="../../function/doc/reference.html#functionN">function0</a>&lt;void&gt;(f)</code>
81+
href="../../../function/doc/reference.html#functionN">function0</a>&lt;void&gt;(f)</code>
8282
is valid. The second form requires that a C++ exception is currently
8383
being handled (see section 15.1 in the C++ standard).
8484
</dt>

doc/v2/foo.cpp

Lines changed: 0 additions & 142 deletions
This file was deleted.

doc/v2/make_function.html

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
4+
<link rel="stylesheet" type="text/css" href="../boost.css">
5+
<title>Boost.Python - &lt;boost/python/make_function.hpp&gt;</title>
6+
</head>
7+
<body link="#0000ff" vlink="#800080">
8+
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
9+
"header">
10+
<tr>
11+
<td valign="top" width="300">
12+
<h3><a href="../../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../../c++boost.gif" border="0"></a></h3>
13+
</td>
14+
<td valign="top">
15+
<h1 align="center">Boost.Python</h1>
16+
<h2 align="center">Header &lt;boost/python/make_function.hpp&gt;</h2>
17+
</td>
18+
</tr>
19+
</table>
20+
<hr>
21+
<h2>Contents</h2>
22+
<dl class="page-index">
23+
<dt><a href="#introduction">Introduction</a></dt>
24+
25+
<dt><a href="#functions">Functions</a></dt>
26+
<dl class="page-index">
27+
<dt><a href="#make_function-spec">make_function</a></dt>
28+
<dt><a href="#make_constructor-spec">make_constructor</a></dt>
29+
</dl>
30+
31+
<dt><a href="#examples">Example</a></dt>
32+
33+
</dl>
34+
<hr>
35+
<h2><a name="introduction"></a>Introduction</h2>
36+
<p>
37+
38+
<code><a href="#make_function-spec">make_function</a>()</code> and
39+
<code><a href="#make_constructor-spec">make_constructor</a>()</code>
40+
are the functions used internally by <code>class_&lt;&gt;::<a
41+
href="class.html#class_-spec-modifiers">def</a></code>,
42+
<code>class_&lt;&gt;::<a
43+
href="module.html#module-spec-modifiers">def</a></code>,
44+
and
45+
<code>class_&lt;&gt;::<a
46+
href="class.html#class_-spec-modifiers">def_init</a></code>
47+
to produce Python callable objects which wrap C++ functions and member
48+
functions.
49+
</p>
50+
51+
<h2><a name="functions"></a>Functions</h2>
52+
53+
<pre>
54+
<a name="make_function-spec">template &lt;class F&gt;
55+
objects::function* make_function(F f)&lt;/a&gt;
56+
57+
template &lt;class F, class Policies&gt;
58+
objects::function* make_function(F f, Policies const&amp; policies)
59+
</pre>
60+
<dl class="function-semantics">
61+
62+
<dt><b>Requires:</b> <code>F</code> is a function pointer or member
63+
function pointer type</dt>
64+
65+
<dt><b>Effects:</b> Creates a Python callable object which, when
66+
called from Python, converts its arguments to C++ and calls
67+
<code>f</code>. If <code>F</code> is a pointer-to-member-function
68+
type, the target object of the function call (<code>*this</code>)
69+
will be taken from the first Python argument, and subsequent Python
70+
arguments will be used as the arguments to <code>f</code>. If
71+
<code>policies</code> are supplied, it must be a model of <a
72+
href="CallPolicies.html">CallPolicies</a>, and will be applied to
73+
the function as described <a href="CallPolicies.html">here</a>.</dt>
74+
75+
<dt><b>Returns:</b> A pointer convertible to <code>PyObject*</code>
76+
which refers to the new Python callable object.</dt>
77+
</dl>
78+
79+
<pre>
80+
<a name="make_constructor-spec">template &lt;class T, class ArgList, class Generator&gt;
81+
objects::function* make_constructor();</a>
82+
</pre>
83+
<dl class="make_constructor-semantics">
84+
85+
<dt><b>Requires:</b> <code>T</code> is a class
86+
type. <code>ArgList</code> is an <a
87+
href="../../../mpl/doc/Sequences.html">MPL sequence</a> of C++
88+
argument types (<i>A1,&nbsp;A2,...&nbsp;AN</i>) such that if
89+
<code>a1,&nbsp;a2</code>...&nbsp;<code>aN</code> are objects of type
90+
<i>A1,&nbsp;A2,...&nbsp;AN</i> respectively, the expression
91+
<code>new Generator::apply&lt;T&gt;::type(a1,&nbsp;a2</code>...&nbsp;<code>aN</code>) is
92+
valid. Generator is a model of <a
93+
href="HolderGenerator.html">HolderGenerator</a>.
94+
</dt>
95+
96+
<dt><b>Effects:</b> Creates a Python callable object which, when
97+
called from Python, expects its first argument to be a Boost.Python
98+
extension class object. It converts its remaining its arguments to
99+
C++ and passes them to the constructor of a dynamically-allocated
100+
<code>Generator::apply&lt;T&gt;::type</code> object. The result is
101+
installed in the extension class object.
102+
103+
</dt>
104+
105+
<dt><b>Returns:</b> The new Python callable object</dt>
106+
107+
</dl>
108+
109+
<h2><a name="examples"></a>Example</h2>
110+
111+
<p>C++ function exposed below returns a callable object wrapping one
112+
of two functions.
113+
114+
<pre>
115+
#include &lt;boost/python/make_function.hpp&gt;
116+
#include &lt;boost/python/module.hpp&gt;
117+
118+
char const* foo() { return "foo"; }
119+
char const* bar() { return "bar"; }
120+
121+
PyObject* choose_function(bool selector)
122+
{
123+
if (selector)
124+
return boost::python::make_function(foo);
125+
else
126+
return boost::python::make_function(bar);
127+
}
128+
129+
BOOST_PYTHON_MODULE_INIT(make_function_test)
130+
{
131+
module("make_function_test")
132+
.def("choose_function", choose_function);
133+
}
134+
</pre>
135+
</p>
136+
It can be used this way in Python:
137+
<pre>
138+
&gt;&gt;&gt; from make_function_test import *
139+
&gt;&gt;&gt; f = choose_function(1)
140+
&gt;&gt;&gt; g = choose_function(0)
141+
&gt;&gt;&gt; f()
142+
'foo'
143+
&gt;&gt;&gt; g()
144+
'bar'
145+
</pre>
146+
147+
<p>
148+
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
149+
14 February 2002
150+
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
151+
</p>
152+
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a>
153+
2002. All Rights Reserved.</i></p>
154+
</body>
155+
</html>

0 commit comments

Comments
 (0)