new director test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9213 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b9bf752f46
commit
55d4c5e59b
5 changed files with 359 additions and 0 deletions
81
SWIG/Examples/test-suite/python/director_classic_runme.py
Normal file
81
SWIG/Examples/test-suite/python/director_classic_runme.py
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
from director_classic import *
|
||||
|
||||
class TargetLangPerson(Person):
|
||||
def __init__(self):
|
||||
Person.__init__(self)
|
||||
def id(self):
|
||||
identifier = "TargetLangPerson"
|
||||
return identifier
|
||||
|
||||
class TargetLangChild(Child):
|
||||
def __init__(self):
|
||||
Child.__init__(self)
|
||||
def id(self):
|
||||
identifier = "TargetLangChild"
|
||||
return identifier
|
||||
|
||||
class TargetLangGrandChild(GrandChild):
|
||||
def __init__(self):
|
||||
GrandChild.__init__(self)
|
||||
def id(self):
|
||||
identifier = "TargetLangGrandChild"
|
||||
return identifier
|
||||
|
||||
def check(person, expected):
|
||||
|
||||
debug = 0
|
||||
# Normal target language polymorphic call
|
||||
ret = person.id()
|
||||
if (debug):
|
||||
print(ret)
|
||||
if (ret != expected):
|
||||
raise ("Failed. Received: " + ret + " Expected: " + expected)
|
||||
|
||||
# Polymorphic call from C++
|
||||
caller = Caller()
|
||||
caller.setCallback(person)
|
||||
ret = caller.call()
|
||||
if (debug):
|
||||
print(ret)
|
||||
if (ret != expected):
|
||||
raise ("Failed. Received: " + ret + " Expected: " + expected)
|
||||
|
||||
# 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)
|
||||
if (ret != expected):
|
||||
raise ("Failed. Received: " + ret + " Expected: " + expected)
|
||||
|
||||
caller.resetCallback()
|
||||
if (debug):
|
||||
print("----------------------------------------")
|
||||
|
||||
|
||||
|
||||
person = Person();
|
||||
check(person, "Person");
|
||||
del person
|
||||
|
||||
person = Child();
|
||||
check(person, "Child");
|
||||
del person
|
||||
|
||||
person = GrandChild();
|
||||
check(person, "GrandChild");
|
||||
del person
|
||||
|
||||
person = TargetLangPerson();
|
||||
check(person, "TargetLangPerson");
|
||||
del person
|
||||
|
||||
person = TargetLangChild();
|
||||
check(person, "TargetLangChild");
|
||||
del person
|
||||
|
||||
person = TargetLangGrandChild();
|
||||
check(person, "TargetLangGrandChild");
|
||||
del person
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue