import source from 1.3.40
[external/swig.git] / Examples / octave / reference / example.i
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
13 class Vector {
14 public:
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 %{
22 Vector addv(Vector &a, Vector &b) {
23   return a+b;
24 }
25 %}
26
27 /* Wrapper around an array of vectors class */
28
29 class VectorArray {
30 public:
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