2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 18:12:43 +00:00

Tests and fixes for a bad interaction between wrapper<> and operators

support.  "self" arguments weren't getting unwrapped properly.


[SVN r35365]
This commit is contained in:
Dave Abrahams
2006-09-28 14:41:01 +00:00
parent 5e5d34cc36
commit 94500ae36d
6 changed files with 77 additions and 30 deletions

View File

@@ -0,0 +1,42 @@
#include "boost/python.hpp"
#include <memory>
struct vector
{
virtual ~vector() {}
vector operator+( const vector& x ) const
{ return vector(); }
vector& operator+=( const vector& x )
{ return *this; }
vector operator-() const
{ return *this; }
};
struct dvector : vector
{};
using namespace boost::python;
struct vector_wrapper
: vector, wrapper< vector >
{
vector_wrapper(vector const&) {}
vector_wrapper() {}
};
BOOST_PYTHON_MODULE( operators_wrapper_ext )
{
class_< vector_wrapper >( "vector" )
.def( self + self )
.def( self += self )
.def( -self )
;
scope().attr("v") = vector();
std::auto_ptr<vector> dp(new dvector);
register_ptr_to_python< std::auto_ptr<vector> >();
scope().attr("d") = dp;
}