Merge branch 'ejulien-python_operator_overload_test_suite'
* ejulien-python_operator_overload_test_suite: Add __str__ to operator_overload testcase for python builtin Python operator_overload runtime testcase cleanup Work around a limitation of the Python binding generator related to the += family of operators. Fix Python 3 division member operator when -builtin is not used. Fix class member division operator. Remove the PY3BUILTIN switch as its behavior can be achieved with the existing SWIG_FEATURES=-builtin switch. Implement the operator overload test suite for Python. Conflicts: Examples/test-suite/operator_overload.i
This commit is contained in:
commit
5e6ab1d61d
4 changed files with 98 additions and 10 deletions
|
|
@ -73,6 +73,10 @@ see bottom for a set of possible tests
|
|||
%rename(OrOperator) operator ||;
|
||||
#endif
|
||||
|
||||
#if defined(SWIGPYTHON)
|
||||
%feature("python:slot", "tp_str", functype="reprfunc") Op::__str__;
|
||||
#endif
|
||||
|
||||
#ifdef SWIGD
|
||||
// Due to the way operator overloading is implemented in D1 and D2, the prefix
|
||||
// increment/decrement operators (D1) resp. the postfix ones (D2) are ignored.
|
||||
|
|
@ -109,11 +113,11 @@ public:
|
|||
return *this;
|
||||
}
|
||||
// +=,-=... are member fns
|
||||
void operator+=(const Op& o){ i+=o.i;}
|
||||
void operator-=(const Op& o){ i-=o.i;}
|
||||
void operator*=(const Op& o){ i*=o.i;}
|
||||
void operator/=(const Op& o){ i/=o.i;}
|
||||
void operator%=(const Op& o){ i%=o.i;}
|
||||
Op &operator+=(const Op& o){ i+=o.i; return *this; }
|
||||
Op &operator-=(const Op& o){ i-=o.i; return *this; }
|
||||
Op &operator*=(const Op& o){ i*=o.i; return *this; }
|
||||
Op &operator/=(const Op& o){ i/=o.i; return *this; }
|
||||
Op &operator%=(const Op& o){ i%=o.i; return *this; }
|
||||
// the +,-,*,... are friends
|
||||
// (just to make life harder)
|
||||
friend Op operator+(const Op& a,const Op& b){return Op(a.i+b.i);}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue