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