$self special variable for %extend
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9530 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0cccd3cabe
commit
1a439a9e19
8 changed files with 62 additions and 30 deletions
|
|
@ -3101,7 +3101,7 @@ struct Vector {
|
|||
%extend Vector {
|
||||
char *__str__() {
|
||||
static char tmp[1024];
|
||||
sprintf(tmp,"Vector(%g,%g,%g)", self->x,self->y,self->z);
|
||||
sprintf(tmp,"Vector(%g,%g,%g)", $self->x,$self->y,$self->z);
|
||||
return tmp;
|
||||
}
|
||||
Vector(double x, double y, double z) {
|
||||
|
|
@ -3138,9 +3138,9 @@ For example, if you wanted to overload a Python operator, you might do this:
|
|||
%extend Vector {
|
||||
Vector __add__(Vector *other) {
|
||||
Vector v;
|
||||
v.x = self->x + other->x;
|
||||
v.y = self->y + other->y;
|
||||
v.z = self->z + other->z;
|
||||
v.x = $self->x + other->x;
|
||||
v.y = $self->y + other->y;
|
||||
v.z = $self->z + other->z;
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue