PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/csharp/reference/example.i

#
Swig | 46 lines | 29 code | 12 blank | 5 comment | 0 complexity | f938896108e73666eec0117148301e11 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};
43
44
45
46