/tags/rel-1-3-26/SWIG/Examples/java/reference/example.i
Swig | 46 lines | 29 code | 12 blank | 5 comment | 0 complexity | 8bea50b57406769cc6cd72dc98dbb913 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
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}; 43 44 45 46