Overload resolution now works in PHP out of the box.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9305 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-20 06:59:07 +00:00
commit 3dc5e0e91a
6 changed files with 28 additions and 20 deletions

View file

@ -42,6 +42,10 @@ char *overloaded(double d) {
return "Overloaded with double";
}
char *overloaded(const char * str) {
return "Overloaded with char *";
}
char *overloaded( const Circle& ) {
return "Overloaded with Circle";
}

View file

@ -9,8 +9,8 @@ public:
}
virtual ~Shape() {
nshapes--;
};
double x, y;
}
double x, y;
void move(double dx, double dy);
virtual double area(void) = 0;
virtual double perimeter(void) = 0;
@ -22,8 +22,8 @@ class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { };
~Circle() { };
Circle(double r) : radius(r) { }
~Circle() { }
virtual double area(void);
virtual double perimeter(void);
};
@ -32,7 +32,7 @@ class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { };
Square(double w) : width(w) { }
~Square() { }
virtual double area(void);
virtual double perimeter(void);
@ -40,6 +40,7 @@ public:
char *overloaded( int i );
char *overloaded( double d );
char *overloaded( const char * str );
char *overloaded( const Circle& );
char *overloaded( const Shape& );

View file

@ -36,9 +36,9 @@ print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
print "\nHere are some properties of the shapes:\n";
foreach (array(1,2.1,"3.6",$c,$s) as $o) {
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
print " ".get_class($o)." $o\n";
print " overloaded= " . overloaded($o) . "\n";
print " overloaded = " . overloaded($o) . "\n";
}
# Need to unset($o) or else we hang on to a reference to the Square object.