use $self special variable instead of self in %extend

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9533 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2006-11-08 01:01:37 +00:00
commit 65c52f7c06
20 changed files with 52 additions and 52 deletions

View file

@ -5,7 +5,7 @@
{
virtual int dummy() // Had to remove virtual to work
{
return self->getFooBar();
return $self->getFooBar();
}
};

View file

@ -6,7 +6,7 @@
%extend Foo {
Foo(int a) { return new Foo(); }
~Foo() { delete self;}
~Foo() { delete $self;}
int spam(int x) { return x; }
int spam(int x, int y) { return x + y ; }
int spam(int x, int y,int z) { return x + y ; }
@ -41,7 +41,7 @@ public:
%extend Bar {
Bar(int a) { return new Bar(); }
~Bar() { delete self;}
~Bar() { delete $self;}
int spam() { return 1}
int spam(int x) { return x; }
int spam(int x, int y) { return x + y ; }
@ -56,7 +56,7 @@ public:
%extend FooT {
FooT(int a) { return new FooT<T>(); }
~FooT() { delete self;}
~FooT() { delete $self;}
int spam(int x) { return x; }
int spam(int x, int y) { return x + y ; }
int spam(int x, int y,int z) { return x + y ; }
@ -96,7 +96,7 @@ public:
%extend BarT {
BarT(int a) { return new BarT<T>(); }
~BarT() { delete self;}
~BarT() { delete $self;}
int spam() { return 1}
int spam(int x) { return x; }
int spam(int x, int y) { return x + y ; }

View file

@ -41,7 +41,7 @@ void do_stuff(Foo *f) {
%extend Foo {
~Foo() {
free((void *) self);
free((void *) $self);
g_fooCount--;
}
}

View file

@ -167,36 +167,36 @@ inline bool operator>=(const Op& a,const Op& b){return a.i>=b.i;}
// we need to extend the class
// to make the friends & non members part of the class
%extend Op{
Op operator &&(const Op& b){return Op(self->i&&b.i);}
Op operator or(const Op& b){return Op(self->i||b.i);}
Op operator &&(const Op& b){return Op($self->i&&b.i);}
Op operator or(const Op& b){return Op($self->i||b.i);}
Op operator+(const Op& b){return Op(self->i+b.i);}
Op operator-(const Op& b){return Op(self->i-b.i);}
Op operator*(const Op& b){return Op(self->i*b.i);}
Op operator/(const Op& b){return Op(self->i/b.i);}
Op operator%(const Op& b){return Op(self->i%b.i);}
Op operator+(const Op& b){return Op($self->i+b.i);}
Op operator-(const Op& b){return Op($self->i-b.i);}
Op operator*(const Op& b){return Op($self->i*b.i);}
Op operator/(const Op& b){return Op($self->i/b.i);}
Op operator%(const Op& b){return Op($self->i%b.i);}
bool operator==(const Op& b){return self->i==b.i;}
bool operator!=(const Op& b){return self->i!=b.i;}
bool operator< (const Op& b){return self->i<b.i;}
bool operator<=(const Op& b){return self->i<=b.i;}
bool operator> (const Op& b){return self->i>b.i;}
bool operator>=(const Op& b){return self->i>=b.i;}
bool operator==(const Op& b){return $self->i==b.i;}
bool operator!=(const Op& b){return $self->i!=b.i;}
bool operator< (const Op& b){return $self->i<b.i;}
bool operator<=(const Op& b){return $self->i<=b.i;}
bool operator> (const Op& b){return $self->i>b.i;}
bool operator>=(const Op& b){return $self->i>=b.i;}
// we also add the __str__() fn to the class
// this allows it to be converted to a string (so it can be printed)
const char* __str__()
{
static char buffer[255];
sprintf(buffer,"Op(%d)",self->i);
sprintf(buffer,"Op(%d)",$self->i);
return buffer;
}
// to get the [] operator working correctly we need to extend with two function
// __getitem__ & __setitem__
int __getitem__(unsigned i)
{ return (*self)[i]; }
{ return (*$self)[i]; }
void __setitem__(unsigned i,int v)
{ (*self)[i]=v; }
{ (*$self)[i]=v; }
}
/*

View file

@ -40,14 +40,14 @@ struct Foo {
return new Bar();
}
~Bar() {
if (self) delete self;
delete $self;
}
#else
Bar() {
return (Bar *) malloc(sizeof(Bar));
}
~Bar() {
if (self) free(self);
free($self);
}
#endif
}