2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-22 05:22:45 +00:00

Compare commits

...

22 Commits

Author SHA1 Message Date
nobody
ee43d1884c This commit was manufactured by cvs2svn to create tag
'Version_1_33_1_beta'.

[SVN r31604]
2005-11-08 23:18:41 +00:00
Dave Abrahams
9e588c4ca2 merged from trunk
[SVN r31558]
2005-11-04 21:39:06 +00:00
Dave Abrahams
ccabeef937 merged from trunk
[SVN r31529]
2005-11-01 15:09:28 +00:00
Dave Abrahams
fecdada51d merged from trunk
[SVN r31516]
2005-10-31 19:25:36 +00:00
Dave Abrahams
f0d1de94a0 merged from trunk
[SVN r31495]
2005-10-27 12:22:23 +00:00
Dave Abrahams
c9bca62047 merged from trunk
[SVN r31467]
2005-10-25 19:10:23 +00:00
Dave Abrahams
312908b72c merged from trunk
[SVN r31399]
2005-10-19 22:03:37 +00:00
Dave Abrahams
ae438aa67a merged from trunk
[SVN r31397]
2005-10-19 18:28:28 +00:00
Dave Abrahams
daf842e534 Add the ability to easily use new-style polymorphism wrappers with
smart pointer held_type.


[SVN r31395]
2005-10-19 18:22:53 +00:00
Dave Abrahams
8fa75c8fb5 merged from trunk
[SVN r31394]
2005-10-19 18:19:23 +00:00
nobody
2e8a265abf This commit was manufactured by cvs2svn to create branch 'RC_1_33_0'.
[SVN r31393]
2005-10-19 18:17:14 +00:00
Dave Abrahams
55f6c08095 merged from trunk
[SVN r31386]
2005-10-19 13:18:01 +00:00
Dave Abrahams
8aa504f190 merged from trunk
[SVN r31330]
2005-10-14 19:30:27 +00:00
Dave Abrahams
2cede68e3a merged from trunk
[SVN r31326]
2005-10-14 16:44:24 +00:00
Dave Abrahams
354151926b merged from trunk
[SVN r31323]
2005-10-14 15:54:40 +00:00
Dave Abrahams
92c9053dcd merged from trunk
[SVN r31320]
2005-10-14 15:05:40 +00:00
Dave Abrahams
f20e7d5e5c merged from trunk
[SVN r31291]
2005-10-11 21:24:00 +00:00
Dave Abrahams
0af24b311e merged from trunk
[SVN r31280]
2005-10-11 13:19:43 +00:00
Ralf W. Grosse-Kunstleve
783c8c422e bug fix merged from trunk
[SVN r30472]
2005-08-04 20:19:24 +00:00
Dave Abrahams
79a25bfd4c merged from trunk
[SVN r30402]
2005-08-03 12:26:12 +00:00
Dave Abrahams
35472e60e3 merged from trunk
[SVN r30399]
2005-08-03 11:40:17 +00:00
nobody
2aa129a02f This commit was manufactured by cvs2svn to create branch 'RC_1_33_0'.
[SVN r30300]
2005-07-28 18:22:24 +00:00
33 changed files with 977 additions and 800 deletions

View File

@@ -82,9 +82,12 @@
boost installation (if you have already built boost from the top level boost installation (if you have already built boost from the top level
this may have no effect, since the work is already done).</p> this may have no effect, since the work is already done).</p>
<h3><a name="configuration">Basic Configuration</a></h3> <h3><a name="configuration">Basic Configuration</a></h3> You may
You may need to configure the following variables to point Boost.Build at need to configure the following variables to point Boost.Build at
your Python installation: your Python installation. Variables can be either set in the
environment or passed on the <code>bjam</code> command-line
as <code>-s</code><i>name</i><code>=</code><i>value</i>. Variable
names are case-sensitive.
<table border="1" summary="build configuration variables"> <table border="1" summary="build configuration variables">
<tr> <tr>
@@ -98,28 +101,29 @@
</tr> </tr>
<tr> <tr>
<td><code>PYTHON_ROOT</code></td>
<td>The root directory of your Python installation</td>
<td>Windows:&nbsp;<code>c:/tools/python</code>
Unix:&nbsp;<code>/usr/local</code></td>
<td>On Unix, this is the <code>--with-prefix=</code> directory used
to configure Python</td>
</tr>
<tr> <tr>
<td><code>PYTHON_VERSION</code></td> <td><code>PYTHON_VERSION</code></td>
<td>The The 2-part python Major.Minor version number</td> <td>The The 2-part python Major.Minor version number</td>
<td><code>2.2</code></td> <td><code>2.4</code></td>
<td>Be sure not to include a third number, e.g. <b>not</b> <td>Be sure not to include a third number, e.g. <b>not</b>
"<code>2.2.1</code>", even if that's the version you have.</td> "<code>2.2.1</code>", even if that's the version you have.</td>
</tr> </tr>
<td><code>PYTHON_ROOT</code></td>
<td>The root directory of your Python installation</td>
<td>Windows:&nbsp;<code>c:/Python</code><i>(10*Version)</i>, e.g. <code>c:/Python24</code>
<br>
*nix/Cygwin:&nbsp;<code>/usr</code></td>
<td>On *nix, this should be the <code>--prefix=</code> directory used
to configure Python when it was built and installed.</td>
</tr>
<tr> <tr>
<td><code>PYTHON_INCLUDES</code></td> <td><code>PYTHON_INCLUDES</code></td>
@@ -172,7 +176,7 @@
<tr> <tr>
<td><code>CYGWIN_PYTHON_[DEBUG_]ROOT</code></td> <td><code>CYGWIN_PYTHON_[DEBUG_]ROOT</code></td>
<td>unix-style path containing the <code>include/</code> directory <td>*nix-style path containing the <code>include/</code> directory
containing containing
<code>python$(CYGWIN_PYTHON_[DEBUG_]VERSION)/python.h</code>.</td> <code>python$(CYGWIN_PYTHON_[DEBUG_]VERSION)/python.h</code>.</td>
@@ -219,8 +223,10 @@
<h3><a name="mingw">Notes for MinGW (and Cygwin with -mno-cygwin) GCC <h3><a name="mingw">Notes for MinGW (and Cygwin with -mno-cygwin) GCC
Users</a></h3> Users</a></h3>
<p>You will need to create a MinGW-compatible version of the Python <p>If you are using a version of Python prior to 2.4.1 with a
library; the one shipped with Python will only work with a MinGW prior to 3.0.0 (with binutils-2.13.90-20030111-1), you will
need to create a MinGW-compatible version of the Python library;
the one shipped with Python will only work with a
Microsoft-compatible linker. Follow the instructions in the Microsoft-compatible linker. Follow the instructions in the
"Non-Microsoft" section of the "Building Extensions: Tips And Tricks" "Non-Microsoft" section of the "Building Extensions: Tips And Tricks"
chapter in <a href= chapter in <a href=
@@ -359,7 +365,7 @@ path-global BOOST_ROOT : ../../.. ;
<p>The first two variants of the <code>boost_python</code> library are <p>The first two variants of the <code>boost_python</code> library are
built by default, and are compatible with the default Python built by default, and are compatible with the default Python
distribution. The <code>debug-python</code> variant corresponds to a distribution. The <code>debug-python</code> variant corresponds to a
specially-built debugging version of Python. On Unix platforms, this specially-built debugging version of Python. On *nix platforms, this
python is built by adding <code>--with-pydebug</code> when configuring python is built by adding <code>--with-pydebug</code> when configuring
the Python build. On Windows, the debugging version of Python is the Python build. On Windows, the debugging version of Python is
generated by the "Win32 Debug" target of the <code>PCBuild.dsw</code> generated by the "Win32 Debug" target of the <code>PCBuild.dsw</code>

View File

@@ -3,14 +3,14 @@
<html> <html>
<head> <head>
<meta name="generator" content= <meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st April 2002), see www.w3.org"> "HTML Tidy for Cygwin (vers 1st September 2004), see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<link rel="stylesheet" type="text/css" href="boost.css"> <link rel="stylesheet" type="text/css" href="boost.css">
<title>Boost.Python - News/Change Log</title> <title>Boost.Python - News/Change Log</title>
</head> </head>
<body link="#0000ff" vlink="#800080"> <body link="#0000FF" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary= <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header"> "header">
<tr> <tr>
@@ -29,32 +29,98 @@
<hr> <hr>
<dl class="page-index"> <dl class="page-index">
<dt>19 October 2005 - 1.33.1 release</dt>
<dd>
<ul>
<li><code>wrapper&lt;T&gt;</code> can now be used as expected with a
held type of <i>some-smart-pointer</i><code>&lt;T&gt;</code></li>
<li>The build now assumes Python 2.4 by default, rather than 2.2</li>
<li>Support Python that's built without Unicode support</li>
<li>Support for wrapping classes with overloaded address-of
(<code>&amp;</code>) operators</li>
</ul>
</dd>
<dt>14 August 2005 - 1.33 release</dt>
<dd>
<ul>
<li>Support for docstrings on nonstatic properties.</li>
<li>We now export the client-provided docstrings for
<code>init&lt;optional&lt;&gt; &gt;</code> and
<i>XXX</i><code>_FUNCTION_OVERLOADS()</code> for only the last
overload.</li>
<li>Fixed some support for Embedded VC++ 4</li>
<li>Better support for rvalue from-python conversions of shared_ptr:
always return a pointer that holds the owning python object *unless*
the python object contains a NULL shared_ptr holder of the right
type.</li>
<li>Support for exposing <code>vector&lt;T*&gt;</code> with the
indexing suite.</li>
<li>Support for GCC-3.3 on MacOS.</li>
<li>updated visual studio project build file to include two new files
(slice.cpp and wrapper.cpp)</li>
<li>Added search feature to the index page.</li>
<li>Numerous fixes to the tutorial</li>
<li>Numerous workarounds for MSVC 6 and 7, GCC 2.96, and EDG
2.45</li>
</ul>
</dd>
<dt>11 March 2005</dt> <dt>11 March 2005</dt>
<dd> <dd>
<ul> <ul>
<li>Added a hack that will fool PyDoc into working with Boost.Python, thanks to Nick Rasmussen</li> <li>Added a hack that will fool PyDoc into working with Boost.Python,
thanks to Nick Rasmussen</li>
</ul> </ul>
</dd> </dd>
<dt>19 November 2004 - 1.32 release</dt> <dt>19 November 2004 - 1.32 release</dt>
<dd> <dd>
<ul> <ul>
<li>Updated to use the Boost Software License.</li> <li>Updated to use the Boost Software License.</li>
<li>A new, <a href="tutorial/doc/html/python/exposing.html#python.class_virtual_functions">better method of wrapping classes with virtual functions</a> has been implemented.</li>
<li>Support for upcoming GCC symbol export control features have been folded in, thanks to Niall Douglas.</li> <li>A new, <a href=
"tutorial/doc/html/python/exposing.html#python.class_virtual_functions">
better method of wrapping classes with virtual functions</a> has been
implemented.</li>
<li>Support for upcoming GCC symbol export control features have been
folded in, thanks to Niall Douglas.</li>
<li>Improved support for <code>std::auto_ptr</code>-like types.</li> <li>Improved support for <code>std::auto_ptr</code>-like types.</li>
<li>The Visual C++ bug that makes top-level <i>cv-qualification</i> of function parameter types part of the function type has been worked around.</li>
<li>Components used by other libraries have been moved out of <code>python/detail</code> and into <code> boost/detail</code> to improve dependency relationships.</li> <li>The Visual C++ bug that makes top-level <i>cv-qualification</i>
of function parameter types part of the function type has been worked
around.</li>
<li>Components used by other libraries have been moved out of
<code>python/detail</code> and into <code>boost/detail</code> to
improve dependency relationships.</li>
<li>Miscellaneous bug fixes and compiler workarounds.</li> <li>Miscellaneous bug fixes and compiler workarounds.</li>
</ul> </ul>
</dd> </dd>
<dt>8 Sept 2004</dt> <dt>8 Sept 2004</dt>
<dd> <dd>Support for Python's Bool type, thanks to <a href=
Support for Python's Bool type, thanks to <a "mailto:dholth-at-fastmail.fm">Daniel Holth</a>.</dd>
mailto="dholth-at-fastmail.fm">Daniel Holth</a>.
</dd>
<dt>11 Sept 2003</dt> <dt>11 Sept 2003</dt>
@@ -88,17 +154,17 @@
<dt>10 August 2003</dt> <dt>10 August 2003</dt>
<dd>Added the new <code>properties</code> unit tests contributed by <a <dd>Added the new <code>properties</code> unit tests contributed by
href="mailto:romany-at-actimize.com">Roman Yakovenko</a> and documented <a href="mailto:romany-at-actimize.com">Roman Yakovenko</a> and
<code>add_static_property</code> at his urging.</dd> documented <code>add_static_property</code> at his urging.</dd>
<dt>1 August 2003</dt> <dt>1 August 2003</dt>
<dd> <dd>
Added the new <code>arg</code> class contributed by <a href= Added the new <code>arg</code> class contributed by <a href=
"mailto:nickm-at-sitius.com">Nikolay Mladenov</a> which supplies the "mailto:nickm-at-sitius.com">Nikolay Mladenov</a> which supplies the
ability to wrap functions that can be called with ommitted arguments ability to wrap functions that can be called with ommitted arguments in
in the middle: the middle:
<pre> <pre>
void f(int x = 0, double y = 3.14, std::string z = std::string("foo")); void f(int x = 0, double y = 3.14, std::string z = std::string("foo"));
@@ -108,14 +174,12 @@ BOOST_PYTHON_MODULE(test)
, (arg("x", 0), arg("y", 3.14), arg("z", "foo"))); , (arg("x", 0), arg("y", 3.14), arg("z", "foo")));
} }
</pre> </pre>And in Python:
And in Python:
<pre> <pre>
&gt;&gt;&gt; import test &gt;&gt;&gt; import test
&gt;&gt;&gt; f(0, z = "bar") &gt;&gt;&gt; f(0, z = "bar")
&gt;&gt;&gt; f(z = "bar", y = 0.0) &gt;&gt;&gt; f(z = "bar", y = 0.0)
</pre> </pre>Thanks, Nikolay!
Thanks, Nikolay!
</dd> </dd>
<dt>22 July 2003</dt> <dt>22 July 2003</dt>
@@ -127,39 +191,36 @@ BOOST_PYTHON_MODULE(test)
<dd>Added the new <code><a href= <dd>Added the new <code><a href=
"v2/return_arg.html">return_arg</a></code> policy from <a href= "v2/return_arg.html">return_arg</a></code> policy from <a href=
"mailto:nickm-at-sitius.com">Nikolay Mladenov</a>. Thanks, "mailto:nickm-at-sitius.com">Nikolay Mladenov</a>. Thanks, Nikolay!</dd>
Nikolay!</dd>
<dt>18 March, 2003</dt> <dt>18 March, 2003</dt>
<dd><a href="mailto:Gottfried.Ganssauge-at-haufe.de">Gottfried <dd><a href="mailto:Gottfried.Ganssauge-at-haufe.de">Gottfried
Gan&szlig;auge</a> has contributed <a href= Gan&szlig;auge</a> has contributed <a href=
"v2/opaque_pointer_converter.html">opaque pointer support</a>.<br> "v2/opaque_pointer_converter.html">opaque pointer support</a>.<br>
<a href="mailto:nicodemus-at-globalite.com.br">Bruno da Silva de Oliveira</a> <a href="mailto:nicodemus-at-globalite.com.br">Bruno da Silva de
has contributed the exciting <a href="../pyste/index.html">Pyste</a> Oliveira</a> has contributed the exciting <a href=
("Pie-steh") package.</dd> "../pyste/index.html">Pyste</a> ("Pie-steh") package.</dd>
<dt>24 February 2003</dt> <dt>24 February 2003</dt>
<dd>Finished improved support for <code>boost::shared_ptr</code>. Now <dd>Finished improved support for <code>boost::shared_ptr</code>. Now any
any wrapped object of C++ class <code>X</code> can be converted wrapped object of C++ class <code>X</code> can be converted automatically
automatically to <code>shared_ptr&lt;X&gt;</code>, regardless of how it to <code>shared_ptr&lt;X&gt;</code>, regardless of how it was wrapped.
was wrapped. The <code>shared_ptr</code> will manage the lifetime of The <code>shared_ptr</code> will manage the lifetime of the Python object
the Python object which supplied the <code>X</code>, rather than just which supplied the <code>X</code>, rather than just the <code>X</code>
the <code>X</code> object itself, and when such a object itself, and when such a <code>shared_ptr</code> is converted back
<code>shared_ptr</code> is converted back to Python, the original to Python, the original Python object will be returned.</dd>
Python object will be returned.</dd>
<dt>19 January 2003</dt> <dt>19 January 2003</dt>
<dd>Integrated <code>staticmethod</code> support from <a href= <dd>Integrated <code>staticmethod</code> support from <a href=
"mailto:nickm-at-sitius.com">Nikolay Mladenov</a>. Thanks, "mailto:nickm-at-sitius.com">Nikolay Mladenov</a>. Thanks, Nikolay!</dd>
Nikolay!</dd>
<dt>29 December 2002</dt> <dt>29 December 2002</dt>
<dd>Added Visual Studio project file and instructions from Brett <dd>Added Visual Studio project file and instructions from Brett Calcott.
Calcott. Thanks, Brett!</dd> Thanks, Brett!</dd>
<dt>20 December 2002</dt> <dt>20 December 2002</dt>
@@ -168,9 +229,9 @@ BOOST_PYTHON_MODULE(test)
<dt>18 December 2002</dt> <dt>18 December 2002</dt>
<dd>Optimized from_python conversions for wrapped classes by putting <dd>Optimized from_python conversions for wrapped classes by putting the
the conversion logic in the shared library instead of registering conversion logic in the shared library instead of registering separate
separate converters for each class in each extension module</dd> converters for each class in each extension module</dd>
<dt>19 November 2002</dt> <dt>19 November 2002</dt>
@@ -208,11 +269,9 @@ BOOST_PYTHON_MODULE(test)
<p>Revised <p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
19 November 2004 19 November 2004
<!--webbot bot="Timestamp" endspan i-checksum="39359" --> <!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
</p>
<p><i>&copy; Copyright <a href="../../../people/dave_abrahams.htm">Dave <p><i>&copy; Copyright <a href="../../../people/dave_abrahams.htm">Dave
Abrahams</a> 2002-2003.</i></p> Abrahams</a> 2002-2003.</i></p>
</body> </body>
</html> </html>

View File

@@ -42,7 +42,7 @@
<dl class="page-index"> <dl class="page-index">
<dt><b><a href= <dt><b><a href=
"http://www.neuralynx.com/neuralab/index.htm">NeuraLab</a></b></dt> "http://www.neuralynx.com">NeuraLab</a></b></dt>
<dd>Neuralab is a data analysis environment specifically tailored for <dd>Neuralab is a data analysis environment specifically tailored for
neural data from <a href="http://www.neuralynx.com">Neuralynx</a> neural data from <a href="http://www.neuralynx.com">Neuralynx</a>
@@ -351,13 +351,13 @@
<p>Two projects have been developed so far with this technology:</p> <p>Two projects have been developed so far with this technology:</p>
<p><b><a href="http://www.esss.com.br/dev_simba.phtml">Simba</a></b> <p><b><a href="http://www.esss.com.br/index.php?pg=dev_projetos">Simba</a></b>
provides 3D visualization of geological formations gattered from the provides 3D visualization of geological formations gattered from the
simulation of the evolution of oil systems, allowing the user to simulation of the evolution of oil systems, allowing the user to
analyse various aspects of the simulation, like deformation, pressure analyse various aspects of the simulation, like deformation, pressure
and fluids, along the time of the simulation.</p> and fluids, along the time of the simulation.</p>
<p><b><a href="http://www.esss.com.br/dev_aero.phtml">Aero</a></b> <p><b><a href="http://www.esss.com.br/index.php?pg=dev_projetos">Aero</a></b>
aims to construct a CFD with brazilian technology, which involves aims to construct a CFD with brazilian technology, which involves
various companies and universities. ESSS is responsible for various various companies and universities. ESSS is responsible for various
of the application modules, including GUI and post-processing of of the application modules, including GUI and post-processing of

View File

@@ -79,7 +79,7 @@ call_method&lt;ResultType&gt;(self_object, "<i>method-name</i>", a1, a2... a<i>N
the arguments <code>a1</code>...<code>a<i>N</i></code> are copied into the arguments <code>a1</code>...<code>a<i>N</i></code> are copied into
new Python objects, but this behavior can be overridden by the use of new Python objects, but this behavior can be overridden by the use of
<code><a href="ptr.html#ptr-spec">ptr()</a></code> and <a href= <code><a href="ptr.html#ptr-spec">ptr()</a></code> and <a href=
"../../../bind/ref.html#reference_wrapper">ref()</a>:</p> "../../../bind/ref.html">ref()</a>:</p>
<pre> <pre>
class X : boost::noncopyable class X : boost::noncopyable
{ {
@@ -128,7 +128,7 @@ void apply(PyObject* callable, X&amp; x)
<tr> <tr>
<td><code><a href= <td><code><a href=
"../../../bind/ref.html#reference_wrapper">boost::reference_wrapper</a>&lt;T&gt;</code></td> "../../../bind/ref.html">boost::reference_wrapper</a>&lt;T&gt;</code></td>
<td>The Python argument contains a pointer to, rather than a copy of, <td>The Python argument contains a pointer to, rather than a copy of,
<code>x.get()</code>. Note: failure to ensure that no Python code <code>x.get()</code>. Note: failure to ensure that no Python code

View File

@@ -3,21 +3,21 @@
<html> <html>
<head> <head>
<meta name="generator" content= <meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st April 2002), see www.w3.org"> "HTML Tidy for Cygwin (vers 1st September 2004), see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-latin-1-dos">
<link rel="stylesheet" type="text/css" href="../boost.css"> <link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - &lt;boost/python/class.hpp&gt;, <title>Boost.Python - &lt;boost/python/class.hpp&gt;,
&lt;boost/python/class_fwd.hpp&gt;</title> &lt;boost/python/class_fwd.hpp&gt;</title>
</head> </head>
<body link="#0000ff" vlink="#800080"> <body link="#0000FF" vlink="#800080">
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary= <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
"header"> "header">
<tr> <tr>
<td valign="top" width="300"> <td valign="top" width="300">
<h3><a href="../../../../index.htm"><img height="86" width="277" <h3><a href="../../../../index.htm"><img height="86" width="277" alt=
alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3> "C++ Boost" src="../../../../boost.png" border="0"></a></h3>
</td> </td>
<td valign="top"> <td valign="top">
@@ -55,8 +55,7 @@
</dl> </dl>
</dd> </dd>
<dt><a href="#bases-spec">Class template <dt><a href="#bases-spec">Class template <code>bases</code></a></dt>
<code>bases</code></a></dt>
<dd> <dd>
<dl class="page-index"> <dl class="page-index">
@@ -71,31 +70,30 @@
</dl> </dl>
<hr> <hr>
<h2><a name="introduction"></a>Introduction</h2> <h2><a name="introduction" id="introduction"></a>Introduction</h2>
<p><code>&lt;boost/python/class.hpp&gt;</code> defines the interface <p><code>&lt;boost/python/class.hpp&gt;</code> defines the interface
through which users expose their C++ classes to Python. It declares the through which users expose their C++ classes to Python. It declares the
<code>class_</code> class template, which is parameterized on the class <code>class_</code> class template, which is parameterized on the class
type being exposed. It also exposes the <code>init</code>, type being exposed. It also exposes the <code>init</code>,
<code>optional</code> and <code>bases</code> utility class templates, <code>optional</code> and <code>bases</code> utility class templates, which
which are used in conjunction with <code>class_</code>.</p> are used in conjunction with <code>class_</code>.</p>
<p><code>&lt;boost/python/class_fwd.hpp&gt;</code> contains a forward <p><code>&lt;boost/python/class_fwd.hpp&gt;</code> contains a forward
declaration of the <code>class_</code> class template.</p> declaration of the <code>class_</code> class template.</p>
<h2><a name="classes"></a>Classes</h2> <h2><a name="classes" id="classes"></a>Classes</h2>
<h3><a name="class_-spec"></a>Class template <h3><a name="class_-spec" id="class_-spec"></a>Class template
<code>class_&lt;T,&nbsp;<font color="#007F00">Bases,&nbsp;HeldType, <code>class_&lt;T,&nbsp;<font color="#007F00">Bases,&nbsp;HeldType,
NonCopyable</font>&gt;</code></h3> NonCopyable</font>&gt;</code></h3>
<p>Creates a Python class associated with the C++ type passed as its <p>Creates a Python class associated with the C++ type passed as its first
first parameter. Although it has four template parameters, only the first parameter. Although it has four template parameters, only the first one is
one is required. The three optional arguments can actually be supplied required. The three optional arguments can actually be supplied
<font color="#007F00"><b>in any order</b></font>; Boost.Python determines <font color="#007F00"><b>in any order</b></font>; Boost.Python determines
the role of the argument from its type.<br> the role of the argument from its type.<br>
<br> <br></p>
</p>
<table border="1" summary="class_ template parameters"> <table border="1" summary="class_ template parameters">
<tr> <tr>
@@ -121,16 +119,16 @@
<td>A specialization of <a href= <td>A specialization of <a href=
"#bases-spec"><code>bases&lt;</code>...<code>&gt;</code></a> which "#bases-spec"><code>bases&lt;</code>...<code>&gt;</code></a> which
specifies previously-exposed C++ base classes of <code>T</code><a specifies previously-exposed C++ base classes of <code>T</code><a href=
href="#footnote_1">[1]</a>.</td> "#footnote_1">[1]</a>.</td>
<td>Registers <code>from_python</code> conversions from wrapped <td>Registers <code>from_python</code> conversions from wrapped
<code>T</code> instances to each of its exposed direct and indirect <code>T</code> instances to each of its exposed direct and indirect
bases. For each polymorphic base <code>B</code>, registers bases. For each polymorphic base <code>B</code>, registers conversions
conversions from indirectly-held wrapped <code>B</code> instances to from indirectly-held wrapped <code>B</code> instances to
<code>T</code>.</td> <code>T</code>.</td>
<td><code><a href="#bases">bases&lt;&gt;</a></code></td> <td><code><a href="#bases-spec">bases&lt;&gt;</a></code></td>
</tr> </tr>
<tr> <tr>
@@ -139,12 +137,20 @@
<td>Must be <code>T</code>, a class derived from <code>T</code>, or a <td>Must be <code>T</code>, a class derived from <code>T</code>, or a
<a href="Dereferenceable.html">Dereferenceable</a> type for which <a href="Dereferenceable.html">Dereferenceable</a> type for which
<code><a href= <code><a href=
"pointee.html#pointee-spec">pointee</a>&lt;HeldType&gt;::type</code> "pointee.html#pointee-spec">pointee</a>&lt;HeldType&gt;::type</code> is
is <code>T</code> or a class derived from <code>T</code>.</td> <code>T</code> or a class derived from <code>T</code>.</td>
<td>Specifies the type which is actually embedded in a Python object <td>Specifies the type that is actually embedded in a Python object
wrapping a <code>T</code> instance. More details <a href= wrapping a <code>T</code> instance when <code>T</code>'s constructor is
"#HeldType">below</a>.</td> called or when a <code>T</code> or <code>T*</code> is converted to
Python without the use of <a href=
"http://www.boost.org/libs/python/doc/v2/callbacks.html#argument_handling">
<code>ptr</code></a>, <a href=
"http://www.boost.org/libs/python/doc/v2/callbacks.html#argument_handling">
<code>ref</code></a>, or <a href="CallPolicies.html">Call Policies</a>
such as <code><a href=
"return_internal_reference.html">return_internal_reference</a></code>.
More details <a href="#HeldType">below</a>.</td>
<td><code>T</code></td> <td><code>T</code></td>
</tr> </tr>
@@ -153,7 +159,7 @@
<td><code><font color="#007F00">NonCopyable</font></code></td> <td><code><font color="#007F00">NonCopyable</font></code></td>
<td>If supplied, must be <a href= <td>If supplied, must be <a href=
"../../../utility/utility.htm#Class%20noncopyable">boost::noncopyable</a>.</td> "../../../utility/utility.htm#Class_noncopyable">boost::noncopyable</a>.</td>
<td>Suppresses automatic registration of <code>to_python</code> <td>Suppresses automatic registration of <code>to_python</code>
conversions which copy <code>T</code> instances. Required when conversions which copy <code>T</code> instances. Required when
@@ -164,41 +170,40 @@
</tr> </tr>
</table> </table>
<h4><a name="#HeldType">HeldType Semantics</a></h4> <h4><a name="HeldType" id="HeldType">HeldType Semantics</a></h4>
<ol> <ol>
<li>If <code>HeldType</code> is derived from T, its exposed <li>If <code>HeldType</code> is derived from T, its exposed
constructor(s) must accept an initial <code>PyObject*</code> argument constructor(s) must accept an initial <code>PyObject*</code> argument
which refers back to the Python object that contains the which refers back to the Python object that contains the
<code>HeldType</code> instance, as shown in <a href= <code>HeldType</code> instance, as shown in <a href=
"call_method.html#example">this example</a>. This argument is not "call_method.html#examples">this example</a>. This argument is not
included in the <em><a href= included in the <em><a href=
"init.html#init-expressions">init-expression</a></em> passed to <a "init.html#init-expressions">init-expression</a></em> passed to <a href=
href="#class-spec-modifiers"><code>def(init_expr)</code></a>, below, "#class_-spec-modifiers"><code>def(init_expr)</code></a>, below, nor is
nor is it passed explicitly by users when Python instances of it passed explicitly by users when Python instances of <code>T</code> are
<code>T</code> are created. This idiom allows C++ virtual functions created. This idiom allows C++ virtual functions which will be overridden
which will be overridden in Python to access the Python object so the in Python to access the Python object so the Python method can be
Python method can be invoked. Boost.Python automatically registers invoked. Boost.Python automatically registers additional converters which
additional converters which allow wrapped instances of <code>T</code> allow wrapped instances of <code>T</code> to be passed to wrapped C++
to be passed to wrapped C++ functions expecting <code>HeldType</code> functions expecting <code>HeldType</code> arguments.</li>
arguments.</li>
<li>Because Boost.Python will always allow wrapped instances of <li>Because Boost.Python will always allow wrapped instances of
<code>T</code> to be passed in place of <code>HeldType</code> <code>T</code> to be passed in place of <code>HeldType</code> arguments,
arguments, specifying a smart pointer for <code>HeldType</code> allows specifying a smart pointer for <code>HeldType</code> allows users to pass
users to pass Python <code>T</code> instances where a smart Python <code>T</code> instances where a smart pointer-to-<code>T</code>
pointer-to-<code>T</code> is expected. Smart pointers such as is expected. Smart pointers such as <code>std::auto_ptr&lt;&gt;</code> or
<code>std::auto_ptr&lt;&gt;</code> or <code><a href= <code><a href=
"../../../smart_ptr/shared_ptr.htm">boost::shared_ptr&lt;&gt;</a></code> "../../../smart_ptr/shared_ptr.htm">boost::shared_ptr&lt;&gt;</a></code>
which contain a nested type <code>element_type</code> designating the which contain a nested type <code>element_type</code> designating the
referent type are automatically supported; additional smart pointer referent type are automatically supported; additional smart pointer types
types can be supported by specializing <a href= can be supported by specializing <a href=
"pointee.html#pointee-spec">pointee&lt;HeldType&gt;</a>.</li> "pointee.html#pointee-spec">pointee&lt;HeldType&gt;</a>.</li>
<li>As in case 1 above, when <code>HeldType</code> is a smart pointer <li>As in case 1 above, when <code>HeldType</code> is a smart pointer to
to a class derived from <code>T</code>, the initial a class derived from <code>T</code>, the initial <code>PyObject*</code>
<code>PyObject*</code> argument must be supplied by all of argument must be supplied by all of <code>HeldType</code>'s exposed
<code>HeldType</code>'s exposed constructors.</li> constructors.</li>
<li>Except in cases 1 and 3, users may optionally specify that T itself <li>Except in cases 1 and 3, users may optionally specify that T itself
gets initialized with a similar initial <code>PyObject*</code> argument gets initialized with a similar initial <code>PyObject*</code> argument
@@ -206,8 +211,8 @@
"has_back_reference.html#has_back_reference-spec">has_back_reference&lt;T&gt;</a>.</li> "has_back_reference.html#has_back_reference-spec">has_back_reference&lt;T&gt;</a>.</li>
</ol> </ol>
<h4><a name="class_-spec-synopsis"></a>Class template <code>class_</code> <h4><a name="class_-spec-synopsis" id="class_-spec-synopsis"></a>Class
synopsis</h4> template <code>class_</code> synopsis</h4>
<pre> <pre>
namespace boost { namespace python namespace boost { namespace python
{ {
@@ -287,8 +292,8 @@ namespace boost { namespace python
}} }}
</pre> </pre>
<h4><a name="class_-spec-ctors"></a>Class template <code>class_</code> <h4><a name="class_-spec-ctors" id="class_-spec-ctors"></a>Class template
constructors</h4> <code>class_</code> constructors</h4>
<pre> <pre>
class_(char const* name); class_(char const* name);
class_(char const* name, char const* docstring); class_(char const* name, char const* docstring);
@@ -306,24 +311,24 @@ class_(char const* name, char const* docstring, Init init_spec);
<a href="definitions.html#ntbs">ntbs</a>. If <code>init_spec</code> is <a href="definitions.html#ntbs">ntbs</a>. If <code>init_spec</code> is
supplied, it must be either the special enumeration constant supplied, it must be either the special enumeration constant
<code>no_init</code> or an <a href= <code>no_init</code> or an <a href=
"init.html#init-expression">init-expression</a> compatible with "init.html#init-expressions">init-expression</a> compatible with
<code>T</code>.</dt> <code>T</code>.</dt>
<dt><b>Effects:</b> Constructs a <code>class_</code> object holding a <dt><b>Effects:</b> Constructs a <code>class_</code> object holding a
Boost.Python extension class named <code>name</code>. The Boost.Python extension class named <code>name</code>. The
<code>name</code>d attribute of the <a href= <code>name</code>d attribute of the <a href=
"scope.html#introduction">current scope</a> is bound to the new "scope.html#introduction">current scope</a> is bound to the new extension
extension class.</dt> class.</dt>
<dd> <dd>
<ul> <ul>
<li>If supplied, the value of <code>docstring</code> is bound to <li>If supplied, the value of <code>docstring</code> is bound to the
the <code>__doc__</code> attribute of the extension class.</li> <code>__doc__</code> attribute of the extension class.</li>
<li>If <code>init_spec</code> is <code>no_init</code>, a special <li>If <code>init_spec</code> is <code>no_init</code>, a special
<code>__init__</code> function is generated which always raises a <code>__init__</code> function is generated which always raises a
Python exception. Otherwise, <code>this-&gt;def(init_spec)</code> Python exception. Otherwise, <code>this-&gt;def(init_spec)</code> is
is called.</li> called.</li>
<li>If <code>init_spec</code> is not supplied, <li>If <code>init_spec</code> is not supplied,
<code>this-&gt;def(init&lt;&gt;())</code> is called.</li> <code>this-&gt;def(init&lt;&gt;())</code> is called.</li>
@@ -333,46 +338,44 @@ class_(char const* name, char const* docstring, Init init_spec);
<dt><b>Rationale:</b>Allowing the user to specify constructor arguments <dt><b>Rationale:</b>Allowing the user to specify constructor arguments
in the <code>class_&lt;&gt;</code> constructor helps her to avoid the in the <code>class_&lt;&gt;</code> constructor helps her to avoid the
common run-time errors which result from invoking wrapped member common run-time errors which result from invoking wrapped member
functions without having exposed an <code>__init__</code> function functions without having exposed an <code>__init__</code> function which
which creates the requisite <code>T</code> instance. Types which are creates the requisite <code>T</code> instance. Types which are not
not default-constructible will cause a compile-time error unless default-constructible will cause a compile-time error unless
<code>Init</code> is supplied. The user must always supply <code>Init</code> is supplied. The user must always supply
<code>name</code> as there is currently no portable method to derive <code>name</code> as there is currently no portable method to derive the
the text of the class name from its type.</dt> text of the class name from its type.</dt>
</dl> </dl>
<h4><a name="class_-spec-modifiers"></a>Class template <h4><a name="class_-spec-modifiers" id="class_-spec-modifiers"></a>Class
<code>class_</code> modifier functions</h4> template <code>class_</code> modifier functions</h4>
<pre> <pre>
template &lt;class Init&gt; template &lt;class Init&gt;
class_&amp; def(Init init_expr); class_&amp; def(Init init_expr);
</pre> </pre>
<dl class="function-semantics"> <dl class="function-semantics">
<dt><b>Requires:</b> <code>init_expr</code> is the result of an <a <dt><b>Requires:</b> <code>init_expr</code> is the result of an <a href=
href="init.html#init-expression">init-expression</a> compatible with "init.html#init-expressions">init-expression</a> compatible with
<code>T</code>.</dt> <code>T</code>.</dt>
<dt><b>Effects:</b> For each <a href="init.html#init-expressions">valid <dt><b>Effects:</b> For each <a href="init.html#init-expressions">valid
prefix</a> <em>P</em> of <code>Init</code>, adds an prefix</a> <em>P</em> of <code>Init</code>, adds an
<code>__init__(</code>...<code>)</code> function overload to the <code>__init__(</code>...<code>)</code> function overload to the
extension class accepting <em>P</em> as arguments. Each overload extension class accepting <em>P</em> as arguments. Each overload
generated constructs an object of <code>HeldType</code> according to generated constructs an object of <code>HeldType</code> according to the
the semantics described <a href="#HeldType">above</a>, using a copy of semantics described <a href="#HeldType">above</a>, using a copy of
<code>init_expr</code>'s <a href="CallPolicies.html">call policies</a>. <code>init_expr</code>'s <a href="CallPolicies.html">call policies</a>.
If the longest <a href="init.html#init-expressions">valid prefix</a> of If the longest <a href="init.html#init-expressions">valid prefix</a> of
<code>Init</code> contains <em>N</em> types and <code>init_expr</code> <code>Init</code> contains <em>N</em> types and <code>init_expr</code>
holds <em>M</em> keywords, an initial sequence of the keywords are used holds <em>M</em> keywords, an initial sequence of the keywords are used
for all but the first <em>N</em>&nbsp;-&nbsp;<em>M</em> arguments of for all but the first <em>N</em> - <em>M</em> arguments of each
each overload.</dt> overload.</dt>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
<dt><b>Rationale:</b> Allows users to easily expose a class' <dt><b>Rationale:</b> Allows users to easily expose a class' constructor
constructor to Python.</dt> to Python.</dt>
</dl> </dl><br>
<br>
<pre> <pre>
template &lt;class F&gt; template &lt;class F&gt;
class_&amp; def(char const* name, Fn fn); class_&amp; def(char const* name, Fn fn);
@@ -392,19 +395,18 @@ class_&amp; def(char const* name, Fn fn, A1 const&amp; a1, A2 const&amp; a2, A3
<dd> <dd>
<ul> <ul>
<li> <li>If <code>a1</code> is the result of an <a href=
If <code>a1</code> is the result of an <a href=
"overloads.html#overload-dispatch-expression"><em>overload-dispatch-expression</em></a>, "overloads.html#overload-dispatch-expression"><em>overload-dispatch-expression</em></a>,
only the second form is allowed and fn must be a pointer to only the second form is allowed and fn must be a pointer to function
function or pointer to member function whose <a href= or pointer to member function whose <a href="definitions.html#arity">
"definitions.html#arity">arity</a> is the same as A1's <a href= arity</a> is the same as A1's <a href=
"overloads.html#overload-dispatch-expression"><em>maximum "overloads.html#overload-dispatch-expression"><em>maximum
arity</em></a>. arity</em></a>.
<dl> <dl>
<dt><b>Effects:</b> For each prefix <em>P</em> of <dt><b>Effects:</b> For each prefix <em>P</em> of
<code>Fn</code>'s sequence of argument types, beginning with <code>Fn</code>'s sequence of argument types, beginning with the
the one whose length is <code>A1</code>'s <a href= one whose length is <code>A1</code>'s <a href=
"overloads.html#overload-dispatch-expression"><em>minimum "overloads.html#overload-dispatch-expression"><em>minimum
arity</em></a>, adds a arity</em></a>, adds a
<code><em>name</em>(</code>...<code>)</code> method overload to <code><em>name</em>(</code>...<code>)</code> method overload to
@@ -414,34 +416,31 @@ class_&amp; def(char const* name, Fn fn, A1 const&amp; a1, A2 const&amp; a2, A3
policies</a>. If the longest valid prefix of <code>A1</code> policies</a>. If the longest valid prefix of <code>A1</code>
contains <em>N</em> types and <code>a1</code> holds <em>M</em> contains <em>N</em> types and <code>a1</code> holds <em>M</em>
keywords, an initial sequence of the keywords are used for all keywords, an initial sequence of the keywords are used for all
but the first <em>N</em>&nbsp;-&nbsp;<em>M</em> arguments of but the first <em>N</em> - <em>M</em> arguments of each
each overload.<br> overload.<br></dt>
</dt>
</dl> </dl>
</li> </li>
<li> <li>Otherwise, a single method overload is built around fn, which
Otherwise, a single method overload is built around fn, which
must not be null: must not be null:
<ul> <ul>
<li>If fn is a function pointer, its first argument must be of <li>If fn is a function pointer, its first argument must be of
the form <code>U</code>, <code>U&nbsp;<em>cv</em>&amp;</code>, the form <code>U</code>, <code>U <em>cv</em>&amp;</code>, <code>U
<code>U&nbsp;<em>cv</em>*</code>, or <em>cv</em>*</code>, or <code>U <em>cv</em>* const&amp;</code>,
<code>U&nbsp;<em>cv</em>*&nbsp;const&amp;</code>, where where <code>T*</code> is convertible to <code>U*</code>, and
<code>T*</code> is convertible to <code>U*</code>, and <code>a1</code>-<code>a3</code>, if supplied, may be selected in
<code>a1</code>-<code>a3</code>, if supplied, may be selected any order from the table below.</li>
in any order from the table below.</li>
<li>Otherwise, if fn is a member function pointer, its target <li>Otherwise, if fn is a member function pointer, its target
must be <code>T</code> or one of its public base classes, and must be <code>T</code> or one of its public base classes, and
<code>a1</code>-<code>a3</code>, if supplied, may be selected <code>a1</code>-<code>a3</code>, if supplied, may be selected in
in any order from the table below.</li> any order from the table below.</li>
<li>Otherwise, <code>Fn</code> must be [derived from] <code><a <li>Otherwise, <code>Fn</code> must be [derived from]
href="object.html#object-spec">object</a></code>, and <code><a href="object.html#object-spec">object</a></code>, and
<code>a1-a2</code>, if supplied, may be selcted in any order <code>a1-a2</code>, if supplied, may be selcted in any order from
from the first two rows of the table below. To be useful, the first two rows of the table below. To be useful,
<code>fn</code> should be <a href= <code>fn</code> should be <a href=
"http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-6"> "http://www.python.org/doc/current/lib/built-in-funcs.html#l2h-6">
callable</a>.</li> callable</a>.</li>
@@ -509,8 +508,8 @@ class_&amp; staticmethod(char const* name);
<dt><b>Effects:</b> Replaces the existing named attribute <i>x</i> with <dt><b>Effects:</b> Replaces the existing named attribute <i>x</i> with
the result of invoking <code>staticmethod(</code><i>x</i><code>)</code> the result of invoking <code>staticmethod(</code><i>x</i><code>)</code>
in Python. Specifies that the corresponding method is static and in Python. Specifies that the corresponding method is static and
therefore no object instance will be passed to it. This is equivalent therefore no object instance will be passed to it. This is equivalent to
to the Python statement:</dt> the Python statement:</dt>
<dd> <dd>
<pre> <pre>
@@ -523,9 +522,7 @@ setattr(self, name, staticmethod(getattr(self, name)))
"definitions.html#raise">raise</a> a RuntimeError.</dt> "definitions.html#raise">raise</a> a RuntimeError.</dt>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
</dl> </dl><br>
<br>
<pre> <pre>
template &lt;<i>unspecified</i>&gt; template &lt;<i>unspecified</i>&gt;
class_&amp; def(<a href= class_&amp; def(<a href=
@@ -556,15 +553,14 @@ class_&amp; setattr(char const* name, U const&amp; u);
<dd> <dd>
<blockquote> <blockquote>
<code><a href= <code><a href=
"http://www.python.org/doc/current/api/object.html#l2h-166">PyObject_SetAttrString</a>(this-&gt;ptr(),&nbsp;name,&nbsp;<a "http://www.python.org/doc/current/api/object.html#l2h-166">PyObject_SetAttrString</a>(this-&gt;ptr(),
href="object.html#object-spec-ctors">object</a>(u).ptr());</code> name, <a href=
"object.html#object-spec-ctors">object</a>(u).ptr());</code>
</blockquote> </blockquote>
</dd> </dd>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
</dl> </dl><br>
<br>
<pre> <pre>
template &lt;class Get&gt; template &lt;class Get&gt;
void add_property(char const* name, Get const&amp; fget, char const* doc=0); void add_property(char const* name, Get const&amp; fget, char const* doc=0);
@@ -582,18 +578,17 @@ void add_property(
<dt><b>Effects:</b> Creates a new Python <a href= <dt><b>Effects:</b> Creates a new Python <a href=
"http://www.python.org/2.2.2/descrintro.html#property"><code>property</code></a> "http://www.python.org/2.2.2/descrintro.html#property"><code>property</code></a>
class instance, passing <code><a href= class instance, passing <code><a href=
"object.html#object-spec-ctors">object</a>(fget)</code> (and <code><a "object.html#object-spec-ctors">object</a>(fget)</code> (and
href="object.html#object-spec-ctors">object</a>(fset)</code> in the <code><a href="object.html#object-spec-ctors">object</a>(fset)</code> in
second form) with an (optional) docstring <code>doc</code> to its constructor, the second form) with an (optional) docstring <code>doc</code> to its
then adds that property to the Python class object under construction constructor, then adds that property to the Python class object under
with the given attribute <code>name</code>.</dt> construction with the given attribute <code>name</code>.</dt>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
<dt><b>Rationale:</b> Allows users to easily expose functions that can <dt><b>Rationale:</b> Allows users to easily expose functions that can be
be invoked from Python with attribute access syntax.</dt> invoked from Python with attribute access syntax.</dt>
</dl> </dl><br>
<br>
<pre> <pre>
template &lt;class Get&gt; template &lt;class Get&gt;
void add_static_property(char const* name, Get const&amp; fget); void add_static_property(char const* name, Get const&amp; fget);
@@ -607,12 +602,12 @@ void add_static_property(char const* name, Get const&amp; fget, Set const&amp; f
"http://www.python.org/doc/current/ref/identifiers.html">identifier "http://www.python.org/doc/current/ref/identifiers.html">identifier
naming rules</a>.</dt> naming rules</a>.</dt>
<dt><b>Effects:</b> Creates a Boost.Python.StaticProperty object, <dt><b>Effects:</b> Creates a Boost.Python.StaticProperty object, passing
passing <code><a href= <code><a href="object.html#object-spec-ctors">object</a>(fget)</code>
"object.html#object-spec-ctors">object</a>(fget)</code> (and <code><a (and <code><a href=
href="object.html#object-spec-ctors">object</a>(fset)</code> in the "object.html#object-spec-ctors">object</a>(fset)</code> in the second
second form) to its constructor, then adds that property to the Python form) to its constructor, then adds that property to the Python class
class under construction with the given attribute <code>name</code>. under construction with the given attribute <code>name</code>.
StaticProperty is a special subclass of Python's <a href= StaticProperty is a special subclass of Python's <a href=
"http://www.python.org/2.2.2/descrintro.html#property"><code>property</code></a> "http://www.python.org/2.2.2/descrintro.html#property"><code>property</code></a>
class which can be called without an initial <code>self</code> class which can be called without an initial <code>self</code>
@@ -620,10 +615,9 @@ void add_static_property(char const* name, Get const&amp; fget, Set const&amp; f
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
<dt><b>Rationale:</b> Allows users to easily expose functions that can <dt><b>Rationale:</b> Allows users to easily expose functions that can be
be invoked from Python with static attribute access syntax.</dt> invoked from Python with static attribute access syntax.</dt>
</dl> </dl><br>
<br>
<pre> <pre>
template &lt;class D&gt; template &lt;class D&gt;
class_&amp; def_readonly(char const* name, D T::*pm, char const* doc=0); class_&amp; def_readonly(char const* name, D T::*pm, char const* doc=0);
@@ -643,21 +637,19 @@ class_&amp; def_readonly(char const* name, D const&amp; d);
<pre> <pre>
this-&gt;add_property(name, <a href= this-&gt;add_property(name, <a href=
"data_members.html#make_getter-spec">make_getter</a>(pm), doc); "data_members.html#make_getter-spec">make_getter</a>(pm), doc);
</pre> </pre>and
and
<pre> <pre>
this-&gt;add_static_property(name, <a href= this-&gt;add_static_property(name, <a href=
"data_members.html#make_getter-spec">make_getter</a>(d)); "data_members.html#make_getter-spec">make_getter</a>(d));
</pre> </pre>respectively.<br>
respectively.<br>
<br> <br>
</dd> </dd>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
<dt><b>Rationale:</b> Allows users to easily expose a class' data <dt><b>Rationale:</b> Allows users to easily expose a class' data member
member or free variable such that it can be inspected from Python with or free variable such that it can be inspected from Python with a natural
a natural syntax.</dt> syntax.</dt>
</dl> </dl>
<pre> <pre>
template &lt;class D&gt; template &lt;class D&gt;
@@ -674,22 +666,20 @@ class_&amp; def_readwrite(char const* name, D&amp; d);
this-&gt;add_property(name, <a href= this-&gt;add_property(name, <a href=
"data_members.html#make_getter-spec">make_getter</a>(pm), <a href= "data_members.html#make_getter-spec">make_getter</a>(pm), <a href=
"data_members.html#make_setter-spec">make_setter</a>(pm), doc); "data_members.html#make_setter-spec">make_setter</a>(pm), doc);
</pre> </pre>and
and
<pre> <pre>
this-&gt;add_static_property(name, <a href= this-&gt;add_static_property(name, <a href=
"data_members.html#make_getter-spec">make_getter</a>(d), <a href= "data_members.html#make_getter-spec">make_getter</a>(d), <a href=
"data_members.html#make_setter-spec">make_setter</a>(d)); "data_members.html#make_setter-spec">make_setter</a>(d));
</pre> </pre>respectively.<br>
respectively.<br>
<br> <br>
</dd> </dd>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
<dt><b>Rationale:</b> Allows users to easily expose a class' data or <dt><b>Rationale:</b> Allows users to easily expose a class' data or free
free variable member such that it can be inspected and set from Python variable member such that it can be inspected and set from Python with a
with a natural syntax.</dt> natural syntax.</dt>
</dl> </dl>
<pre> <pre>
template &lt;typename PickleSuite&gt; template &lt;typename PickleSuite&gt;
@@ -697,49 +687,46 @@ class_&amp; def_pickle(PickleSuite const&amp;);
</pre> </pre>
<dl class="function-semantics"> <dl class="function-semantics">
<dt><b>Requires:</b> PickleSuite must be publically derived from <a <dt><b>Requires:</b> PickleSuite must be publically derived from <a href=
href="pickle.html"><code>pickle_suite</code></a>.</dt> "pickle.html"><code>pickle_suite</code></a>.</dt>
<dt><b>Effects:</b> Defines a legal combination of the special <dt><b>Effects:</b> Defines a legal combination of the special attributes
attributes and methods: <code>__getinitargs__</code>, and methods: <code>__getinitargs__</code>, <code>__getstate__</code>,
<code>__getstate__</code>, <code>__setstate__</code>, <code>__setstate__</code>, <code>__getstate_manages_dict__</code>,
<code>__getstate_manages_dict__</code>,
<code>__safe_for_unpickling__</code>, <code>__reduce__</code></dt> <code>__safe_for_unpickling__</code>, <code>__reduce__</code></dt>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
<dt><b>Rationale:</b> Provides an <a href="pickle.html">easy to use <dt><b>Rationale:</b> Provides an <a href="pickle.html">easy to use
high-level interface</a> for establishing complete pickle support for high-level interface</a> for establishing complete pickle support for the
the wrapped class. The user is protected by compile-time consistency wrapped class. The user is protected by compile-time consistency
checks.</dt> checks.</dt>
</dl> </dl><br>
<br>
<pre> <pre>
class_&amp; enable_pickling(); class_&amp; enable_pickling();
</pre> </pre>
<dl class="function-semantics"> <dl class="function-semantics">
<dt><b>Effects:</b> Defines the <code>__reduce__</code> method and <dt><b>Effects:</b> Defines the <code>__reduce__</code> method and the
the <code>__safe_for_unpickling__</code> attribute. <code>__safe_for_unpickling__</code> attribute.</dt>
<dt><b>Returns:</b> <code>*this</code></dt> <dt><b>Returns:</b> <code>*this</code></dt>
<dt><b>Rationale:</b> Light-weight alternative to <dt><b>Rationale:</b> Light-weight alternative to
<code>def_pickle()</code>. Enables implementation of <code>def_pickle()</code>. Enables implementation of <a href=
<a href="pickle.html">pickle support</a> from Python.</dt> "pickle.html">pickle support</a> from Python.</dt>
</dl> </dl><br>
<br>
<h3><a name="bases-spec" id="bases-spec"></a>Class template
<code>bases&lt;T1, T2,</code>...<code>TN&gt;</code></h3>
<h3><a name="bases-spec"></a>Class template <p>An <a href="../../../mpl/doc/refmanual/forward-sequence.html">MPL
<code>bases&lt;T1,&nbsp;T2,</code>...<code>TN&gt;</code></h3> sequence</a> which can be used in
<code>class_&lt;</code>...<code>&gt;</code> instantiations indicate a list
of base classes.</p>
<p>An <a href="../../../mpl/doc/refmanual/forward-sequence.html">MPL sequence</a> <h4><a name="bases-spec-synopsis" id="bases-spec-synopsis"></a>Class
which can be used in <code>class_&lt;</code>...<code>&gt;</code> template <code>bases</code> synopsis</h4>
instantiations indicate a list of base classes.</p>
<h4><a name="bases-spec-synopsis"></a>Class template <code>bases</code>
synopsis</h4>
<pre> <pre>
namespace boost { namespace python namespace boost { namespace python
{ {
@@ -749,7 +736,7 @@ namespace boost { namespace python
}} }}
</pre> </pre>
<h2><a name="examples"></a>Example(s)</h2> <h2><a name="examples" id="examples"></a>Example(s)</h2>
<p>Given a C++ class declaration:</p> <p>Given a C++ class declaration:</p>
<pre> <pre>
@@ -766,8 +753,7 @@ class Foo : public Bar, public Baz
private: private:
... ...
}; };
</pre> </pre>A corresponding Boost.Python extension class can be created with:
A corresponding Boost.Python extension class can be created with:
<pre> <pre>
using namespace boost::python; using namespace boost::python;
@@ -784,21 +770,18 @@ class_&lt;Foo,bases&lt;Bar,Baz&gt; &gt;("Foo",
; ;
</pre> </pre>
<hr> <hr>
<a name="footnote_1">[1]</a> By "previously-exposed" we mean that the for <a name="footnote_1" id="footnote_1">[1]</a> By "previously-exposed" we
each <code>B</code> in <code>bases</code>, an instance of mean that the for each <code>B</code> in <code>bases</code>, an instance of
<code>class_&lt;B<font color="#007F00">, ...</font>&gt;</code> must have <code>class_&lt;B<font color="#007F00">, ...</font>&gt;</code> must have
already been constructed. already been constructed.
<pre> <pre>
class_&lt;Base&gt;("Base"); class_&lt;Base&gt;("Base");
class_&lt;Derived, bases&lt;Base&gt; &gt;("Derived"); class_&lt;Derived, bases&lt;Base&gt; &gt;("Derived");
</pre> </pre>Revised
Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan --> <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
5 August, 2002 <!--webbot bot="Timestamp" endspan i-checksum="39359" --> 1 November, 2005 <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave
<p><i>&copy; Copyright <a href= Abrahams</a> 2002.</i></p>
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
</body> </body>
</html> </html>

View File

@@ -134,7 +134,7 @@ void handle_exception() throw();
"make_function.html#make_function-spec">make_function</a>()</code>, "make_function.html#make_function-spec">make_function</a>()</code>,
<code><a href= <code><a href=
"make_function.html#make_constructor-spec">make_constructor</a>()</code>, "make_function.html#make_constructor-spec">make_constructor</a>()</code>,
<code><a href="def.html#def-spec">def</a>()</code> and <code><a href= <code><a href="def.html#class_-spec-modifiers">def</a>()</code> and <code><a href=
"class.html#def-spec">class_::def</a>()</code>. The second form can be "class.html#def-spec">class_::def</a>()</code>. The second form can be
more convenient to use (see the <a href="#examples">example</a> below), more convenient to use (see the <a href="#examples">example</a> below),
but various compilers have problems when exceptions are rethrown from but various compilers have problems when exceptions are rethrown from

View File

@@ -45,7 +45,7 @@
<dt><a href="#iterator-spec-synopsis">Class <dt><a href="#iterator-spec-synopsis">Class
<code>iterator</code> synopsis</a></dt> <code>iterator</code> synopsis</a></dt>
<dt><a href="#iterator-spec-ctors">Class template <dt><a href="#iterator-spec-constructors">Class template
<code>iterator</code> constructor</a></dt> <code>iterator</code> constructor</a></dt>
</dl> </dl>
</dd> </dd>

View File

@@ -71,7 +71,7 @@ This macro generates two functions in the scope where it is used:
and <code>void&nbsp;init_module_<i>name</i>()</code>, whose body must and <code>void&nbsp;init_module_<i>name</i>()</code>, whose body must
follow the macro invocation. <code>init_<i>name</i></code> passes follow the macro invocation. <code>init_<i>name</i></code> passes
<code>init_module_<i>name</i></code> to <code><a <code>init_module_<i>name</i></code> to <code><a
href="errors.html#handle_exception">handle_exception</a>()</code> so href="errors.html#handle_exception-spec">handle_exception</a>()</code> so
that any C++ exceptions generated are safely processeed. During the that any C++ exceptions generated are safely processeed. During the
body of <code>init_<i>name</i></code>, the current <code><a body of <code>init_<i>name</i></code>, the current <code><a
href="scope.html#scope-spec">scope</a></code> refers to the module href="scope.html#scope-spec">scope</a></code> refers to the module

View File

@@ -186,7 +186,7 @@
</dl> </dl>
<dl class="page-index"> <dl class="page-index">
<dt><a href="#operators-spec">operators</a></dt> <dt><a href="#object_operators-spec">operators</a></dt>
</dl> </dl>
</dd> </dd>
@@ -232,7 +232,7 @@ x[slice(_,_,-1)]
<p>The policies which are used for proxies representing an attribute <p>The policies which are used for proxies representing an attribute
access to a <code>const&nbsp;object</code>.</p> access to a <code>const&nbsp;object</code>.</p>
<h4><a name="class-spec-synopsis"></a>Class <h4><a name="const_attribute_policies-spec-synopsis"></a>Class
<code>const_attribute_policies</code> synopsis</h4> <code>const_attribute_policies</code> synopsis</h4>
<pre> <pre>
namespace boost { namespace python { namespace api namespace boost { namespace python { namespace api

View File

@@ -123,7 +123,7 @@ explicit opaque_pointer_converter(char const* name);
<h2><a name="examples"></a>Example</h2> <h2><a name="examples"></a>Example</h2>
please see example for <a href="return_opaque_pointer.html#example"> please see example for <a href="return_opaque_pointer.html#examples">
return_opaque_pointer</a>. return_opaque_pointer</a>.
<h2><a name="see-also"></a>See Also</h2> <h2><a name="see-also"></a>See Also</h2>

View File

@@ -57,7 +57,7 @@
<dt><a href="#self_t-spec-value-unary-ops">Class <dt><a href="#self_t-spec-value-unary-ops">Class
<code>self_t</code> unary operations</a></dt> <code>self_t</code> unary operations</a></dt>
<dt><a href="#self_t-spec-value-value-ops">Class <dt><a href="#self_t-spec-value-ops">Class
<code>self_t</code> value operations</a></dt> <code>self_t</code> value operations</a></dt>
</dl> </dl>
</dd> </dd>

View File

@@ -51,13 +51,11 @@
3.1, and 3.2 on <a href="http://www.redhat.com">RedHat Linux 7.3</a> 3.1, and 3.2 on <a href="http://www.redhat.com">RedHat Linux 7.3</a>
for Intel x86</dt> for Intel x86</dt>
<dt><a href= <dt>Tru64 CXX 6.5.1 on OSF v. 5.1 for Dec/Compaq
"http://www.tru64unix.compaq.com/cplus/index.html">Tru64 CXX Alpha</dt>
6.5.1</a> on OSF v. 5.1 for Dec/Compaq Alpha</dt>
<dt><a href= <dt>
"http://www.sgi.com/developers/devtools/languages/mipspro.html"> MIPSPro 7.3.1.2m on <a href=
MIPSPro 7.3.1.2m</a> on <a href=
"http://www.sgi.com/software/irix6.5/">IRIX 6.5</a> for SGI "http://www.sgi.com/software/irix6.5/">IRIX 6.5</a> for SGI
mips</dt> mips</dt>
@@ -70,21 +68,16 @@
<dd> <dd>
<dl> <dl>
<dt><a href= <dt>KCC 3.4d on OSF v. 5.1 for Dec/Compaq Alpha</dt>
"http://developer.intel.com/software/products/kcc/">KCC
3.4d</a> on OSF v. 5.1 for Dec/Compaq Alpha</dt>
<dt><a href= <dt>KCC 3.4d</a> on AIX</dt>
"http://developer.intel.com/software/products/kcc/">KCC
3.4d</a> on AIX</dt>
</dl> </dl>
</dd> </dd>
</dl> </dl>
<br> <br>
</dd> </dd>
<dt><a href="http://www.microsoft.com/windowsxp/default.asp">Microsoft <dt>Microsoft Windows XP Professional with Python <a href=
Windows XP Professional</a> with Python <a href=
"http://www.python.org/2.2">2.2</a>, <a href= "http://www.python.org/2.2">2.2</a>, <a href=
"http://www.python.org/2.2.1">2.2.1</a>, and <a href= "http://www.python.org/2.2.1">2.2.1</a>, and <a href=
"http://www.python.org/2.2.2">2.2.2b1</a>:</dt> "http://www.python.org/2.2.2">2.2.2b1</a>:</dt>

View File

@@ -45,8 +45,8 @@
<p><code>&lt;boost/python/pointee.hpp&gt;</code> introduces a <p><code>&lt;boost/python/pointee.hpp&gt;</code> introduces a
traits <a traits <a
href="../../../mpl/doc/index.html#metafunctions">metafunction</a> href="../../../mpl/doc/refmanual/metafunction.html">metafunction</a>
template <code>pointee&lt;T&gt;</code> which can be used to extract the &quot;pointed-to&quot; type from the type of a pointer or smart pointer. template <code>pointee&lt;T&gt;</code> that can be used to extract the &quot;pointed-to&quot; type from the type of a pointer or smart pointer.
<h2><a name="classes"></a>Classes</h2> <h2><a name="classes"></a>Classes</h2>

View File

@@ -76,7 +76,7 @@
<dt><a href= <dt><a href=
"Dereferenceable.html#Dereferenceable-concept">Dereferenceable</a></dt> "Dereferenceable.html#Dereferenceable-concept">Dereferenceable</a></dt>
<dt><a href="Dereferenceable.html#Extractor-concept">Extractor</a></dt> <dt><a href="Extractor.html#Extractor-concept">Extractor</a></dt>
<dt><a href= <dt><a href=
"HolderGenerator.html#HolderGenerator-concept">HolderGenerator</a></dt> "HolderGenerator.html#HolderGenerator-concept">HolderGenerator</a></dt>
@@ -981,7 +981,7 @@
<dd> <dd>
<dl class="index"> <dl class="index">
<dt>class template <a href= <dt>class template <a href=
"pointee.html#pointee">pointee</a></dt> "pointee.html#pointee-spec">pointee</a></dt>
</dl> </dl>
</dd> </dd>
</dl> </dl>

View File

@@ -102,9 +102,9 @@ template &lt;class T&gt; struct apply
<dt><b>Returns:</b> <code>typedef <a href= <dt><b>Returns:</b> <code>typedef <a href=
"to_python_indirect.html#to_python_indirect-spec">to_python_indirect</a>&lt;T,V&gt; "to_python_indirect.html#to_python_indirect-spec">to_python_indirect</a>&lt;T,V&gt;
type</code>, where <code>V</code> is a <a href= type</code>, where <code>V</code> is a class whose
"to_python_indirect.html#HolderObjectGenerator">HolderObjectGenerator</a> static <code>execute</code> function constructs an instance
which constructs an instance holder containing an <i>unowned</i> holder containing an <i>unowned</i>
<code>U*</code> pointing to the referent of the wrapped function's <code>U*</code> pointing to the referent of the wrapped function's
return value.</dt> return value.</dt>
</dl> </dl>

View File

@@ -137,8 +137,8 @@ namespace boost { namespace python
}} }}
</pre> </pre>
<h4><a name="default_call_policies-spec-statics"></a>Class <h4><a name="return_internal_reference-spec-statics"></a>Class
<code>default_call_policies</code> static functions</h4> <code>return_internal_reference</code> static functions</h4>
<pre> <pre>
PyObject* postcall(PyObject* args, PyObject* result); PyObject* postcall(PyObject* args, PyObject* result);
</pre> </pre>

View File

@@ -53,7 +53,7 @@ for the Python <a
href="http://www.python.org/doc/2.3.3/api/slice-objects.html">slice</a> href="http://www.python.org/doc/2.3.3/api/slice-objects.html">slice</a>
type.</p> type.</p>
<h2><a name="classes"></a>Classes</h2> <h2><a name="classes"></a>Classes</h2>
<h3><a name="class-spec"></a>Class <code>slice</code></h3> <h3><a name="slice-spec"></a>Class <code>slice</code></h3>
<p>Exposes the extended slicing protocol by wrapping the built-in slice <p>Exposes the extended slicing protocol by wrapping the built-in slice
type. The semantics of the constructors and member functions defined type. The semantics of the constructors and member functions defined
below can be fully understood by reading the <a below can be fully understood by reading the <a
@@ -134,7 +134,7 @@ slice(Int1 start, Int2 stop, Int3 step);
<dt><b>Effects:</b> constructs a new slice with start stop and step <dt><b>Effects:</b> constructs a new slice with start stop and step
values.&nbsp; Equivalent to the slice object created values.&nbsp; Equivalent to the slice object created
by the built-in Python function <code><a by the built-in Python function <code><a
href="http://www.python.org/doc/current/lib/built-in-functions.html#12h-62">slice(start,stop,step)</a></code>, href="http://www.python.org/doc/current/lib/built-in-funcs.html">slice(start,stop,step)</a></code>,
or as part of the Python expression <code>base[start:stop:step]</code>.</dt> or as part of the Python expression <code>base[start:stop:step]</code>.</dt>
<dt><b>Throws:</b> <code>error_already_set</code> and sets a Python <code>TypeError</code> <dt><b>Throws:</b> <code>error_already_set</code> and sets a Python <code>TypeError</code>
exception if no conversion is possible from the arguments to type exception if no conversion is possible from the arguments to type

View File

@@ -1,62 +1,13 @@
// Copyright David Abrahams 2003. // Copyright David Abrahams 2005.
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
#ifndef IS_XXX_DWA2003224_HPP #ifndef IS_XXX_DWA2003224_HPP
# define IS_XXX_DWA2003224_HPP # define IS_XXX_DWA2003224_HPP
# include <boost/config.hpp> # include <boost/detail/is_xxx.hpp>
# include <boost/mpl/bool.hpp>
# include <boost/preprocessor/enum_params.hpp>
# if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
# include <boost/type_traits/is_reference.hpp>
# include <boost/type_traits/add_reference.hpp>
# define BOOST_PYTHON_IS_XXX_DEF(name, qualified_name, nargs) \ # define BOOST_PYTHON_IS_XXX_DEF(name, qualified_name, nargs) \
template <class X_> \ BOOST_DETAIL_IS_XXX_DEF(name, qualified_name, nargs)
struct is_##name \
{ \
typedef char yes; \
typedef char (&no)[2]; \
\
static typename add_reference<X_>::type dummy; \
\
struct helpers \
{ \
template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class U) > \
static yes test( \
qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, U) >&, int \
); \
\
template <class U> \
static no test(U&, ...); \
}; \
\
BOOST_STATIC_CONSTANT( \
bool, value \
= !is_reference<X_>::value \
& (sizeof(helpers::test(dummy, 0)) == sizeof(yes))); \
\
typedef mpl::bool_<value> type; \
};
# else
# define BOOST_PYTHON_IS_XXX_DEF(name, qualified_name, nargs) \
template <class T> \
struct is_##name : mpl::false_ \
{ \
}; \
\
template < BOOST_PP_ENUM_PARAMS_Z(1, nargs, class T) > \
struct is_##name< \
qualified_name< BOOST_PP_ENUM_PARAMS_Z(1, nargs, T) > \
> \
: mpl::true_ \
{ \
};
# endif
#endif // IS_XXX_DWA2003224_HPP #endif // IS_XXX_DWA2003224_HPP

View File

@@ -22,6 +22,26 @@
#ifdef _DEBUG #ifdef _DEBUG
# ifndef BOOST_DEBUG_PYTHON # ifndef BOOST_DEBUG_PYTHON
# ifdef _MSC_VER
// VC8.0 will complain if system headers are #included both with
// and without _DEBUG defined, so we have to #include all the
// system headers used by pyconfig.h right here.
# include <stddef.h>
# include <stdarg.h>
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
# include <errno.h>
# include <ctype.h>
# include <wchar.h>
# include <basetsd.h>
# include <io.h>
# include <limits.h>
# include <float.h>
# include <string.h>
# include <math.h>
# include <time.h>
# endif
# undef _DEBUG // Don't let Python force the debug library just because we're debugging. # undef _DEBUG // Don't let Python force the debug library just because we're debugging.
# define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H # define DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
# endif # endif
@@ -143,6 +163,10 @@ typedef int pid_t;
#ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H #ifdef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
# undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H # undef DEBUG_UNDEFINED_FROM_WRAP_PYTHON_H
# define _DEBUG # define _DEBUG
# ifdef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
# undef _CRT_NOFORCE_MANIFEST_DEFINED_FROM_WRAP_PYTHON_H
# undef _CRT_NOFORCE_MANIFEST
# endif
#endif #endif
#if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2 #if !defined(PY_MAJOR_VERSION) || PY_MAJOR_VERSION < 2

View File

@@ -30,6 +30,10 @@
# include <boost/mpl/for_each.hpp> # include <boost/mpl/for_each.hpp>
# include <boost/mpl/placeholders.hpp> # include <boost/mpl/placeholders.hpp>
# include <boost/mpl/single_view.hpp> # include <boost/mpl/single_view.hpp>
# include <boost/mpl/assert.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_convertible.hpp> # include <boost/type_traits/is_convertible.hpp>
# include <boost/noncopyable.hpp> # include <boost/noncopyable.hpp>
@@ -49,6 +53,12 @@ struct register_base_of
template <class Base> template <class Base>
inline void operator()(Base*) const inline void operator()(Base*) const
{ {
# if !BOOST_WORKAROUND(BOOST_MSVC, == 1200)
BOOST_MPL_ASSERT_NOT((is_same<Base,Derived>));
# else
BOOST_STATIC_ASSERT(!(is_same<Base,Derived>::value));
# endif
// Register the Base class // Register the Base class
register_dynamic_id<Base>(); register_dynamic_id<Base>();
@@ -186,7 +196,7 @@ struct class_metadata
, mpl::if_< , mpl::if_<
use_value_holder use_value_holder
, value_holder<T> , value_holder<T>
, pointer_holder<held_type,T> , pointer_holder<held_type,wrapped>
> >
>::type holder; >::type holder;
@@ -199,7 +209,8 @@ struct class_metadata
template <class T2> template <class T2>
inline static void register_aux(python::wrapper<T2>*) inline static void register_aux(python::wrapper<T2>*)
{ {
class_metadata::register_aux2((T2*)0, mpl::true_()); typedef typename mpl::not_<is_same<T2,wrapped> >::type use_callback;
class_metadata::register_aux2((T2*)0, use_callback());
} }
inline static void register_aux(void*) inline static void register_aux(void*)
@@ -242,6 +253,7 @@ struct class_metadata
// //
inline static void maybe_register_class_to_python(void*, mpl::true_) {} inline static void maybe_register_class_to_python(void*, mpl::true_) {}
template <class T2> template <class T2>
inline static void maybe_register_class_to_python(T2*, mpl::false_) inline static void maybe_register_class_to_python(T2*, mpl::false_)
{ {

View File

@@ -29,6 +29,8 @@
# include <boost/preprocessor/repetition/enum_params.hpp> # include <boost/preprocessor/repetition/enum_params.hpp>
# include <boost/preprocessor/repetition/enum_binary_params.hpp> # include <boost/preprocessor/repetition/enum_binary_params.hpp>
# include <boost/utility/addressof.hpp>
namespace boost { namespace python { namespace objects { namespace boost { namespace python { namespace objects {
# if BOOST_WORKAROUND(__GNUC__, == 2) # if BOOST_WORKAROUND(__GNUC__, == 2)
@@ -86,12 +88,12 @@ private: // required holder implementation
template <class Value> template <class Value>
void* value_holder<Value>::holds(type_info dst_t, bool null_ptr_only) void* value_holder<Value>::holds(type_info dst_t, bool null_ptr_only)
{ {
if (void* wrapped = holds_wrapped(dst_t, &m_held, &m_held)) if (void* wrapped = holds_wrapped(dst_t, boost::addressof(m_held), boost::addressof(m_held)))
return wrapped; return wrapped;
type_info src_t = python::type_id<Value>(); type_info src_t = python::type_id<Value>();
return src_t == dst_t ? &m_held return src_t == dst_t ? boost::addressof(m_held)
: find_static_type(&m_held, src_t, dst_t); : find_static_type(boost::addressof(m_held), src_t, dst_t);
} }
template <class Value, class Held> template <class Value, class Held>
@@ -132,7 +134,7 @@ void* value_holder_back_reference<Value,Held>::holds(
BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil) BOOST_PP_REPEAT_1ST(N, BOOST_PYTHON_UNFORWARD_LOCAL, nil)
) )
{ {
python::detail::initialize_wrapper(self, &this->m_held); python::detail::initialize_wrapper(self, boost::addressof(this->m_held));
} }
# undef N # undef N

View File

@@ -55,12 +55,15 @@ namespace detail
} }
# endif # endif
# if !defined(BOOST_MSVC) || BOOST_WORKAROUND(_MSC_FULL_VER, > 140040607) # if defined(BOOST_MSVC) && BOOST_WORKAROUND(_MSC_FULL_VER, <= 140040607) || BOOST_WORKAROUND(BOOST_INTEL_WIN, >= 900)
// No operator T&
# else
template <class T> template <class T>
operator T&() const operator T&() const
{ {
converter::return_from_python<T&> converter; converter::return_from_python<T&> converter;
return converter(m_obj.release()); return converter(const_cast<handle<>&>(m_obj).release());
} }
# endif # endif

View File

@@ -70,10 +70,8 @@ namespace detail
: m_pmf(pmf) : m_pmf(pmf)
{} {}
#if !BOOST_WORKAROUND(__EDG_VERSION__, <= 245)
private: private:
#endif friend class python::def_visitor_access;
friend class def_visitor_access;
template <class C_, class Options> template <class C_, class Options>
void visit(C_& c, char const* name, Options& options) const void visit(C_& c, char const* name, Options& options) const

View File

@@ -101,6 +101,10 @@ bpl-test crossmod_exception
[ bpl-test andreas_beyer ] [ bpl-test andreas_beyer ]
[ bpl-test polymorphism ] [ bpl-test polymorphism ]
[ bpl-test polymorphism2 ] [ bpl-test polymorphism2 ]
[ bpl-test wrapper_held_type ]
[ bpl-test polymorphism2_auto_ptr ]
[ bpl-test auto_ptr ] [ bpl-test auto_ptr ]
[ bpl-test minimal ] [ bpl-test minimal ]
[ bpl-test args ] [ bpl-test args ]
@@ -115,7 +119,7 @@ bpl-test crossmod_exception
[ bpl-test keywords : keywords.cpp keywords_test.py ] [ bpl-test keywords : keywords.cpp keywords_test.py ]
[ extension builtin_converters : test_builtin_converters.cpp <template>../build/extension ] [ extension builtin_converters : test_builtin_converters.cpp <template>../build/extension ]
[ boost-python-runtest builtin_converters : test_builtin_converters.py <pyd>builtin_converters ] [ boost-python-runtest builtin_converters : test_builtin_converters.py <pyd>builtin_converters : : : -v ]
[ bpl-test test_pointer_adoption ] [ bpl-test test_pointer_adoption ]
[ bpl-test operators ] [ bpl-test operators ]
@@ -164,11 +168,11 @@ bpl-test crossmod_exception
[ bpl-test vector_indexing_suite ] [ bpl-test vector_indexing_suite ]
[ bpl-test pointer_vector ] [ bpl-test pointer_vector ]
[ extension map_indexing_suite_ext [ extension map_indexing_suite_ext
: map_indexing_suite.cpp int_map_indexing_suite.cpp <template>../build/extension ] : map_indexing_suite.cpp int_map_indexing_suite.cpp <template>../build/extension ]
[ boost-python-runtest
map_indexing_suite : map_indexing_suite.py <pyd>map_indexing_suite_ext ] #[ boost-python-runtest
# map_indexing_suite : map_indexing_suite.py <pyd>map_indexing_suite_ext : : : -v ]
# if $(TEST_BIENSTMAN_NON_BUGS) # if $(TEST_BIENSTMAN_NON_BUGS)
# { # {

View File

@@ -1,4 +1,3 @@
#define BOOST_NO_STD_WSTRING
// Copyright David Abrahams 2002. // Copyright David Abrahams 2002.
// Distributed under the Boost Software License, Version 1.0. (See // Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at // accompanying file LICENSE_1_0.txt or copy at

View File

@@ -13,6 +13,14 @@
#include <boost/python/call.hpp> #include <boost/python/call.hpp>
#include <boost/utility.hpp> #include <boost/utility.hpp>
#include <memory>
#ifdef HELD_BY_AUTO_PTR
# define HELD_PTR(X) , std::auto_ptr< X >
#else
# define HELD_PTR(X)
#endif
using namespace boost::python; using namespace boost::python;
struct P struct P
@@ -123,19 +131,23 @@ C& getCCppObj ()
A* pass_a(A* x) { return x; } A* pass_a(A* x) { return x; }
#ifdef HELD_BY_AUTO_PTR
BOOST_PYTHON_MODULE_INIT(polymorphism2_auto_ptr_ext)
#else
BOOST_PYTHON_MODULE_INIT(polymorphism2_ext) BOOST_PYTHON_MODULE_INIT(polymorphism2_ext)
#endif
{ {
class_<ACallback,boost::noncopyable>("A") class_<ACallback HELD_PTR(A),boost::noncopyable>("A")
.def("f", &A::f, &ACallback::default_f) .def("f", &A::f, &ACallback::default_f)
; ;
def("getBCppObj", getBCppObj, return_value_policy<reference_existing_object>()); def("getBCppObj", getBCppObj, return_value_policy<reference_existing_object>());
class_<C,bases<A>,boost::noncopyable>("C") class_<C HELD_PTR(C),bases<A>,boost::noncopyable>("C")
.def("f", &C::f) .def("f", &C::f)
; ;
class_<DCallback,bases<A>,boost::noncopyable>("D") class_<DCallback HELD_PTR(D),bases<A>,boost::noncopyable>("D")
.def("f", &D::f) .def("f", &D::f)
.def("g", &D::g) .def("g", &D::g)
; ;
@@ -152,7 +164,7 @@ BOOST_PYTHON_MODULE_INIT(polymorphism2_ext)
.def("f", pure_virtual(&P::f)) .def("f", pure_virtual(&P::f))
; ;
class_<Q, bases<P> >("Q") class_<Q HELD_PTR(Q), bases<P> >("Q")
.def("g", &P::g) // make sure virtual inheritance doesn't interfere .def("g", &P::g) // make sure virtual inheritance doesn't interfere
; ;
} }

View File

@@ -2,7 +2,7 @@
# Software License, Version 1.0. (See accompanying # Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import unittest import unittest
from polymorphism2_ext import * import sys
class PolymorphTest(unittest.TestCase): class PolymorphTest(unittest.TestCase):
@@ -78,10 +78,17 @@ class PolymorphTest(unittest.TestCase):
self.failUnlessEqual ('R.f', r.f()) self.failUnlessEqual ('R.f', r.f())
if __name__ == "__main__": def test():
# remove the option that upsets unittest
# remove the option which upsets unittest
import sys import sys
sys.argv = [ x for x in sys.argv if x != '--broken-auto-ptr' ] sys.argv = [ x for x in sys.argv if x != '--broken-auto-ptr' ]
unittest.main() unittest.main()
# This nasty hack basically says that if we're loaded by another module, we'll
# be testing polymorphism2_auto_ptr_ext instead of polymorphism2_ext.
if __name__ == "__main__":
from polymorphism2_ext import *
test()
else:
from polymorphism2_auto_ptr_ext import *

View File

@@ -0,0 +1,6 @@
// Copyright David Abrahams 2005. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define HELD_BY_AUTO_PTR
#include "polymorphism2.cpp"

View File

@@ -0,0 +1,5 @@
# Copyright David Abrahams 2005. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
import polymorphism2
polymorphism2.test()

View File

@@ -85,14 +85,14 @@ BOOST_PYTHON_MODULE(builtin_converters)
def("rewrap_value_complex_double", by_value<std::complex<double> >::rewrap); def("rewrap_value_complex_double", by_value<std::complex<double> >::rewrap);
def("rewrap_value_complex_long_double", by_value<std::complex<long double> >::rewrap); def("rewrap_value_complex_long_double", by_value<std::complex<long double> >::rewrap);
def("rewrap_value_wstring", def("rewrap_value_wstring",
# ifdef BOOST_NO_STD_WSTRING # if defined(BOOST_NO_STD_WSTRING) || !defined(Py_USING_UNICODE)
identity_ identity_
# else # else
by_value<std::wstring>::rewrap by_value<std::wstring>::rewrap
# endif # endif
); );
def("rewrap_value_string", def("rewrap_value_string",
# ifdef BOOST_NO_STD_WSTRING # if defined(BOOST_NO_STD_WSTRING) || !defined(Py_USING_UNICODE)
identity_ identity_
# else # else
by_value<std::wstring>::rewrap by_value<std::wstring>::rewrap

View File

@@ -78,12 +78,23 @@ r"""
'hello, world' 'hello, world'
>>> rewrap_value_string('yo, wassup?') >>> rewrap_value_string('yo, wassup?')
'yo, wassup?' 'yo, wassup?'
>>> rewrap_value_wstring(u'yo, wassup?')
>>> try:
... if unicode: pass
... except:
... print "u'yo, wassup?'"
... else:
... eval("rewrap_value_wstring(u'yo, wassup?')")
u'yo, wassup?' u'yo, wassup?'
test that overloading on unicode works: test that overloading on unicode works:
>>> rewrap_value_string(u'yo, wassup?') >>> try:
... if unicode: pass
... except:
... print "u'yo, wassup?'"
... else:
... eval("rewrap_value_string(u'yo, wassup?')")
u'yo, wassup?' u'yo, wassup?'
wrap strings with embedded nulls: wrap strings with embedded nulls:

68
test/wrapper_held_type.cpp Executable file
View File

@@ -0,0 +1,68 @@
// Copyright David Abrahams 2005. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/def.hpp>
#include <boost/python/class.hpp>
#include <boost/python/wrapper.hpp>
#include <boost/python/module.hpp>
#include <boost/python/implicit.hpp>
#include <memory>
struct data
{
virtual int id() const
{
return 42;
}
};
std::auto_ptr<data> create_data()
{
return std::auto_ptr<data>( new data );
}
void do_nothing( std::auto_ptr<data>& ){}
namespace bp = boost::python;
struct data_wrapper : data, bp::wrapper< data >
{
data_wrapper(data const & arg )
: data( arg )
, bp::wrapper< data >()
{}
data_wrapper()
: data()
, bp::wrapper< data >()
{}
virtual int id() const
{
if( bp::override id = this->get_override( "id" ) )
return bp::call<int>(id.ptr()); // id();
else
return data::id( );
}
virtual int default_id( ) const
{
return this->data::id( );
}
};
BOOST_PYTHON_MODULE(wrapper_held_type_ext)
{
bp::class_< data_wrapper, std::auto_ptr< data > >( "data" )
.def( "id", &data::id, &::data_wrapper::default_id );
bp::def( "do_nothing", &do_nothing );
bp::def( "create_data", &create_data );
}
#include "module_tail.cpp"

34
test/wrapper_held_type.py Normal file
View File

@@ -0,0 +1,34 @@
# Copyright David Abrahams 2005. Distributed under the Boost
# Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
'''
>>> from wrapper_held_type_ext import *
>>> d = data()
>>> print d.id()
42
>>> do_nothing( d )
>>> print d.id()
42
>>> d = create_data()
>>> print d.id()
42
>>> do_nothing( d )
>>> print d.id()
42
'''
def run(args = None):
import sys
import doctest
if args is not None:
sys.argv = args
return doctest.testmod(sys.modules.get(__name__))
if __name__ == '__main__':
print "running..."
import sys
status = run()[0]
if (status == 0): print "Done."
sys.exit(status)