~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Examples/python/shadow/runme.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-11-10 16:29:56 UTC
  • mfrom: (1.2.8 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20081110162956-xue6itkuqhbza87s
Tags: 1.3.36-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop pike and libchicken-dev from the build-depends 
    (both are universe)
  - Use python2.5 instead of python2.4.
  - use php5
  - Clean Runtime/ as well.
  - debian/Rules (clean): Remove Lib/ocaml/swigp4.ml.
  - drop "--without-mzscheme", we don't have it in our build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# file: runme.py
2
 
 
3
 
# This file illustrates the shadow-class C++ interface generated
4
 
# by SWIG.
5
 
 
6
 
import example 
7
 
 
8
 
# ----- Object creation -----
9
 
 
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
15
 
 
16
 
# ----- Access a static member -----
17
 
 
18
 
print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
19
 
 
20
 
# ----- Member data access -----
21
 
 
22
 
# Set the location of the object
23
 
 
24
 
c.x = 20
25
 
c.y = 30
26
 
 
27
 
s.x = -10
28
 
s.y = 5
29
 
 
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)
33
 
 
34
 
# ----- Call some methods -----
35
 
 
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()
41
 
 
42
 
print "\nGuess I'll clean up now"
43
 
 
44
 
# Note: this invokes the virtual destructor
45
 
del c
46
 
del s
47
 
 
48
 
s = 3
49
 
print example.cvar.Shape_nshapes,"shapes remain"
50
 
print "Goodbye"
51