File: director_classic_runme.php

package info (click to toggle)
swig 4.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 45,980 kB
  • sloc: cpp: 54,284; ansic: 29,022; java: 17,595; python: 12,734; cs: 10,421; ruby: 7,263; yacc: 6,501; makefile: 5,860; javascript: 5,538; sh: 5,422; perl: 4,246; php: 3,733; ml: 2,198; tcl: 2,015; lisp: 1,448; xml: 115
file content (144 lines) | stat: -rw-r--r-- 3,148 bytes parent folder | download | duplicates (3)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php

require "tests.php";

// No new functions
check::functions(array());
// New classes
check::classes(array('Being','Person','Child','GrandChild','OrphanPerson','OrphanChild','Caller'));
// No new vars
check::globals(array());

class TargetLangPerson extends Person {
  function id() {
    $identifier = "TargetLangPerson";
    return $identifier;
  }
}

class TargetLangChild extends Child {
  function id() {
    $identifier = "TargetLangChild";
    return $identifier;
  }
}

class TargetLangGrandChild extends GrandChild {
  function id() {
    $identifier = "TargetLangGrandChild";
    return $identifier;
  }
}

# Semis - don't override id() in target language
class TargetLangSemiPerson extends Person {
  # No id() override
}

class TargetLangSemiChild extends Child {
  # No id() override
}

class TargetLangSemiGrandChild extends GrandChild {
  # No id() override
}

# Orphans - don't override id() in C++
class TargetLangOrphanPerson extends OrphanPerson {
  function id() {
    $identifier = "TargetLangOrphanPerson";
    return $identifier;
  }
}

class TargetLangOrphanChild extends OrphanChild {
  function id() {
    $identifier = "TargetLangOrphanChild";
    return $identifier;
  }
}

function mycheck($person, $expected) {
  $debug = 0;
  # Normal target language polymorphic call
  $ret = $person->id();
  if ($debug)
    print $ret . "\n";
  check::equal($ret, $expected, "#1 failed");

  # Polymorphic call from C++
  $caller = new Caller();
  $caller->setCallback($person);
  $ret = $caller->call();
  if ($debug)
    print $ret . "\n";
  check::equal($ret, $expected, "#2 failed");

  # Polymorphic call of object created in target language and passed to 
  # C++ and back again
  $baseclass = $caller->baseClass();
  $ret = $baseclass->id();
  if ($debug)
    print $ret . "\n";
  check::equal($ret, $expected, "#3 failed");

  $caller->resetCallback();
  if ($debug)
    print "----------------------------------------\n";
}

$person = new Person();
mycheck($person, "Person");
unset($person);

$person = new Child();
mycheck($person, "Child");
unset($person);

$person = new GrandChild();
mycheck($person, "GrandChild");
unset($person);

$person = new TargetLangPerson();
mycheck($person, "TargetLangPerson");
unset($person);

$person = new TargetLangChild();
mycheck($person, "TargetLangChild");
unset($person);

$person = new TargetLangGrandChild();
mycheck($person, "TargetLangGrandChild");
unset($person);

# Semis - don't override id() in target language
$person = new TargetLangSemiPerson();
mycheck($person, "Person");
unset($person);

$person = new TargetLangSemiChild();
mycheck($person, "Child");
unset($person);

$person = new TargetLangSemiGrandChild();
mycheck($person, "GrandChild");
unset($person);

# Orphans - don't override id() in C++
$person = new OrphanPerson();
mycheck($person, "Person");
unset($person);

$person = new OrphanChild();
mycheck($person, "Child");
unset($person);

$person = new TargetLangOrphanPerson();
mycheck($person, "TargetLangOrphanPerson");
unset($person);

$person = new TargetLangOrphanChild();
mycheck($person, "TargetLangOrphanChild");
unset($person);

check::done();