/trunk/Examples/go/reference/example.i
Swig | 42 lines | 29 code | 8 blank | 5 comment | 0 complexity | 522140ddae96154424fc2fe299af7afa 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 11class Vector { 12public: 13 Vector(double x, double y, double z); 14 ~Vector(); 15 char *print(); 16}; 17 18/* This helper function calls an overloaded operator */ 19%inline %{ 20Vector addv(Vector &a, Vector &b) { 21 return a+b; 22} 23%} 24 25/* Wrapper around an array of vectors class */ 26 27class VectorArray { 28public: 29 VectorArray(int maxsize); 30 ~VectorArray(); 31 int size(); 32 33 /* This wrapper provides an alternative to the [] operator */ 34 %extend { 35 Vector &get(int index) { 36 return (*$self)[index]; 37 } 38 void set(int index, Vector &a) { 39 (*$self)[index] = a; 40 } 41 } 42};