PageRenderTime 19ms CodeModel.GetById 9ms app.highlight 9ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/Root-branch-php-utl/SWIG/Examples/python/reference/example.i

#
Swig | 48 lines | 30 code | 13 blank | 5 comment | 0 complexity | edff5e7d19cfc9349a9da02312c4fd16 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
11%rename(cprint) print;
12
13class Vector {
14public:
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 %{
22Vector addv(Vector &a, Vector &b) {
23  return a+b;
24}
25%}
26
27/* Wrapper around an array of vectors class */
28
29class VectorArray {
30public:
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