summaryrefslogtreecommitdiff
path: root/Examples/test-suite/octave/director_basic_runme.m
blob: 9de54a385ba89bd090f6302378f6388deb58d9d3 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
director_basic


function self=OctFoo()
  global director_basic;
  self=subclass(director_basic.Foo());
  self.ping=@OctFoo_ping;
end
function string=OctFoo_ping(self)
  string="OctFoo::ping()";
end

a = OctFoo();

if (!strcmp(a.ping(),"OctFoo::ping()"))
  error(a.ping())
endif

if (!strcmp(a.pong(),"Foo::pong();OctFoo::ping()"))
  error(a.pong())
endif

b = director_basic.Foo();

if (!strcmp(b.ping(),"Foo::ping()"))
  error(b.ping())
endif

if (!strcmp(b.pong(),"Foo::pong();Foo::ping()"))
  error(b.pong())
endif

a = director_basic.A1(1);

if (a.rg(2) != 2)
  error
endif

function self=OctClass()
  global director_basic;
  self=subclass(director_basic.MyClass());
  self.method=@OctClass_method;
  self.vmethod=@OctClass_vmethod;
end
function OctClass_method(self,vptr)
  self.cmethod = 7;
end
function out=OctClass_vmethod(self,b)
  b.x = b.x + 31;
  out=b;
end

b = director_basic.Bar(3);
d = director_basic.MyClass();
c = OctClass();

cc = director_basic.MyClass_get_self(c);
dd = director_basic.MyClass_get_self(d);

bc = cc.cmethod(b);
bd = dd.cmethod(b);

cc.method(b);
if (c.cmethod != 7)
  error
endif

if (bc.x != 34)
  error
endif


if (bd.x != 16)
  error
endif


function self=OctMulti()
  global director_basic;
  self=subclass(director_basic.Foo(),director_basic.MyClass());
  self.vmethod=@OctMulti_vmethod;
  self.ping=@OctMulti_ping;
end
function out=OctMulti_vmethod(self,b)
  b.x = b.x + 31;
  out=b;
end
function out=OctMulti_ping(self)
  out="OctFoo::ping()";
end

a = 0;
for i=0:100,
    octmult = OctMulti();
    octmult.pong();
    clear octmult 
endfor


octmult = OctMulti();


p1 = director_basic.Foo_get_self(octmult);
p2 = director_basic.MyClass_get_self(octmult);

p1.ping();
p2.vmethod(bc);