2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-19 16:32:16 +00:00

Compare commits

...

33 Commits

Author SHA1 Message Date
nobody
7cbf652c85 This commit was manufactured by cvs2svn to create tag
'Version_1_29_0'.

[SVN r15904]
2002-10-11 15:17:55 +00:00
Dave Abrahams
0e7e64c4a9 Note about broken 2.95.3 EH implementation :(
[SVN r15890]
2002-10-11 04:19:04 +00:00
Dave Abrahams
dae2e27a32 tweak
[SVN r15876]
2002-10-10 18:11:05 +00:00
Dave Abrahams
3744f8b4c1 tweak
[SVN r15874]
2002-10-10 18:09:37 +00:00
Dave Abrahams
e9a3d020f3 tweak
[SVN r15873]
2002-10-10 18:06:08 +00:00
Dave Abrahams
77b6388723 Move joel's updates over from the main trunk (finish)
[SVN r15870]
2002-10-10 17:52:30 +00:00
Dave Abrahams
a4912cebe0 Acknowledge Paul M and Aleksey G
[SVN r15868]
2002-10-10 17:04:57 +00:00
Dave Abrahams
956b0c5038 doc tweaks; added known-working-platforms page
[SVN r15867]
2002-10-10 16:45:45 +00:00
Dave Abrahams
682f175412 GCC 2.96 workaround
[SVN r15866]
2002-10-10 16:44:47 +00:00
Dave Abrahams
0dc693a9e3 Clean up RC branch some more
[SVN r15862]
2002-10-10 14:14:27 +00:00
Dave Abrahams
fa61758f32 Move joel's updates over from the main trunk
[SVN r15861]
2002-10-10 14:01:40 +00:00
Dave Abrahams
53cebbf024 Moved trunk revision over
[SVN r15857]
2002-10-10 13:10:51 +00:00
Dave Abrahams
64035277dc clean up v1 flotsam
[SVN r15856]
2002-10-10 13:05:52 +00:00
nobody
a8d37ebc4a This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15847]
2002-10-10 08:59:20 +00:00
Dave Abrahams
d5cfa0483a Clean up Boost.Python v1 flotsam, update documentation, prepare for release
[SVN r15829]
2002-10-09 16:58:35 +00:00
Dave Abrahams
9e21275595 Bug fix (thanks to Leonardo Rochael Almeida <leo@hiper.com.br>).
[SVN r15828]
2002-10-09 16:14:19 +00:00
nobody
0faabfb091 This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15827]
2002-10-09 14:31:40 +00:00
Dave Abrahams
ee6e678c95 Workaround GCC 3.x problem
[SVN r15791]
2002-10-07 20:13:00 +00:00
Ralf W. Grosse-Kunstleve
66358ecfd8 adjustment for Mac OS 10.2 c++
[SVN r15781]
2002-10-07 17:51:31 +00:00
Dave Abrahams
dfdf805106 Make AIX work again
[SVN r15743]
2002-10-05 20:11:57 +00:00
Dave Abrahams
281a5271da Make AIX work again
[SVN r15742]
2002-10-05 20:02:08 +00:00
Dave Abrahams
6eaa0827e5 Patches for CWPro8.3
[SVN r15734]
2002-10-05 16:39:34 +00:00
Dave Abrahams
c33ac6b47a Merge Trunk changes to RC_1_29_0
[SVN r15732]
2002-10-05 12:53:06 +00:00
Ralf W. Grosse-Kunstleve
0462c4d2f4 changes from branch merged to enable cxx 6.51 compilations
[SVN r15716]
2002-10-04 16:44:38 +00:00
nobody
1b35d5d3df This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15703]
2002-10-04 00:45:30 +00:00
nobody
512b912a9c This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15698]
2002-10-03 23:21:49 +00:00
Joel de Guzman
7da5d6344d Removing V1 Artifacts
[SVN r15592]
2002-10-01 00:31:57 +00:00
Joel de Guzman
f4ba587b19 reverting mistake
[SVN r15591]
2002-09-30 23:46:05 +00:00
Joel de Guzman
f1612c4294 Removing more V1 artifacts
[SVN r15590]
2002-09-30 23:44:55 +00:00
Joel de Guzman
f1b376776e merged from HEAD
[SVN r15589]
2002-09-30 23:20:11 +00:00
Joel de Guzman
eb6994e6b4 Removing BPL V1 Artifacts
[SVN r15569]
2002-09-30 07:18:46 +00:00
nobody
bd0b01c049 This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15564]
2002-09-30 03:35:54 +00:00
nobody
628573eb58 This commit was manufactured by cvs2svn to create branch 'RC_1_29_0'.
[SVN r15460]
2002-09-19 20:49:39 +00:00
17 changed files with 611 additions and 23 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -52,8 +52,11 @@
<hr>
<h2><a name="requirements">Requirements</a></h2>
Boost.Python requires <a href="http://www.python.org">Python</a> 2.2 or
later.
<b>Boost.Python</b> version 2 requires <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
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>

View File

@@ -28,6 +28,36 @@
</table>
<hr>
<h2>Synopsis</h2>
Welcome to version 2 of <b>Boost.Python</b>, a C++ library which enables
seamless interoperability between C++ and the <a href=
"http://www.python.org">Python</a> programming language. The new version
has been rewritten from the ground up, with a more convenient and
flexible interface, and many new capabilities, including support for:
<ul>
<li>References and Pointers</li>
<li>Globally Registered Type Coercions</li>
<li>Automatic Cross-Module Type Conversions</li>
<li>Efficient Function Overloading</li>
<li>C++ to Python Exception Translation</li>
<li>Default Arguments</li>
<li>Keyword Arguments</li>
<li>Manipulating Python objects in C++</li>
<li>Exporting C++ Iterators as Python Iterators</li>
<li>Documentation Strings</li>
</ul>
<hr>
<h2>Contents</h2>
<dl class="index">
@@ -39,7 +69,8 @@
<dt><a href="v2/configuration.html">Configuration Information</a></dt>
<dt><a href="v2/rationale.html">Rationale</a></dt>
<dt><a href="v2/platforms.html">Known Working Platforms and
Compilers</a></dt>
<dt><a href="v2/definitions.html">Definitions</a></dt>
@@ -51,9 +82,9 @@
</dl>
<hr>
<p>Revised
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
08 October, 2002
08 October, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>

View File

@@ -32,18 +32,36 @@
the architect, designer, and implementor of <b>Boost.Python</b>.</p>
<p>Joel de Guzman implemented the <a href="overloads.html">default
argument support</a> and wrote the excellent tutorial documentation.</p>
argument support</a> and wrote the excellent <a href=
"../tutorial/index.html">tutorial documentation</a>.</p>
<p><a href="../../../../people/ralf_w_grosse_kunstleve.htm">Ralf W.
Grosse-Kunstleve</a> implemented the <a href="pickle.html">pickle
support</a>, and has enthusiastically supported the library since its
birth, contributing to design decisions and providing invaluable
real-world insight into user requirements. Ralf has written some
extensions for converting C++ containers that I hope will be incorporated
into the library soon. He also implemented the cross-module support in
the first version of Boost.Python. More importantly, Ralf makes sure
nobody forgets the near-perfect synergy of C++ and Python for solving the
problems of large-scale software construction.</p>
real-world insight into user requirements. Ralf has written some <a href=
"faq.html#question2">extensions</a> for converting C++ containers that I
hope will be incorporated into the library soon. He also implemented the
cross-module support in the first version of Boost.Python. More
importantly, Ralf makes sure nobody forgets the near-perfect synergy of
C++ and Python for solving the problems of large-scale software
construction.</p>
<p><a href="../../../../people/aleksey_gurtovoy.htm">Aleksey Gurtovoy</a>
wrote an incredible C++ <a href="http://www.mywikinet.com/mpl">Template
Metaprogramming Library</a> which allows Boost.Python to perform much of
its compile-time magic. In addition, Aleksey very generously contributed
his time and deep knowledge of the quirks of various buggy compilers to
help us get around problems at crucial moments.</p>
<p><a href="../../../../people/paul_mensonides.htm">Paul Mensonides</a>,
building on the work <a href="../../../../people/vesa_karvonen.htm">Vesa
Karvonen</a>, wrote a similarly amazing <a href=
"../../../preprocessor/doc/index.html">Preprocessor Metaprogramming
Library</a>, and generously contributed the time and expertise to get it
working in the Boost.Python library, rewriting much of Boost.Python to
use the new preproccessor metaprogramming constructs and helping us to
work around buggy and slow C++ preprocessors.</p>
<p><a href="mailto:achim@procoders.net">Achim Domma</a> contributed some
of the <a href="reference.html#object_wrappers">Object Wrappers</a> and

141
doc/v2/platforms.html Normal file
View File

@@ -0,0 +1,141 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Windows (vers 1st August 2002), see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../boost.css">
<title>Boost.Python - Known Working Platforms and Compilers</title>
</head>
<body link="#0000ff" vlink="#800080">
<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="../../../../c++boost.gif" border="0"></a></h3>
</td>
<td valign="top">
<h1 align="center">Boost.Python</h1>
<h2 align="center">Known Working Platforms and Compilers</h2>
</td>
</tr>
</table>
<hr>
<b>Boost.Python</b> has been successfully tested on the following
platforms and compilers:
<dl class="page-index">
<dt>Unix Platforms:</dt>
<dd>
<dl>
<dt>with Python <a href="http://www.python.org/2.2">2.2</a> and <a
href="http://www.python.org/2.2.2">2.2.2b1</a>:</dt>
<dd>
<dl>
<dt><a href="http://gcc.gnu.org">GCC</a> 2.96, 3.0.4,
3.1, and 3.2 on <a href="http://www.redhat.com">RedHat Linux 7.3</a>
for Intel x86. </dt>
<dt><a href="http://gcc.gnu.org">GCC</a> 2.95.3
(20010315 release) on <a
href="http://www.redhat.com">RedHat Linux 7.3</a> for
Intel x86. All tests passed except those involving C++
exceptions. Bugs in the C++ exception-handling
implementation prevented these tests from running to
completion.</dt>
<dt><a href=
"http://www.tru64unix.compaq.com/cplus/index.html">Tru64 CXX
6.5.1</a> on OSF v. 5.1 for Dec/Compaq Alpha</dt>
<dt><a href=
"http://www.sgi.com/developers/devtools/languages/mipspro.html">
MIPSPro 7.3.1.2m</a> on <a href=
"http://www.sgi.com/software/irix6.5/">IRIX 6.5</a> for SGI
mips</dt>
<dt><a href="http://gcc.gnu.org">GCC 3.1</a> on SunOS 5.8</dt>
</dl>
</dd>
<dt>with Python <a href=
"http://www.python.org/2.2.1">2.2.1</a></dt>
<dd>
<dl>
<dt><a href=
"http://developer.intel.com/software/products/kcc/">KCC
3.4d</a> on OSF v. 5.1 for Dec/Compaq Alpha</dt>
<dt><a href=
"http://developer.intel.com/software/products/kcc/">KCC
3.4d</a> on AIX</dt>
</dl>
</dd>
</dl>
<br>
</dd>
<dt><a href="http://www.microsoft.com/windowsxp/default.asp">Microsoft
Windows XP Professional</a> with Python <a href=
"http://www.python.org/2.2">2.2</a>, <a href=
"http://www.python.org/2.2.1">2.2.1</a>, and <a href=
"http://www.python.org/2.2.2">2.2.2b1</a>:</dt>
<dd>
<dl>
<dt><a href=
"http://msdn.microsoft.com/visualc/default.asp">Microsoft Visual
C++</a> 6, 7, and 7.1 beta</dt>
<dt><a href=
"http://msdn.microsoft.com/visualc/default.asp">Microsoft Visual
C++ 6</a> with <a href="http://www.stlport.org">STLPort
4.5.3</a></dt>
<dt><a href=
"http://www.metrowerks.com/MW/Develop/Desktop/Windows/Professional/Default.htm">
Metrowerks CodeWarrior</a> 7.2, 8.0, 8.2 and 8.3 beta</dt>
<dt><a href=
"http://www.intel.com/software/products/compilers/c60/">Intel
C++</a> 5.0, 6.0, and 7.0 beta</dt>
<dt><a href=
"http://www.intel.com/software/products/compilers/c60/">Intel C++
5.0</a> with <a href="http://www.stlport.org">STLPort
4.5.3</a></dt>
<dt><a href="http://www.cygwin.com">Cygwin</a> <a href=
"http://gcc.gnu.org">GCC</a> 3.0.4 and 3.2</dt>
<dt><a href="http://www.mingw.org">MinGW-1.1</a> (<a href=
"http://gcc.gnu.org">GCC 2.95.3-5</a>)</dt>
<dt><a href="http://www.mingw.org">MinGW-2.0</a> (<a href=
"http://gcc.gnu.org">GCC 3.2</a>)</dt>
</dl>
</dd>
</dl>
<hr>
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
10 October, 2002
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p><i>&copy; Copyright <a href=
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All Rights
Reserved.</i></p>
</body>
</html>

View File

@@ -352,8 +352,8 @@
<dd>
<dl class="index">
<dt><a href="object.html#object-spec">object</a></dt>
</dl>
</dd>
</dl>
</dd>
</dl>
</dd>
@@ -898,7 +898,7 @@
<p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
3 June, 2002 <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
08 October, 2002 <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
</p>
<p class="c3">&copy; Copyright <a href=

View File

@@ -157,7 +157,7 @@ BOOST_PYTHON_MODULE(nested)
42
</pre>
<p>Revised 03 October, 2002</p>
<p>Revised 09 October, 2002</p>
<p><i>&copy; Copyright <a href=
"../../../../people/dave_abrahams.htm">Dave Abrahams</a> 2002. All Rights

Binary file not shown.

Binary file not shown.

View File

@@ -94,7 +94,8 @@ struct rvalue_from_python_data : rvalue_from_python_storage<T>
{
# if (!defined(__MWERKS__) || __MWERKS__ >= 0x3000) \
&& (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 245) \
&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014)
&& (!defined(__DECCXX_VER) || __DECCXX_VER > 60590014) \
&& !(defined(__APPLE__) && defined(__MACH__) && __APPLE_CC__ <= 1161)
// This must always be a POD struct with m_data its first member.
BOOST_STATIC_ASSERT(BOOST_PYTHON_OFFSETOF(rvalue_from_python_storage<T>,stage1) == 0);
# endif

View File

@@ -38,7 +38,7 @@ namespace objects
namespace detail
{
template <class T, class F> struct member_function_cast;
template <class Func, class CallPolicies, class NameSpaceT>
static void name_space_def(
NameSpaceT& name_space
@@ -51,7 +51,7 @@ namespace detail
)
{
typedef typename NameSpaceT::wrapped_type wrapped_type;
objects::add_to_namespace(
name_space, name,
make_keyword_range_function(
@@ -162,10 +162,10 @@ namespace detail
{
// define the NTH stub function of stubs
define_stub_function<N>::define(name, stubs, kw, policies, name_space, doc);
if (kw.second > kw.first)
--kw.second;
// call the next define_with_defaults_helper
define_with_defaults_helper<N-1>::def(name, stubs, kw, policies, name_space, doc);
}

View File

@@ -0,0 +1,53 @@
// Copyright David Abrahams 2002. 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.
#ifdef BOOST_PYTHON_V2
# error obsolete
#endif
#ifndef MODULE_INIT_DWA2002529_HPP
# define MODULE_INIT_DWA2002529_HPP
# ifndef BOOST_PYTHON_MODULE_INIT
# if defined(_WIN32) || defined(__CYGWIN__)
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" __declspec(dllexport) void init##name() \
{ \
boost::python::handle_exception(&init_module_##name); \
} \
void init_module_##name()
# elif defined(_AIX)
# include <boost/python/detail/aix_init_module.hpp>
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" \
{ \
extern PyObject* _PyImport_LoadDynamicModule(char*, char*, FILE *); \
void init##name() \
{ \
boost::python::detail::aix_init_module(_PyImport_LoadDynamicModule, &init_module_##name); \
} \
} \
void init_module_##name()
# else
# define BOOST_PYTHON_MODULE_INIT(name) \
void init_module_##name(); \
extern "C" void init##name() \
{ \
boost::python::handle_exception(&init_module_##name); \
} \
void init_module_##name()
# endif
# endif
#endif // MODULE_INIT_DWA2002529_HPP

View File

@@ -208,7 +208,7 @@ class init : public init_base<init<BOOST_PYTHON_OVERLOAD_ARGS> >
: base(doc_)
{
}
template <class Keywords>
init(char const* doc_, Keywords const& kw)
: base(doc_, std::make_pair(kw.base(), kw.base() + Keywords::size))

View File

@@ -0,0 +1,340 @@
// Copyright David Abrahams 2002. 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.
#ifndef OPERATORS2_DWA2002530_HPP
# define OPERATORS2_DWA2002530_HPP
# include <boost/python/detail/wrap_python.hpp>
# include <boost/python/converter/arg_to_python.hpp>
# include <boost/python/detail/operator_id.hpp>
# include <boost/python/detail/not_specified.hpp>
# include <boost/python/back_reference.hpp>
# include <boost/mpl/if.hpp>
# include <boost/python/self.hpp>
# include <boost/python/other.hpp>
# include <boost/lexical_cast.hpp>
# include <boost/python/refcount.hpp>
# include <string>
# include <complex>
namespace boost { namespace python {
namespace detail
{
// This is essentially the old v1 to_python(). It will be eliminated
// once the public interface for to_python is settled on.
template <class T>
PyObject* convert_result(T const& x)
{
return converter::arg_to_python<T>(x).release();
}
// Operator implementation template declarations. The nested apply
// declaration here keeps MSVC6 happy.
template <operator_id> struct operator_l
{
template <class L, class R> struct apply;
};
template <operator_id> struct operator_r
{
template <class L, class R> struct apply;
};
template <operator_id> struct operator_1
{
template <class T> struct apply;
};
// MSVC6 doesn't want us to do this sort of inheritance on a nested
// class template, so we use this layer of indirection to avoid
// ::template<...> on the nested apply functions below
template <operator_id id, class L, class R>
struct operator_l_inner
: operator_l<id>::template apply<L,R>
{};
template <operator_id id, class L, class R>
struct operator_r_inner
: operator_r<id>::template apply<L,R>
{};
template <operator_id id, class T>
struct operator_1_inner
: operator_1<id>::template apply<T>
{};
// Define three different binary_op templates which take care of
// these cases:
// self op self
// self op R
// L op self
//
// The inner apply metafunction is used to adjust the operator to
// the class type being defined. Inheritance of the outer class is
// simply used to provide convenient access to the operation's
// name().
// self op self
template <operator_id id>
struct binary_op : operator_l<id>
{
template <class T>
struct apply : operator_l_inner<id,T,T>
{
};
};
// self op R
template <operator_id id, class R>
struct binary_op_l : operator_l<id>
{
template <class T>
struct apply : operator_l_inner<id,T,R>
{
};
};
// L op self
template <operator_id id, class L>
struct binary_op_r : operator_r<id>
{
template <class T>
struct apply : operator_r_inner<id,L,T>
{
};
};
template <operator_id id>
struct unary_op : operator_1<id>
{
template <class T>
struct apply : operator_1_inner<id,T>
{
};
};
// This type is what actually gets returned from operators used on
// self_t
template <operator_id id, class L = not_specified, class R = not_specified>
struct operator_
: mpl::if_<
is_same<L,self_t>
, typename mpl::if_<
is_same<R,self_t>
, binary_op<id>
, binary_op_l<id,typename unwrap_other<R>::type>
>::type
, typename mpl::if_<
is_same<L,not_specified>
, unary_op<id>
, binary_op_r<id,typename unwrap_other<L>::type>
>::type
>::type
{
};
}
# define BOOST_PYTHON_BINARY_OPERATION(id, rid, expr) \
namespace detail \
{ \
template <> \
struct operator_l<op_##id> \
{ \
template <class L, class R> \
struct apply \
{ \
static inline PyObject* execute(L const& l, R const& r) \
{ \
return detail::convert_result(expr); \
} \
}; \
static char const* name() { return "__" #id "__"; } \
}; \
\
template <> \
struct operator_r<op_##id> \
{ \
template <class L, class R> \
struct apply \
{ \
static inline PyObject* execute(R const& r, L const& l) \
{ \
return detail::convert_result(expr); \
} \
}; \
static char const* name() { return "__" #rid "__"; } \
}; \
}
# define BOOST_PYTHON_BINARY_OPERATOR(id, rid, op) \
BOOST_PYTHON_BINARY_OPERATION(id, rid, l op r) \
namespace self_ns \
{ \
template <class L, class R> \
inline detail::operator_<detail::op_##id,L,R> \
operator##op(L const&, R const&) \
{ \
return detail::operator_<detail::op_##id,L,R>(); \
} \
}
BOOST_PYTHON_BINARY_OPERATOR(add, radd, +)
BOOST_PYTHON_BINARY_OPERATOR(sub, rsub, -)
BOOST_PYTHON_BINARY_OPERATOR(mul, rmul, *)
BOOST_PYTHON_BINARY_OPERATOR(div, rdiv, /)
BOOST_PYTHON_BINARY_OPERATOR(mod, rmod, %)
BOOST_PYTHON_BINARY_OPERATOR(lshift, rlshift, <<)
BOOST_PYTHON_BINARY_OPERATOR(rshift, rrshift, >>)
BOOST_PYTHON_BINARY_OPERATOR(and, rand, &)
BOOST_PYTHON_BINARY_OPERATOR(xor, rxor, ^)
BOOST_PYTHON_BINARY_OPERATOR(or, ror, |)
BOOST_PYTHON_BINARY_OPERATOR(gt, lt, >)
BOOST_PYTHON_BINARY_OPERATOR(ge, le, >=)
BOOST_PYTHON_BINARY_OPERATOR(lt, gt, <)
BOOST_PYTHON_BINARY_OPERATOR(le, ge, <=)
BOOST_PYTHON_BINARY_OPERATOR(eq, eq, ==)
BOOST_PYTHON_BINARY_OPERATOR(ne, ne, !=)
# undef BOOST_PYTHON_BINARY_OPERATOR
// pow isn't an operator in C++; handle it specially.
BOOST_PYTHON_BINARY_OPERATION(pow, rpow, pow(l,r))
# undef BOOST_PYTHON_BINARY_OPERATION
namespace self_ns
{
# ifndef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
template <class L, class R>
inline detail::operator_<detail::op_pow,L,R>
pow(L const&, R const&)
{
return detail::operator_<detail::op_pow,L,R>();
}
# else
// When there's no argument-dependent lookup, we need these
// overloads to handle the case when everything is imported into the
// global namespace. Note that the plain overload below does /not/
// take const& arguments. This is needed by MSVC6 at least, or it
// complains of ambiguities, since there's no partial ordering.
inline detail::operator_<detail::op_pow,self_t,self_t>
pow(self_t, self_t)
{
return detail::operator_<detail::op_pow,self_t,self_t>();
}
template <class R>
inline detail::operator_<detail::op_pow,self_t,R>
pow(self_t const&, R const&)
{
return detail::operator_<detail::op_pow,self_t,R>();
}
template <class L>
inline detail::operator_<detail::op_pow,L,self_t>
pow(L const&, self_t const&)
{
return detail::operator_<detail::op_pow,L,self_t>();
}
# endif
}
# define BOOST_PYTHON_INPLACE_OPERATOR(id, op) \
namespace detail \
{ \
template <> \
struct operator_l<op_##id> \
{ \
template <class L, class R> \
struct apply \
{ \
static inline PyObject* \
execute(back_reference<L&> l, R const& r) \
{ \
l.get() op r; \
return python::incref(l.source().ptr()); \
} \
}; \
static char const* name() { return "__" #id "__"; } \
}; \
} \
namespace self_ns \
{ \
template <class R> \
inline detail::operator_<detail::op_##id,self_t,R> \
operator##op(self_t const&, R const&) \
{ \
return detail::operator_<detail::op_##id,self_t,R>(); \
} \
}
BOOST_PYTHON_INPLACE_OPERATOR(iadd,+=)
BOOST_PYTHON_INPLACE_OPERATOR(isub,-=)
BOOST_PYTHON_INPLACE_OPERATOR(imul,*=)
BOOST_PYTHON_INPLACE_OPERATOR(idiv,/=)
BOOST_PYTHON_INPLACE_OPERATOR(imod,%=)
BOOST_PYTHON_INPLACE_OPERATOR(ilshift,<<=)
BOOST_PYTHON_INPLACE_OPERATOR(irshift,>>=)
BOOST_PYTHON_INPLACE_OPERATOR(iand,&=)
BOOST_PYTHON_INPLACE_OPERATOR(ixor,^=)
BOOST_PYTHON_INPLACE_OPERATOR(ior,|=)
# define BOOST_PYTHON_UNARY_OPERATOR(id, op, func_name) \
namespace detail \
{ \
template <> \
struct operator_1<op_##id> \
{ \
template <class T> \
struct apply \
{ \
static PyObject* execute(T const& x) \
{ \
return detail::convert_result(op(x)); \
} \
}; \
static char const* name() { return "__" #id "__"; } \
}; \
} \
namespace self_ns \
{ \
inline detail::operator_<detail::op_##id> \
func_name(self_t const&) \
{ \
return detail::operator_<detail::op_##id>(); \
} \
}
# undef BOOST_PYTHON_INPLACE_OPERATOR
BOOST_PYTHON_UNARY_OPERATOR(neg, -, operator-)
BOOST_PYTHON_UNARY_OPERATOR(pos, +, operator+)
BOOST_PYTHON_UNARY_OPERATOR(abs, abs, abs)
BOOST_PYTHON_UNARY_OPERATOR(invert, ~, operator~)
BOOST_PYTHON_UNARY_OPERATOR(int, long, int_)
BOOST_PYTHON_UNARY_OPERATOR(long, PyLong_FromLong, long_)
BOOST_PYTHON_UNARY_OPERATOR(float, double, float_)
BOOST_PYTHON_UNARY_OPERATOR(complex, std::complex<double>, complex_)
BOOST_PYTHON_UNARY_OPERATOR(str, lexical_cast<std::string>, str)
# undef BOOST_PYTHON_UNARY_OPERATOR
}} // namespace boost::python
# ifdef BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP
using boost::python::self_ns::abs;
using boost::python::self_ns::int_;
using boost::python::self_ns::long_;
using boost::python::self_ns::float_;
using boost::python::self_ns::complex_;
using boost::python::self_ns::str;
using boost::python::self_ns::pow;
# endif
#endif // OPERATORS2_DWA2002530_HPP

View File

@@ -129,7 +129,7 @@ get_signature(RT(ClassT::*)(BOOST_PYTHON_SIGNATURE_TYPES) const)
#endif // N < (BOOST_PYTHON_MAX_ARITY - 2)
# undef BOOST_PYTHON_SIGNATURE_PARAMS
# undef BOOST_PYTHON_SIGNATURE_TYPES
# undef BOOST_PYTHON_SIGNATURE_TYPES
# undef BOOST_PYTHON_TRAILING_SIGNATURE_TYPES
#endif // !defined(BOOST_PP_IS_ITERATING)

View File

@@ -79,6 +79,7 @@ private:
BOOST_PYTHON_MODULE(iterator_ext)
{
using boost::python::iterator; // gcc 2.96 bug workaround
def("range", &::range);
class_<list_int>("list_int")