PageRenderTime 24ms CodeModel.GetById 20ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/xml/example_title_add.i

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