PageRenderTime 106ms CodeModel.GetById 71ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 1ms

/trunk/Examples/test-suite/octave/director_basic_runme.m

#
Objective C | 110 lines | 81 code | 29 blank | 0 comment | 13 complexity | b6b47f50cd7b79dce886ca9a71659d86 MD5 | raw file
  1director_basic
  2
  3
  4function self=OctFoo()
  5  global director_basic;
  6  self=subclass(director_basic.Foo());
  7  self.ping=@OctFoo_ping;
  8end
  9function string=OctFoo_ping(self)
 10  string="OctFoo::ping()";
 11end
 12
 13a = OctFoo();
 14
 15if (!strcmp(a.ping(),"OctFoo::ping()"))
 16  error(a.ping())
 17endif
 18
 19if (!strcmp(a.pong(),"Foo::pong();OctFoo::ping()"))
 20  error(a.pong())
 21endif
 22
 23b = director_basic.Foo();
 24
 25if (!strcmp(b.ping(),"Foo::ping()"))
 26  error(b.ping())
 27endif
 28
 29if (!strcmp(b.pong(),"Foo::pong();Foo::ping()"))
 30  error(b.pong())
 31endif
 32
 33a = director_basic.A1(1);
 34
 35if (a.rg(2) != 2)
 36  error
 37endif
 38
 39function self=OctClass()
 40  global director_basic;
 41  self=subclass(director_basic.MyClass());
 42  self.method=@OctClass_method;
 43  self.vmethod=@OctClass_vmethod;
 44end
 45function OctClass_method(self,vptr)
 46  self.cmethod = 7;
 47end
 48function out=OctClass_vmethod(self,b)
 49  b.x = b.x + 31;
 50  out=b;
 51end
 52
 53b = director_basic.Bar(3);
 54d = director_basic.MyClass();
 55c = OctClass();
 56
 57cc = director_basic.MyClass_get_self(c);
 58dd = director_basic.MyClass_get_self(d);
 59
 60bc = cc.cmethod(b);
 61bd = dd.cmethod(b);
 62
 63cc.method(b);
 64if (c.cmethod != 7)
 65  error
 66endif
 67
 68if (bc.x != 34)
 69  error
 70endif
 71
 72
 73if (bd.x != 16)
 74  error
 75endif
 76
 77
 78function self=OctMulti()
 79  global director_basic;
 80  self=subclass(director_basic.Foo(),director_basic.MyClass());
 81  self.vmethod=@OctMulti_vmethod;
 82  self.ping=@OctMulti_ping;
 83end
 84function out=OctMulti_vmethod(self,b)
 85  b.x = b.x + 31;
 86  out=b;
 87end
 88function out=OctMulti_ping(self)
 89  out="OctFoo::ping()";
 90end
 91
 92a = 0;
 93for i=0:100,
 94    octmult = OctMulti();
 95    octmult.pong();
 96    clear octmult 
 97endfor
 98
 99
100octmult = OctMulti();
101
102
103p1 = director_basic.Foo_get_self(octmult);
104p2 = director_basic.MyClass_get_self(octmult);
105
106p1.ping();
107p2.vmethod(bc);
108
109
110