PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
MATLAB | 110 lines | 81 code | 29 blank | 0 comment | 9 complexity | b6b47f50cd7b79dce886ca9a71659d86 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. director_basic
  2. function self=OctFoo()
  3. global director_basic;
  4. self=subclass(director_basic.Foo());
  5. self.ping=@OctFoo_ping;
  6. end
  7. function string=OctFoo_ping(self)
  8. string="OctFoo::ping()";
  9. end
  10. a = OctFoo();
  11. if (!strcmp(a.ping(),"OctFoo::ping()"))
  12. error(a.ping())
  13. endif
  14. if (!strcmp(a.pong(),"Foo::pong();OctFoo::ping()"))
  15. error(a.pong())
  16. endif
  17. b = director_basic.Foo();
  18. if (!strcmp(b.ping(),"Foo::ping()"))
  19. error(b.ping())
  20. endif
  21. if (!strcmp(b.pong(),"Foo::pong();Foo::ping()"))
  22. error(b.pong())
  23. endif
  24. a = director_basic.A1(1);
  25. if (a.rg(2) != 2)
  26. error
  27. endif
  28. function self=OctClass()
  29. global director_basic;
  30. self=subclass(director_basic.MyClass());
  31. self.method=@OctClass_method;
  32. self.vmethod=@OctClass_vmethod;
  33. end
  34. function OctClass_method(self,vptr)
  35. self.cmethod = 7;
  36. end
  37. function out=OctClass_vmethod(self,b)
  38. b.x = b.x + 31;
  39. out=b;
  40. end
  41. b = director_basic.Bar(3);
  42. d = director_basic.MyClass();
  43. c = OctClass();
  44. cc = director_basic.MyClass_get_self(c);
  45. dd = director_basic.MyClass_get_self(d);
  46. bc = cc.cmethod(b);
  47. bd = dd.cmethod(b);
  48. cc.method(b);
  49. if (c.cmethod != 7)
  50. error
  51. endif
  52. if (bc.x != 34)
  53. error
  54. endif
  55. if (bd.x != 16)
  56. error
  57. endif
  58. function self=OctMulti()
  59. global director_basic;
  60. self=subclass(director_basic.Foo(),director_basic.MyClass());
  61. self.vmethod=@OctMulti_vmethod;
  62. self.ping=@OctMulti_ping;
  63. end
  64. function out=OctMulti_vmethod(self,b)
  65. b.x = b.x + 31;
  66. out=b;
  67. end
  68. function out=OctMulti_ping(self)
  69. out="OctFoo::ping()";
  70. end
  71. a = 0;
  72. for i=0:100,
  73. octmult = OctMulti();
  74. octmult.pong();
  75. clear octmult
  76. endfor
  77. octmult = OctMulti();
  78. p1 = director_basic.Foo_get_self(octmult);
  79. p2 = director_basic.MyClass_get_self(octmult);
  80. p1.ping();
  81. p2.vmethod(bc);