/trunk/Examples/python/reference/example.i
Swig | 48 lines | 30 code | 13 blank | 5 comment | 0 complexity | d28b8a619647c686c77fae6746cdd086 MD5 | raw file
1/* File : example.i */ 2 3/* This file has a few "typical" uses of C++ references. */ 4 5%module example 6 7%{ 8#include "example.h" 9%} 10 11%rename(cprint) print; 12 13class Vector { 14public: 15 Vector(double x, double y, double z); 16 ~Vector(); 17 char *print(); 18}; 19 20/* This helper function calls an overloaded operator */ 21%inline %{ 22Vector addv(Vector &a, Vector &b) { 23 return a+b; 24} 25%} 26 27/* Wrapper around an array of vectors class */ 28 29class VectorArray { 30public: 31 VectorArray(int maxsize); 32 ~VectorArray(); 33 int size(); 34 35 /* This wrapper provides an alternative to the [] operator */ 36 %extend { 37 Vector &get(int index) { 38 return (*$self)[index]; 39 } 40 void set(int index, Vector &a) { 41 (*$self)[index] = a; 42 } 43 } 44}; 45 46 47 48