Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Tests / SwigTest / runme.py
blob42a5aa363491ca3f2887ded01fcce632cd49da4d
1 # file: runme.py
3 # This file illustrates the shadow-class C++ interface generated
4 # by SWIG.
6 import example
8 # ----- Object creation -----
10 print "Creating some objects:"
11 c = example.Circle(10)
12 print " Created circle", c
13 s = example.Square(10)
14 print " Created square", s
16 # ----- Access a static member -----
18 print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
20 # ----- Member data access -----
22 # Set the location of the object
24 c.x = 20
25 c.y = 30
27 s.x = -10
28 s.y = 5
30 print "\nHere is their current position:"
31 print " Circle = (%f, %f)" % (c.x,c.y)
32 print " Square = (%f, %f)" % (s.x,s.y)
34 # ----- Call some methods -----
36 print "\nHere are some properties of the shapes:"
37 for o in [c,s]:
38 print " ", o
39 print " area = ", o.area()
40 print " perimeter = ", o.perimeter()
42 print "\nGuess I'll clean up now"
44 # Note: this invokes the virtual destructor
45 del c
46 del s
48 s = 3
49 print example.cvar.Shape_nshapes,"shapes remain"
50 print "Goodbye"