PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/octave/operator/example.i

#
Swig | 25 lines | 17 code | 4 blank | 4 comment | 0 complexity | 395bdf3bbbd2bf729eb4e4bf784cdabf MD5 | raw file
 1/* File : example.i */
 2%module example
 3#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
 4%{
 5#include "example.h"
 6%}
 7
 8/* Rename friend operator */
 9%rename(op_scalar_mul_ComplexVal) operator*(const double&, const ComplexVal&);
10
11/* Now grab the original header file */
12%include "example.h"
13
14/* An output method that turns a complex into a short string */
15%extend ComplexVal {
16   char *__str__() {
17       static char temp[512];
18       sprintf(temp,"(%g,%g)", $self->re(), $self->im());
19       return temp;
20   }
21
22   ComplexVal __paren__(int j) {
23     return ComplexVal($self->re()*j,$self->im()*j);
24   }
25};