Added example of friend operator use to Examples/octave/operator, fixed minor bug that causes a panic in octave 3.0.5. Tested examples work for octave 3.0.5, 3.2.4, and 3.4.0. (thanks to Karl Wette)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12794 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3372c2ba62
commit
2f68aa0a34
4 changed files with 9 additions and 7 deletions
|
|
@ -30,7 +30,6 @@ public:
|
||||||
double im() const { return ipart; }
|
double im() const { return ipart; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ComplexVal operator*(const double &s, const ComplexVal &c) {
|
||||||
|
return ComplexVal(s*c.re(), s*c.im());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
#include "example.h"
|
#include "example.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
/* Rename friend operator */
|
||||||
|
%rename(op_scalar_mul_ComplexVal) operator*(const double&, const ComplexVal&);
|
||||||
|
|
||||||
/* Now grab the original header file */
|
/* Now grab the original header file */
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
@ -20,5 +23,3 @@
|
||||||
return ComplexVal($self->re()*j,$self->im()*j);
|
return ComplexVal($self->re()*j,$self->im()*j);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,3 +22,5 @@ printf("f = %s\n",disp(f));
|
||||||
# paren overloading
|
# paren overloading
|
||||||
printf("a(3)= %s\n",disp(a(3)));
|
printf("a(3)= %s\n",disp(a(3)));
|
||||||
|
|
||||||
|
# friend operator
|
||||||
|
printf("2*a = %s\n",disp(2*a));
|
||||||
|
|
|
||||||
|
|
@ -789,7 +789,7 @@ namespace Swig {
|
||||||
octave_value fcn = get_global_value(symbol, true);
|
octave_value fcn = get_global_value(symbol, true);
|
||||||
if (!fcn.is_function() && !fcn.is_function_handle())
|
if (!fcn.is_function() && !fcn.is_function_handle())
|
||||||
return false;
|
return false;
|
||||||
ret = fcn.subsref("(", std::list < octave_value_list > (1, args));
|
ret = fcn.subsref("(", std::list < octave_value_list > (1, args), 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue