4 require "director_classic.php";
7 check::functions(array(being_id,person_id,child_id,grandchild_id,caller_delcallback,caller_setcallback,caller_resetcallback,caller_call,caller_baseclass));
9 check::classes(array(Being,Person,Child,GrandChild,OrphanPerson,OrphanChild,Caller));
11 check::globals(array());
13 class TargetLangPerson extends Person {
15 $identifier = "TargetLangPerson";
20 class TargetLangChild extends Child {
22 $identifier = "TargetLangChild";
27 class TargetLangGrandChild extends GrandChild {
29 $identifier = "TargetLangGrandChild";
34 # Semis - don't override id() in target language
35 class TargetLangSemiPerson extends Person {
39 class TargetLangSemiChild extends Child {
43 class TargetLangSemiGrandChild extends GrandChild {
47 # Orphans - don't override id() in C++
48 class TargetLangOrphanPerson extends OrphanPerson {
50 $identifier = "TargetLangOrphanPerson";
55 class TargetLangOrphanChild extends OrphanChild {
57 $identifier = "TargetLangOrphanChild";
62 function mycheck($person, $expected) {
64 # Normal target language polymorphic call
68 check::equal($ret, $expected, "#1 failed");
70 # Polymorphic call from C++
71 $caller = new Caller();
72 $caller->setCallback($person);
73 $ret = $caller->call();
76 check::equal($ret, $expected, "#2 failed");
78 # Polymorphic call of object created in target language and passed to
80 $baseclass = $caller->baseClass();
81 $ret = $baseclass->id();
84 # TODO: Currently we do not track the dynamic type of returned
85 # objects, so in case it's possible that the dynamic type is not equal
86 # to the static type, we skip this check.
87 if (get_parent_class($person) === false)
88 check::equal($ret, $expected, "#3 failed");
90 $caller->resetCallback();
92 print "----------------------------------------\n";
95 $person = new Person();
96 mycheck($person, "Person");
99 $person = new Child();
100 mycheck($person, "Child");
103 $person = new GrandChild();
104 mycheck($person, "GrandChild");
107 $person = new TargetLangPerson();
108 mycheck($person, "TargetLangPerson");
111 $person = new TargetLangChild();
112 mycheck($person, "TargetLangChild");
115 $person = new TargetLangGrandChild();
116 mycheck($person, "TargetLangGrandChild");
119 # Semis - don't override id() in target language
120 $person = new TargetLangSemiPerson();
121 mycheck($person, "Person");
124 $person = new TargetLangSemiChild();
125 mycheck($person, "Child");
128 $person = new TargetLangSemiGrandChild();
129 mycheck($person, "GrandChild");
132 # Orphans - don't override id() in C++
133 $person = new OrphanPerson();
134 mycheck($person, "Person");
137 $person = new OrphanChild();
138 mycheck($person, "Child");
141 $person = new TargetLangOrphanPerson();
142 mycheck($person, "TargetLangOrphanPerson");
145 $person = new TargetLangOrphanChild();
146 mycheck($person, "TargetLangOrphanChild");