Revert "Merge pull request #853 from ivannp/underscores"

This reverts commit a964098754, reversing
changes made to bda3a11f9e.

SWIG should only provide default operator names that provide special
standard or conventional meaning in the target language.
This commit is contained in:
William S Fulton 2016-12-22 19:47:54 +00:00
commit f9158e525f
4 changed files with 38 additions and 68 deletions

View file

@ -19,37 +19,10 @@ double Circle::perimeter() {
return 2*M_PI*radius; return 2*M_PI*radius;
} }
Circle::Circle(double xx, double yy, double rr)
: radius(rr)
{
x = xx;
y = yy;
}
bool Circle::operator==(const Circle & other)
{
return x == other.x && y == other.y && radius == other.radius;
}
bool Circle::operator!=(const Circle & other)
{
return !operator==(other);
}
double Square::area() { double Square::area() {
return width*width; return width*width;
} }
bool Square::operator==(const Square & other)
{
return x == other.x && y == other.y && width == other.width;
}
bool Square::operator!=(const Square & other)
{
return !operator==(other);
}
double Square::perimeter() { double Square::perimeter() {
return 4*width; return 4*width;
} }

View file

@ -20,12 +20,8 @@ private:
double radius; double radius;
public: public:
Circle(double r) : radius(r) { } Circle(double r) : radius(r) { }
Circle(double xx, double yy, double rr);
virtual double area(); virtual double area();
virtual double perimeter(); virtual double perimeter();
bool operator==(const Circle & other);
bool operator!=(const Circle & other);
}; };
class Square : public Shape { class Square : public Shape {
@ -35,7 +31,4 @@ public:
Square(double w) : width(w) { } Square(double w) : width(w) { }
virtual double area(); virtual double area();
virtual double perimeter(); virtual double perimeter();
bool operator==(const Square & other);
bool operator!=(const Square & other);
}; };

View file

@ -31,14 +31,6 @@ print("Here is their current position:")
sprintf(" Circle = (%f, %f)", circle$x,circle$y) sprintf(" Circle = (%f, %f)", circle$x,circle$y)
sprintf(" Square = (%f, %f)", square$x,square$y) sprintf(" Square = (%f, %f)", square$x,square$y)
c2 <- Circle(1, 5, 15)
c1 <- circle
c1$move(1, 5)
print(Circle_MemberEq(c1, c2))
print(Circle_MemberNotEq(c1, c2))
print(c1$MemberEq(c2))
# ----- Call some methods ----- # ----- Call some methods -----
print ("Here are some properties of the shapes:") print ("Here are some properties of the shapes:")

View file

@ -1,31 +1,42 @@
#ifdef __cplusplus #ifdef __cplusplus
%rename(MemberPlusPlus) *::operator++; // These are auto-supported by the Perl-module
%rename(MemberMinMin) *::operator--; %rename(__plusplus__) *::operator++;
%rename(MemberAdd) *::operator+; %rename(__minmin__) *::operator--;
%rename(MemberSub) *::operator-; %rename(__add__) *::operator+;
%rename(MemberNeg) *::operator-(); %rename(__sub__) *::operator-;
%rename(MemberNegConst) *::operator-() const; %rename(__neg__) *::operator-();
%rename(MemberMul) *::operator*; %rename(__neg__) *::operator-() const;
%rename(MemberDiv) *::operator/; %rename(__mul__) *::operator*;
%rename(MemberEq) *::operator==; %rename(__div__) *::operator/;
%rename(MemberNotEq) *::operator!=; %rename(__eq__) *::operator==;
%rename(MemberMod) *::operator%; %rename(__ne__) *::operator!=;
%rename(MemberGreater) *::operator>; %rename(__mod__) *::operator%;
%rename(MemberLess) *::operator<; %rename(__gt__) *::operator>;
%rename(MemberNot) *::operator!; %rename(__lt__) *::operator<;
%rename(MemberLShift) *::operator<<; %rename(__not__) *::operator!;
%rename(MemberRShift) *::operator>>;
%rename(MemberAnd) *::operator&; // These are renamed, but no 'use overload...' is added
%rename(MemberOr) *::operator|; %rename(__lshift__) *::operator<<;
%rename(MemberXor) *::operator^; %rename(__rshift__) *::operator>>;
%rename(MemberInvert) *::operator~; %rename(__and__) *::operator&;
%rename(MemberLessOrEq) *::operator<=; %rename(__or__) *::operator|;
%rename(MemberGreaterOrEq) *::operator>=; %rename(__xor__) *::operator^;
%rename(MemberCall) *::operator(); %rename(__invert__) *::operator~;
%rename(MemberGetItem) *::operator[]; %rename(__le__) *::operator<=;
%rename(MemberAssign) *::operator=; %rename(__ge__) *::operator>=;
%rename(MemberArrowStar) *::operator->*; %rename(__call__) *::operator();
%rename(__getitem__) *::operator[];
%rename(__seteq__) *::operator=;
%rename(__land__) operator&&;
%rename(__lor__) operator||;
%rename(__plusplus__) *::operator++;
%rename(__minusminus__) *::operator--;
%rename(__arrowstar__) *::operator->*;
%rename(__index__) *::operator[];
%rename(Equal) operator =; %rename(Equal) operator =;
%rename(PlusEqual) operator +=; %rename(PlusEqual) operator +=;
@ -55,4 +66,5 @@
%rename(MinusMinusPrefix) operator--(); %rename(MinusMinusPrefix) operator--();
%rename(MinusMinusPostfix) operator--(int); %rename(MinusMinusPostfix) operator--(int);
#endif #endif