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"; } # TODO: Currently we do not track the dynamic type of returned # objects, so in case it's possible that the dynamic type is not equal # to the static type, we skip this check. if (get_parent_class($person) === false) { check::equal($ret, $expected, "#3 failed"); } $caller->resetCallback(); if ($debug) { print "----------------------------------------\n"; } }