PageRenderTime 2097ms CodeModel.GetById 2ms app.highlight 16ms RepoModel.GetById 2ms app.codeStats 2072ms

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

#
Objective C | 98 lines | 74 code | 24 blank | 0 comment | 6 complexity | 168e96aff7298695046a230adc01e911 MD5 | raw file
 1director_classic
 2
 3TargetLangPerson=@() subclass(Person(),'id',@(self) "TargetLangPerson");
 4TargetLangChild=@() subclass(Child(),'id',@(self) "TargetLangChild");
 5TargetLangGrandChild=@() subclass(GrandChild(),'id',@(self) "TargetLangGrandChild");
 6
 7# Semis - don't override id() in target language
 8TargetLangSemiPerson=@() subclass(Person());
 9TargetLangSemiChild=@() subclass(Child());
10TargetLangSemiGrandChild=@() subclass(GrandChild());
11
12# Orphans - don't override id() in C++
13TargetLangOrphanPerson=@() subclass(OrphanPerson(),'id',@(self) "TargetLangOrphanPerson");
14TargetLangOrphanChild=@() subclass(OrphanChild(),'id',@(self) "TargetLangOrphanChild");
15
16
17function check(person,expected)
18  global Caller;
19
20  # Normal target language polymorphic call
21  ret = person.id();
22  if (ret != expected)
23    raise ("Failed. Received: " + ret + " Expected: " + expected);
24  endif
25
26  # Polymorphic call from C++
27  caller = Caller();
28  caller.setCallback(person);
29  ret = caller.call();
30  if (ret != expected)
31    error ("Failed. Received: " + ret + " Expected: " + expected);
32  endif
33
34  # Polymorphic call of object created in target language and passed to C++ and back again
35  baseclass = caller.baseClass();
36  ret = baseclass.id();
37  if (ret != expected)
38    error ("Failed. Received: " + ret + " Expected: " + expected);
39  endif
40
41  caller.resetCallback();
42end
43
44
45person = Person();
46check(person, "Person");
47clear person;
48
49person = Child();
50check(person, "Child");
51clear person;
52
53person = GrandChild();
54check(person, "GrandChild"); 
55clear person;
56
57person = TargetLangPerson();
58check(person, "TargetLangPerson"); 
59clear person;
60
61person = TargetLangChild();
62check(person, "TargetLangChild"); 
63clear person;
64
65person = TargetLangGrandChild();
66check(person, "TargetLangGrandChild"); 
67clear person;
68
69# Semis - don't override id() in target language
70person = TargetLangSemiPerson();
71check(person, "Person"); 
72clear person;
73
74person = TargetLangSemiChild();
75check(person, "Child"); 
76clear person;
77
78person = TargetLangSemiGrandChild();
79check(person, "GrandChild"); 
80clear person;
81
82# Orphans - don't override id() in C++
83person = OrphanPerson();
84check(person, "Person");
85clear person;
86
87person = OrphanChild();
88check(person, "Child");
89clear person;
90
91person = TargetLangOrphanPerson();
92check(person, "TargetLangOrphanPerson"); 
93clear person;
94
95person = TargetLangOrphanChild();
96check(person, "TargetLangOrphanChild"); 
97clear person;
98