PageRenderTime 13ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/extend.i

#
Swig | 53 lines | 49 code | 4 blank | 0 comment | 0 complexity | 33abc5dff56d4738ac09bc5f23f35097 MD5 | raw file
 1%module extend
 2
 3%extend Base {
 4  ~Base() {
 5    delete $self; 
 6  }
 7  static int zeroVal() {
 8    return 0;
 9  }
10  virtual int currentValue() {
11    return $self->value;
12  }
13  int extendmethod(int v) {
14    int ret = $self->method(v);
15    return ret * 2;
16  }
17};
18
19%inline %{
20struct Base {
21  Base(int v = 0) : value(v) {}
22  int value;
23  virtual int method(int v) {
24    return v;
25  }
26};
27struct Derived : Base {
28  double actualval;
29};
30%}
31
32%{
33  double extendval = 0;
34  double Derived_extendval_get(Derived *self) {
35    return self->actualval * 100;
36  }
37  void Derived_extendval_set(Derived *self, double d) {
38    self->actualval = d/100;
39  }
40%}
41
42%extend Derived {
43  Derived(int v) {
44    Derived *$self = new Derived();
45    $self->value = v*2;
46    return $self;
47  }
48  virtual int method(int v) {
49    int ret = $self->Base::method(v);
50    return ret * 2;
51  }
52  double extendval;
53}