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

« back to all changes in this revision

Viewing changes to Examples/tcl/class/example2.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-09-01 18:35:55 UTC
  • mfrom: (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050901183555-eq59uwhq8b62e44c
Tags: 1.3.24-1ubuntu4
* Use php5-dev instead of php4-dev, to kick php4 out of main.
* Drop support for generation of pike bindings, as nothing uses it,
  and swig is the only thing keeping pike7.6 in main (Ubuntu #13796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# file: example1.tcl
2
 
 
3
 
# This file illustrates the high level C++ interface.
4
 
# In this case C++ classes work kind of like Tk widgets
5
 
 
6
 
catch { load ./example[info sharedlibextension] example}
7
 
 
8
 
# ----- Object creation -----
9
 
 
10
 
puts "Creating some objects:"
11
 
Circle c 10
12
 
puts "    Created circle [c cget -this]"
13
 
Square s 10
14
 
puts "    Created square [s cget -this]"
15
 
 
16
 
# ----- Access a static member -----
17
 
 
18
 
puts "\nA total of $Shape_nshapes shapes were created"
19
 
 
20
 
# ----- Member data access -----
21
 
 
22
 
# Set the location of the object
23
 
 
24
 
c configure -x 20 -y 30
25
 
s configure -x -10 -y 5
26
 
 
27
 
puts "\nHere is their current position:"
28
 
puts "    Circle = ([c cget -x], [c cget -y])"
29
 
puts "    Square = ([s cget -x], [s cget -y])"
30
 
 
31
 
# ----- Call some methods -----
32
 
 
33
 
puts "\nHere are some properties of the shapes:"
34
 
foreach o "c s" {
35
 
      puts "    [$o cget -this]"
36
 
      puts "        area      = [$o area]"
37
 
      puts "        perimeter = [$o perimeter]"
38
 
}
39
 
 
40
 
# ----- Delete everything -----
41
 
 
42
 
puts "\nGuess I'll clean up now"
43
 
 
44
 
# Note: this invokes the virtual destructor
45
 
rename c ""
46
 
rename s ""
47
 
 
48
 
puts "$Shape_nshapes shapes remain"
49
 
puts "Goodbye"
50