Debian Codegraph @

Tests/UseSWIG/ModuleName/runme.py

raw
1 # file: runme.py
2
3 # This file illustrates the shadow-class C++ interface generated
4 # by SWIG.
5
6 from __future__ import print_function
7
8 import new_example
9
10 # ----- Object creation -----
11
12 print ("Creating some objects:")
13 c = new_example.Circle(10)
14 print (" Created circle", c)
15 s = new_example.Square(10)
16 print (" Created square", s)
17
18 # ----- Access a static member -----
19
20 print ("\nA total of", new_example.cvar.Shape_nshapes,"shapes were created")
21
22 # ----- Member data access -----
23
24 # Set the location of the object
25
26 c.x = 20
27 c.y = 30
28
29 s.x = -10
30 s.y = 5
31
32 print ("\nHere is their current position:")
33 print (" Circle = (%f, %f)" % (c.x,c.y))
34 print (" Square = (%f, %f)" % (s.x,s.y))
35
36 # ----- Call some methods -----
37
38 print ("\nHere are some properties of the shapes:")
39 for o in [c,s]:
40 print (" ", o)
41 print (" area = ", o.area())
42 print (" perimeter = ", o.perimeter())
43
44 print ("\nGuess I'll clean up now")
45
46 # Note: this invokes the virtual destructor
47 del c
48 del s
49
50 s = 3
51 print (new_example.cvar.Shape_nshapes,"shapes remain")
52 print ("Goodbye")