import source from 1.3.40
[external/swig.git] / Examples / test-suite / python / director_basic_runme.py
1 import director_basic
2
3 class PyFoo(director_basic.Foo):
4         def ping(self):
5                 return "PyFoo::ping()"
6
7
8 a = PyFoo()
9
10 if a.ping() != "PyFoo::ping()":
11         raise RuntimeError, a.ping()
12
13 if a.pong() != "Foo::pong();PyFoo::ping()":
14         raise RuntimeError, a.pong()
15
16 b = director_basic.Foo()
17
18 if b.ping() != "Foo::ping()":
19         raise RuntimeError, b.ping()
20
21 if b.pong() != "Foo::pong();Foo::ping()":
22         raise RuntimeError, b.pong()
23
24 a = director_basic.A1(1)
25
26 if a.rg(2) != 2:
27         raise RuntimeError
28
29
30
31 class PyClass(director_basic.MyClass):
32         def method(self, vptr):
33                 self.cmethod = 7
34                 pass
35         
36         def vmethod(self, b):
37                 b.x = b.x + 31
38                 return b
39
40
41 b = director_basic.Bar(3)
42 d = director_basic.MyClass()
43 c = PyClass()
44
45 cc = director_basic.MyClass_get_self(c)
46 dd = director_basic.MyClass_get_self(d)
47
48 bc = cc.cmethod(b)
49 bd = dd.cmethod(b)
50
51 cc.method(b)
52 if c.cmethod != 7:
53         raise RuntimeError
54
55 if bc.x != 34:
56         raise RuntimeError
57
58
59 if bd.x != 16:
60         raise RuntimeError
61
62
63
64 class PyMulti(director_basic.Foo, director_basic.MyClass):
65         def __init__(self):
66                 director_basic.Foo.__init__(self)
67                 director_basic.MyClass.__init__(self)           
68                 pass
69
70                 
71         def vmethod(self, b):
72                 b.x = b.x  + 31
73                 return b
74
75         
76         def ping(self):
77                 return "PyFoo::ping()"
78
79 a = 0
80 for i in range(0,100):
81     pymult = PyMulti()
82     pymult.pong()
83     del pymult 
84
85
86
87 pymult = PyMulti()
88
89
90
91
92 p1 = director_basic.Foo_get_self(pymult)
93 p2 = director_basic.MyClass_get_self(pymult)
94
95 p1.ping()
96 p2.vmethod(bc)
97
98