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

/trunk/Examples/python/operator/example.i

#
Swig | 28 lines | 14 code | 7 blank | 7 comment | 0 complexity | 18eb5f303b9d2ec817c4fcfa82d16c00 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/* This header file is a little tough to handle because it has overloaded
 9   operators and constructors.  We're going to try and deal with that here */
10
11/* This turns the copy constructor in a function ComplexCopy() that can
12   be called */
13
14%rename(ComplexCopy) Complex::Complex(Complex const &);
15
16/* Now grab the original header file */
17%include "example.h"
18
19/* An output method that turns a complex into a short string */
20%extend Complex {
21   char *__str__() {
22       static char temp[512];
23       sprintf(temp,"(%g,%g)", $self->re(), $self->im());
24       return temp;
25   }
26};
27
28