mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 05:22:45 +00:00
Compare commits
102 Commits
svn-branch
...
boost-1.34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2d247a113 | ||
|
|
a784bfc0f8 | ||
|
|
b8937d0bae | ||
|
|
4827ae73d5 | ||
|
|
8eddc7aa37 | ||
|
|
98a468dadc | ||
|
|
ea4e6c0a4c | ||
|
|
7cd7f6d8ee | ||
|
|
4c39e8c990 | ||
|
|
6c6f654fbe | ||
|
|
b7eaea096e | ||
|
|
904ae8604c | ||
|
|
44d53c448b | ||
|
|
e61401d27e | ||
|
|
be7ca7d269 | ||
|
|
47b4b4efbb | ||
|
|
4fa07f2b3d | ||
|
|
c880e7d69d | ||
|
|
c73ad50286 | ||
|
|
0910710ac4 | ||
|
|
04c528138b | ||
|
|
1b66cd9643 | ||
|
|
c2dd9fa833 | ||
|
|
b085121369 | ||
|
|
fa219bce9b | ||
|
|
10b85d67e7 | ||
|
|
ca91dc828e | ||
|
|
3a53c1dec0 | ||
|
|
da8e309957 | ||
|
|
2bd9141d4a | ||
|
|
c3bda6a903 | ||
|
|
d61909d3ea | ||
|
|
1755dad7e6 | ||
|
|
3b392c99be | ||
|
|
24ba93607b | ||
|
|
49d4aac8ec | ||
|
|
545be29ad3 | ||
|
|
8553c109c7 | ||
|
|
315c3d50ee | ||
|
|
d5219979a4 | ||
|
|
d42054f3a0 | ||
|
|
72b06e70ee | ||
|
|
375cc3aa93 | ||
|
|
4eb286a034 | ||
|
|
a824230155 | ||
|
|
1bc3750ab3 | ||
|
|
36abcee847 | ||
|
|
b8b7768eb7 | ||
|
|
7ad9dc6c64 | ||
|
|
decc34551a | ||
|
|
5acb44ede0 | ||
|
|
ef62f87963 | ||
|
|
b5c893381f | ||
|
|
815969bf8b | ||
|
|
0d57e9e808 | ||
|
|
7ba6a00617 | ||
|
|
e70bbe4791 | ||
|
|
7ff0f62729 | ||
|
|
95f0b39c90 | ||
|
|
23057688f9 | ||
|
|
029618f719 | ||
|
|
38f7a4e9b6 | ||
|
|
326c871224 | ||
|
|
924eeccd53 | ||
|
|
4a63cf4843 | ||
|
|
1d65b74273 | ||
|
|
3c1ae689a7 | ||
|
|
a99bd50e52 | ||
|
|
8b178594ff | ||
|
|
786aeef998 | ||
|
|
45e4cf506f | ||
|
|
8fb6e1f48d | ||
|
|
ecf70b05f2 | ||
|
|
c54acdb9db | ||
|
|
489dae2b58 | ||
|
|
f852ce6f7b | ||
|
|
e500919d25 | ||
|
|
7a645a6d8a | ||
|
|
fa2185e5ab | ||
|
|
5cc33461dd | ||
|
|
7b93f2fdc5 | ||
|
|
219743964d | ||
|
|
e7927ef4ea | ||
|
|
8c1f04bd4c | ||
|
|
136587c96f | ||
|
|
23664ec448 | ||
|
|
6b1a3c4489 | ||
|
|
fa4ebe5c53 | ||
|
|
28ef4a9e38 | ||
|
|
5d1053552c | ||
|
|
0a38ca1660 | ||
|
|
5791e3b58e | ||
|
|
2bfd2fa0fd | ||
|
|
0793267bf0 | ||
|
|
eca25c0b7d | ||
|
|
a8bad65556 | ||
|
|
6ef31ba33a | ||
|
|
c15216b385 | ||
|
|
a1ff35769b | ||
|
|
22e82ae30f | ||
|
|
2d117bc4ad | ||
|
|
6347ca8065 |
@@ -1,99 +0,0 @@
|
|||||||
# (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and
|
|
||||||
# distribute this software is granted provided this copyright notice appears
|
|
||||||
# in all copies. This software is provided "as is" without express or implied
|
|
||||||
# warranty, and with no claim as to its suitability for any purpose.
|
|
||||||
#
|
|
||||||
# Boost.Python library Jamfile
|
|
||||||
|
|
||||||
|
|
||||||
# declare the location of this subproject relative to the root
|
|
||||||
subproject libs/python/build ;
|
|
||||||
|
|
||||||
# bring in the rules for python
|
|
||||||
import python ;
|
|
||||||
|
|
||||||
if [ check-python-config ]
|
|
||||||
{
|
|
||||||
|
|
||||||
local bpl-linkflags ;
|
|
||||||
|
|
||||||
if $(UNIX) && ( $(OS) = AIX )
|
|
||||||
{
|
|
||||||
bpl-linkflags = <linkflags>"-e initlibboost_python" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Enabling intrinsics (/0i) or maximize speed (/02) seem to cause
|
|
||||||
# internal compiler errors with this toolset.
|
|
||||||
local msvc-stlport-workarounds
|
|
||||||
= <optimization>off "<cxxflags>-Ogty -O1 -Gs" ;
|
|
||||||
|
|
||||||
local sources =
|
|
||||||
numeric.cpp
|
|
||||||
list.cpp
|
|
||||||
long.cpp
|
|
||||||
dict.cpp
|
|
||||||
tuple.cpp
|
|
||||||
str.cpp
|
|
||||||
slice.cpp
|
|
||||||
|
|
||||||
aix_init_module.cpp
|
|
||||||
converter/from_python.cpp
|
|
||||||
converter/registry.cpp
|
|
||||||
converter/type_id.cpp
|
|
||||||
object/enum.cpp
|
|
||||||
object/class.cpp
|
|
||||||
object/function.cpp
|
|
||||||
object/inheritance.cpp
|
|
||||||
object/life_support.cpp
|
|
||||||
object/pickle_support.cpp
|
|
||||||
errors.cpp
|
|
||||||
module.cpp
|
|
||||||
converter/builtin_converters.cpp
|
|
||||||
converter/arg_to_python_base.cpp
|
|
||||||
object/iterator.cpp
|
|
||||||
object/stl_iterator.cpp
|
|
||||||
object_protocol.cpp
|
|
||||||
object_operators.cpp
|
|
||||||
wrapper.cpp
|
|
||||||
exec.cpp
|
|
||||||
import.cpp
|
|
||||||
;
|
|
||||||
|
|
||||||
dll boost_python
|
|
||||||
: ../src/$(sources)
|
|
||||||
: $(BOOST_PYTHON_V2_PROPERTIES)
|
|
||||||
<define>BOOST_PYTHON_SOURCE
|
|
||||||
$(bpl-linkflags)
|
|
||||||
<msvc-stlport><release>$(msvc-stlport-workarounds)
|
|
||||||
<darwin><*><linkflags>-bind_at_load
|
|
||||||
<gcc-3_3-darwin><*><linkflags>-bind_at_load
|
|
||||||
;
|
|
||||||
|
|
||||||
template extension
|
|
||||||
: <dll>boost_python
|
|
||||||
: <sysinclude>../../..
|
|
||||||
;
|
|
||||||
|
|
||||||
lib boost_python
|
|
||||||
: # sources
|
|
||||||
../src/$(sources)
|
|
||||||
|
|
||||||
: # requirements
|
|
||||||
$(BOOST_PYTHON_V2_PROPERTIES)
|
|
||||||
<define>BOOST_PYTHON_SOURCE
|
|
||||||
<define>BOOST_STATIC_LIB
|
|
||||||
$(bpl-linkflags)
|
|
||||||
<msvc-stlport><release>$(msvc-stlport-workarounds)
|
|
||||||
;
|
|
||||||
|
|
||||||
stage bin-stage : <dll>boost_python <lib>boost_python
|
|
||||||
: <tag><debug>"_debug"
|
|
||||||
<tag><debug-python>"_pydebug"
|
|
||||||
:
|
|
||||||
debug release
|
|
||||||
;
|
|
||||||
|
|
||||||
install python lib
|
|
||||||
: <dll>boost_python <lib>boost_python
|
|
||||||
;
|
|
||||||
}
|
|
||||||
@@ -1,32 +1,35 @@
|
|||||||
|
# Copyright David Abrahams 2001-2006. 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 os ;
|
import os ;
|
||||||
import modules ;
|
import modules ;
|
||||||
|
|
||||||
import python ;
|
import python ;
|
||||||
|
|
||||||
if [ python.configured ] {
|
if ! [ python.configured ] && ! ( --without-python in [ modules.peek : ARGV ] )
|
||||||
|
{
|
||||||
|
# Attempt default configuration of python
|
||||||
|
import toolset : using ;
|
||||||
|
using python ;
|
||||||
|
|
||||||
|
if ! [ python.configured ]
|
||||||
|
{
|
||||||
|
ECHO "WARNING: No python installation configured and autoconfiguration" ;
|
||||||
|
ECHO " failed. See http://www.boost.org/libs/python/doc/building.html" ;
|
||||||
|
ECHO " for configuration instructions or pass --without-python to" ;
|
||||||
|
ECHO " suppress this message and silently skip all Boost.Python targets" ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ python.configured ] {
|
||||||
|
|
||||||
project boost/python
|
project boost/python
|
||||||
: source-location ../src
|
: source-location ../src
|
||||||
: requirements
|
|
||||||
#<include>$(PYTHON_PATH)/include
|
|
||||||
# $(lib_condition)<library-path>$(PYTHON_PATH)/libs
|
|
||||||
# <link>shared:<library>$(PYTHON_LIB)
|
|
||||||
# <define>$(defines)
|
|
||||||
#: usage-requirements # requirement that will be propageted to *users* of this library
|
|
||||||
# <include>$(PYTHON_PATH)/include
|
|
||||||
|
|
||||||
# We have a bug which causes us to conclude that conditionalized
|
|
||||||
# properties in this section are not free.
|
|
||||||
# $(lib_condition)<library-path>$(PYTHON_PATH)/lib/python2.2/config
|
|
||||||
# <shared>true:<find-library>$(PYTHON_LIB)
|
|
||||||
|
|
||||||
# <library-path>$(PYTHON_PATH)/lib/python2.2/config
|
|
||||||
# <library>$(PYTHON_LIB)
|
|
||||||
;
|
;
|
||||||
|
|
||||||
lib boost_python
|
lib boost_python
|
||||||
:
|
: # sources
|
||||||
numeric.cpp
|
numeric.cpp
|
||||||
list.cpp
|
list.cpp
|
||||||
long.cpp
|
long.cpp
|
||||||
@@ -56,10 +59,31 @@ lib boost_python
|
|||||||
wrapper.cpp
|
wrapper.cpp
|
||||||
import.cpp
|
import.cpp
|
||||||
exec.cpp
|
exec.cpp
|
||||||
: <link>static:<define>BOOST_PYTHON_STATIC_LIB
|
: # requirements
|
||||||
|
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||||
<define>BOOST_PYTHON_SOURCE
|
<define>BOOST_PYTHON_SOURCE
|
||||||
<library>/python//python
|
|
||||||
: <link>shared
|
# On Windows, all code using Python has to link to the Python
|
||||||
|
# import library.
|
||||||
|
#
|
||||||
|
# On *nix we never link libboost_python to libpython. When
|
||||||
|
# extending Python, all Python symbols are provided by the
|
||||||
|
# Python interpreter executable. When embedding Python, the
|
||||||
|
# client executable is expected to explicitly link to
|
||||||
|
# /python//python (the target representing libpython) itself.
|
||||||
|
#
|
||||||
|
# python_for_extensions is a target defined by Boost.Build to
|
||||||
|
# provide the Python include paths, and on Windows, the Python
|
||||||
|
# import library, as usage requirements.
|
||||||
|
<library>/python//python_for_extensions
|
||||||
|
|
||||||
|
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||||
|
|
||||||
|
: # default build
|
||||||
|
<link>shared
|
||||||
|
: # usage requirements
|
||||||
|
<link>static:<define>BOOST_PYTHON_STATIC_LIB
|
||||||
|
<python-debugging>on:<define>BOOST_DEBUG_PYTHON
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Binary file not shown.
@@ -1,5 +1,11 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1 +1,5 @@
|
|||||||
|
.. Copyright David Abrahams 2006. 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)
|
||||||
|
|
||||||
This file has been moved to http://www.boost-consulting.com/writing/bpl.txt.
|
This file has been moved to http://www.boost-consulting.com/writing/bpl.txt.
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
Copyright David Abrahams 2006. 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)
|
||||||
|
|
||||||
.. This is a comment. Note how any initial comments are moved by
|
.. This is a comment. Note how any initial comments are moved by
|
||||||
transforms to after the document title, subtitle, and docinfo.
|
transforms to after the document title, subtitle, and docinfo.
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
:version: $Revision$
|
:version: $Revision$
|
||||||
:copyright: This stylesheet has been placed in the public domain.
|
:copyright: This stylesheet has been placed in the public domain.
|
||||||
|
|
||||||
|
boostinspect:nolicense
|
||||||
|
|
||||||
Default cascading style sheet for the HTML output of Docutils.
|
Default cascading style sheet for the HTML output of Docutils.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
/* Copyright David Abrahams 2006. 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)
|
||||||
|
*/
|
||||||
H1
|
H1
|
||||||
{
|
{
|
||||||
FONT-SIZE: 200%
|
FONT-SIZE: 200%
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
@@ -63,11 +66,9 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2><a name="requirements">Requirements</a></h2>
|
<h2><a name="requirements">Requirements</a></h2>
|
||||||
<b>Boost.Python</b> version 2 requires <a href=
|
<b>Boost.Python</b> requires <a href=
|
||||||
"http://www.python.org/2.2">Python 2.2</a> <i>or <a href=
|
"http://www.python.org/2.2">Python 2.2</a> <i>or <a href=
|
||||||
"http://www.python.org">newer</a></i>. An unsupported archive of
|
"http://www.python.org">newer</a></i>.
|
||||||
Boost.Python version 1, which works with versions of Python since 1.5.2,
|
|
||||||
is available <a href="../build/python_v1.zip">here</a>.
|
|
||||||
|
|
||||||
<h2><a name="building">Building Boost.Python</a></h2>
|
<h2><a name="building">Building Boost.Python</a></h2>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
@@ -39,6 +42,12 @@
|
|||||||
<li>New <a href="v2/docstring_options.html"
|
<li>New <a href="v2/docstring_options.html"
|
||||||
><code>docstring_options.hpp</code></a> header to
|
><code>docstring_options.hpp</code></a> header to
|
||||||
control the content of docstrings.
|
control the content of docstrings.
|
||||||
|
|
||||||
|
<li>Support for converting <code>void*</code> to/from python,
|
||||||
|
with <code><a
|
||||||
|
href="v2/opaque.html">opaque_pointer_converter</a></code>
|
||||||
|
as the return value policy. Thanks to Niall Douglas for the
|
||||||
|
initial patch.
|
||||||
</ul>
|
</ul>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
@@ -210,7 +219,7 @@ BOOST_PYTHON_MODULE(test)
|
|||||||
|
|
||||||
<dd><a href="mailto:Gottfried.Ganssauge-at-haufe.de">Gottfried
|
<dd><a href="mailto:Gottfried.Ganssauge-at-haufe.de">Gottfried
|
||||||
Ganßauge</a> has contributed <a href=
|
Ganßauge</a> has contributed <a href=
|
||||||
"v2/opaque_pointer_converter.html">opaque pointer support</a>.<br>
|
"v2/opaque.html">opaque pointer support</a>.<br>
|
||||||
<a href="mailto:nicodemus-at-globalite.com.br">Bruno da Silva de
|
<a href="mailto:nicodemus-at-globalite.com.br">Bruno da Silva de
|
||||||
Oliveira</a> has contributed the exciting <a href=
|
Oliveira</a> has contributed the exciting <a href=
|
||||||
"../pyste/index.html">Pyste</a> ("Pie-steh") package.</dd>
|
"../pyste/index.html">Pyste</a> ("Pie-steh") package.</dd>
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
.. Copyright David Abrahams 2006. 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)
|
||||||
|
|
||||||
How Runtime Polymorphism is expressed in Boost.Python:
|
How Runtime Polymorphism is expressed in Boost.Python:
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -1,436 +1,445 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<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="utf-8">
|
<meta http-equiv="Content-Type" content="text/html">
|
||||||
<link rel="stylesheet" type="text/css" href="boost.css">
|
<link rel="stylesheet" type="text/css" href="boost.css">
|
||||||
|
|
||||||
<title>Boost.Python - Projects using Boost.Python</title>
|
<title>Boost.Python - Projects using Boost.Python</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" alt=
|
<h3><a href="../../../index.htm"><img height="86" width="277" 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">
|
||||||
<h1 align="center"><a href="index.html">Boost.Python</a></h1>
|
<h1 align="center"><a href="index.html">Boost.Python</a></h1>
|
||||||
|
|
||||||
<h2 align="center">Projects using Boost.Python</h2>
|
<h2 align="center">Projects using Boost.Python</h2>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2>Introduction</h2>
|
<h2>Introduction</h2>
|
||||||
|
|
||||||
<p>This is a partial list of projects using Boost.Python. If you are
|
<p>This is a partial list of projects using Boost.Python. If you are using
|
||||||
using Boost.Python as your Python/C++ binding solution, we'd be proud to
|
Boost.Python as your Python/C++ binding solution, we'd be proud to list
|
||||||
list your project on this page. Just <a href=
|
your project on this page. Just <a href=
|
||||||
"mailto:c++-sig@python.org">post</a> a short description of your project
|
"mailto:c++-sig@python.org">post</a> a short description of your project
|
||||||
and how Boost.Python helps you get the job done, and we'll add it to this
|
and how Boost.Python helps you get the job done, and we'll add it to this
|
||||||
page .</p>
|
page .</p>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h3>Data Analysis</h3>
|
<h3>Data Analysis</h3>
|
||||||
|
|
||||||
<dl class="page-index">
|
<dl class="page-index">
|
||||||
<dt><b><a href=
|
<dt><b><a href="http://www.neuralynx.com">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>
|
acquisition systems. Neuralab combines presentation quality graphics, a
|
||||||
acquisition systems. Neuralab combines presentation quality graphics, a
|
numerical analysis library, and the <a href=
|
||||||
numerical analysis library, and the <a href=
|
"http://www.python.org">Python</a> scripting engine in a single
|
||||||
"http://www.python.org">Python</a> scripting engine in a single
|
application. With Neuralab, Neuralynx users can perform common analysis
|
||||||
application. With Neuralab, Neuralynx users can perform common analysis
|
tasks with just a few mouse clicks. More advanced users can create custom
|
||||||
tasks with just a few mouse clicks. More advanced users can create
|
Python scripts, which can optionally be assigned to menus and mouse
|
||||||
custom Python scripts, which can optionally be assigned to menus and
|
clicks.</dd>
|
||||||
mouse clicks.</dd>
|
</dl>
|
||||||
</dl>
|
|
||||||
|
<dl class="page-index">
|
||||||
<dl class="page-index">
|
<dt><b>TSLib</b> - <a href="http://www.fortressinv.com">Fortress
|
||||||
<dt><b>TSLib</b> - <a href="http://www.fortressinv.com">Fortress
|
Investment Group LLC</a></dt>
|
||||||
Investment Group LLC</a></dt>
|
|
||||||
|
<dd>
|
||||||
<dd>
|
Fortress Investment Group has contracted <a href=
|
||||||
Fortress Investment Group has contracted <a href=
|
"http://www.boost-consulting.com">Boost Consulting</a> to develop core
|
||||||
"http://www.boost-consulting.com">Boost Consulting</a> to develop
|
internal financial analysis tools in C++ and to prepare Python bindings
|
||||||
core internal financial analysis tools in C++ and to prepare Python
|
for them using Boost.Python.
|
||||||
bindings for them using Boost.Python.
|
|
||||||
|
<p>Tom Barket of Fortress writes:</p>
|
||||||
<p>Tom Barket of Fortress writes:</p>
|
|
||||||
|
<blockquote>
|
||||||
<blockquote>
|
We have a large C++ analytical library specialized for research in
|
||||||
We have a large C++ analytical library specialized for research in
|
finance and economics, built for speed and mission critical
|
||||||
finance and economics, built for speed and mission critical
|
stability. Yet Python offers us the flexibility to test out new ideas
|
||||||
stability. Yet Python offers us the flexibility to test out new
|
quickly and increase the productivity of our time versus working in
|
||||||
ideas quickly and increase the productivity of our time versus
|
C++. There are several key features which make Python stand out. Its
|
||||||
working in C++. There are several key features which make Python
|
elegance, stability, and breadth of resources on the web are all
|
||||||
stand out. Its elegance, stability, and breadth of resources on the
|
valuable, but the most important is its extensibility, due to its
|
||||||
web are all valuable, but the most important is its extensibility,
|
open source transparency. Boost.Python makes Python extensibility
|
||||||
due to its open source transparency. Boost.Python makes Python
|
extremely simple and straightforward, yet preserves a great deal of
|
||||||
extensibility extremely simple and straightforward, yet preserves a
|
power and control.
|
||||||
great deal of power and control.
|
</blockquote>
|
||||||
</blockquote>
|
</dd>
|
||||||
</dd>
|
</dl>
|
||||||
</dl>
|
|
||||||
|
<h3>Educational</h3>
|
||||||
<h3>Educational</h3>
|
|
||||||
|
<dl class="page-index">
|
||||||
<dl class="page-index">
|
<dt><a href="http://edu.kde.org/kig"><b>Kig</b></a></dt>
|
||||||
<dt><a href="http://edu.kde.org/kig"><b>Kig</b></a></dt>
|
|
||||||
|
<dd>
|
||||||
<dd>
|
<p>KDE Interactive Geometry is a high-school level educational tool,
|
||||||
<p>KDE Interactive Geometry is a high-school level educational tool,
|
built for the KDE desktop. It is a nice tool to let students work with
|
||||||
built for the KDE desktop. It is a nice tool to let students work
|
geometrical constructions. It is meant to be the most intuitive, yet
|
||||||
with geometrical constructions. It is meant to be the most intuitive,
|
featureful application of its kind.</p>
|
||||||
yet featureful application of its kind.</p>
|
|
||||||
|
<p>Versions after 0.6.x (will) support objects built by the user
|
||||||
<p>Versions after 0.6.x (will) support objects built by the user
|
himself in the Python language. The exporting of the relevant internal
|
||||||
himself in the Python language. The exporting of the relevant
|
API's were done using Boost.Python, which made the process very
|
||||||
internal API's were done using Boost.Python, which made the process
|
easy.</p>
|
||||||
very easy.</p>
|
</dd>
|
||||||
</dd>
|
</dl>
|
||||||
</dl>
|
|
||||||
|
<h3>Enterprise Software</h3>
|
||||||
<h3>Enterprise Software</h3>
|
|
||||||
|
<dl class="page-index">
|
||||||
<dl class="page-index">
|
<dt><b><a href="http://openwbem.sourceforge.net">OpenWBEM</a></b></dt>
|
||||||
<dt><b><a href="http://openwbem.sourceforge.net">OpenWBEM</a></b></dt>
|
|
||||||
|
<dd>
|
||||||
<dd>
|
The OpenWBEM project is an effort to develop an open-source
|
||||||
The OpenWBEM project is an effort to develop an open-source
|
implementation of Web Based Enterprise Management suitable for
|
||||||
implementation of Web Based Enterprise Management suitable for
|
commercial and non-commercial application
|
||||||
commercial and non-commercial application
|
|
||||||
|
<p><a href="mailto:dnuffer@sco.com">Dan Nuffer</a> writes:</p>
|
||||||
<p><a href="mailto:dnuffer@sco.com">Dan Nuffer</a> writes:</p>
|
|
||||||
|
<blockquote>
|
||||||
<blockquote>
|
I'm using Boost.Python to wrap the client API of OpenWBEM.This will
|
||||||
I'm using Boost.Python to wrap the client API of OpenWBEM.This will
|
make it easier to do rapid prototyping, testing, and scripting when
|
||||||
make it easier to do rapid prototyping, testing, and scripting when
|
developing management solutions that use WBEM.
|
||||||
developing management solutions that use WBEM.
|
</blockquote>
|
||||||
</blockquote>
|
</dd>
|
||||||
</dd>
|
|
||||||
|
<dt><b><a href="http://www.transversal.com">Metafaq</a></b></dt>
|
||||||
<dt><b><a href="http://www.transversal.com">Metafaq</a></b></dt>
|
|
||||||
|
<dd>
|
||||||
<dd>
|
Metafaq, from <a href="http://www.transversal.com">Transversal,
|
||||||
Metafaq, from <a href="http://www.transversal.com">Transversal,
|
Inc.</a>, is an enterprise level online knowledge base management
|
||||||
Inc.</a>, is an enterprise level online knowledge base management
|
system.
|
||||||
system.
|
|
||||||
|
<p><a href="mailto:ben.young-at-transversal.com">Ben Young</a>
|
||||||
<p><a href="mailto:ben.young-at-transversal.com">Ben Young</a>
|
writes:</p>
|
||||||
writes:</p>
|
|
||||||
|
<blockquote>
|
||||||
<blockquote>
|
Boost.Python is used in an automated process to generate python
|
||||||
Boost.Python is used in an automated process to generate python
|
bindings to our api which is exposed though multiple backends and
|
||||||
bindings to our api which is exposed though multiple backends and
|
frontends. This allows us to write quick tests and bespoke scripts to
|
||||||
frontends. This allows us to write quick tests and bespoke scripts
|
perform one off tasks without having to go through the full
|
||||||
to perform one off tasks without having to go through the full
|
compilation cycle.
|
||||||
compilation cycle.
|
</blockquote>
|
||||||
</blockquote>
|
</dd>
|
||||||
</dd>
|
</dl>
|
||||||
</dl>
|
|
||||||
|
<h3>Games</h3>
|
||||||
<h3>Games</h3>
|
|
||||||
|
<dl>
|
||||||
<dl>
|
<dt><b><a href="http://www.firaxis.com">Civilization IV</a></b></dt>
|
||||||
<dt><b><a href="http://www.firaxis.com">Civilization IV</a></b></dt>
|
</dl>
|
||||||
</dl>
|
|
||||||
|
<blockquote>
|
||||||
<blockquote>
|
“The fourth game in the PC strategy series that has sold over five
|
||||||
“The fourth game in the PC strategy series that has
|
million copies, Sid Meier's Civilization IV is a bold step forward for
|
||||||
sold over five million copies, Sid Meier's Civilization IV is a bold
|
the franchise, with spectacular new 3D graphics and all-new single and
|
||||||
step forward for the franchise, with spectacular new 3D graphics and
|
multiplayer content. Civilization IV will also set a new standard for
|
||||||
all-new single and multiplayer content. Civilization IV will also set a
|
user-modification, allowing gamers to create their own add-ons using
|
||||||
new standard for user-modification, allowing gamers to create their own
|
Python and XML.
|
||||||
add-ons using Python and XML.
|
|
||||||
|
<p>Sid Meier's Civilization IV will be released for PC in late 2005. For
|
||||||
<p>Sid Meier's Civilization IV will be released for PC in late 2005.
|
more information please visit <a href=
|
||||||
For more information please visit <a href=
|
"http://www.firaxis.com">http://www.firaxis.com</a> or write <a href=
|
||||||
"http://www.firaxis.com">http://www.firaxis.com</a> or write <a href=
|
"mailto:kgilmore@firaxis.com">kgilmore@firaxis.com</a>”</p>
|
||||||
"mailto:kgilmore@firaxis.com">kgilmore@firaxis.com</a>”</p>
|
</blockquote>
|
||||||
</blockquote>
|
|
||||||
|
<p>Boost.Python is used as the interface layer between the C++ game code
|
||||||
<p>Boost.Python is used as the interface layer between the C++ game code
|
and Python. Python is used for many purposes in the game, including map
|
||||||
and Python. Python is used for many purposes in the game, including map
|
generation, interface screens, game events, tools, tutorials, etc. Most
|
||||||
generation, interface screens, game events, tools, tutorials, etc. Most
|
high-level game operations have been exposed to Python in order to give
|
||||||
high-level game operations have been exposed to Python in order to give
|
modders the power they need to customize the game.</p>
|
||||||
modders the power they need to customize the game.</p>
|
|
||||||
|
<blockquote>
|
||||||
<blockquote>
|
-Mustafa Thamer, Civ4 Lead Programmer
|
||||||
-Mustafa Thamer, Civ4 Lead Programmer
|
</blockquote>
|
||||||
</blockquote>
|
|
||||||
|
<dl class="page-index">
|
||||||
<dl class="page-index">
|
<dt><b><a href="http://vegastrike.sourceforge.net">Vega
|
||||||
<dt><b><a href="http://vegastrike.sourceforge.net">Vega
|
Strike</a></b></dt>
|
||||||
Strike</a></b></dt>
|
|
||||||
|
<dd>
|
||||||
<dd>
|
<a href="http://vegastrike.sourceforge.net">Vega Strike</a> is the 3D
|
||||||
<a href="http://vegastrike.sourceforge.net">Vega Strike</a> is the 3D
|
Space Simulator that allows you to trade and bounty hunt in a vast
|
||||||
Space Simulator that allows you to trade and bounty hunt in a vast
|
universe. Players face dangers, decisions, piracy, and aliens.
|
||||||
universe. Players face dangers, decisions, piracy, and aliens.
|
|
||||||
|
<p><a href="http://vegastrike.sourceforge.net">Vega Strike</a> has
|
||||||
<p><a href="http://vegastrike.sourceforge.net">Vega Strike</a> has
|
decided to base its scripting on python, using boost as the layer
|
||||||
decided to base its scripting on python, using boost as the layer
|
between the class hierarchy in python and the class hierarchy in C++.
|
||||||
between the class hierarchy in python and the class hierarchy in C++.
|
The result is a very flexible scripting system that treats units as
|
||||||
The result is a very flexible scripting system that treats units as
|
native python classes when designing missions or writing AI's.</p>
|
||||||
native python classes when designing missions or writing AI's.</p>
|
|
||||||
|
<p>A large economic and planetary simulation is currently being run in
|
||||||
<p>A large economic and planetary simulation is currently being run
|
the background in python and the results are returned back into C++ in
|
||||||
in the background in python and the results are returned back into
|
the form of various factions' spaceships appearing near worlds that
|
||||||
C++ in the form of various factions' spaceships appearing near worlds
|
they are simulated to be near in python if the player is in the general
|
||||||
that they are simulated to be near in python if the player is in the
|
neighborhood.</p>
|
||||||
general neighborhood.</p>
|
</dd>
|
||||||
</dd>
|
</dl>
|
||||||
</dl>
|
|
||||||
|
<h3>Graphics</h3>
|
||||||
<h3>Graphics</h3>
|
|
||||||
|
<dl class="page-index">
|
||||||
<dl class="page-index">
|
<dt><b><a href="http://sourceforge.net/projects/pyosg">OpenSceneGraph
|
||||||
<dt><b><a href="http://sourceforge.net/projects/pyosg">OpenSceneGraph
|
Bindings</a></b></dt>
|
||||||
Bindings</a></b></dt>
|
|
||||||
|
<dd><a href="mailto:gideon@computer.org">Gideon May</a> has created a set
|
||||||
<dd><a href="mailto:gideon@computer.org">Gideon May</a> has created a
|
of bindings for <a href=
|
||||||
set of bindings for <a href=
|
"http://www.openscenegraph.org">OpenSceneGraph</a>, a cross-platform
|
||||||
"http://www.openscenegraph.org">OpenSceneGraph</a>, a cross-platform
|
C++/OpenGL library for the real-time visualization.<br>
|
||||||
C++/OpenGL library for the real-time visualization.<br>
|
</dd>
|
||||||
</dd>
|
|
||||||
|
<dt><b><a href=
|
||||||
<dt><b><a href=
|
"http://www.slac.stanford.edu/grp/ek/hippodraw/index.html">HippoDraw</a></b></dt>
|
||||||
"http://www.slac.stanford.edu/grp/ek/hippodraw/index.html">HippoDraw</a></b></dt>
|
|
||||||
|
<dd>
|
||||||
<dd>
|
HippoDraw is a data analysis environment consisting of a canvas upon
|
||||||
HippoDraw is a data analysis environment consisting of a canvas upon
|
which graphs such as histograms, scattter plots, etc, are prsented. It
|
||||||
which graphs such as histograms, scattter plots, etc, are prsented.
|
has a highly interactive GUI interface, but some things you need to do
|
||||||
It has a highly interactive GUI interface, but some things you need
|
with scripts. HippoDraw can be run as Python extension module so that
|
||||||
to do with scripts. HippoDraw can be run as Python extension module
|
all the manipulation can be done from either Python or the GUI.
|
||||||
so that all the manipulation can be done from either Python or the
|
|
||||||
GUI.
|
<p>Before the web page came online, <a href=
|
||||||
|
"mailto:Paul_Kunz@SLAC.Stanford.EDU">Paul F. Kunz</a> wrote:</p>
|
||||||
<p>Before the web page came online, <a href=
|
|
||||||
"mailto:Paul_Kunz@SLAC.Stanford.EDU">Paul F. Kunz</a> wrote:</p>
|
<blockquote>
|
||||||
|
Don't have a web page for the project, but the organization's is
|
||||||
<blockquote>
|
<a href=
|
||||||
Don't have a web page for the project, but the organization's is <a
|
"http://www.slac.stanford.edu">http://www.slac.stanford.edu</a> (the
|
||||||
href=
|
first web server site in America, I installed it).
|
||||||
"http://www.slac.stanford.edu">http://www.slac.stanford.edu</a>
|
</blockquote>Which was just too cool a piece of trivia to omit.<br>
|
||||||
(the first web server site in America, I installed it).
|
|
||||||
</blockquote>
|
</dd>
|
||||||
Which was just too cool a piece of trivia to omit.<br>
|
|
||||||
|
<dt><a href="http://www.iplt.org"><b>IPLT</b></a></dt>
|
||||||
</dd>
|
|
||||||
|
<dd>
|
||||||
<dt><a href="http://www.iplt.org"><b>IPLT</b></a></dt>
|
<a href="mailto:ansgar.philippsen-at-unibas.ch">Ansgar Philippsen</a>
|
||||||
|
writes:
|
||||||
<dd>
|
|
||||||
<a href="mailto:ansgar.philippsen-at-unibas.ch">Ansgar Philippsen</a>
|
<blockquote>
|
||||||
writes:
|
IPLT is an image processing library and toolbox for the structural
|
||||||
|
biology electron microscopy community. I would call it a
|
||||||
<blockquote>
|
budding/evolving project, since it is currently not in production
|
||||||
IPLT is an image processing library and toolbox for the structural
|
stage, but rather under heavy development. Python is used as the main
|
||||||
biology electron microscopy community. I would call it a
|
scripting/interaction level, but also for rapid prototyping, since
|
||||||
budding/evolving project, since it is currently not in production
|
the underlying C++ class library is pretty much fully exposed via
|
||||||
stage, but rather under heavy development. Python is used as the
|
boost.python (at least the high-level interface). The combined power
|
||||||
main scripting/interaction level, but also for rapid prototyping,
|
of C++ and Python for this project turned out to be just awesome.
|
||||||
since the underlying C++ class library is pretty much fully exposed
|
</blockquote><br>
|
||||||
via boost.python (at least the high-level interface). The combined
|
|
||||||
power of C++ and Python for this project turned out to be just
|
</dd>
|
||||||
awesome.
|
|
||||||
</blockquote>
|
<dt><a href=
|
||||||
<br>
|
"http://www.procoders.net/pythonmagick"><b>PythonMagick</b></a></dt>
|
||||||
|
|
||||||
</dd>
|
<dd>PythonMagick binds the <a href=
|
||||||
|
"http://www.graphicsmagick.org">GraphicsMagick</a> image manipulation
|
||||||
<dt><a href=
|
library to Python.<br>
|
||||||
"http://www.procoders.net/pythonmagick"><b>PythonMagick</b></a></dt>
|
</dd>
|
||||||
|
|
||||||
<dd>PythonMagick binds the <a href=
|
<dt><a href="http://www.vpython.org"><b>VPython</b></a></dt>
|
||||||
"http://www.graphicsmagick.org">GraphicsMagick</a> image manipulation
|
|
||||||
library to Python.<br>
|
<dd>
|
||||||
</dd>
|
<a href="mailto:Bruce_Sherwood-at-ncsu.edu">Bruce Sherwood</a> writes:
|
||||||
</dl>
|
|
||||||
|
<blockquote>
|
||||||
<h3>Scientific Computing</h3>
|
VPython is an extension for Python that makes it easy to create
|
||||||
|
navigable 3D animations, which are generated as a side effect of
|
||||||
<dl class="page index">
|
computational code. VPython is used in education for various
|
||||||
<dt><a href="http://camfr.sourceforge.net"><b>CAMFR</b></a></dt>
|
purposes, including teaching physics and programming, but it has also
|
||||||
|
been used by research scientists to visualize systems or data in 3D.
|
||||||
<dd>
|
</blockquote><br>
|
||||||
CAMFR is a photonics and electromagnetics modelling tool. Python is
|
|
||||||
used for computational steering.
|
</dd>
|
||||||
|
</dl>
|
||||||
<p><a href="mailto:Peter.Bienstman@rug.ac.be">Peter Bienstman</a>
|
|
||||||
writes:</p>
|
<h3>Scientific Computing</h3>
|
||||||
|
|
||||||
<blockquote>
|
<dl class="page index">
|
||||||
Thanks for providing such a great tool!
|
<dt><a href="http://camfr.sourceforge.net"><b>CAMFR</b></a></dt>
|
||||||
</blockquote>
|
|
||||||
</dd>
|
<dd>
|
||||||
|
CAMFR is a photonics and electromagnetics modelling tool. Python is
|
||||||
<dt><a href="http://cctbx.sourceforge.net"><b>cctbx - Computational
|
used for computational steering.
|
||||||
Crystallography Toolbox</b></a></dt>
|
|
||||||
|
<p><a href="mailto:Peter.Bienstman@rug.ac.be">Peter Bienstman</a>
|
||||||
<dd>
|
writes:</p>
|
||||||
Computational Crystallography is concerned with the derivation of
|
|
||||||
atomic models of crystal structures, given experimental X-ray
|
<blockquote>
|
||||||
diffraction data. The cctbx is an open-source library of fundamental
|
Thanks for providing such a great tool!
|
||||||
algorithms for crystallographic computations. The core algorithms are
|
</blockquote>
|
||||||
implemented in C++ and accessed through higher-level Python
|
</dd>
|
||||||
interfaces.
|
|
||||||
|
<dt><a href="http://cctbx.sourceforge.net"><b>cctbx - Computational
|
||||||
<p>The cctbx grew together with Boost.Python and is designed from the
|
Crystallography Toolbox</b></a></dt>
|
||||||
ground up as a hybrid Python/C++ system. With one minor exception,
|
|
||||||
run-time polymorphism is completely handled by Python. C++
|
<dd>
|
||||||
compile-time polymorphism is used to implement performance critical
|
Computational Crystallography is concerned with the derivation of
|
||||||
algorithms. The Python and C++ layers are seamlessly integrated using
|
atomic models of crystal structures, given experimental X-ray
|
||||||
Boost.Python.</p>
|
diffraction data. The cctbx is an open-source library of fundamental
|
||||||
|
algorithms for crystallographic computations. The core algorithms are
|
||||||
<p>The SourceForge cctbx project is organized in modules to
|
implemented in C++ and accessed through higher-level Python interfaces.
|
||||||
facilitate use in non-crystallographic applications. The scitbx
|
|
||||||
module implements a general purpose array family for scientific
|
<p>The cctbx grew together with Boost.Python and is designed from the
|
||||||
applications and pure C++ ports of FFTPACK and the LBFGS conjugate
|
ground up as a hybrid Python/C++ system. With one minor exception,
|
||||||
gradient minimizer.</p>
|
run-time polymorphism is completely handled by Python. C++ compile-time
|
||||||
</dd>
|
polymorphism is used to implement performance critical algorithms. The
|
||||||
|
Python and C++ layers are seamlessly integrated using Boost.Python.</p>
|
||||||
<dt><a href="http://www.llnl.gov/CASC/emsolve"><b>EMSolve</b></a></dt>
|
|
||||||
|
<p>The SourceForge cctbx project is organized in modules to facilitate
|
||||||
<dd>EMSolve is a provably stable, charge conserving, and energy
|
use in non-crystallographic applications. The scitbx module implements
|
||||||
conserving solver for Maxwell's equations.<br>
|
a general purpose array family for scientific applications and pure C++
|
||||||
</dd>
|
ports of FFTPACK and the L-BFGS quasi-Newton minimizer.</p>
|
||||||
|
</dd>
|
||||||
<dt><b><a href="http://cern.ch/gaudi">Gaudi</a></b> and <b><a href=
|
|
||||||
"http://cern.ch/Gaudi/RootPython/">RootPython</a></b></dt>
|
<dt><a href="http://www.llnl.gov/CASC/emsolve"><b>EMSolve</b></a></dt>
|
||||||
|
|
||||||
<dd>
|
<dd>EMSolve is a provably stable, charge conserving, and energy
|
||||||
Gaudi is a framework for particle physics collision data processing
|
conserving solver for Maxwell's equations.<br>
|
||||||
applications developed in the context of the LHCb and ATLAS
|
</dd>
|
||||||
experiments at CERN.
|
|
||||||
|
<dt><b><a href="http://cern.ch/gaudi">Gaudi</a></b> and <b><a href=
|
||||||
<p><a href="mailto:Pere.Mato@cern.ch">Pere Mato Vila</a> writes:</p>
|
"http://cern.ch/Gaudi/RootPython/">RootPython</a></b></dt>
|
||||||
|
|
||||||
<blockquote>
|
<dd>
|
||||||
We are using Boost.Python to provide scripting/interactive
|
Gaudi is a framework for particle physics collision data processing
|
||||||
capability to our framework. We have a module called "GaudiPython"
|
applications developed in the context of the LHCb and ATLAS experiments
|
||||||
implemented using Boost.Python that allows the interaction with any
|
at CERN.
|
||||||
framework service or algorithm from python. RootPython also uses
|
|
||||||
Boost.Python to provide a generic "gateway" between the <a href=
|
<p><a href="mailto:Pere.Mato@cern.ch">Pere Mato Vila</a> writes:</p>
|
||||||
"http://root.cern.ch">ROOT</a> framework and python
|
|
||||||
|
<blockquote>
|
||||||
<p>Boost.Python is great. We managed very quickly to interface our
|
We are using Boost.Python to provide scripting/interactive capability
|
||||||
framework to python, which is great language. We are trying to
|
to our framework. We have a module called "GaudiPython" implemented
|
||||||
facilitate to our physicists (end-users) a rapid analysis
|
using Boost.Python that allows the interaction with any framework
|
||||||
application development environment based on python. For that,
|
service or algorithm from python. RootPython also uses Boost.Python
|
||||||
Boost.Python plays and essential role.</p>
|
to provide a generic "gateway" between the <a href=
|
||||||
</blockquote>
|
"http://root.cern.ch">ROOT</a> framework and python
|
||||||
</dd>
|
|
||||||
|
<p>Boost.Python is great. We managed very quickly to interface our
|
||||||
<dt><b><a href="http://www.esss.com.br">ESSS</a></b></dt>
|
framework to python, which is great language. We are trying to
|
||||||
|
facilitate to our physicists (end-users) a rapid analysis application
|
||||||
<dd>
|
development environment based on python. For that, Boost.Python plays
|
||||||
ESSS (Engineering Simulation and Scientific Software) is a company
|
and essential role.</p>
|
||||||
that provides engineering solutions and acts in the brazilian and
|
</blockquote>
|
||||||
south-american market providing products and services related to
|
</dd>
|
||||||
Computational Fluid Dynamics and Image Analysis.
|
|
||||||
|
<dt><b><a href="http://www.esss.com.br">ESSS</a></b></dt>
|
||||||
<p><a href="mailto:bruno@esss.com.br">Bruno da Silva de Oliveira</a>
|
|
||||||
writes:</p>
|
<dd>
|
||||||
|
ESSS (Engineering Simulation and Scientific Software) is a company that
|
||||||
<blockquote>
|
provides engineering solutions and acts in the brazilian and
|
||||||
Recently we moved our work from working exclusively with C++ to an
|
south-american market providing products and services related to
|
||||||
hybrid-language approach, using Python and C++, with Boost.Python
|
Computational Fluid Dynamics and Image Analysis.
|
||||||
providing the layer between the two. The results are great so far!
|
|
||||||
</blockquote>
|
<p><a href="mailto:bruno@esss.com.br">Bruno da Silva de Oliveira</a>
|
||||||
|
writes:</p>
|
||||||
<p>Two projects have been developed so far with this technology:</p>
|
|
||||||
|
<blockquote>
|
||||||
<p><b><a href="http://www.esss.com.br/index.php?pg=dev_projetos">Simba</a></b>
|
Recently we moved our work from working exclusively with C++ to an
|
||||||
provides 3D visualization of geological formations gattered from the
|
hybrid-language approach, using Python and C++, with Boost.Python
|
||||||
simulation of the evolution of oil systems, allowing the user to
|
providing the layer between the two. The results are great so far!
|
||||||
analyse various aspects of the simulation, like deformation, pressure
|
</blockquote>
|
||||||
and fluids, along the time of the simulation.</p>
|
|
||||||
|
<p>Two projects have been developed so far with this technology:</p>
|
||||||
<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
|
<p><b><a href=
|
||||||
various companies and universities. ESSS is responsible for various
|
"http://www.esss.com.br/index.php?pg=dev_projetos">Simba</a></b>
|
||||||
of the application modules, including GUI and post-processing of
|
provides 3D visualization of geological formations gattered from the
|
||||||
results.</p>
|
simulation of the evolution of oil systems, allowing the user to
|
||||||
</dd>
|
analyse various aspects of the simulation, like deformation, pressure
|
||||||
|
and fluids, along the time of the simulation.</p>
|
||||||
<dt><b><a href="http://www.rationaldiscovery.com">Rational Discovery
|
|
||||||
LLC</a></b></dt>
|
<p><b><a href=
|
||||||
|
"http://www.esss.com.br/index.php?pg=dev_projetos">Aero</a></b> aims to
|
||||||
<dd>
|
construct a CFD with brazilian technology, which involves various
|
||||||
Rational Discovery provides computational modeling, combinatorial
|
companies and universities. ESSS is responsible for various of the
|
||||||
library design and custom software development services to the
|
application modules, including GUI and post-processing of results.</p>
|
||||||
pharmaceutical, biotech and chemical industries. We do a substantial
|
</dd>
|
||||||
amount of internal research to develop new approaches for applying
|
|
||||||
machine-learning techniques to solve chemical problems. Because we're
|
<dt><b><a href="http://www.rationaldiscovery.com">Rational Discovery
|
||||||
a small organization and chemistry is a large and complex field, it
|
LLC</a></b></dt>
|
||||||
is essential that we be able to quickly and easily prototype and test
|
|
||||||
new algorithms.
|
<dd>
|
||||||
|
Rational Discovery provides computational modeling, combinatorial
|
||||||
<p>For our internal software, we implement core data structures in C
|
library design and custom software development services to the
|
||||||
and expose them to Python using Boost.Python. Algorithm development
|
pharmaceutical, biotech and chemical industries. We do a substantial
|
||||||
is done in Python and then translated to C if required (often it's
|
amount of internal research to develop new approaches for applying
|
||||||
not). This hybrid development approach not only greatly increases our
|
machine-learning techniques to solve chemical problems. Because we're a
|
||||||
productivity, but it also allows "non-developers" (people without C
|
small organization and chemistry is a large and complex field, it is
|
||||||
experience) to take part in method development. Learning C is a
|
essential that we be able to quickly and easily prototype and test new
|
||||||
daunting task, but "Python fits your brain." (Thanks to Bruce Eckel
|
algorithms.
|
||||||
for the quote.)</p>
|
|
||||||
</dd>
|
<p>For our internal software, we implement core data structures in C
|
||||||
</dl>
|
and expose them to Python using Boost.Python. Algorithm development is
|
||||||
|
done in Python and then translated to C if required (often it's not).
|
||||||
<h3>Systems Libraries</h3>
|
This hybrid development approach not only greatly increases our
|
||||||
|
productivity, but it also allows "non-developers" (people without C
|
||||||
<dl>
|
experience) to take part in method development. Learning C is a
|
||||||
<dt><a href="http://itamarst.org/software"><b>Fusion</b></a></dt>
|
daunting task, but "Python fits your brain." (Thanks to Bruce Eckel for
|
||||||
|
the quote.)</p>
|
||||||
<dd>
|
</dd>
|
||||||
<p>Fusion is a library that supports implementing protocols in C++
|
</dl>
|
||||||
for use with Twisted, allowing control over memory allocation
|
|
||||||
strategies, fast method calls internally, etc.. Fusion supports TCP,
|
<h3>Systems Libraries</h3>
|
||||||
UDP and multicast, and is implemented using the Boost.Python python
|
|
||||||
bindings.</p>
|
<dl>
|
||||||
|
<dt><a href="http://itamarst.org/software"><b>Fusion</b></a></dt>
|
||||||
<p>Fusion is licensed under the MIT license, and available for
|
|
||||||
download from <a href=
|
<dd>
|
||||||
"http://itamarst.org/software">http://itamarst.org/software</a>.</p>
|
<p>Fusion is a library that supports implementing protocols in C++ for
|
||||||
</dd>
|
use with Twisted, allowing control over memory allocation strategies,
|
||||||
</dl>
|
fast method calls internally, etc.. Fusion supports TCP, UDP and
|
||||||
|
multicast, and is implemented using the Boost.Python python
|
||||||
<h3>Tools</h3>
|
bindings.</p>
|
||||||
|
|
||||||
<dl>
|
<p>Fusion is licensed under the MIT license, and available for download
|
||||||
<dt><a href="http://www.jayacard.org"><b>Jayacard</b></a></dt>
|
from <a href=
|
||||||
|
"http://itamarst.org/software">http://itamarst.org/software</a>.</p>
|
||||||
<dd>
|
</dd>
|
||||||
Jayacard aims at developing a secure portable open source operating
|
</dl>
|
||||||
system for contactless smart cards and a complete suite of high
|
|
||||||
quality development tools to ease smart card OS and application
|
<h3>Tools</h3>
|
||||||
development.
|
|
||||||
|
<dl>
|
||||||
<p>The core of the smart card reader management is written in C++ but
|
<dt><a href="http://www.jayacard.org"><b>Jayacard</b></a></dt>
|
||||||
all the development tools are written in the friendly Python
|
|
||||||
language. Boost plays the fundamental role of binding the tools to
|
<dd>
|
||||||
our core smart card reader library.</p>
|
Jayacard aims at developing a secure portable open source operating
|
||||||
</dd>
|
system for contactless smart cards and a complete suite of high quality
|
||||||
</dl>
|
development tools to ease smart card OS and application development.
|
||||||
<hr>
|
|
||||||
|
<p>The core of the smart card reader management is written in C++ but
|
||||||
<p>Revised
|
all the development tools are written in the friendly Python language.
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
Boost plays the fundamental role of binding the tools to our core smart
|
||||||
15 July, 2003</p>
|
card reader library.</p>
|
||||||
|
</dd>
|
||||||
<p><i>© Copyright <a href="../../../people/dave_abrahams.htm">Dave
|
</dl>
|
||||||
Abrahams</a> 2002-2003.</i></p>
|
<hr>
|
||||||
</body>
|
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||||
|
15 July, 2003</p>
|
||||||
|
|
||||||
|
<p><i>© Copyright <a href="../../../people/dave_abrahams.htm">Dave
|
||||||
|
Abrahams</a> 2002-2003.</i></p>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
# Copyright Joel de Guzman 2006. 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)
|
||||||
project boost/libs/python/doc/tutorial/doc ;
|
project boost/libs/python/doc/tutorial/doc ;
|
||||||
|
|
||||||
import boostbook : boostbook ;
|
import boostbook : boostbook ;
|
||||||
|
|||||||
@@ -23,23 +23,24 @@
|
|||||||
|
|
||||||
p
|
p
|
||||||
{
|
{
|
||||||
text-align: justify;
|
text-align: left;
|
||||||
font-size: 11pt;
|
font-size: 10pt;
|
||||||
line-height: 1.2;
|
line-height: 1.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
Program listings
|
Program listings
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
tt.computeroutput
|
/* Code on paragraphs */
|
||||||
|
p tt.computeroutput
|
||||||
{
|
{
|
||||||
font-size: 10pt;
|
font-size: 9pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre.synopsis
|
pre.synopsis
|
||||||
{
|
{
|
||||||
font-size: 10pt;
|
font-size: 90%;
|
||||||
margin: 1pc 4% 0pc 4%;
|
margin: 1pc 4% 0pc 4%;
|
||||||
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
||||||
}
|
}
|
||||||
@@ -47,32 +48,36 @@
|
|||||||
.programlisting,
|
.programlisting,
|
||||||
.screen
|
.screen
|
||||||
{
|
{
|
||||||
font-size: 10pt;
|
font-size: 9pt;
|
||||||
display: block;
|
display: block;
|
||||||
margin: 1pc 4% 0pc 4%;
|
margin: 1pc 4% 0pc 4%;
|
||||||
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Program listings in tables don't get borders */
|
||||||
|
td .programlisting,
|
||||||
|
td .screen
|
||||||
|
{
|
||||||
|
margin: 0pc 0pc 0pc 0pc;
|
||||||
|
padding: 0pc 0pc 0pc 0pc;
|
||||||
|
}
|
||||||
|
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
Headings
|
Headings
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
h1,
|
h1, h2, h3, h4, h5, h6
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6
|
|
||||||
{
|
{
|
||||||
text-align: left;
|
text-align: left;
|
||||||
margin-top: 2pc;
|
margin: 1em 0em 0.5em 0em;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 { font: 170% }
|
h1 { font: 140% }
|
||||||
h2 { font: bold 140% }
|
h2 { font: bold 140% }
|
||||||
h3 { font: bold 120% }
|
h3 { font: bold 130% }
|
||||||
h4 { font: bold 100% }
|
h4 { font: bold 120% }
|
||||||
h5 { font: italic 100% }
|
h5 { font: italic 110% }
|
||||||
h6 { font: italic 100% }
|
h6 { font: italic 100% }
|
||||||
|
|
||||||
/* Top page titles */
|
/* Top page titles */
|
||||||
@@ -89,12 +94,41 @@
|
|||||||
margin-bottom: 1pc;
|
margin-bottom: 1pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1.title { font-size: 220% }
|
h1.title { font-size: 140% }
|
||||||
h2.title { font-size: 220% }
|
h2.title { font-size: 140% }
|
||||||
h3.title { font-size: 170% }
|
h3.title { font-size: 130% }
|
||||||
h4.title { font-size: 140% }
|
h4.title { font-size: 120% }
|
||||||
h5.title { font-size: 120% }
|
h5.title { font-size: 110% }
|
||||||
h6.title { font-size: 120% }
|
h6.title { font-size: 100% }
|
||||||
|
|
||||||
|
.section h1
|
||||||
|
{
|
||||||
|
margin: 0em 0em 0.5em 0em;
|
||||||
|
font-size: 140%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section h2 { font-size: 140% }
|
||||||
|
.section h3 { font-size: 130% }
|
||||||
|
.section h4 { font-size: 120% }
|
||||||
|
.section h5 { font-size: 110% }
|
||||||
|
.section h6 { font-size: 100% }
|
||||||
|
|
||||||
|
/* Code on titles */
|
||||||
|
h1 tt.computeroutput { font-size: 140% }
|
||||||
|
h2 tt.computeroutput { font-size: 140% }
|
||||||
|
h3 tt.computeroutput { font-size: 130% }
|
||||||
|
h4 tt.computeroutput { font-size: 120% }
|
||||||
|
h5 tt.computeroutput { font-size: 110% }
|
||||||
|
h6 tt.computeroutput { font-size: 100% }
|
||||||
|
|
||||||
|
/*=============================================================================
|
||||||
|
Author
|
||||||
|
=============================================================================*/
|
||||||
|
|
||||||
|
h3.author
|
||||||
|
{
|
||||||
|
font-size: 100%
|
||||||
|
}
|
||||||
|
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
Lists
|
Lists
|
||||||
@@ -102,20 +136,20 @@
|
|||||||
|
|
||||||
li
|
li
|
||||||
{
|
{
|
||||||
font-size: 11pt;
|
font-size: 10pt;
|
||||||
line-height: 1.3;
|
line-height: 1.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unordered lists */
|
/* Unordered lists */
|
||||||
ul
|
ul
|
||||||
{
|
{
|
||||||
text-align: justify;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ordered lists */
|
/* Ordered lists */
|
||||||
ol
|
ol
|
||||||
{
|
{
|
||||||
text-align: justify;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
@@ -159,9 +193,9 @@
|
|||||||
.toc
|
.toc
|
||||||
{
|
{
|
||||||
margin: 1pc 4% 0pc 4%;
|
margin: 1pc 4% 0pc 4%;
|
||||||
padding: 0.5pc;
|
padding: 0.1pc 1pc 0.1pc 1pc;
|
||||||
font-size: 11pt;
|
font-size: 80%;
|
||||||
line-height: 1.3;
|
line-height: 1.15;
|
||||||
}
|
}
|
||||||
|
|
||||||
.boost-toc
|
.boost-toc
|
||||||
@@ -180,7 +214,6 @@
|
|||||||
margin-left: 4%;
|
margin-left: 4%;
|
||||||
padding-right: 0.5em;
|
padding-right: 0.5em;
|
||||||
padding-left: 0.5em;
|
padding-left: 0.5em;
|
||||||
font-size: 120%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.informaltable table,
|
.informaltable table,
|
||||||
@@ -202,8 +235,8 @@
|
|||||||
div.table table tr td
|
div.table table tr td
|
||||||
{
|
{
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
text-align: justify;
|
text-align: left;
|
||||||
font-size: 11pt;
|
font-size: 9pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.informaltable table tr th,
|
div.informaltable table tr th,
|
||||||
@@ -211,51 +244,76 @@
|
|||||||
{
|
{
|
||||||
padding: 0.5em 0.5em 0.5em 0.5em;
|
padding: 0.5em 0.5em 0.5em 0.5em;
|
||||||
border: 1pt solid white;
|
border: 1pt solid white;
|
||||||
|
font-size: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
Blurbs
|
Blurbs
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
div.informaltable table tr td.blurb
|
div.note,
|
||||||
|
div.tip,
|
||||||
|
div.important,
|
||||||
|
div.caution,
|
||||||
|
div.warning,
|
||||||
|
p.blurb
|
||||||
{
|
{
|
||||||
font-size: 10pt; /* A little bit smaller than the main text */
|
font-size: 9pt; /* A little bit smaller than the main text */
|
||||||
line-height: 1.2;
|
line-height: 1.2;
|
||||||
|
display: block;
|
||||||
|
margin: 1pc 4% 0pc 4%;
|
||||||
|
padding: 0.5pc 0.5pc 0.5pc 0.5pc;
|
||||||
}
|
}
|
||||||
|
|
||||||
td.blurb img
|
p.blurb img
|
||||||
{
|
{
|
||||||
padding: 1pt;
|
padding: 1pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=============================================================================
|
/*=============================================================================
|
||||||
Misc
|
Variable Lists
|
||||||
=============================================================================*/
|
=============================================================================*/
|
||||||
|
|
||||||
/* Tone down the title of Parameter lists */
|
/* Make the terms in definition lists bold */
|
||||||
div.variablelist p.title
|
div.variablelist dl dt,
|
||||||
|
span.term
|
||||||
{
|
{
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 100%;
|
font-size: 10pt;
|
||||||
text-align: left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tabularize parameter lists */
|
div.variablelist table tbody tr td
|
||||||
|
{
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 0em 2em 0em 0em;
|
||||||
|
font-size: 10pt;
|
||||||
|
margin: 0em 0em 0.5em 0em;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
div.variablelist dl dt
|
div.variablelist dl dt
|
||||||
{
|
{
|
||||||
float: left;
|
margin-bottom: 0.2em;
|
||||||
clear: left;
|
|
||||||
display: block;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
div.variablelist dl dd
|
div.variablelist dl dd
|
||||||
{
|
{
|
||||||
display: block;
|
margin: 0em 0em 0.5em 2em;
|
||||||
clear: right;
|
font-size: 10pt;
|
||||||
padding-left: 8pc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.variablelist table tbody tr td p,
|
||||||
|
div.variablelist dl dd p
|
||||||
|
{
|
||||||
|
margin: 0em 0em 0.5em 0em;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*=============================================================================
|
||||||
|
Misc
|
||||||
|
=============================================================================*/
|
||||||
|
|
||||||
/* Title of books and articles in bibliographies */
|
/* Title of books and articles in bibliographies */
|
||||||
span.title
|
span.title
|
||||||
{
|
{
|
||||||
@@ -294,6 +352,14 @@
|
|||||||
{
|
{
|
||||||
color: #9c5a9c;
|
color: #9c5a9c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
|
||||||
|
h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover,
|
||||||
|
h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited
|
||||||
|
{
|
||||||
|
text-decoration: none; /* no underline */
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
/* Syntax Highlighting */
|
/* Syntax Highlighting */
|
||||||
.keyword { color: #0000AA; }
|
.keyword { color: #0000AA; }
|
||||||
@@ -322,41 +388,50 @@
|
|||||||
/* Program listing */
|
/* Program listing */
|
||||||
pre.synopsis
|
pre.synopsis
|
||||||
{
|
{
|
||||||
background-color: #F3F3F3;
|
border: 1px solid #DCDCDC;
|
||||||
border: 1pt solid #C0C0C0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.programlisting,
|
.programlisting,
|
||||||
.screen
|
.screen
|
||||||
{
|
{
|
||||||
background-color: #F3F3F3;
|
border: 1px solid #DCDCDC;
|
||||||
border: 1pt solid #C0C0C0;
|
}
|
||||||
|
|
||||||
|
td .programlisting,
|
||||||
|
td .screen
|
||||||
|
{
|
||||||
|
border: 0px solid #DCDCDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Blurbs */
|
/* Blurbs */
|
||||||
div.informaltable table tr td.blurb
|
div.note,
|
||||||
|
div.tip,
|
||||||
|
div.important,
|
||||||
|
div.caution,
|
||||||
|
div.warning,
|
||||||
|
p.blurb
|
||||||
{
|
{
|
||||||
background-color: #FFFFF0;
|
border: 1px solid #DCDCDC;
|
||||||
border: 1pt solid #707070;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Table of contents */
|
/* Table of contents */
|
||||||
.toc
|
.toc
|
||||||
{
|
{
|
||||||
background-color: #F3F3F3;
|
border: 1px solid #DCDCDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tables */
|
/* Tables */
|
||||||
div.informaltable table tr td,
|
div.informaltable table tr td,
|
||||||
div.table table tr td
|
div.table table tr td
|
||||||
{
|
{
|
||||||
background-color: #F0F0F0;
|
border: 1px solid #DCDCDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.informaltable table tr th,
|
div.informaltable table tr th,
|
||||||
div.table table tr th
|
div.table table tr th
|
||||||
{
|
{
|
||||||
background-color: #E4E4E4;
|
background-color: #F0F0F0;
|
||||||
|
border: 1px solid #DCDCDC;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
@@ -396,6 +471,12 @@
|
|||||||
border: 1px solid gray;
|
border: 1px solid gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td .programlisting,
|
||||||
|
td .screen
|
||||||
|
{
|
||||||
|
border: 0px solid #DCDCDC;
|
||||||
|
}
|
||||||
|
|
||||||
/* Table of contents */
|
/* Table of contents */
|
||||||
.toc
|
.toc
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -9,7 +12,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -31,7 +34,7 @@
|
|||||||
<div><p class="copyright">Copyright © 2002-2005 Joel
|
<div><p class="copyright">Copyright © 2002-2005 Joel
|
||||||
de Guzman, David Abrahams</p></div>
|
de Guzman, David Abrahams</p></div>
|
||||||
<div><div class="legalnotice">
|
<div><div class="legalnotice">
|
||||||
<a name="id427816"></a><p>
|
<a name="id376848"></a><p>
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
|
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
|
||||||
http://www.boost.org/LICENSE_1_0.txt </a>)
|
http://www.boost.org/LICENSE_1_0.txt </a>)
|
||||||
@@ -83,18 +86,18 @@
|
|||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="python.quickstart"></a>QuickStart</h2></div></div></div>
|
<a name="python.quickstart"></a>QuickStart</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
QuickStartThe Boost Python Library is a framework for interfacing Python and
|
The Boost Python Library is a framework for interfacing Python and C++. It
|
||||||
C++. It allows you to quickly and seamlessly expose C++ classes functions and
|
allows you to quickly and seamlessly expose C++ classes functions and objects
|
||||||
objects to Python, and vice-versa, using no special tools -- just your C++
|
to Python, and vice-versa, using no special tools -- just your C++ compiler.
|
||||||
compiler. It is designed to wrap C++ interfaces non-intrusively, so that you
|
It is designed to wrap C++ interfaces non-intrusively, so that you should not
|
||||||
should not have to change the C++ code at all in order to wrap it, making Boost.Python
|
have to change the C++ code at all in order to wrap it, making Boost.Python
|
||||||
ideal for exposing 3rd-party libraries to Python. The library's use of advanced
|
ideal for exposing 3rd-party libraries to Python. The library's use of advanced
|
||||||
metaprogramming techniques simplifies its syntax for users, so that wrapping
|
metaprogramming techniques simplifies its syntax for users, so that wrapping
|
||||||
code takes on the look of a kind of declarative interface definition language
|
code takes on the look of a kind of declarative interface definition language
|
||||||
(IDL).
|
(IDL).
|
||||||
</p>
|
</p>
|
||||||
<a name="quickstart.hello_world"></a><h2>
|
<a name="quickstart.hello_world"></a><h2>
|
||||||
<a name="id372244"></a>
|
<a name="id447173"></a>
|
||||||
Hello World
|
Hello World
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -123,19 +126,23 @@
|
|||||||
That's it. We're done. We can now build this as a shared library. The resulting
|
That's it. We're done. We can now build this as a shared library. The resulting
|
||||||
DLL is now visible to Python. Here's a sample Python session:
|
DLL is now visible to Python. Here's a sample Python session:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">hello</span>
|
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">hello</span>
|
||||||
<span class="special">>>></span> <span class="keyword">print</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">greet</span><span class="special">()</span>
|
<span class="special">>>></span> <span class="keyword">print</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">greet</span><span class="special">()</span>
|
||||||
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span>
|
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p></p>
|
<p>
|
||||||
<div class="blockquote"><blockquote class="blockquote"><p><span class="emphasis"><em><span class="bold"><b>Next stop... Building your Hello World module
|
</p>
|
||||||
from start to finish...</b></span></em></span></p></blockquote></div>
|
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||||
|
<span class="emphasis"><em><span class="bold"><b>Next stop... Building your Hello World module
|
||||||
|
from start to finish...</b></span></em></span>
|
||||||
|
</p></blockquote></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"><small><p>Last revised: October 31, 2005 at 18:46:06 GMT</p></small></td>
|
<td align="left"><small><p>Last revised: August 31, 2006 at 05:59:58 GMT</p></small></td>
|
||||||
<td align="right"><small></small></td>
|
<td align="right"><small></small></td>
|
||||||
</tr></table>
|
</tr></table>
|
||||||
<hr>
|
<hr>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -27,19 +30,20 @@
|
|||||||
<a name="python.embedding"></a>Embedding</h2></div></div></div>
|
<a name="python.embedding"></a>Embedding</h2></div></div></div>
|
||||||
<div class="toc"><dl><dt><span class="section"><a href="embedding.html#python.using_the_interpreter">Using the interpreter</a></span></dt></dl></div>
|
<div class="toc"><dl><dt><span class="section"><a href="embedding.html#python.using_the_interpreter">Using the interpreter</a></span></dt></dl></div>
|
||||||
<p>
|
<p>
|
||||||
EmbeddingBy now you should know how to use Boost.Python to call your C++ code
|
By now you should know how to use Boost.Python to call your C++ code from Python.
|
||||||
from Python. However, sometimes you may need to do the reverse: call Python
|
However, sometimes you may need to do the reverse: call Python code from the
|
||||||
code from the C++-side. This requires you to <span class="emphasis"><em>embed</em></span> the
|
C++-side. This requires you to <span class="emphasis"><em>embed</em></span> the Python interpreter
|
||||||
Python interpreter into your C++ program.
|
into your C++ program.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Currently, Boost.Python does not directly support everything you'll need when
|
Currently, Boost.Python does not directly support everything you'll need when
|
||||||
embedding. Therefore you'll need to use the <a href="http://www.python.org/doc/current/api/api.html" target="_top">Python/C
|
embedding. Therefore you'll need to use the <a href="http://www.python.org/doc/current/api/api.html" target="_top">Python/C
|
||||||
API</a> to fill in the gaps. However, Boost.Python already makes embedding
|
API</a> to fill in the gaps. However, Boost.Python already makes embedding
|
||||||
a lot easier and, in a future version, it may become unnecessary to touch the
|
a lot easier and, in a future version, it may become unnecessary to touch the
|
||||||
Python/C API at all. So stay tuned... <span class="inlinemediaobject"><img src="../images/smiley.png"></span></p>
|
Python/C API at all. So stay tuned... <span class="inlinemediaobject"><img src="../images/smiley.png" alt="smiley"></span>
|
||||||
|
</p>
|
||||||
<a name="embedding.building_embedded_programs"></a><h2>
|
<a name="embedding.building_embedded_programs"></a><h2>
|
||||||
<a name="id457321"></a>
|
<a name="id462650"></a>
|
||||||
Building embedded programs
|
Building embedded programs
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -83,7 +87,7 @@ exe embedded_program # name of the executable
|
|||||||
<find-library>$(PYTHON_EMBEDDED_LIBRARY) ;
|
<find-library>$(PYTHON_EMBEDDED_LIBRARY) ;
|
||||||
</pre>
|
</pre>
|
||||||
<a name="embedding.getting_started"></a><h2>
|
<a name="embedding.getting_started"></a><h2>
|
||||||
<a name="id457409"></a>
|
<a name="id462747"></a>
|
||||||
Getting started
|
Getting started
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -92,7 +96,7 @@ exe embedded_program # name of the executable
|
|||||||
</p>
|
</p>
|
||||||
<div class="orderedlist"><ol type="1">
|
<div class="orderedlist"><ol type="1">
|
||||||
<li>
|
<li>
|
||||||
#include <tt class="literal"><boost/python.hpp></tt><br><br>
|
#include <tt class="literal"><boost/python.hpp></tt><br><br>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Call <a href="http://www.python.org/doc/current/api/initialization.html#l2h-652" target="_top">Py_Initialize</a>()
|
Call <a href="http://www.python.org/doc/current/api/initialization.html#l2h-652" target="_top">Py_Initialize</a>()
|
||||||
@@ -110,24 +114,25 @@ exe embedded_program # name of the executable
|
|||||||
<p>
|
<p>
|
||||||
(Of course, there can be other C++ code between all of these steps.)
|
(Of course, there can be other C++ code between all of these steps.)
|
||||||
</p>
|
</p>
|
||||||
<div class="blockquote"><blockquote class="blockquote"><p><span class="emphasis"><em><span class="bold"><b>Now that we can embed the interpreter in
|
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||||
our programs, lets see how to put it to use...</b></span></em></span></p></blockquote></div>
|
<span class="emphasis"><em><span class="bold"><b>Now that we can embed the interpreter in
|
||||||
|
our programs, lets see how to put it to use...</b></span></em></span>
|
||||||
|
</p></blockquote></div>
|
||||||
<div class="section" lang="en">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.using_the_interpreter"></a>Using the interpreter</h3></div></div></div>
|
<a name="python.using_the_interpreter"></a>Using the interpreter</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Using the interpreterAs you probably already know, objects in Python are
|
As you probably already know, objects in Python are reference-counted. Naturally,
|
||||||
reference-counted. Naturally, the <tt class="literal">PyObject</tt>s of the Python/C
|
the <tt class="literal">PyObject</tt>s of the Python/C API are also reference-counted.
|
||||||
API are also reference-counted. There is a difference however. While the
|
There is a difference however. While the reference-counting is fully automatic
|
||||||
reference-counting is fully automatic in Python, the Python/C API requires
|
in Python, the Python/C API requires you to do it <a href="http://www.python.org/doc/current/api/refcounts.html" target="_top">by
|
||||||
you to do it <a href="http://www.python.org/doc/current/api/refcounts.html" target="_top">by
|
|
||||||
hand</a>. This is messy and especially hard to get right in the presence
|
hand</a>. This is messy and especially hard to get right in the presence
|
||||||
of C++ exceptions. Fortunately Boost.Python provides the <a href="../../../../v2/handle.html" target="_top">handle</a>
|
of C++ exceptions. Fortunately Boost.Python provides the <a href="../../../../v2/handle.html" target="_top">handle</a>
|
||||||
and <a href="../../../../v2/object.html" target="_top">object</a> class templates to
|
and <a href="../../../../v2/object.html" target="_top">object</a> class templates to
|
||||||
automate the process.
|
automate the process.
|
||||||
</p>
|
</p>
|
||||||
<a name="using_the_interpreter.reference_counting_handles_and_objects"></a><h2>
|
<a name="using_the_interpreter.reference_counting_handles_and_objects"></a><h2>
|
||||||
<a name="id457544"></a>
|
<a name="id462914"></a>
|
||||||
Reference-counting handles and objects
|
Reference-counting handles and objects
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -161,19 +166,17 @@ exe embedded_program # name of the executable
|
|||||||
a new reference is <a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a>
|
a new reference is <a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a>
|
||||||
which we'll discuss in the next section.
|
which we'll discuss in the next section.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> <span class="bold"><b>Handle is a class <span class="emphasis"><em>template</em></span>,
|
||||||
<tbody><tr><td class="blurb">
|
so why haven't we been using any template parameters?</b></span><br> <br>
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span> <span class="bold"><b>Handle is a class <span class="emphasis"><em>template</em></span>, so why
|
<tt class="literal">handle</tt> has a single template parameter specifying the
|
||||||
haven't we been using any template parameters?</b></span><br><br><tt class="literal">handle</tt> has a single template parameter specifying
|
type of the managed object. This type is <tt class="literal">PyObject</tt> 99%
|
||||||
the type of the managed object. This type is <tt class="literal">PyObject</tt>
|
of the time, so the parameter was defaulted to <tt class="literal">PyObject</tt>
|
||||||
99% of the time, so the parameter was defaulted to <tt class="literal">PyObject</tt>
|
for convenience. Therefore we can use the shorthand <tt class="literal">handle<></tt>
|
||||||
for convenience. Therefore we can use the shorthand <tt class="literal">handle<></tt>
|
instead of the longer, but equivalent, <tt class="literal">handle<PyObject></tt>.
|
||||||
instead of the longer, but equivalent, <tt class="literal">handle<PyObject></tt>.
|
</p>
|
||||||
</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<a name="using_the_interpreter.running_python_code"></a><h2>
|
<a name="using_the_interpreter.running_python_code"></a><h2>
|
||||||
<a name="id457863"></a>
|
<a name="id463241"></a>
|
||||||
Running Python code
|
Running Python code
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -184,7 +187,8 @@ exe embedded_program # name of the executable
|
|||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">PyObject</span><span class="special">*</span> <a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a><span class="special">(</span><span class="keyword">char</span> <span class="special">*</span><span class="identifier">str</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">start</span><span class="special">,</span> <span class="identifier">PyObject</span> <span class="special">*</span><span class="identifier">globals</span><span class="special">,</span> <span class="identifier">PyObject</span> <span class="special">*</span><span class="identifier">locals</span><span class="special">)</span>
|
<span class="identifier">PyObject</span><span class="special">*</span> <a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a><span class="special">(</span><span class="keyword">char</span> <span class="special">*</span><span class="identifier">str</span><span class="special">,</span> <span class="keyword">int</span> <span class="identifier">start</span><span class="special">,</span> <span class="identifier">PyObject</span> <span class="special">*</span><span class="identifier">globals</span><span class="special">,</span> <span class="identifier">PyObject</span> <span class="special">*</span><span class="identifier">locals</span><span class="special">)</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a>
|
<p>
|
||||||
|
<a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a>
|
||||||
takes the code to execute as a null-terminated (C-style) string in its <tt class="literal">str</tt>
|
takes the code to execute as a null-terminated (C-style) string in its <tt class="literal">str</tt>
|
||||||
parameter. The function returns a new reference to a Python object. Which
|
parameter. The function returns a new reference to a Python object. Which
|
||||||
object is returned depends on the <tt class="literal">start</tt> paramater.
|
object is returned depends on the <tt class="literal">start</tt> paramater.
|
||||||
@@ -195,8 +199,9 @@ exe embedded_program # name of the executable
|
|||||||
</p>
|
</p>
|
||||||
<div class="informaltable">
|
<div class="informaltable">
|
||||||
<h4>
|
<h4>
|
||||||
<a name="id458033"></a><span class="table-title">Start symbols</span>
|
<a name="id463420"></a>
|
||||||
</h4>
|
<span class="table-title">Start symbols</span>
|
||||||
|
</h4>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col>
|
<col>
|
||||||
@@ -267,18 +272,16 @@ exe embedded_program # name of the executable
|
|||||||
This should create a file called 'hello.txt' in the current directory containing
|
This should create a file called 'hello.txt' in the current directory containing
|
||||||
a phrase that is well-known in programming circles.
|
a phrase that is well-known in programming circles.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> <span class="bold"><b>Note</b></span> that we wrap
|
||||||
<tbody><tr><td class="blurb">
|
the return value of <a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a>
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span> <span class="bold"><b>Note</b></span> that we wrap the return value of <a href="http://www.python.org/doc/current/api/veryhigh.html#l2h-55" target="_top">PyRun_String</a>
|
in a (nameless) <tt class="literal">handle</tt> even though we are not interested
|
||||||
in a (nameless) <tt class="literal">handle</tt> even though we are not interested
|
in it. If we didn't do this, the the returned object would be kept alive
|
||||||
in it. If we didn't do this, the the returned object would be kept
|
unnecessarily. Unless you want to be a Dr. Frankenstein, always wrap <tt class="literal">PyObject*</tt>s
|
||||||
alive unnecessarily. Unless you want to be a Dr. Frankenstein, always
|
in <tt class="literal">handle</tt>s.
|
||||||
wrap <tt class="literal">PyObject*</tt>s in <tt class="literal">handle</tt>s.
|
</p>
|
||||||
</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<a name="using_the_interpreter.beyond_handles"></a><h2>
|
<a name="using_the_interpreter.beyond_handles"></a><h2>
|
||||||
<a name="id458506"></a>
|
<a name="id463926"></a>
|
||||||
Beyond handles
|
Beyond handles
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -324,17 +327,15 @@ exe embedded_program # name of the executable
|
|||||||
|
|
||||||
<span class="keyword">int</span> <span class="identifier">five_squared</span> <span class="special">=</span> <span class="identifier">extract</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="identifier">result</span><span class="special">);</span>
|
<span class="keyword">int</span> <span class="identifier">five_squared</span> <span class="special">=</span> <span class="identifier">extract</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="identifier">result</span><span class="special">);</span>
|
||||||
</pre>
|
</pre>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> <span class="bold"><b>Note</b></span> that <tt class="literal">object</tt>'s
|
||||||
<tbody><tr><td class="blurb">
|
member function to return the wrapped <tt class="literal">PyObject*</tt> is called
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span> <span class="bold"><b>Note</b></span> that <tt class="literal">object</tt>'s member
|
<tt class="literal">ptr</tt> instead of <tt class="literal">get</tt>. This makes sense
|
||||||
function to return the wrapped <tt class="literal">PyObject*</tt> is called
|
if you take into account the different functions that <tt class="literal">object</tt>
|
||||||
<tt class="literal">ptr</tt> instead of <tt class="literal">get</tt>. This makes
|
and <tt class="literal">handle</tt> perform.
|
||||||
sense if you take into account the different functions that <tt class="literal">object</tt>
|
</p>
|
||||||
and <tt class="literal">handle</tt> perform. </td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<a name="using_the_interpreter.exception_handling"></a><h2>
|
<a name="using_the_interpreter.exception_handling"></a><h2>
|
||||||
<a name="id459120"></a>
|
<a name="id464549"></a>
|
||||||
Exception handling
|
Exception handling
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -26,10 +29,9 @@
|
|||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="python.exception"></a> Exception Translation</h2></div></div></div>
|
<a name="python.exception"></a> Exception Translation</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Exception TranslationAll C++ exceptions must be caught at the boundary with
|
All C++ exceptions must be caught at the boundary with Python code. This boundary
|
||||||
Python code. This boundary is the point where C++ meets Python. Boost.Python
|
is the point where C++ meets Python. Boost.Python provides a default exception
|
||||||
provides a default exception handler that translates selected standard exceptions,
|
handler that translates selected standard exceptions, then gives up:
|
||||||
then gives up:
|
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">raise</span> <span class="identifier">RuntimeError</span><span class="special">,</span> <span class="string">'unidentifiable C++ Exception'</span>
|
<span class="keyword">raise</span> <span class="identifier">RuntimeError</span><span class="special">,</span> <span class="string">'unidentifiable C++ Exception'</span>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -35,7 +38,7 @@
|
|||||||
<dt><span class="section"><a href="exposing.html#python.class_operators_special_functions">Class Operators/Special Functions</a></span></dt>
|
<dt><span class="section"><a href="exposing.html#python.class_operators_special_functions">Class Operators/Special Functions</a></span></dt>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<p>
|
<p>
|
||||||
Exposing ClassesNow let's expose a C++ class to Python.
|
Now let's expose a C++ class to Python.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Consider a C++ class/struct that we want to expose to Python:
|
Consider a C++ class/struct that we want to expose to Python:
|
||||||
@@ -69,7 +72,8 @@
|
|||||||
we may use our class <tt class="literal">World</tt> in Python. Here's a sample Python
|
we may use our class <tt class="literal">World</tt> in Python. Here's a sample Python
|
||||||
session:
|
session:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">hello</span>
|
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">hello</span>
|
||||||
<span class="special">>>></span> <span class="identifier">planet</span> <span class="special">=</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">World</span><span class="special">()</span>
|
<span class="special">>>></span> <span class="identifier">planet</span> <span class="special">=</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">World</span><span class="special">()</span>
|
||||||
@@ -81,10 +85,10 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.constructors"></a>Constructors</h3></div></div></div>
|
<a name="python.constructors"></a>Constructors</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
ConstructorsOur previous example didn't have any explicit constructors. Since
|
Our previous example didn't have any explicit constructors. Since <tt class="literal">World</tt>
|
||||||
<tt class="literal">World</tt> is declared as a plain struct, it has an implicit
|
is declared as a plain struct, it has an implicit default constructor. Boost.Python
|
||||||
default constructor. Boost.Python exposes the default constructor by default,
|
exposes the default constructor by default, which is why we were able to
|
||||||
which is why we were able to write
|
write
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="identifier">planet</span> <span class="special">=</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">World</span><span class="special">()</span>
|
<span class="special">>>></span> <span class="identifier">planet</span> <span class="special">=</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">World</span><span class="special">()</span>
|
||||||
@@ -93,7 +97,8 @@
|
|||||||
We may wish to wrap a class with a non-default constructor. Let us build
|
We may wish to wrap a class with a non-default constructor. Let us build
|
||||||
on our previous example:
|
on our previous example:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">struct</span> <span class="identifier">World</span>
|
<span class="keyword">struct</span> <span class="identifier">World</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
@@ -121,7 +126,8 @@
|
|||||||
<span class="special">;</span>
|
<span class="special">;</span>
|
||||||
<span class="special">}</span>
|
<span class="special">}</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><tt class="literal">init<std::string>()</tt> exposes the constructor taking
|
<p>
|
||||||
|
<tt class="literal">init<std::string>()</tt> exposes the constructor taking
|
||||||
in a <tt class="literal">std::string</tt> (in Python, constructors are spelled
|
in a <tt class="literal">std::string</tt> (in Python, constructors are spelled
|
||||||
"<tt class="literal">"<span class="underline">_init</span>_"</tt>").
|
"<tt class="literal">"<span class="underline">_init</span>_"</tt>").
|
||||||
</p>
|
</p>
|
||||||
@@ -153,9 +159,9 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.class_data_members"></a>Class Data Members</h3></div></div></div>
|
<a name="python.class_data_members"></a>Class Data Members</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Class Data MembersData members may also be exposed to Python so that they
|
Data members may also be exposed to Python so that they can be accessed as
|
||||||
can be accessed as attributes of the corresponding Python class. Each data
|
attributes of the corresponding Python class. Each data member that we wish
|
||||||
member that we wish to be exposed may be regarded as <span class="bold"><b>read-only</b></span>
|
to be exposed may be regarded as <span class="bold"><b>read-only</b></span>
|
||||||
or <span class="bold"><b>read-write</b></span>. Consider this class <tt class="literal">Var</tt>:
|
or <span class="bold"><b>read-write</b></span>. Consider this class <tt class="literal">Var</tt>:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
@@ -179,7 +185,8 @@
|
|||||||
Then, in Python, assuming we have placed our Var class inside the namespace
|
Then, in Python, assuming we have placed our Var class inside the namespace
|
||||||
hello as we did before:
|
hello as we did before:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">Var</span><span class="special">(</span><span class="string">'pi'</span><span class="special">)</span>
|
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">Var</span><span class="special">(</span><span class="string">'pi'</span><span class="special">)</span>
|
||||||
<span class="special">>>></span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">value</span> <span class="special">=</span> <span class="number">3.14</span>
|
<span class="special">>>></span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">value</span> <span class="special">=</span> <span class="number">3.14</span>
|
||||||
@@ -201,13 +208,13 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.class_properties"></a>Class Properties</h3></div></div></div>
|
<a name="python.class_properties"></a>Class Properties</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Class PropertiesIn C++, classes with public data members are usually frowned
|
In C++, classes with public data members are usually frowned upon. Well designed
|
||||||
upon. Well designed classes that take advantage of encapsulation hide the
|
classes that take advantage of encapsulation hide the class' data members.
|
||||||
class' data members. The only way to access the class' data is through access
|
The only way to access the class' data is through access (getter/setter)
|
||||||
(getter/setter) functions. Access functions expose class properties. Here's
|
functions. Access functions expose class properties. Here's an example:
|
||||||
an example:
|
</p>
|
||||||
|
<p>
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">struct</span> <span class="identifier">Num</span>
|
<span class="keyword">struct</span> <span class="identifier">Num</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
@@ -231,7 +238,8 @@
|
|||||||
<p>
|
<p>
|
||||||
And at last, in Python:
|
And at last, in Python:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">Num</span><span class="special">()</span>
|
<span class="special">>>></span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">Num</span><span class="special">()</span>
|
||||||
<span class="special">>>></span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">value</span> <span class="special">=</span> <span class="number">3.14</span>
|
<span class="special">>>></span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">value</span> <span class="special">=</span> <span class="number">3.14</span>
|
||||||
@@ -244,7 +252,8 @@
|
|||||||
<span class="bold"><b>read-only</b></span> since the <tt class="literal">rovalue</tt>
|
<span class="bold"><b>read-only</b></span> since the <tt class="literal">rovalue</tt>
|
||||||
setter member function is not passed in:
|
setter member function is not passed in:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"rovalue"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">Num</span><span class="special">::</span><span class="identifier">get</span><span class="special">)</span>
|
<span class="special">.</span><span class="identifier">add_property</span><span class="special">(</span><span class="string">"rovalue"</span><span class="special">,</span> <span class="special">&</span><span class="identifier">Num</span><span class="special">::</span><span class="identifier">get</span><span class="special">)</span>
|
||||||
</pre>
|
</pre>
|
||||||
@@ -253,7 +262,7 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.inheritance"></a>Inheritance</h3></div></div></div>
|
<a name="python.inheritance"></a>Inheritance</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
InheritanceIn the previous examples, we dealt with classes that are not polymorphic.
|
In the previous examples, we dealt with classes that are not polymorphic.
|
||||||
This is not often the case. Much of the time, we will be wrapping polymorphic
|
This is not often the case. Much of the time, we will be wrapping polymorphic
|
||||||
classes and class hierarchies related by inheritance. We will often have
|
classes and class hierarchies related by inheritance. We will often have
|
||||||
to write Boost.Python wrappers for classes that are derived from abstract
|
to write Boost.Python wrappers for classes that are derived from abstract
|
||||||
@@ -335,9 +344,9 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.class_virtual_functions"></a>Class Virtual Functions</h3></div></div></div>
|
<a name="python.class_virtual_functions"></a>Class Virtual Functions</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Class Virtual FunctionsIn this section, we shall learn how to make functions
|
In this section, we shall learn how to make functions behave polymorphically
|
||||||
behave polymorphically through virtual functions. Continuing our example,
|
through virtual functions. Continuing our example, let us add a virtual function
|
||||||
let us add a virtual function to our <tt class="literal">Base</tt> class:
|
to our <tt class="literal">Base</tt> class:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">struct</span> <span class="identifier">Base</span>
|
<span class="keyword">struct</span> <span class="identifier">Base</span>
|
||||||
@@ -373,13 +382,10 @@
|
|||||||
The <tt class="computeroutput"><span class="identifier">wrapper</span></tt> template makes
|
The <tt class="computeroutput"><span class="identifier">wrapper</span></tt> template makes
|
||||||
the job of wrapping classes that are meant to overridden in Python, easier.
|
the job of wrapping classes that are meant to overridden in Python, easier.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/alert.png" alt="alert"></span> <span class="bold"><b>MSVC6/7 Workaround</b></span><br>
|
||||||
<tbody><tr><td class="blurb">
|
<br> If you are using Microsoft Visual C++ 6 or 7, you have to write <tt class="computeroutput"><span class="identifier">f</span></tt> as:<br> <br> <tt class="computeroutput"><span class="keyword">return</span> <span class="identifier">call</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="keyword">this</span><span class="special">-></span><span class="identifier">get_override</span><span class="special">(</span><span class="string">"f"</span><span class="special">).</span><span class="identifier">ptr</span><span class="special">());</span></tt>.
|
||||||
<span class="inlinemediaobject"><img src="../images/alert.png"></span> <span class="bold"><b>MSVC6/7 Workaround</b></span><br><br> If you are using
|
</p>
|
||||||
Microsoft Visual C++ 6 or 7, you have to write <tt class="computeroutput"><span class="identifier">f</span></tt>
|
|
||||||
as:<br><br><tt class="computeroutput"><span class="keyword">return</span> <span class="identifier">call</span><span class="special"><</span><span class="keyword">int</span><span class="special">>(</span><span class="keyword">this</span><span class="special">-></span><span class="identifier">get_override</span><span class="special">(</span><span class="string">"f"</span><span class="special">).</span><span class="identifier">ptr</span><span class="special">());</span></tt>.</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
<p>
|
||||||
BaseWrap's overridden virtual member function <tt class="computeroutput"><span class="identifier">f</span></tt>
|
BaseWrap's overridden virtual member function <tt class="computeroutput"><span class="identifier">f</span></tt>
|
||||||
in effect calls the corresponding method of the Python object through <tt class="computeroutput"><span class="identifier">get_override</span></tt>.
|
in effect calls the corresponding method of the Python object through <tt class="computeroutput"><span class="identifier">get_override</span></tt>.
|
||||||
@@ -392,28 +398,24 @@
|
|||||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"f"</span><span class="special">,</span> <span class="identifier">pure_virtual</span><span class="special">(&</span><span class="identifier">Base</span><span class="special">::</span><span class="identifier">f</span><span class="special">))</span>
|
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"f"</span><span class="special">,</span> <span class="identifier">pure_virtual</span><span class="special">(&</span><span class="identifier">Base</span><span class="special">::</span><span class="identifier">f</span><span class="special">))</span>
|
||||||
<span class="special">;</span>
|
<span class="special">;</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><tt class="computeroutput"><span class="identifier">pure_virtual</span></tt> signals Boost.Python
|
<p>
|
||||||
|
<tt class="computeroutput"><span class="identifier">pure_virtual</span></tt> signals Boost.Python
|
||||||
that the function <tt class="computeroutput"><span class="identifier">f</span></tt> is a
|
that the function <tt class="computeroutput"><span class="identifier">f</span></tt> is a
|
||||||
pure virtual function.
|
pure virtual function.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> <span class="bold"><b>member function and methods</b></span><br>
|
||||||
<tbody><tr><td class="blurb">
|
<br> Python, like many object oriented languages uses the term <span class="bold"><b>methods</b></span>. Methods correspond roughly to C++'s <span class="bold"><b>member functions</b></span>
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span> <span class="bold"><b>member function and methods</b></span><br><br> Python,
|
</p>
|
||||||
like many object oriented languages uses the term <span class="bold"><b>methods</b></span>.
|
|
||||||
Methods correspond roughly to C++'s <span class="bold"><b>member functions</b></span>
|
|
||||||
</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="section" lang="en">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.virtual_functions_with_default_implementations"></a>Virtual Functions with Default Implementations</h3></div></div></div>
|
<a name="python.virtual_functions_with_default_implementations"></a>Virtual Functions with Default Implementations</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Virtual Functions with Default ImplementationsWe've seen in the previous
|
We've seen in the previous section how classes with pure virtual functions
|
||||||
section how classes with pure virtual functions are wrapped using Boost.Python's
|
are wrapped using Boost.Python's <a href="../../../../v2/wrapper.html" target="_top">class
|
||||||
<a href="../../../../v2/wrapper.html" target="_top">class wrapper</a> facilities. If
|
wrapper</a> facilities. If we wish to wrap <span class="bold"><b>non</b></span>-pure-virtual
|
||||||
we wish to wrap <span class="bold"><b>non</b></span>-pure-virtual functions
|
functions instead, the mechanism is a bit different.
|
||||||
instead, the mechanism is a bit different.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Recall that in the <a href="exposing.html#python.class_virtual_functions" title="Class Virtual Functions">previous
|
Recall that in the <a href="exposing.html#python.class_virtual_functions" title="Class Virtual Functions">previous
|
||||||
@@ -458,13 +460,11 @@
|
|||||||
we have to check if there is an override for <tt class="computeroutput"><span class="identifier">f</span></tt>.
|
we have to check if there is an override for <tt class="computeroutput"><span class="identifier">f</span></tt>.
|
||||||
If none, then we call <tt class="computeroutput"><span class="identifier">Base</span><span class="special">::</span><span class="identifier">f</span><span class="special">()</span></tt>.
|
If none, then we call <tt class="computeroutput"><span class="identifier">Base</span><span class="special">::</span><span class="identifier">f</span><span class="special">()</span></tt>.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/alert.png" alt="alert"></span> <span class="bold"><b>MSVC6/7 Workaround</b></span><br>
|
||||||
<tbody><tr><td class="blurb">
|
<br> If you are using Microsoft Visual C++ 6 or 7, you have to rewrite
|
||||||
<span class="inlinemediaobject"><img src="../images/alert.png"></span> <span class="bold"><b>MSVC6/7 Workaround</b></span><br><br> If you are using
|
the line with the <tt class="computeroutput"><span class="special">*</span><span class="identifier">note</span><span class="special">*</span></tt> as:<br> <br> <tt class="computeroutput"><span class="keyword">return</span> <span class="identifier">call</span><span class="special"><</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*>(</span><span class="identifier">f</span><span class="special">.</span><span class="identifier">ptr</span><span class="special">());</span></tt>.
|
||||||
Microsoft Visual C++ 6 or 7, you have to rewrite the line with the
|
</p>
|
||||||
<tt class="computeroutput"><span class="special">*</span><span class="identifier">note</span><span class="special">*</span></tt> as:<br><br><tt class="computeroutput"><span class="keyword">return</span> <span class="identifier">call</span><span class="special"><</span><span class="keyword">char</span> <span class="keyword">const</span><span class="special">*>(</span><span class="identifier">f</span><span class="special">.</span><span class="identifier">ptr</span><span class="special">());</span></tt>.</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
<p>
|
||||||
Finally, exposing:
|
Finally, exposing:
|
||||||
</p>
|
</p>
|
||||||
@@ -482,7 +482,8 @@
|
|||||||
<p>
|
<p>
|
||||||
In Python, the results would be as expected:
|
In Python, the results would be as expected:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="identifier">base</span> <span class="special">=</span> <span class="identifier">Base</span><span class="special">()</span>
|
<span class="special">>>></span> <span class="identifier">base</span> <span class="special">=</span> <span class="identifier">Base</span><span class="special">()</span>
|
||||||
<span class="special">>>></span> <span class="keyword">class</span> <span class="identifier">Derived</span><span class="special">(</span><span class="identifier">Base</span><span class="special">):</span>
|
<span class="special">>>></span> <span class="keyword">class</span> <span class="identifier">Derived</span><span class="special">(</span><span class="identifier">Base</span><span class="special">):</span>
|
||||||
@@ -509,9 +510,9 @@
|
|||||||
<div class="section" lang="en">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.class_operators_special_functions"></a>Class Operators/Special Functions</h3></div></div></div>
|
<a name="python.class_operators_special_functions"></a>Class Operators/Special Functions</h3></div></div></div>
|
||||||
<a name="class_operators_special_functions.class_operators_special_functionspython_operators"></a><h2>
|
<a name="class_operators_special_functions.python_operators"></a><h2>
|
||||||
<a name="id447955"></a>
|
<a name="id453009"></a>
|
||||||
Class Operators/Special FunctionsPython Operators
|
Python Operators
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
C is well known for the abundance of operators. C++ extends this to the extremes
|
C is well known for the abundance of operators. C++ extends this to the extremes
|
||||||
@@ -522,7 +523,8 @@
|
|||||||
Consider a file position class <tt class="literal">FilePos</tt> and a set of operators
|
Consider a file position class <tt class="literal">FilePos</tt> and a set of operators
|
||||||
that take on FilePos instances:
|
that take on FilePos instances:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">class</span> <span class="identifier">FilePos</span> <span class="special">{</span> <span class="comment">/*...*/</span> <span class="special">};</span>
|
<span class="keyword">class</span> <span class="identifier">FilePos</span> <span class="special">{</span> <span class="comment">/*...*/</span> <span class="special">};</span>
|
||||||
|
|
||||||
@@ -558,7 +560,7 @@
|
|||||||
expressions".
|
expressions".
|
||||||
</p>
|
</p>
|
||||||
<a name="class_operators_special_functions.special_methods"></a><h2>
|
<a name="class_operators_special_functions.special_methods"></a><h2>
|
||||||
<a name="id448698"></a>
|
<a name="id453761"></a>
|
||||||
Special Methods
|
Special Methods
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -586,13 +588,12 @@
|
|||||||
<p>
|
<p>
|
||||||
Need we say more?
|
Need we say more?
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> What is the business of <tt class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></tt>? Well, the method <tt class="computeroutput"><span class="identifier">str</span></tt>
|
||||||
<tbody><tr><td class="blurb">
|
requires the <tt class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></tt>
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span>
|
to do its work (i.e. <tt class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></tt> is used by the method defined by
|
||||||
What is the business of <tt class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></tt>? Well, the method <tt class="computeroutput"><span class="identifier">str</span></tt> requires the <tt class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></tt> to do its work (i.e. <tt class="computeroutput"><span class="keyword">operator</span><span class="special"><<</span></tt>
|
<tt class="computeroutput"><span class="identifier">def</span><span class="special">(</span><span class="identifier">str</span><span class="special">(</span><span class="identifier">self</span><span class="special">))</span></tt>.
|
||||||
is used by the method defined by <tt class="computeroutput"><span class="identifier">def</span><span class="special">(</span><span class="identifier">str</span><span class="special">(</span><span class="identifier">self</span><span class="special">))</span></tt>.</td></tr></tbody>
|
</p>
|
||||||
</table></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -32,13 +35,15 @@
|
|||||||
<dt><span class="section"><a href="functions.html#python.auto_overloading">Auto-Overloading</a></span></dt>
|
<dt><span class="section"><a href="functions.html#python.auto_overloading">Auto-Overloading</a></span></dt>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<p>
|
<p>
|
||||||
FunctionsIn this chapter, we'll look at Boost.Python powered functions in closer
|
In this chapter, we'll look at Boost.Python powered functions in closer detail.
|
||||||
detail. We shall see some facilities to make exposing C++ functions to Python
|
We shall see some facilities to make exposing C++ functions to Python safe
|
||||||
safe from potential pifalls such as dangling pointers and references. We shall
|
from potential pifalls such as dangling pointers and references. We shall also
|
||||||
also see facilities that will make it even easier for us to expose C++ functions
|
see facilities that will make it even easier for us to expose C++ functions
|
||||||
that take advantage of C++ features such as overloading and default arguments.
|
that take advantage of C++ features such as overloading and default arguments.
|
||||||
</p>
|
</p>
|
||||||
<div class="blockquote"><blockquote class="blockquote"><p><span class="emphasis"><em>Read on...</em></span></p></blockquote></div>
|
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||||
|
<span class="emphasis"><em>Read on...</em></span>
|
||||||
|
</p></blockquote></div>
|
||||||
<p>
|
<p>
|
||||||
But before you do, you might want to fire up Python 2.2 or later and type
|
But before you do, you might want to fire up Python 2.2 or later and type
|
||||||
<tt class="literal">>>> import this</tt>.
|
<tt class="literal">>>> import this</tt>.
|
||||||
@@ -69,15 +74,15 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.call_policies"></a>Call Policies</h3></div></div></div>
|
<a name="python.call_policies"></a>Call Policies</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Call PoliciesIn C++, we often deal with arguments and return types such as
|
In C++, we often deal with arguments and return types such as pointers and
|
||||||
pointers and references. Such primitive types are rather, ummmm, low level
|
references. Such primitive types are rather, ummmm, low level and they really
|
||||||
and they really don't tell us much. At the very least, we don't know the
|
don't tell us much. At the very least, we don't know the owner of the pointer
|
||||||
owner of the pointer or the referenced object. No wonder languages such as
|
or the referenced object. No wonder languages such as Java and Python never
|
||||||
Java and Python never deal with such low level entities. In C++, it's usually
|
deal with such low level entities. In C++, it's usually considered a good
|
||||||
considered a good practice to use smart pointers which exactly describe ownership
|
practice to use smart pointers which exactly describe ownership semantics.
|
||||||
semantics. Still, even good C++ interfaces use raw references and pointers
|
Still, even good C++ interfaces use raw references and pointers sometimes,
|
||||||
sometimes, so Boost.Python must deal with them. To do this, it may need your
|
so Boost.Python must deal with them. To do this, it may need your help. Consider
|
||||||
help. Consider the following C++ function:
|
the following C++ function:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">X</span><span class="special">&</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">Y</span><span class="special">&</span> <span class="identifier">y</span><span class="special">,</span> <span class="identifier">Z</span><span class="special">*</span> <span class="identifier">z</span><span class="special">);</span>
|
<span class="identifier">X</span><span class="special">&</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">Y</span><span class="special">&</span> <span class="identifier">y</span><span class="special">,</span> <span class="identifier">Z</span><span class="special">*</span> <span class="identifier">z</span><span class="special">);</span>
|
||||||
@@ -135,7 +140,8 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
<p>
|
<p>
|
||||||
We could copy result into a new object:
|
We could copy result into a new object:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">y</span><span class="special">,</span> <span class="identifier">z</span><span class="special">).</span><span class="identifier">set</span><span class="special">(</span><span class="number">42</span><span class="special">)</span> <span class="comment"># Result disappears
|
<span class="special">>>></span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">y</span><span class="special">,</span> <span class="identifier">z</span><span class="special">).</span><span class="identifier">set</span><span class="special">(</span><span class="number">42</span><span class="special">)</span> <span class="comment"># Result disappears
|
||||||
</span><span class="special">>>></span> <span class="identifier">y</span><span class="special">.</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="comment"># No crash, but still bad
|
</span><span class="special">>>></span> <span class="identifier">y</span><span class="special">.</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">get</span><span class="special">()</span> <span class="comment"># No crash, but still bad
|
||||||
@@ -149,7 +155,8 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
<p>
|
<p>
|
||||||
Our problems do not end there. Suppose Y is implemented as follows:
|
Our problems do not end there. Suppose Y is implemented as follows:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">struct</span> <span class="identifier">Y</span>
|
<span class="keyword">struct</span> <span class="identifier">Y</span>
|
||||||
<span class="special">{</span>
|
<span class="special">{</span>
|
||||||
@@ -202,7 +209,7 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
<li><span class="bold"><b>BOOM!</b></span></li>
|
<li><span class="bold"><b>BOOM!</b></span></li>
|
||||||
</ol></div>
|
</ol></div>
|
||||||
<a name="call_policies.call_policies"></a><h2>
|
<a name="call_policies.call_policies"></a><h2>
|
||||||
<a name="id450599"></a>
|
<a name="id455614"></a>
|
||||||
Call Policies
|
Call Policies
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -283,22 +290,19 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
and hold the instance
|
and hold the instance
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/smiley.png" alt="smiley"></span> <span class="bold"><b>Remember the Zen, Luke:</b></span><br>
|
||||||
<tbody><tr><td class="blurb">
|
<br> "Explicit is better than implicit"<br> "In the face
|
||||||
<span class="inlinemediaobject"><img src="../images/smiley.png"></span> <span class="bold"><b>Remember the Zen, Luke:</b></span><br><br> "Explicit
|
of ambiguity, refuse the temptation to guess"<br>
|
||||||
is better than implicit"<br> "In the face of ambiguity,
|
</p>
|
||||||
refuse the temptation to guess"<br>
|
|
||||||
</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="section" lang="en">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.overloading"></a>Overloading</h3></div></div></div>
|
<a name="python.overloading"></a>Overloading</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
OverloadingThe following illustrates a scheme for manually wrapping an overloaded
|
The following illustrates a scheme for manually wrapping an overloaded member
|
||||||
member functions. Of course, the same technique can be applied to wrapping
|
functions. Of course, the same technique can be applied to wrapping overloaded
|
||||||
overloaded non-member functions.
|
non-member functions.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
We have here our C++ class:
|
We have here our C++ class:
|
||||||
@@ -351,8 +355,8 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.default_arguments"></a>Default Arguments</h3></div></div></div>
|
<a name="python.default_arguments"></a>Default Arguments</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Default ArgumentsBoost.Python wraps (member) function pointers. Unfortunately,
|
Boost.Python wraps (member) function pointers. Unfortunately, C++ function
|
||||||
C++ function pointers carry no default argument info. Take a function <tt class="literal">f</tt>
|
pointers carry no default argument info. Take a function <tt class="literal">f</tt>
|
||||||
with default arguments:
|
with default arguments:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
@@ -401,7 +405,7 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<a name="default_arguments.boost_python_function_overloads"></a><h2>
|
<a name="default_arguments.boost_python_function_overloads"></a><h2>
|
||||||
<a name="id452559"></a>
|
<a name="id457647"></a>
|
||||||
BOOST_PYTHON_FUNCTION_OVERLOADS
|
BOOST_PYTHON_FUNCTION_OVERLOADS
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -431,7 +435,7 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
<span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span> <span class="identifier">foo</span><span class="special">,</span> <span class="identifier">foo_overloads</span><span class="special">());</span>
|
<span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span> <span class="identifier">foo</span><span class="special">,</span> <span class="identifier">foo_overloads</span><span class="special">());</span>
|
||||||
</pre>
|
</pre>
|
||||||
<a name="default_arguments.boost_python_member_function_overloads"></a><h2>
|
<a name="default_arguments.boost_python_member_function_overloads"></a><h2>
|
||||||
<a name="id452863"></a>
|
<a name="id457963"></a>
|
||||||
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS
|
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -477,7 +481,7 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
reference</a> for details.
|
reference</a> for details.
|
||||||
</p>
|
</p>
|
||||||
<a name="default_arguments.init_and_optional"></a><h2>
|
<a name="default_arguments.init_and_optional"></a><h2>
|
||||||
<a name="id453212"></a>
|
<a name="id458323"></a>
|
||||||
init and optional
|
init and optional
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -507,10 +511,10 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.auto_overloading"></a>Auto-Overloading</h3></div></div></div>
|
<a name="python.auto_overloading"></a>Auto-Overloading</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Auto-OverloadingIt was mentioned in passing in the previous section that
|
It was mentioned in passing in the previous section that <tt class="literal">BOOST_PYTHON_FUNCTION_OVERLOADS</tt>
|
||||||
<tt class="literal">BOOST_PYTHON_FUNCTION_OVERLOADS</tt> and <tt class="literal">BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS</tt>
|
and <tt class="literal">BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS</tt> can also be
|
||||||
can also be used for overloaded functions and member functions with a common
|
used for overloaded functions and member functions with a common sequence
|
||||||
sequence of initial arguments. Here is an example:
|
of initial arguments. Here is an example:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">()</span>
|
<span class="keyword">void</span> <span class="identifier">foo</span><span class="special">()</span>
|
||||||
@@ -544,14 +548,14 @@ Namespaces are one honking great idea -- let's do more of those!
|
|||||||
Then...
|
Then...
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span> <span class="identifier">foo</span><span class="special">,</span> <span class="identifier">foo_overloads</span><span class="special">());</span>
|
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"foo"</span><span class="special">,</span> <span class="special">(</span><span class="keyword">void</span><span class="special">(*)(</span><span class="keyword">bool</span><span class="special">,</span> <span class="keyword">int</span><span class="special">,</span> <span class="keyword">char</span><span class="special">))</span><span class="number">0</span><span class="special">,</span> <span class="identifier">foo_overloads</span><span class="special">());</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
Notice though that we have a situation now where we have a minimum of zero
|
Notice though that we have a situation now where we have a minimum of zero
|
||||||
(0) arguments and a maximum of 3 arguments.
|
(0) arguments and a maximum of 3 arguments.
|
||||||
</p>
|
</p>
|
||||||
<a name="auto_overloading.manual_wrapping"></a><h2>
|
<a name="auto_overloading.manual_wrapping"></a><h2>
|
||||||
<a name="id453917"></a>
|
<a name="id459095"></a>
|
||||||
Manual Wrapping
|
Manual Wrapping
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -25,9 +28,9 @@
|
|||||||
<div class="section" lang="en">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="python.hello"></a> Building Hello World</h2></div></div></div>
|
<a name="python.hello"></a> Building Hello World</h2></div></div></div>
|
||||||
<a name="hello._building_hello_worldfrom_start_to_finish"></a><h2>
|
<a name="hello.from_start_to_finish"></a><h2>
|
||||||
<a name="id442456"></a>
|
<a name="id377427"></a>
|
||||||
Building Hello WorldFrom Start To Finish
|
From Start To Finish
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
Now the first thing you'd want to do is to build the Hello World module and
|
Now the first thing you'd want to do is to build the Hello World module and
|
||||||
@@ -35,17 +38,16 @@
|
|||||||
necessary to achieve that. We shall use the build tool that comes bundled with
|
necessary to achieve that. We shall use the build tool that comes bundled with
|
||||||
every boost distribution: <span class="bold"><b>bjam</b></span>.
|
every boost distribution: <span class="bold"><b>bjam</b></span>.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> <span class="bold"><b>Building without bjam</b></span><br>
|
||||||
<tbody><tr><td class="blurb">
|
<br> Besides bjam, there are of course other ways to get your module built.
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span> <span class="bold"><b>Building without bjam</b></span><br><br> Besides bjam,
|
What's written here should not be taken as "the one and only way".
|
||||||
there are of course other ways to get your module built. What's written
|
There are of course other build tools apart from <tt class="literal">bjam</tt>.<br>
|
||||||
here should not be taken as "the one and only way". There are
|
<br> Take note however that the preferred build tool for Boost.Python is
|
||||||
of course other build tools apart from <tt class="literal">bjam</tt>.<br><br> Take note however that the preferred build tool for Boost.Python
|
bjam. There are so many ways to set up the build incorrectly. Experience shows
|
||||||
is bjam. There are so many ways to set up the build incorrectly. Experience
|
that 90% of the "I can't build Boost.Python" problems come from people
|
||||||
shows that 90% of the "I can't build Boost.Python" problems
|
who had to use a different tool.
|
||||||
come from people who had to use a different tool. </td></tr></tbody>
|
</p>
|
||||||
</table></div>
|
|
||||||
<p>
|
<p>
|
||||||
We shall skip over the details. Our objective will be to simply create the
|
We shall skip over the details. Our objective will be to simply create the
|
||||||
hello world module and run it in Python. For a complete reference to building
|
hello world module and run it in Python. For a complete reference to building
|
||||||
@@ -99,10 +101,12 @@
|
|||||||
platforms. The complete list of Bjam executables can be found <a href="http://sourceforge.net/project/showfiles.php?group_id=7586" target="_top">here</a>.
|
platforms. The complete list of Bjam executables can be found <a href="http://sourceforge.net/project/showfiles.php?group_id=7586" target="_top">here</a>.
|
||||||
</p>
|
</p>
|
||||||
<a name="hello.let_s_jam_"></a><h2>
|
<a name="hello.let_s_jam_"></a><h2>
|
||||||
<a name="id373799"></a>
|
<a name="id377613"></a>
|
||||||
Let's Jam!
|
Let's Jam!
|
||||||
</h2>
|
</h2>
|
||||||
<p><span class="inlinemediaobject"><img src="../images/jam.png"></span></p>
|
<p>
|
||||||
|
<span class="inlinemediaobject"><img src="../images/jam.png" alt="jam"></span>
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Here is our minimalist Jamfile:
|
Here is our minimalist Jamfile:
|
||||||
</p>
|
</p>
|
||||||
@@ -148,10 +152,11 @@ extension hello # Declare a Python extension called hello
|
|||||||
The last part tells BJam that we are depending on the Boost Python Library.
|
The last part tells BJam that we are depending on the Boost Python Library.
|
||||||
</p>
|
</p>
|
||||||
<a name="hello.running_bjam"></a><h2>
|
<a name="hello.running_bjam"></a><h2>
|
||||||
<a name="id373910"></a>
|
<a name="id377751"></a>
|
||||||
Running bjam
|
Running bjam
|
||||||
</h2>
|
</h2>
|
||||||
<p><span class="emphasis"><em>bjam</em></span> is run using your operating system's command line
|
<p>
|
||||||
|
<span class="emphasis"><em>bjam</em></span> is run using your operating system's command line
|
||||||
interpreter.
|
interpreter.
|
||||||
</p>
|
</p>
|
||||||
<div class="blockquote"><blockquote class="blockquote"><p>
|
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||||
@@ -175,13 +180,10 @@ set PYTHON_VERSION=2.2
|
|||||||
The above assumes that the Python installation is in <tt class="literal">c:/dev/tools/python</tt>
|
The above assumes that the Python installation is in <tt class="literal">c:/dev/tools/python</tt>
|
||||||
and that we are using Python version 2.2. You'll have to tweak these appropriately.
|
and that we are using Python version 2.2. You'll have to tweak these appropriately.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/tip.png" alt="tip"></span> Be sure not to include a third number, e.g. <span class="bold"><b>not</b></span> "2.2.1", even if that's the version you
|
||||||
<tbody><tr><td class="blurb">
|
have.
|
||||||
<span class="inlinemediaobject"><img src="../images/tip.png"></span>
|
</p>
|
||||||
Be sure not to include a third number, e.g. <span class="bold"><b>not</b></span>
|
|
||||||
"2.2.1", even if that's the version you have.</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
<p>
|
||||||
Take note that you may also do that through the Jamrules file we put in our
|
Take note that you may also do that through the Jamrules file we put in our
|
||||||
project as detailed above. The file has <a href="../../../../../example/tutorial/Jamrules" target="_top">detailed
|
project as detailed above. The file has <a href="../../../../../example/tutorial/Jamrules" target="_top">detailed
|
||||||
@@ -251,23 +253,29 @@ b and object bin\tutorial\hello.pyd\vc-7_1\debug\threading-multi\hello.exp
|
|||||||
<p>
|
<p>
|
||||||
if you are on Unix.
|
if you are on Unix.
|
||||||
</p>
|
</p>
|
||||||
<p><tt class="literal">boost_python.dll</tt> and <tt class="literal">hello.pyd</tt> can be
|
<p>
|
||||||
|
<tt class="literal">boost_python.dll</tt> and <tt class="literal">hello.pyd</tt> can be
|
||||||
found somewhere in your project's <tt class="literal">bin</tt> directory. After a
|
found somewhere in your project's <tt class="literal">bin</tt> directory. After a
|
||||||
successful build, you can just link in these DLLs with the Python interpreter.
|
successful build, you make it possible for the system to find boost_python.dll
|
||||||
In Windows for example, you can simply put these libraries inside the directory
|
or libboost_python.so (usually done with LD_LIBRARY_PATH, DYLD_LIBRARY_PATH,
|
||||||
where the Python executable is.
|
or some other variable on *nix and with PATH on Windows) and for Python to
|
||||||
|
find the hello module (Done with PYTHONPATH on all systems.)
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
You may now fire up Python and run our hello module:
|
You may now fire up Python and run our hello module:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">hello</span>
|
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">hello</span>
|
||||||
<span class="special">>>></span> <span class="keyword">print</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">greet</span><span class="special">()</span>
|
<span class="special">>>></span> <span class="keyword">print</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">greet</span><span class="special">()</span>
|
||||||
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span>
|
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p></p>
|
<p>
|
||||||
<div class="blockquote"><blockquote class="blockquote"><p><span class="bold"><b>There you go... Have fun!</b></span></p></blockquote></div>
|
</p>
|
||||||
|
<div class="blockquote"><blockquote class="blockquote"><p>
|
||||||
|
<span class="bold"><b>There you go... Have fun!</b></span>
|
||||||
|
</p></blockquote></div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
<td align="left"></td>
|
<td align="left"></td>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -26,10 +29,12 @@
|
|||||||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||||||
<a name="python.iterators"></a>Iterators</h2></div></div></div>
|
<a name="python.iterators"></a>Iterators</h2></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
IteratorsIn C++, and STL in particular, we see iterators everywhere. Python
|
In C++, and STL in particular, we see iterators everywhere. Python also has
|
||||||
also has iterators, but these are two very different beasts.
|
iterators, but these are two very different beasts.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<span class="bold"><b>C++ iterators:</b></span>
|
||||||
</p>
|
</p>
|
||||||
<p><span class="bold"><b>C++ iterators:</b></span></p>
|
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li>
|
<li>
|
||||||
C++ has 5 type categories (random-access, bidirectional, forward, input,
|
C++ has 5 type categories (random-access, bidirectional, forward, input,
|
||||||
@@ -42,7 +47,9 @@
|
|||||||
A pair of iterators is needed to represent a (first/last) range.
|
A pair of iterators is needed to represent a (first/last) range.
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p><span class="bold"><b>Python Iterators:</b></span></p>
|
<p>
|
||||||
|
<span class="bold"><b>Python Iterators:</b></span>
|
||||||
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li>
|
<li>
|
||||||
1 category (forward)
|
1 category (forward)
|
||||||
@@ -58,7 +65,8 @@
|
|||||||
The typical Python iteration protocol: <tt class="literal"><span class="bold"><b>for y
|
The typical Python iteration protocol: <tt class="literal"><span class="bold"><b>for y
|
||||||
in x...</b></span></tt> is as follows:
|
in x...</b></span></tt> is as follows:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">__iter__</span><span class="special">()</span> <span class="comment"># get iterator
|
<span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">.</span><span class="identifier">__iter__</span><span class="special">()</span> <span class="comment"># get iterator
|
||||||
</span><span class="keyword">try</span><span class="special">:</span>
|
</span><span class="keyword">try</span><span class="special">:</span>
|
||||||
@@ -72,7 +80,8 @@
|
|||||||
as Python iterators. What we need to do is to produce appropriate <tt class="computeroutput"><span class="identifier">__iter__</span></tt> function from C++ iterators that
|
as Python iterators. What we need to do is to produce appropriate <tt class="computeroutput"><span class="identifier">__iter__</span></tt> function from C++ iterators that
|
||||||
is compatible with the Python iteration protocol. For example:
|
is compatible with the Python iteration protocol. For example:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">object</span> <span class="identifier">get_iterator</span> <span class="special">=</span> <span class="identifier">iterator</span><span class="special"><</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">>();</span>
|
<span class="identifier">object</span> <span class="identifier">get_iterator</span> <span class="special">=</span> <span class="identifier">iterator</span><span class="special"><</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">>();</span>
|
||||||
<span class="identifier">object</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">get_iterator</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span>
|
<span class="identifier">object</span> <span class="identifier">iter</span> <span class="special">=</span> <span class="identifier">get_iterator</span><span class="special">(</span><span class="identifier">v</span><span class="special">);</span>
|
||||||
@@ -84,7 +93,9 @@
|
|||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"__iter__"</span><span class="special">,</span> <span class="identifier">iterator</span><span class="special"><</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">>())</span>
|
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span><span class="string">"__iter__"</span><span class="special">,</span> <span class="identifier">iterator</span><span class="special"><</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">></span> <span class="special">>())</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><span class="bold"><b>range</b></span></p>
|
<p>
|
||||||
|
<span class="bold"><b>range</b></span>
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
We can create a Python savvy iterator using the range function:
|
We can create a Python savvy iterator using the range function:
|
||||||
</p>
|
</p>
|
||||||
@@ -110,7 +121,9 @@
|
|||||||
adaptable function object (use Target parameter)
|
adaptable function object (use Target parameter)
|
||||||
</li>
|
</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
<p><span class="bold"><b>iterator</b></span></p>
|
<p>
|
||||||
|
<span class="bold"><b>iterator</b></span>
|
||||||
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc"><li>
|
<div class="itemizedlist"><ul type="disc"><li>
|
||||||
iterator<T, Policies>()
|
iterator<T, Policies>()
|
||||||
</li></ul></div>
|
</li></ul></div>
|
||||||
@@ -122,7 +135,8 @@
|
|||||||
Let's put this into action... Here's an example from some hypothetical bogon
|
Let's put this into action... Here's an example from some hypothetical bogon
|
||||||
Particle accelerator code:
|
Particle accelerator code:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">f</span> <span class="special">=</span> <span class="identifier">Field</span><span class="special">()</span>
|
<span class="identifier">f</span> <span class="special">=</span> <span class="identifier">Field</span><span class="special">()</span>
|
||||||
<span class="keyword">for</span> <span class="identifier">x</span> <span class="keyword">in</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">pions</span><span class="special">:</span>
|
<span class="keyword">for</span> <span class="identifier">x</span> <span class="keyword">in</span> <span class="identifier">f</span><span class="special">.</span><span class="identifier">pions</span><span class="special">:</span>
|
||||||
@@ -133,13 +147,16 @@
|
|||||||
<p>
|
<p>
|
||||||
Now, our C++ Wrapper:
|
Now, our C++ Wrapper:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">class_</span><span class="special"><</span><span class="identifier">F</span><span class="special">>(</span><span class="string">"Field"</span><span class="special">)</span>
|
<span class="identifier">class_</span><span class="special"><</span><span class="identifier">F</span><span class="special">>(</span><span class="string">"Field"</span><span class="special">)</span>
|
||||||
<span class="special">.</span><span class="identifier">property</span><span class="special">(</span><span class="string">"pions"</span><span class="special">,</span> <span class="identifier">range</span><span class="special">(&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">p_begin</span><span class="special">,</span> <span class="special">&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">p_end</span><span class="special">))</span>
|
<span class="special">.</span><span class="identifier">property</span><span class="special">(</span><span class="string">"pions"</span><span class="special">,</span> <span class="identifier">range</span><span class="special">(&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">p_begin</span><span class="special">,</span> <span class="special">&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">p_end</span><span class="special">))</span>
|
||||||
<span class="special">.</span><span class="identifier">property</span><span class="special">(</span><span class="string">"bogons"</span><span class="special">,</span> <span class="identifier">range</span><span class="special">(&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">b_begin</span><span class="special">,</span> <span class="special">&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">b_end</span><span class="special">));</span>
|
<span class="special">.</span><span class="identifier">property</span><span class="special">(</span><span class="string">"bogons"</span><span class="special">,</span> <span class="identifier">range</span><span class="special">(&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">b_begin</span><span class="special">,</span> <span class="special">&</span><span class="identifier">F</span><span class="special">::</span><span class="identifier">b_end</span><span class="special">));</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><span class="bold"><b>stl_input_iterator</b></span></p>
|
<p>
|
||||||
|
<span class="bold"><b>stl_input_iterator</b></span>
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
So far, we have seen how to expose C++ iterators and ranges to Python. Sometimes
|
So far, we have seen how to expose C++ iterators and ranges to Python. Sometimes
|
||||||
we wish to go the other way, though: we'd like to pass a Python sequence to
|
we wish to go the other way, though: we'd like to pass a Python sequence to
|
||||||
@@ -147,7 +164,8 @@
|
|||||||
a Python iterator look like an STL iterator. For that, we use <tt class="computeroutput"><span class="identifier">stl_input_iterator</span><span class="special"><></span></tt>.
|
a Python iterator look like an STL iterator. For that, we use <tt class="computeroutput"><span class="identifier">stl_input_iterator</span><span class="special"><></span></tt>.
|
||||||
Consider how we might implement a function that exposes <tt class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">assign</span><span class="special">()</span></tt> to Python:
|
Consider how we might implement a function that exposes <tt class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="keyword">int</span><span class="special">>::</span><span class="identifier">assign</span><span class="special">()</span></tt> to Python:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
<span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||||||
<span class="keyword">void</span> <span class="identifier">list_assign</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">l</span><span class="special">,</span> <span class="identifier">object</span> <span class="identifier">o</span><span class="special">)</span> <span class="special">{</span>
|
<span class="keyword">void</span> <span class="identifier">list_assign</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">list</span><span class="special"><</span><span class="identifier">T</span><span class="special">>&</span> <span class="identifier">l</span><span class="special">,</span> <span class="identifier">object</span> <span class="identifier">o</span><span class="special">)</span> <span class="special">{</span>
|
||||||
@@ -166,7 +184,8 @@
|
|||||||
Now in Python, we can assign any integer sequence to <tt class="computeroutput"><span class="identifier">list_int</span></tt>
|
Now in Python, we can assign any integer sequence to <tt class="computeroutput"><span class="identifier">list_int</span></tt>
|
||||||
objects:
|
objects:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">x</span> <span class="special">=</span> <span class="identifier">list_int</span><span class="special">();</span>
|
<span class="identifier">x</span> <span class="special">=</span> <span class="identifier">list_int</span><span class="special">();</span>
|
||||||
<span class="identifier">x</span><span class="special">.</span><span class="identifier">assign</span><span class="special">([</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">5</span><span class="special">])</span>
|
<span class="identifier">x</span><span class="special">.</span><span class="identifier">assign</span><span class="special">([</span><span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">,</span><span class="number">4</span><span class="special">,</span><span class="number">5</span><span class="special">])</span>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -11,7 +14,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -32,11 +35,11 @@
|
|||||||
<dt><span class="section"><a href="object.html#python.enums">Enums</a></span></dt>
|
<dt><span class="section"><a href="object.html#python.enums">Enums</a></span></dt>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<p>
|
<p>
|
||||||
Object InterfacePython is dynamically typed, unlike C++ which is statically
|
Python is dynamically typed, unlike C++ which is statically typed. Python variables
|
||||||
typed. Python variables may hold an integer, a float, list, dict, tuple, str,
|
may hold an integer, a float, list, dict, tuple, str, long etc., among other
|
||||||
long etc., among other things. In the viewpoint of Boost.Python and C++, these
|
things. In the viewpoint of Boost.Python and C++, these Pythonic variables
|
||||||
Pythonic variables are just instances of class <tt class="literal">object</tt>. We
|
are just instances of class <tt class="literal">object</tt>. We shall see in this
|
||||||
shall see in this chapter how to deal with Python objects.
|
chapter how to deal with Python objects.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
As mentioned, one of the goals of Boost.Python is to provide a bidirectional
|
As mentioned, one of the goals of Boost.Python is to provide a bidirectional
|
||||||
@@ -44,21 +47,24 @@
|
|||||||
C++ <tt class="literal">object</tt>s are as close as possible to Python. This should
|
C++ <tt class="literal">object</tt>s are as close as possible to Python. This should
|
||||||
minimize the learning curve significantly.
|
minimize the learning curve significantly.
|
||||||
</p>
|
</p>
|
||||||
<p><span class="inlinemediaobject"><img src="../images/python.png"></span></p>
|
<p>
|
||||||
|
<span class="inlinemediaobject"><img src="../images/python.png" alt="python"></span>
|
||||||
|
</p>
|
||||||
<div class="section" lang="en">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.basic_interface"></a>Basic Interface</h3></div></div></div>
|
<a name="python.basic_interface"></a>Basic Interface</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Basic InterfaceClass <tt class="literal">object</tt> wraps <tt class="literal">PyObject*</tt>.
|
Class <tt class="literal">object</tt> wraps <tt class="literal">PyObject*</tt>. All the
|
||||||
All the intricacies of dealing with <tt class="literal">PyObject</tt>s such as
|
intricacies of dealing with <tt class="literal">PyObject</tt>s such as managing
|
||||||
managing reference counting are handled by the <tt class="literal">object</tt>
|
reference counting are handled by the <tt class="literal">object</tt> class. C++
|
||||||
class. C++ object interoperability is seamless. Boost.Python C++ <tt class="literal">object</tt>s
|
object interoperability is seamless. Boost.Python C++ <tt class="literal">object</tt>s
|
||||||
can in fact be explicitly constructed from any C++ object.
|
can in fact be explicitly constructed from any C++ object.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
To illustrate, this Python code snippet:
|
To illustrate, this Python code snippet:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">def</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">):</span>
|
<span class="keyword">def</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">):</span>
|
||||||
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">y</span> <span class="special">==</span> <span class="string">'foo'</span><span class="special">):</span>
|
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">y</span> <span class="special">==</span> <span class="string">'foo'</span><span class="special">):</span>
|
||||||
@@ -73,7 +79,8 @@
|
|||||||
<p>
|
<p>
|
||||||
Can be rewritten in C++ using Boost.Python facilities this way:
|
Can be rewritten in C++ using Boost.Python facilities this way:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">object</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">object</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">object</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span>
|
<span class="identifier">object</span> <span class="identifier">f</span><span class="special">(</span><span class="identifier">object</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">object</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">{</span>
|
||||||
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">y</span> <span class="special">==</span> <span class="string">"foo"</span><span class="special">)</span>
|
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">y</span> <span class="special">==</span> <span class="string">"foo"</span><span class="special">)</span>
|
||||||
@@ -95,8 +102,8 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.derived_object_types"></a>Derived Object types</h3></div></div></div>
|
<a name="python.derived_object_types"></a>Derived Object types</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Derived Object typesBoost.Python comes with a set of derived <tt class="literal">object</tt>
|
Boost.Python comes with a set of derived <tt class="literal">object</tt> types
|
||||||
types corresponding to that of Python's:
|
corresponding to that of Python's:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
<li>
|
<li>
|
||||||
@@ -133,7 +140,8 @@
|
|||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">d</span><span class="special">.</span><span class="identifier">keys</span><span class="special">()</span>
|
<span class="identifier">d</span><span class="special">.</span><span class="identifier">keys</span><span class="special">()</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><tt class="literal">make_tuple</tt> is provided for declaring <span class="emphasis"><em>tuple literals</em></span>.
|
<p>
|
||||||
|
<tt class="literal">make_tuple</tt> is provided for declaring <span class="emphasis"><em>tuple literals</em></span>.
|
||||||
Example:
|
Example:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
@@ -171,13 +179,11 @@
|
|||||||
% x,y,z</tt> in Python, which is useful since there's no easy way to
|
% x,y,z</tt> in Python, which is useful since there's no easy way to
|
||||||
do that in std C++.
|
do that in std C++.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/alert.png" alt="alert"></span> <span class="bold"><b>Beware</b></span> the common
|
||||||
<tbody><tr><td class="blurb">
|
pitfall of forgetting that the constructors of most of Python's mutable types
|
||||||
<span class="inlinemediaobject"><img src="../images/alert.png"></span> <span class="bold"><b>Beware</b></span> the common pitfall of forgetting that
|
make copies, just as in Python.
|
||||||
the constructors of most of Python's mutable types make copies, just
|
</p>
|
||||||
as in Python. </td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
<p>
|
||||||
Python:
|
Python:
|
||||||
</p>
|
</p>
|
||||||
@@ -193,7 +199,7 @@
|
|||||||
</span><span class="identifier">d</span><span class="special">[</span><span class="char">'whatever'</span><span class="special">]</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span> <span class="comment">// modifies the copy
|
</span><span class="identifier">d</span><span class="special">[</span><span class="char">'whatever'</span><span class="special">]</span> <span class="special">=</span> <span class="number">3</span><span class="special">;</span> <span class="comment">// modifies the copy
|
||||||
</span></pre>
|
</span></pre>
|
||||||
<a name="derived_object_types.class__lt_t_gt__as_objects"></a><h2>
|
<a name="derived_object_types.class__lt_t_gt__as_objects"></a><h2>
|
||||||
<a name="id455806"></a>
|
<a name="id461067"></a>
|
||||||
class_<T> as objects
|
class_<T> as objects
|
||||||
</h2>
|
</h2>
|
||||||
<p>
|
<p>
|
||||||
@@ -218,9 +224,9 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.extracting_c___objects"></a>Extracting C++ objects</h3></div></div></div>
|
<a name="python.extracting_c___objects"></a>Extracting C++ objects</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Extracting C++ objectsAt some point, we will need to get C++ values out of
|
At some point, we will need to get C++ values out of object instances. This
|
||||||
object instances. This can be achieved with the <tt class="literal">extract<T></tt>
|
can be achieved with the <tt class="literal">extract<T></tt> function. Consider
|
||||||
function. Consider the following:
|
the following:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">double</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">o</span><span class="special">.</span><span class="identifier">attr</span><span class="special">(</span><span class="string">"length"</span><span class="special">);</span> <span class="comment">// compile error
|
<span class="keyword">double</span> <span class="identifier">x</span> <span class="special">=</span> <span class="identifier">o</span><span class="special">.</span><span class="identifier">attr</span><span class="special">(</span><span class="string">"length"</span><span class="special">);</span> <span class="comment">// compile error
|
||||||
@@ -253,8 +259,8 @@
|
|||||||
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">check</span><span class="special">())</span> <span class="special">{</span>
|
<span class="keyword">if</span> <span class="special">(</span><span class="identifier">x</span><span class="special">.</span><span class="identifier">check</span><span class="special">())</span> <span class="special">{</span>
|
||||||
<span class="identifier">Vec2</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">();</span> <span class="special">...</span>
|
<span class="identifier">Vec2</span><span class="special">&</span> <span class="identifier">v</span> <span class="special">=</span> <span class="identifier">x</span><span class="special">();</span> <span class="special">...</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><span class="inlinemediaobject"><img src="../images/tip.png"></span>
|
<p>
|
||||||
The astute reader might have noticed that the <tt class="literal">extract<T></tt>
|
<span class="inlinemediaobject"><img src="../images/tip.png" alt="tip"></span> The astute reader might have noticed that the <tt class="literal">extract<T></tt>
|
||||||
facility in fact solves the mutable copying problem:
|
facility in fact solves the mutable copying problem:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
@@ -266,12 +272,12 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.enums"></a>Enums</h3></div></div></div>
|
<a name="python.enums"></a>Enums</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
EnumsBoost.Python has a nifty facility to capture and wrap C++ enums. While
|
Boost.Python has a nifty facility to capture and wrap C++ enums. While Python
|
||||||
Python has no <tt class="literal">enum</tt> type, we'll often want to expose our
|
has no <tt class="literal">enum</tt> type, we'll often want to expose our C++ enums
|
||||||
C++ enums to Python as an <tt class="literal">int</tt>. Boost.Python's enum facility
|
to Python as an <tt class="literal">int</tt>. Boost.Python's enum facility makes
|
||||||
makes this easy while taking care of the proper conversions from Python's
|
this easy while taking care of the proper conversions from Python's dynamic
|
||||||
dynamic typing to C++'s strong static typing (in C++, ints cannot be implicitly
|
typing to C++'s strong static typing (in C++, ints cannot be implicitly converted
|
||||||
converted to enums). To illustrate, given a C++ enum:
|
to enums). To illustrate, given a C++ enum:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">enum</span> <span class="identifier">choice</span> <span class="special">{</span> <span class="identifier">red</span><span class="special">,</span> <span class="identifier">blue</span> <span class="special">};</span>
|
<span class="keyword">enum</span> <span class="identifier">choice</span> <span class="special">{</span> <span class="identifier">red</span><span class="special">,</span> <span class="identifier">blue</span> <span class="special">};</span>
|
||||||
@@ -291,18 +297,17 @@
|
|||||||
above creates a Python class derived from Python's <tt class="literal">int</tt>
|
above creates a Python class derived from Python's <tt class="literal">int</tt>
|
||||||
type which is associated with the C++ type passed as its first parameter.
|
type which is associated with the C++ type passed as its first parameter.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> <span class="bold"><b>what is a scope?</b></span><br>
|
||||||
<tbody><tr><td class="blurb">
|
<br> The scope is a class that has an associated global Python object which
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span> <span class="bold"><b>what is a scope?</b></span><br><br> The scope is a
|
controls the Python namespace in which new extension classes and wrapped
|
||||||
class that has an associated global Python object which controls the
|
functions will be defined as attributes. Details can be found <a href="../../../../v2/scope.html" target="_top">here</a>.
|
||||||
Python namespace in which new extension classes and wrapped functions
|
</p>
|
||||||
will be defined as attributes. Details can be found <a href="../../../../v2/scope.html" target="_top">here</a>.</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
<p>
|
||||||
You can access those values in Python as
|
You can access those values in Python as
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="identifier">my_module</span><span class="special">.</span><span class="identifier">choice</span><span class="special">.</span><span class="identifier">red</span>
|
<span class="special">>>></span> <span class="identifier">my_module</span><span class="special">.</span><span class="identifier">choice</span><span class="special">.</span><span class="identifier">red</span>
|
||||||
<span class="identifier">my_module</span><span class="special">.</span><span class="identifier">choice</span><span class="special">.</span><span class="identifier">red</span>
|
<span class="identifier">my_module</span><span class="special">.</span><span class="identifier">choice</span><span class="special">.</span><span class="identifier">red</span>
|
||||||
@@ -311,7 +316,8 @@
|
|||||||
where my_module is the module where the enum is declared. You can also create
|
where my_module is the module where the enum is declared. You can also create
|
||||||
a new scope around a class:
|
a new scope around a class:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="identifier">scope</span> <span class="identifier">in_X</span> <span class="special">=</span> <span class="identifier">class_</span><span class="special"><</span><span class="identifier">X</span><span class="special">>(</span><span class="string">"X"</span><span class="special">)</span>
|
<span class="identifier">scope</span> <span class="identifier">in_X</span> <span class="special">=</span> <span class="identifier">class_</span><span class="special"><</span><span class="identifier">X</span><span class="special">>(</span><span class="string">"X"</span><span class="special">)</span>
|
||||||
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
|
<span class="special">.</span><span class="identifier">def</span><span class="special">(</span> <span class="special">...</span> <span class="special">)</span>
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
@@ -10,7 +13,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||||||
<table cellpadding="2" width="100%">
|
<table cellpadding="2" width="100%">
|
||||||
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../../../../../../boost.png"></td>
|
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
|
||||||
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
<td align="center"><a href="../../../../../../../index.htm">Home</a></td>
|
||||||
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
|
||||||
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
<td align="center"><a href="../../../../../../../people/people.htm">People</a></td>
|
||||||
@@ -30,16 +33,16 @@
|
|||||||
<dt><span class="section"><a href="techniques.html#python.reducing_compiling_time">Reducing Compiling Time</a></span></dt>
|
<dt><span class="section"><a href="techniques.html#python.reducing_compiling_time">Reducing Compiling Time</a></span></dt>
|
||||||
</dl></div>
|
</dl></div>
|
||||||
<p>
|
<p>
|
||||||
General TechniquesHere are presented some useful techniques that you can use
|
Here are presented some useful techniques that you can use while wrapping code
|
||||||
while wrapping code with Boost.Python.
|
with Boost.Python.
|
||||||
</p>
|
</p>
|
||||||
<div class="section" lang="en">
|
<div class="section" lang="en">
|
||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.creating_packages"></a>Creating Packages</h3></div></div></div>
|
<a name="python.creating_packages"></a>Creating Packages</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Creating PackagesA Python package is a collection of modules that provide
|
A Python package is a collection of modules that provide to the user a certain
|
||||||
to the user a certain functionality. If you're not familiar on how to create
|
functionality. If you're not familiar on how to create packages, a good introduction
|
||||||
packages, a good introduction to them is provided in the <a href="http://www.python.org/doc/current/tut/node8.html" target="_top">Python
|
to them is provided in the <a href="http://www.python.org/doc/current/tut/node8.html" target="_top">Python
|
||||||
Tutorial</a>.
|
Tutorial</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
@@ -96,15 +99,12 @@
|
|||||||
Compiling these files will generate the following Python extensions: <tt class="literal">core.pyd</tt>,
|
Compiling these files will generate the following Python extensions: <tt class="literal">core.pyd</tt>,
|
||||||
<tt class="literal">io.pyd</tt> and <tt class="literal">filters.pyd</tt>.
|
<tt class="literal">io.pyd</tt> and <tt class="literal">filters.pyd</tt>.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> The extension <tt class="literal">.pyd</tt> is used for python
|
||||||
<tbody><tr><td class="blurb">
|
extension modules, which are just shared libraries. Using the default for
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span>
|
your system, like <tt class="literal">.so</tt> for Unix and <tt class="literal">.dll</tt>
|
||||||
The extension <tt class="literal">.pyd</tt> is used for python extension
|
for Windows, works just as well.
|
||||||
modules, which are just shared libraries. Using the default for your
|
</p>
|
||||||
system, like <tt class="literal">.so</tt> for Unix and <tt class="literal">.dll</tt>
|
|
||||||
for Windows, works just as well.</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
<p>
|
<p>
|
||||||
Now, we create this directory structure for our Python package:
|
Now, we create this directory structure for our Python package:
|
||||||
</p>
|
</p>
|
||||||
@@ -124,7 +124,8 @@
|
|||||||
into his <a href="http://www.python.org/doc/current/tut/node8.html#SECTION008110000000000000000" target="_top">PYTHONPATH</a>
|
into his <a href="http://www.python.org/doc/current/tut/node8.html#SECTION008110000000000000000" target="_top">PYTHONPATH</a>
|
||||||
and fire up the interpreter:
|
and fire up the interpreter:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">io</span>
|
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">io</span>
|
||||||
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">filters</span>
|
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">filters</span>
|
||||||
@@ -146,7 +147,8 @@
|
|||||||
If we want this flexibility, we will have to complicate our package hierarchy
|
If we want this flexibility, we will have to complicate our package hierarchy
|
||||||
a little. First, we will have to change the name of the extension modules:
|
a little. First, we will have to change the name of the extension modules:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="comment">/* file core.cpp */</span>
|
<span class="comment">/* file core.cpp */</span>
|
||||||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">_core</span><span class="special">)</span>
|
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">_core</span><span class="special">)</span>
|
||||||
@@ -178,7 +180,8 @@
|
|||||||
to each one. But if we leave it that way, the user will have to access the
|
to each one. But if we leave it that way, the user will have to access the
|
||||||
functions in the core module with this syntax:
|
functions in the core module with this syntax:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">core</span><span class="special">.</span><span class="identifier">_core</span>
|
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">core</span><span class="special">.</span><span class="identifier">_core</span>
|
||||||
<span class="special">>>></span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">core</span><span class="special">.</span><span class="identifier">_core</span><span class="special">.</span><span class="identifier">foo</span><span class="special">(...)</span>
|
<span class="special">>>></span> <span class="identifier">sounds</span><span class="special">.</span><span class="identifier">core</span><span class="special">.</span><span class="identifier">_core</span><span class="special">.</span><span class="identifier">foo</span><span class="special">(...)</span>
|
||||||
@@ -237,8 +240,8 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.extending_wrapped_objects_in_python"></a>Extending Wrapped Objects in Python</h3></div></div></div>
|
<a name="python.extending_wrapped_objects_in_python"></a>Extending Wrapped Objects in Python</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Extending Wrapped Objects in PythonThanks to Python's flexibility, you can
|
Thanks to Python's flexibility, you can easily add new methods to a class,
|
||||||
easily add new methods to a class, even after it was already created:
|
even after it was already created:
|
||||||
</p>
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="special">>>></span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">(</span><span class="identifier">object</span><span class="special">):</span> <span class="keyword">pass</span>
|
<span class="special">>>></span> <span class="keyword">class</span> <span class="identifier">C</span><span class="special">(</span><span class="identifier">object</span><span class="special">):</span> <span class="keyword">pass</span>
|
||||||
@@ -256,12 +259,14 @@
|
|||||||
<span class="identifier">A</span> <span class="identifier">C</span> <span class="identifier">instance</span><span class="special">!</span>
|
<span class="identifier">A</span> <span class="identifier">C</span> <span class="identifier">instance</span><span class="special">!</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
Yes, Python rox. <span class="inlinemediaobject"><img src="../images/smiley.png"></span></p>
|
Yes, Python rox. <span class="inlinemediaobject"><img src="../images/smiley.png" alt="smiley"></span>
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
We can do the same with classes that were wrapped with Boost.Python. Suppose
|
We can do the same with classes that were wrapped with Boost.Python. Suppose
|
||||||
we have a class <tt class="literal">point</tt> in C++:
|
we have a class <tt class="literal">point</tt> in C++:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">class</span> <span class="identifier">point</span> <span class="special">{...};</span>
|
<span class="keyword">class</span> <span class="identifier">point</span> <span class="special">{...};</span>
|
||||||
|
|
||||||
@@ -274,7 +279,8 @@
|
|||||||
If we are using the technique from the previous session, <a href="techniques.html#python.creating_packages" title="Creating Packages">Creating
|
If we are using the technique from the previous session, <a href="techniques.html#python.creating_packages" title="Creating Packages">Creating
|
||||||
Packages</a>, we can code directly into <tt class="literal">geom/__init__.py</tt>:
|
Packages</a>, we can code directly into <tt class="literal">geom/__init__.py</tt>:
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
<p>
|
||||||
|
</p>
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="keyword">from</span> <span class="identifier">_geom</span> <span class="keyword">import</span> <span class="special">*</span>
|
<span class="keyword">from</span> <span class="identifier">_geom</span> <span class="keyword">import</span> <span class="special">*</span>
|
||||||
|
|
||||||
@@ -285,7 +291,8 @@
|
|||||||
<span class="comment"># now we turn it into a member function
|
<span class="comment"># now we turn it into a member function
|
||||||
</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">__str__</span> <span class="special">=</span> <span class="identifier">point_str</span>
|
</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">__str__</span> <span class="special">=</span> <span class="identifier">point_str</span>
|
||||||
</pre>
|
</pre>
|
||||||
<p><span class="bold"><b>All</b></span> point instances created from C++ will
|
<p>
|
||||||
|
<span class="bold"><b>All</b></span> point instances created from C++ will
|
||||||
also have this member function! This technique has several advantages:
|
also have this member function! This technique has several advantages:
|
||||||
</p>
|
</p>
|
||||||
<div class="itemizedlist"><ul type="disc">
|
<div class="itemizedlist"><ul type="disc">
|
||||||
@@ -357,12 +364,13 @@
|
|||||||
<div class="titlepage"><div><div><h3 class="title">
|
<div class="titlepage"><div><div><h3 class="title">
|
||||||
<a name="python.reducing_compiling_time"></a>Reducing Compiling Time</h3></div></div></div>
|
<a name="python.reducing_compiling_time"></a>Reducing Compiling Time</h3></div></div></div>
|
||||||
<p>
|
<p>
|
||||||
Reducing Compiling TimeIf you have ever exported a lot of classes, you know
|
If you have ever exported a lot of classes, you know that it takes quite
|
||||||
that it takes quite a good time to compile the Boost.Python wrappers. Plus
|
a good time to compile the Boost.Python wrappers. Plus the memory consumption
|
||||||
the memory consumption can easily become too high. If this is causing you
|
can easily become too high. If this is causing you problems, you can split
|
||||||
problems, you can split the class_ definitions in multiple files:
|
the class_ definitions in multiple files:
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
</p>
|
</p>
|
||||||
<p></p>
|
|
||||||
<pre class="programlisting">
|
<pre class="programlisting">
|
||||||
<span class="comment">/* file point.cpp */</span>
|
<span class="comment">/* file point.cpp */</span>
|
||||||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span>
|
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">point</span><span class="special">.</span><span class="identifier">h</span><span class="special">></span>
|
||||||
@@ -419,22 +427,17 @@
|
|||||||
exporting it to Python at the same time: changes in a class will only demand
|
exporting it to Python at the same time: changes in a class will only demand
|
||||||
the compilation of a single cpp, instead of the entire wrapper code.
|
the compilation of a single cpp, instead of the entire wrapper code.
|
||||||
</p>
|
</p>
|
||||||
<div class="informaltable"><table class="table">
|
<p class="blurb">
|
||||||
<colgroup><col></colgroup>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> If you're exporting your classes with <a href="../../../../../pyste/index.html" target="_top">Pyste</a>,
|
||||||
<tbody><tr><td class="blurb">
|
take a look at the <tt class="literal">--multiple</tt> option, that generates the
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span>
|
wrappers in various files as demonstrated here.
|
||||||
If you're exporting your classes with <a href="../../../../../pyste/index.html" target="_top">Pyste</a>,
|
</p>
|
||||||
take a look at the <tt class="literal">--multiple</tt> option, that generates
|
<p class="blurb">
|
||||||
the wrappers in various files as demonstrated here.</td></tr></tbody>
|
<span class="inlinemediaobject"><img src="../images/note.png" alt="note"></span> This method is useful too if you are getting the error
|
||||||
</table></div>
|
message <span class="emphasis"><em>"fatal error C1204:Compiler limit:internal structure
|
||||||
<div class="informaltable"><table class="table">
|
overflow"</em></span> when compiling a large source file, as explained
|
||||||
<colgroup><col></colgroup>
|
in the <a href="../../../../v2/faq.html#c1204" target="_top">FAQ</a>.
|
||||||
<tbody><tr><td class="blurb">
|
</p>
|
||||||
<span class="inlinemediaobject"><img src="../images/note.png"></span>
|
|
||||||
This method is useful too if you are getting the error message <span class="emphasis"><em>"fatal
|
|
||||||
error C1204:Compiler limit:internal structure overflow"</em></span>
|
|
||||||
when compiling a large source file, as explained in the <a href="../../../../v2/faq.html#c1204" target="_top">FAQ</a>.</td></tr></tbody>
|
|
||||||
</table></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||||
|
|||||||
@@ -252,9 +252,10 @@ if you are on Windows, and
|
|||||||
if you are on Unix.
|
if you are on Unix.
|
||||||
|
|
||||||
[^boost_python.dll] and [^hello.pyd] can be found somewhere in your project's
|
[^boost_python.dll] and [^hello.pyd] can be found somewhere in your project's
|
||||||
[^bin] directory. After a successful build, you can just link in these DLLs with
|
[^bin] directory. After a successful build, you make it possible for the system
|
||||||
the Python interpreter. In Windows for example, you can simply put these libraries
|
to find boost_python.dll or libboost_python.so (usually done with LD_LIBRARY_PATH,
|
||||||
inside the directory where the Python executable is.
|
DYLD_LIBRARY_PATH, or some other variable on *nix and with PATH on Windows) and
|
||||||
|
for Python to find the hello module (Done with PYTHONPATH on all systems.)
|
||||||
|
|
||||||
You may now fire up Python and run our hello module:
|
You may now fire up Python and run our hello module:
|
||||||
|
|
||||||
@@ -1099,7 +1100,7 @@ overloaded functions in one-shot:
|
|||||||
|
|
||||||
Then...
|
Then...
|
||||||
|
|
||||||
.def("foo", foo, foo_overloads());
|
.def("foo", (void(*)(bool, int, char))0, foo_overloads());
|
||||||
|
|
||||||
Notice though that we have a situation now where we have a minimum of zero
|
Notice though that we have a situation now where we have a minimum of zero
|
||||||
(0) arguments and a maximum of 3 arguments.
|
(0) arguments and a maximum of 3 arguments.
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
|
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Automatic redirection failed, click this
|
Automatic redirection failed, click this
|
||||||
<a href="doc/html/index.html">link</a>
|
<a href="doc/html/index.html">link</a> <hr>
|
||||||
|
<p>© Copyright Beman Dawes, 2001</p>
|
||||||
|
<p>Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
accompanying file <a href="../../../LICENSE_1_0.txt">
|
||||||
|
LICENSE_1_0.txt</a> or copy at
|
||||||
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
.. Copyright David Abrahams 2006. 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)
|
||||||
|
|
||||||
Here's the plan:
|
Here's the plan:
|
||||||
|
|
||||||
I aim to provide an interface similar to that of Boost.Python v1's
|
I aim to provide an interface similar to that of Boost.Python v1's
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -132,4 +132,6 @@ BOOST_PYTHON_MODULE(my_ext)
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<p><i>© Copyright Joel de Guzman 2003. </i>
|
<p><i>© Copyright Joel de Guzman 2003. </i> 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)
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ struct return_value_policy : Base
|
|||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
|
|
||||||
|
|
||||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
Abrahams</a> 2002. </i>
|
Abrahams</a> 2002.</i> 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)</p>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
@@ -67,8 +70,6 @@
|
|||||||
>error C2064: term does not evaluate to a function taking 2 arguments</a>
|
>error C2064: term does not evaluate to a function taking 2 arguments</a>
|
||||||
</dt>
|
</dt>
|
||||||
|
|
||||||
<dt><a href="#voidptr">How do I handle <tt>void *</tt> conversion?</a></dt>
|
|
||||||
|
|
||||||
<dt><a href="#custom_string"
|
<dt><a href="#custom_string"
|
||||||
>How can I automatically convert my custom string type to
|
>How can I automatically convert my custom string type to
|
||||||
and from a Python string?</a></dt>
|
and from a Python string?</a></dt>
|
||||||
@@ -568,7 +569,7 @@ handle<> f_wrap()
|
|||||||
...
|
...
|
||||||
|
|
||||||
def("f", f_wrap());
|
def("f", f_wrap());
|
||||||
class_<X,X_wrap>("X", init<int>())
|
class_<X,X_wrap,boost::noncopyable>("X", init<int>())
|
||||||
...
|
...
|
||||||
;
|
;
|
||||||
</pre>
|
</pre>
|
||||||
@@ -693,29 +694,6 @@ void Export_FXThread()
|
|||||||
.def("setAutoDelete", (bool (FXThread::*)(bool)) &FXThread::setAutoDelete)</pre>
|
.def("setAutoDelete", (bool (FXThread::*)(bool)) &FXThread::setAutoDelete)</pre>
|
||||||
<p>(The bug has been reported to Microsoft.)</p>
|
<p>(The bug has been reported to Microsoft.)</p>
|
||||||
|
|
||||||
<hr>
|
|
||||||
<h2><a name="voidptr"></a>How do I handle <tt>void *</tt> conversion?</h2>
|
|
||||||
<font size="-1"><i>Niall Douglas provides these notes:</i></font><p>
|
|
||||||
For several reasons Boost.Python does not support <tt>void *</tt> as
|
|
||||||
an argument or as a return value. However, it is possible to wrap
|
|
||||||
functions with <tt>void *</tt> arguments or return values using
|
|
||||||
thin wrappers and the <i>opaque pointer</i> facility. E.g.:
|
|
||||||
<pre>// Declare the following in each translation unit
|
|
||||||
struct void_ {};
|
|
||||||
BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(void_);
|
|
||||||
|
|
||||||
void *foo(int par1, void *par2);
|
|
||||||
|
|
||||||
void_ *foo_wrapper(int par1, void_ *par2)
|
|
||||||
{
|
|
||||||
return (void_ *) foo(par1, par2);
|
|
||||||
}
|
|
||||||
...
|
|
||||||
BOOST_PYTHON_MODULE(bar)
|
|
||||||
{
|
|
||||||
def("foo", &foo_wrapper);
|
|
||||||
}</pre>
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<h2><a name="custom_string"></a>How can I automatically
|
<h2><a name="custom_string"></a>How can I automatically
|
||||||
convert my custom string type to and from a Python string?</h2>
|
convert my custom string type to and from a Python string?</h2>
|
||||||
@@ -873,11 +851,11 @@ BOOST_PYTHON_MODULE(custom_string)
|
|||||||
|
|
||||||
<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 -->
|
||||||
28 January, 2004
|
12 March, 2006
|
||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><i>© Copyright <a href=
|
<p><i>© Copyright <a href=
|
||||||
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002-2003.</i></p>
|
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002-2006.</i></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -360,7 +360,8 @@
|
|||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
|
||||||
|
|
||||||
|
|
||||||
<p class="c3">© Copyright <a href=
|
<p class="c3">© Copyright <a href=
|
||||||
"../../../../people/dave_abrahams.htm">Dave Abrahams</a>
|
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. Distributed
|
||||||
2002.
|
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)</p>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -104,5 +104,7 @@ RuntimeError: Unidentifiable C++ Exception
|
|||||||
|
|
||||||
|
|
||||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
Abrahams</a> 2002. </i>
|
Abrahams</a> 2002. </i> 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)</p>
|
||||||
|
|
||||||
|
|||||||
@@ -1,102 +1,105 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
"HTML Tidy for Windows (vers 1st August 2002), see www.w3.org">
|
"HTML Tidy for Linux/x86 (vers 1 September 2005), 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 - <boost/python/numeric.hpp></title>
|
<title>Boost.Python - <boost/python/numeric.hpp></title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<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">
|
||||||
<h1 align="center"><a href="../index.html">Boost.Python</a></h1>
|
<h1 align="center"><a href="../index.html">Boost.Python</a></h1>
|
||||||
|
|
||||||
<h2 align="center">Header <boost/python/numeric.hpp></h2>
|
<h2 align="center">Header <boost/python/numeric.hpp></h2>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2>Contents</h2>
|
<h2>Contents</h2>
|
||||||
|
|
||||||
<dl class="page-index">
|
<dl class="page-index">
|
||||||
<dt><a href="#introduction">Introduction</a></dt>
|
<dt><a href="#introduction">Introduction</a></dt>
|
||||||
|
|
||||||
<dt><a href="#classes">Classes</a></dt>
|
<dt><a href="#classes">Classes</a></dt>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="page-index">
|
<dl class="page-index">
|
||||||
<dt><a href="#array-spec">Class <code>array</code></a></dt>
|
<dt><a href="#array-spec">Class <code>array</code></a></dt>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="page-index">
|
<dl class="page-index">
|
||||||
<dt><a href="#array-spec-synopsis">Class <code>array</code>
|
<dt><a href="#array-spec-synopsis">Class <code>array</code>
|
||||||
synopsis</a></dt>
|
synopsis</a></dt>
|
||||||
|
|
||||||
<dt><a href="#array-spec-observers">Class <code>array</code>
|
<dt><a href="#array-spec-observers">Class <code>array</code>
|
||||||
observer functions</a></dt>
|
observer functions</a></dt>
|
||||||
|
|
||||||
<dt><a href="#array-spec-statics">Class <code>array</code>
|
<dt><a href="#array-spec-statics">Class <code>array</code> static
|
||||||
static functions</a></dt>
|
functions</a></dt>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><a href="#examples">Example(s)</a></dt>
|
<dt><a href="#examples">Example(s)</a></dt>
|
||||||
</dl>
|
</dl>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<h2><a name="introduction"></a>Introduction</h2>
|
<h2><a name="introduction" id="introduction"></a>Introduction</h2>
|
||||||
|
|
||||||
<p>Exposes a <a href=
|
<p>Exposes a <a href=
|
||||||
"ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> for the Python
|
"ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> for the Python
|
||||||
<a href=
|
<a href=
|
||||||
"http://www.python.org/dev/doc/devel/lib/typesmapping.html">array</a>
|
"http://www.python.org/dev/doc/devel/lib/typesmapping.html">array</a>
|
||||||
type.</p>
|
type.</p>
|
||||||
|
|
||||||
<h2><a name="classes"></a>Classes</h2>
|
<h2><a name="classes" id="classes"></a>Classes</h2>
|
||||||
|
|
||||||
<h3><a name="array-spec"></a>Class <code>array</code></h3>
|
<h3><a name="array-spec" id="array-spec"></a>Class <code>array</code></h3>
|
||||||
|
|
||||||
<p>Provides access to the array types of <a href=
|
<p>Provides access to the array types of <a href=
|
||||||
"http://www.pfdubois.com/numpy/">Numerical Python</a>'s <a href=
|
"http://www.pfdubois.com/numpy/">Numerical Python</a>'s <a href=
|
||||||
"http://www.pfdubois.com/numpy/#Numeric">Numeric</a> and <a href=
|
"http://www.pfdubois.com/numpy/#Numeric">Numeric</a> and <a href=
|
||||||
"http://stsdas.stsci.edu/numarray/index.html">NumArray</a> modules. With
|
"http://stsdas.stsci.edu/numarray/index.html">NumArray</a> modules. With
|
||||||
the exception of the functions documented <a href=
|
the exception of the functions documented <a href=
|
||||||
"#array-spec-observers">below</a>, the semantics of the constructors and
|
"#array-spec-observers">below</a>, the semantics of the constructors and
|
||||||
member functions defined below can be fully understood by reading the <a
|
member functions defined below can be fully understood by reading the
|
||||||
href="ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> concept
|
<a href="ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> concept
|
||||||
definition. Since <code>array</code> is publicly derived from <code><a
|
definition. Since <code>array</code> is publicly derived from
|
||||||
href="object.html#object-spec">object</a></code>, the public object
|
<code><a href="object.html#object-spec">object</a></code>, the public
|
||||||
interface applies to <code>array</code> instances as well.</p>
|
object interface applies to <code>array</code> instances as well.</p>
|
||||||
|
|
||||||
<p><a name="default_search"></a>The default behavior is to use
|
<p><a name="default_search" id="default_search"></a>The default behavior is
|
||||||
<code>numarray.NDArray</code> as the associated Python type if the
|
to use <code>numarray.NDArray</code> as the associated Python type if the
|
||||||
<code>numarray</code> module is installed in the default location.
|
<code>numarray</code> module is installed in the default location.
|
||||||
Otherwise it falls back to use <code>Numeric.ArrayType</code>. If neither
|
Otherwise it falls back to use <code>Numeric.ArrayType</code>. If neither
|
||||||
extension module is installed, conversions to arguments of type
|
extension module is installed, overloads of wrapped C++ functions with
|
||||||
<code>numeric::array</code> will cause overload resolution to reject the
|
<code>numeric::array</code> parameters will never be matched, and other
|
||||||
overload, and other attempted uses of <code>numeric::array</code> will <a
|
attempted uses of <code>numeric::array</code> will <a href=
|
||||||
href="definitions.html#raise">raise</a> an appropriate Python exception.
|
"definitions.html#raise">raise</a> an appropriate Python exception. The
|
||||||
The associated Python type can be set manually using the <code><a href=
|
associated Python type can be set manually using the <code><a href=
|
||||||
"#array-spec-statics">set_module_and_type</a>(...)</code> static
|
"#array-spec-statics">set_module_and_type</a>(...)</code> static
|
||||||
function.</p>
|
function.</p>
|
||||||
|
|
||||||
<h4><a name="array-spec-synopsis"></a>Class <code>array</code>
|
<h4><a name="array-spec-synopsis" id="array-spec-synopsis"></a>Class
|
||||||
synopsis</h4>
|
<code>array</code> synopsis</h4>
|
||||||
<pre>
|
<pre>
|
||||||
namespace boost { namespace python { namespace numeric
|
namespace boost { namespace python { namespace numeric
|
||||||
{
|
{
|
||||||
class array : public object
|
class array : public object
|
||||||
@@ -107,7 +110,7 @@ namespace boost { namespace python { namespace numeric
|
|||||||
object astype(Type const& type_);
|
object astype(Type const& type_);
|
||||||
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
object new_(Type const& type_) const;
|
array new_(Type const& type_) const;
|
||||||
|
|
||||||
template <class Sequence>
|
template <class Sequence>
|
||||||
void resize(Sequence const& x);
|
void resize(Sequence const& x);
|
||||||
@@ -133,14 +136,14 @@ namespace boost { namespace python { namespace numeric
|
|||||||
void tofile(File const& f) const;
|
void tofile(File const& f) const;
|
||||||
|
|
||||||
object factory();
|
object factory();
|
||||||
template <class Buffer>
|
template <class Sequence>
|
||||||
object factory(Buffer const&);
|
object factory(Sequence const&);
|
||||||
template <class Buffer, class Type>
|
template <class Sequence, class Typecode>
|
||||||
object factory(Buffer const&, Type const&);
|
object factory(Sequence const&, Typecode const&, bool copy = true, bool savespace = false);
|
||||||
template <class Buffer, class Type, class Shape>
|
template <class Sequence, class Typecode, class Type>
|
||||||
object factory(Buffer const&, Type const&, Shape const&, bool copy = true, bool savespace = false);
|
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&);
|
||||||
template <class Buffer, class Type, class Shape>
|
template <class Sequence, class Typecode, class Type, class Shape>
|
||||||
object factory(Buffer const&, Type const&, Shape const&, bool copy, bool savespace, char typecode);
|
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&, Shape const&);
|
||||||
|
|
||||||
template <class T1>
|
template <class T1>
|
||||||
explicit array(T1 const& x1);
|
explicit array(T1 const& x1);
|
||||||
@@ -152,6 +155,7 @@ namespace boost { namespace python { namespace numeric
|
|||||||
|
|
||||||
static void set_module_and_type();
|
static void set_module_and_type();
|
||||||
static void set_module_and_type(char const* package_path = 0, char const* type_name = 0);
|
static void set_module_and_type(char const* package_path = 0, char const* type_name = 0);
|
||||||
|
static void get_module_name();
|
||||||
|
|
||||||
object argmax(long axis=-1);
|
object argmax(long axis=-1);
|
||||||
|
|
||||||
@@ -200,54 +204,60 @@ namespace boost { namespace python { namespace numeric
|
|||||||
}}}
|
}}}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<h4><a name="array-spec-observers"></a>Class <code>array</code> observer
|
<h4><a name="array-spec-observers" id="array-spec-observers"></a>Class
|
||||||
functions</h4>
|
<code>array</code> observer functions</h4>
|
||||||
<pre>
|
<pre>
|
||||||
object factory();
|
object factory();
|
||||||
template <class Buffer>
|
template <class Sequence>
|
||||||
object factory(Buffer const&);
|
object factory(Sequence const&);
|
||||||
template <class Buffer, class Type>
|
template <class Sequence, class Typecode>
|
||||||
object factory(Buffer const&, Type const&);
|
object factory(Sequence const&, Typecode const&, bool copy = true, bool savespace = false);
|
||||||
template <class Buffer, class Type, class Shape>
|
template <class Sequence, class Typecode, class Type>
|
||||||
object factory(Buffer const&, Type const&, Shape const&, bool copy = true, bool savespace = false);
|
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&);
|
||||||
template <class Buffer, class Type, class Shape>
|
template <class Sequence, class Typecode, class Type, class Shape>
|
||||||
object factory(Buffer const&, Type const&, Shape const&, bool copy, bool savespace, char typecode);
|
object factory(Sequence const&, Typecode const&, bool copy, bool savespace, Type const&, Shape const&);
|
||||||
</pre>
|
</pre>These functions map to the underlying array type's <code>array()</code>
|
||||||
These functions map to the underlying array type's <code>array()</code>
|
function family. They are not called "<code>array</code>" because of the C++
|
||||||
function family. They are not called "<code>array</code>" because of the
|
limitation that you can't define a member function with the same name as its
|
||||||
C++ limitation that you can't define a member function with the same name
|
enclosing class.
|
||||||
as its enclosing class.
|
<pre>
|
||||||
<pre>
|
|
||||||
template <class Type>
|
template <class Type>
|
||||||
object new_(Type const&) const;
|
array new_(Type const&) const;
|
||||||
</pre>
|
</pre>This function maps to the underlying array type's <code>new()</code>
|
||||||
This function maps to the underlying array type's <code>new()</code>
|
function. It is not called "<code>new</code>" because that is a keyword in
|
||||||
function. It is not called "<code>new</code>" because that is a keyword
|
C++.
|
||||||
in C++.
|
|
||||||
|
|
||||||
<h4><a name="array-spec-statics"></a>Class <code>array</code> static
|
<h4><a name="array-spec-statics" id="array-spec-statics"></a>Class
|
||||||
functions</h4>
|
<code>array</code> static functions</h4>
|
||||||
<pre>
|
<pre>
|
||||||
static void set_module_and_type(char const* package_path, char const* type_name);
|
static void set_module_and_type(char const* package_path, char const* type_name);
|
||||||
static void set_module_and_type();
|
static void set_module_and_type();
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="function-semantics">
|
<dl class="function-semantics">
|
||||||
<dt><b>Requires:</b> <code>package_path</code> and
|
<dt><b>Requires:</b> <code>package_path</code> and
|
||||||
<code>type_name</code>, if supplied, is an <a href=
|
<code>type_name</code>, if supplied, is an <a href=
|
||||||
"definitions.html#ntbs">ntbs</a>.</dt>
|
"definitions.html#ntbs">ntbs</a>.</dt>
|
||||||
|
|
||||||
<dt><b>Effects:</b> The first form sets the package path of the module
|
<dt><b>Effects:</b> The first form sets the package path of the module
|
||||||
which supplies the type named by <code>type_name</code> to
|
that supplies the type named by <code>type_name</code> to
|
||||||
<code>package_path</code>. The second form restores the <a href=
|
<code>package_path</code>. The second form restores the <a href=
|
||||||
"#default_search">default search behavior</a>. The associated Python
|
"#default_search">default search behavior</a>. The associated Python type
|
||||||
type will be searched for only the first time it is needed, and
|
will be searched for only the first time it is needed, and thereafter the
|
||||||
thereafter the first time it is needed after an invocation of
|
first time it is needed after an invocation of
|
||||||
<code>set_module_and_type</code>.</dt>
|
<code>set_module_and_type</code>.</dt>
|
||||||
</dl>
|
</dl>
|
||||||
|
<pre>
|
||||||
|
static std::string get_module_name()
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h2><a name="examples"></a>Example</h2>
|
<dl class="function-semantics">
|
||||||
<pre>
|
<dt><b>Effects:</b> Returns the name of the module containing the class
|
||||||
|
that will be held by new <code>numeric::array</code> instances.</dt>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="examples" id="examples"></a>Example</h2>
|
||||||
|
<pre>
|
||||||
#include <boost/python/numeric.hpp>
|
#include <boost/python/numeric.hpp>
|
||||||
#include <boost/python/tuple.hpp>
|
#include <boost/python/tuple.hpp>
|
||||||
|
|
||||||
@@ -258,10 +268,9 @@ void set_first_element(numeric::array& y, double value)
|
|||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>Revised 03 October, 2002</p>
|
<p>Revised 07 October, 2006</p>
|
||||||
|
|
||||||
<p><i>© Copyright <a href=
|
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
|
Abrahams</a> 2002-2006.</i></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
@@ -851,12 +854,12 @@ void del(proxy<T> const& x);
|
|||||||
</dl>
|
</dl>
|
||||||
<pre>
|
<pre>
|
||||||
<a name="comparisons-spec"></a>
|
<a name="comparisons-spec"></a>
|
||||||
template<class L,class R> bool operator>(L const&l,R const&r);
|
template<class L,class R> object operator>(L const&l,R const&r);
|
||||||
template<class L,class R> bool operator>=(L const&l,R const&r);
|
template<class L,class R> object operator>=(L const&l,R const&r);
|
||||||
template<class L,class R> bool operator<(L const&l,R const&r);
|
template<class L,class R> object operator<(L const&l,R const&r);
|
||||||
template<class L,class R> bool operator<=(L const&l,R const&r);
|
template<class L,class R> object operator<=(L const&l,R const&r);
|
||||||
template<class L,class R> bool operator==(L const&l,R const&r);
|
template<class L,class R> object operator==(L const&l,R const&r);
|
||||||
template<class L,class R> bool operator!=(L const&l,R const&r);
|
template<class L,class R> object operator!=(L const&l,R const&r);
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<dl class="function-semantics">
|
<dl class="function-semantics">
|
||||||
|
|||||||
138
doc/v2/opaque.html
Normal file
138
doc/v2/opaque.html
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright 2003..2006 Haufe Mediengruppe. 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) -->
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../boost.css">
|
||||||
|
|
||||||
|
<title>Boost.Python - <boost/python/opaque_pointer_converter.hpp></title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
||||||
|
"header">
|
||||||
|
<tr>
|
||||||
|
<td valign="top" width="300">
|
||||||
|
<h3><a href="../../../../index.htm"><img height="86" width="277"
|
||||||
|
alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td valign="top">
|
||||||
|
<h1 align="center"><a href="../index.html">Boost.Python</a></h1>
|
||||||
|
|
||||||
|
<h2 align="center">Header
|
||||||
|
<boost/python/opaque_pointer_converter.hpp></h2>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
|
||||||
|
<dl class="page-index">
|
||||||
|
<dt><a href="#classes">Classes</a></dt>
|
||||||
|
|
||||||
|
<dd>
|
||||||
|
<dl class="page-index">
|
||||||
|
<dt><a href="#opaque-spec">Class template
|
||||||
|
<code>opaque<Pointee></code></a></dt>
|
||||||
|
|
||||||
|
<dd>
|
||||||
|
<dl class="page-index">
|
||||||
|
<dt><a href="#opaque-spec-synopsis">Class template
|
||||||
|
<code>opaque</code> synopsis</a></dt>
|
||||||
|
</dl>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt><a href="#macros">Macros</a></dt>
|
||||||
|
<dd>
|
||||||
|
<dl class="page-index">
|
||||||
|
<dt><a href="#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec">Macro
|
||||||
|
<code>BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID</code></a></dt>
|
||||||
|
</dl>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt><a href="#see-also">See Also</a></dt>
|
||||||
|
</dl>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="classes"></a>Classes</h2>
|
||||||
|
|
||||||
|
<h3><a name="opaque-spec"></a>Class template
|
||||||
|
<code>opaque<P></code></h3>
|
||||||
|
|
||||||
|
<p><code>opaque<></code> registers itself as a converter from
|
||||||
|
Python objects to pointers to undefined types and vice versa.</p>
|
||||||
|
|
||||||
|
<h4><a name="opaque-spec-synopsis"></a>Class template
|
||||||
|
<code>opaque</code> synopsis</h4>
|
||||||
|
<pre>
|
||||||
|
namespace boost { namespace python
|
||||||
|
{
|
||||||
|
template<class Pointee>
|
||||||
|
struct opaque
|
||||||
|
{
|
||||||
|
opaque();
|
||||||
|
};
|
||||||
|
}}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h4><a name="opaque-spec-constructor"></a>Class template
|
||||||
|
<code>opaque</code> constructor</h4>
|
||||||
|
<pre>
|
||||||
|
opaque();
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<dl class="function-semantics">
|
||||||
|
<dt><b>Effects:</b>
|
||||||
|
<ul>
|
||||||
|
<li>Registers the instance as a
|
||||||
|
<a href="lvalue_from_pytype.html#lvalue_from_pytype-spec"> <code>lvalue_from_pytype</code></a>
|
||||||
|
converter from Python objects into opaque pointers.</p>
|
||||||
|
<p>The Python Objects created are named after the type pointed to
|
||||||
|
by the opaque pointer being wrapped.</p></li>
|
||||||
|
<li>Registers the instance as a
|
||||||
|
<a href="to_python_converter.html#to_python_converter-spec"> <code>to_python_converter</code></a>
|
||||||
|
from opaque pointers to Python objects.</p></li>
|
||||||
|
</ul>
|
||||||
|
<p>If there is already an instance registered by another module, this
|
||||||
|
instance doesn't try to register again in order to avoid warnings
|
||||||
|
about multiple registrations.</p>
|
||||||
|
|
||||||
|
<h4>Note</h4>
|
||||||
|
<p>Normally only a single instance of this class is created for every
|
||||||
|
Pointee.</p>
|
||||||
|
</dt>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h2><a name="macros"></a>Macros</h2>
|
||||||
|
|
||||||
|
<h3><a name="BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec"></a>
|
||||||
|
Macro BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(Pointee)</h3>
|
||||||
|
<p>This macro must be used to define specializations of the
|
||||||
|
<a href="type_id.html#type_id-spec">type_id</a> function
|
||||||
|
which can't be instantiated for incomplete types.</p>
|
||||||
|
<h4>Note</h4>
|
||||||
|
<p>The macro must be invoked in every translation unit which uses the
|
||||||
|
opaque converter.</p>
|
||||||
|
|
||||||
|
<h2><a name="see-also"></a>See Also</h2>
|
||||||
|
<p>
|
||||||
|
<a href="return_opaque_pointer.html">return_opaque_pointer</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>Revised
|
||||||
|
10 September, 2006
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><i>© Copyright 2003..2006 Haufe Mediengruppe. All Rights
|
||||||
|
Reserved.</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
||||||
<link rel="stylesheet" type="text/css" href="../boost.css">
|
|
||||||
|
|
||||||
<title>Boost.Python - <boost/python/opaque_pointer_converter.hpp></title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
|
|
||||||
"header">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="300">
|
|
||||||
<h3><a href="../../../../index.htm"><img height="86" width="277"
|
|
||||||
alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td valign="top">
|
|
||||||
<h1 align="center"><a href="../index.html">Boost.Python</a></h1>
|
|
||||||
|
|
||||||
<h2 align="center">Header
|
|
||||||
<boost/python/opaque_pointer_converter.hpp></h2>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h2>Contents</h2>
|
|
||||||
|
|
||||||
<dl class="page-index">
|
|
||||||
<dt><a href="#classes">Classes</a></dt>
|
|
||||||
|
|
||||||
<dd>
|
|
||||||
<dl class="page-index">
|
|
||||||
<dt><a href="#opaque_pointer_converter-spec">Class template
|
|
||||||
<code>opaque_pointer_converter<P></code></a></dt>
|
|
||||||
|
|
||||||
<dd>
|
|
||||||
<dl class="page-index">
|
|
||||||
<dt><a href="#opaque_pointer_converter-spec-synopsis">Class template
|
|
||||||
<code>opaque_pointer_converter</code> synopsis</a></dt>
|
|
||||||
</dl>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt><a href="#macros">Macros</a></dt>
|
|
||||||
<dd>
|
|
||||||
<dl class="page-index">
|
|
||||||
<dt><a href="#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec">Macro
|
|
||||||
<code>BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID</code></a></dt>
|
|
||||||
</dl>
|
|
||||||
</dd>
|
|
||||||
|
|
||||||
<dt><a href="#examples">Example</a></dt>
|
|
||||||
|
|
||||||
<dt><a href="#see-also">See Also</a></dt>
|
|
||||||
</dl>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h2><a name="classes"></a>Classes</h2>
|
|
||||||
|
|
||||||
<h3><a name="opaque_pointer_converter-spec"></a>Class template
|
|
||||||
<code>opaque_pointer_converter<P></code></h3>
|
|
||||||
|
|
||||||
<p><code>opaque_pointer_converter<></code> is derived from
|
|
||||||
<a href="to_python_converter.html#to_python_converter-spec">
|
|
||||||
<code>to_python_converter</code></a>
|
|
||||||
and registers itself as an
|
|
||||||
<a href="lvalue_from_pytype.html#lvalue_from_pytype-spec">
|
|
||||||
<code>lvalue_from_pytype</code></a> converter from Python objects
|
|
||||||
into pointers to undefined types.
|
|
||||||
Thus it may be used as a converter from opaque pointers into
|
|
||||||
Python objects and vice versa.</p>
|
|
||||||
|
|
||||||
<h4><a name="opaque_pointer_converter-spec-synopsis"></a>Class template
|
|
||||||
<code>opaque_pointer_converter</code> synopsis</h4>
|
|
||||||
<pre>
|
|
||||||
namespace boost { namespace python
|
|
||||||
{
|
|
||||||
template<class Pointer>
|
|
||||||
struct opaque_pointer_converter
|
|
||||||
: to_python_converter<
|
|
||||||
Pointer, opaque_pointer_converter<Pointer> >
|
|
||||||
{
|
|
||||||
explicit opaque_pointer_converter(char const* name);
|
|
||||||
};
|
|
||||||
}}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h4><a name="opaque_pointer_converter-spec-constructor"></a>Class template
|
|
||||||
<code>opaque_pointer_converter</code> constructor</h4>
|
|
||||||
<pre>
|
|
||||||
explicit opaque_pointer_converter(char const* name);
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<dl class="function-semantics">
|
|
||||||
<dt><b>Effects:</b>
|
|
||||||
<p>Registers the instance as a
|
|
||||||
<a href="lvalue_from_pytype.html#lvalue_from_pytype-spec">
|
|
||||||
<code>lvalue_from_pytype</code></a> converter from Python objects
|
|
||||||
into opaque pointers.</p>
|
|
||||||
<p>The name is used for the type of the Python Objects created;
|
|
||||||
it should be printable but needn't be an
|
|
||||||
<a href="definitions.html#ntbs">ntbs</a> because the object type is
|
|
||||||
not supposed to be user constructible within python scripts.</p>
|
|
||||||
</dt>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
<h2><a name="macros"></a>Macros</h2>
|
|
||||||
|
|
||||||
<h3><a name="BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec"></a>
|
|
||||||
Macro BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID(Pointee)</h3>
|
|
||||||
<p>This macro must be used to define specializations of the
|
|
||||||
<a href="type_id.html#type_id-spec">type_id</a> function
|
|
||||||
which can't be instantiated for incomplete types.</p>
|
|
||||||
<h4>Note</h4>
|
|
||||||
<p>In order for this to work in a cross-module environment the macro must
|
|
||||||
be invoked in every translation unit which uses the
|
|
||||||
opaque_pointer_converter.</p>
|
|
||||||
|
|
||||||
<h2><a name="examples"></a>Example</h2>
|
|
||||||
|
|
||||||
please see example for <a href="return_opaque_pointer.html#examples">
|
|
||||||
return_opaque_pointer</a>.
|
|
||||||
|
|
||||||
<h2><a name="see-also"></a>See Also</h2>
|
|
||||||
<p>
|
|
||||||
<a href="return_opaque_pointer.html">return_opaque_pointer</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>Revised
|
|
||||||
10 March, 2003
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p><i>© Copyright 2003 Haufe Mediengruppe. All Rights
|
|
||||||
Reserved.</i></p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -320,11 +320,9 @@ See also the
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
© Copyright Ralf W. Grosse-Kunstleve 2001-2004. Permission to copy,
|
© Copyright Ralf W. Grosse-Kunstleve 2001-2004. Distributed under
|
||||||
use, modify, sell and distribute this document is granted provided this
|
the Boost Software License, Version 1.0. (See accompanying file
|
||||||
copyright notice appears in all copies. This document is provided "as
|
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
is" without express or implied warranty, and with no claim as to its
|
|
||||||
suitability for any purpose.
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Updated: Feb 2004.
|
Updated: Feb 2004.
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -112,5 +112,8 @@ BOOST_PYTHON_MODULE(pointee_demo)
|
|||||||
|
|
||||||
|
|
||||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
Abrahams</a> 2002. </i>
|
Abrahams</a> 2002. </i> 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)</p>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -259,5 +259,7 @@ void pass_as_arg(expensive_to_copy* x, PyObject* f)
|
|||||||
|
|
||||||
|
|
||||||
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
<p><i>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave
|
||||||
Abrahams</a> 2002. </i>
|
Abrahams</a> 2002. </i> 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)</p>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
@@ -904,26 +907,26 @@
|
|||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"opaque_pointer_converter.html">opaque_pointer_converter.hpp</a></dt>
|
"opaque.html">opaque_pointer_converter.hpp</a></dt>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"opaque_pointer_converter.html#classes">Classes</a></dt>
|
"opaque.html#classes">Classes</a></dt>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"opaque_pointer_converter.html#opaque_pointer_converter-spec">opaque_pointer_converter</a></dt>
|
"opaque.html#opaque-spec">opaque</a></dt>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
<dt><a href="opaque_pointer_converter.html#macros">Macros</a></dt>
|
<dt><a href="opaque.html#macros">Macros</a></dt>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href=
|
<dt><a href=
|
||||||
"opaque_pointer_converter.html#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec">
|
"opaque.html#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec">
|
||||||
BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID</a></dt>
|
BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID</a></dt>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
@@ -1091,6 +1094,16 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt><a href="ssize_t.html">ssize_t.hpp</a></dt>
|
||||||
|
|
||||||
|
<dd>
|
||||||
|
<dl class="index">
|
||||||
|
<dt><a href="ssize_t.html#typedefs">Typedefs</a></dt>
|
||||||
|
|
||||||
|
<dt><a href="ssize_t.html#constants">Constants</a></dt>
|
||||||
|
</dl>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<h2><a name="topics">Topics</a></h2>
|
<h2><a name="topics">Topics</a></h2>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
@@ -67,7 +70,7 @@
|
|||||||
undefined types such that the return value is copied into a
|
undefined types such that the return value is copied into a
|
||||||
new Python object.</p>
|
new Python object.</p>
|
||||||
<p>In addition to specifying the <code>return_opaque_pointer</code>
|
<p>In addition to specifying the <code>return_opaque_pointer</code>
|
||||||
policy the <a href="opaque_pointer_converter.html#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec">
|
policy the <a href="opaque.html#BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID-spec">
|
||||||
<code>BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID</code></a> macro must be
|
<code>BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID</code></a> macro must be
|
||||||
used to define specializations for the
|
used to define specializations for the
|
||||||
<a href="type_id.html#type_id-spec">type_id</a> function
|
<a href="type_id.html#type_id-spec">type_id</a> function
|
||||||
@@ -174,8 +177,8 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
<h2><a name="see-also"></a>See Also</h2>
|
<h2><a name="see-also"></a>See Also</h2>
|
||||||
<p>
|
<p>
|
||||||
<a href="opaque_pointer_converter.html">
|
<a href="opaque.html">
|
||||||
opaque_pointer_converter</a>
|
opaque</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>Revised
|
<p>Revised
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator" content=
|
<meta name="generator" content=
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<!-- Copyright David Abrahams 2006. 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) -->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="generator"
|
<meta name="generator"
|
||||||
|
|||||||
96
doc/v2/ssize_t.html
Normal file
96
doc/v2/ssize_t.html
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<!-- Copyright Ralf W. Grosse-Kunstleve 2006. 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) -->
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="generator" content=
|
||||||
|
"HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org">
|
||||||
|
<meta http-equiv="Content-Type" content=
|
||||||
|
"text/html; charset=us-ascii">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../boost.css">
|
||||||
|
|
||||||
|
<title>Boost.Python - <boost/python/ssize_t.hpp></title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<table border="0" cellpadding="7" cellspacing="0" width="100%"
|
||||||
|
summary="header">
|
||||||
|
<tr>
|
||||||
|
<td valign="top" width="300">
|
||||||
|
<h3><a href="../../../../index.htm"><img height="86" width=
|
||||||
|
"277" alt="C++ Boost" src="../../../../boost.png" border=
|
||||||
|
"0"></a></h3>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td valign="top">
|
||||||
|
<h1 align="center"><a href=
|
||||||
|
"../index.html">Boost.Python</a></h1>
|
||||||
|
|
||||||
|
<h2 align="center">Header
|
||||||
|
<boost/python/ssize_t.hpp></h2>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
|
||||||
|
<dl class="page-index">
|
||||||
|
<dt><a href="#introduction">Introduction</a></dt>
|
||||||
|
|
||||||
|
<dt><a href="#typdefs">Typedef</a></dt>
|
||||||
|
|
||||||
|
<dt><a href="#macros">Constants</a></dt>
|
||||||
|
</dl>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<h2><a name="introduction" id=
|
||||||
|
"introduction"></a>Introduction</h2>
|
||||||
|
|
||||||
|
<p>Python 2.5 introduces a new <tt>Py_ssize_t</tt> typedef and
|
||||||
|
two related macros (<a href=
|
||||||
|
"http://www.python.org/dev/peps/pep-0353/">PEP 353</a>). The
|
||||||
|
<tt><boost/python/ssize_t.hpp></tt> header imports these
|
||||||
|
definitions into the <tt>boost::python</tt> namespace as
|
||||||
|
<tt>ssize_t</tt>, <tt>ssize_t_max</tt>, and <tt>ssize_t_min</tt>.
|
||||||
|
Appropriate definitions are provided for backward compatibility
|
||||||
|
with previous Python versions.</p>
|
||||||
|
|
||||||
|
<h2><a name="typedefs" id="typedefs"></a>Typedefs</h2>Imports
|
||||||
|
<tt>Py_ssize_t</tt> into the <tt>boost::python</tt> namespace if
|
||||||
|
available, or provides an appropriate typedef for backward
|
||||||
|
compatibility:
|
||||||
|
<pre>
|
||||||
|
#if PY_VERSION_HEX >= 0x02050000
|
||||||
|
typedef Py_ssize_t ssize_t;
|
||||||
|
#else
|
||||||
|
typedef int ssize_t;
|
||||||
|
#endif
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<h2><a name="constants" id="constants"></a>Constants</h2>Imports
|
||||||
|
<tt>PY_SSIZE_T_MAX</tt> and <tt>PY_SSIZE_T_MIN</tt> as constants
|
||||||
|
into the <tt>boost::python</tt> namespace if available, or
|
||||||
|
provides appropriate constants for backward compatibility:
|
||||||
|
<pre>
|
||||||
|
#if PY_VERSION_HEX >= 0x02050000
|
||||||
|
ssize_t const ssize_t_max = PY_SSIZE_T_MAX;
|
||||||
|
ssize_t const ssize_t_min = PY_SSIZE_T_MIN;
|
||||||
|
#else
|
||||||
|
ssize_t const ssize_t_max = INT_MAX;
|
||||||
|
ssize_t const ssize_t_min = INT_MIN;
|
||||||
|
#endif
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||||
|
25 September, 2006
|
||||||
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
|
|
||||||
|
<p><i>© Copyright <a href=
|
||||||
|
"../../../../people/ralf_w_grosse_kunstleve.htm">Ralf W.
|
||||||
|
Grosse-Kunstleve</a> 2006.</i></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user