3 # This file illustrates the low-level C++ interface
4 # created by SWIG. In this case, all of our C++ classes
5 # get converted into function calls.
7 catch { load .
/example
[info sharedlibextension
] example
}
9 # ----- Object creation -----
11 puts "Creating some objects:"
13 puts " Created circle $c"
15 puts " Created square $s"
17 # ----- Access a static member -----
19 puts "\nA total of $Shape_nshapes shapes were created"
21 # ----- Member data access -----
23 # Set the location of the object
24 # Note: the base class must be used since that's where x and y
32 puts "\nHere is their current position:"
33 puts " Circle = ([Shape_x_get $c], [Shape_y_get $c])"
34 puts " Square = ([Shape_x_get $s], [Shape_y_get $s])"
36 # ----- Call some methods -----
38 puts "\nHere are some properties of the shapes:"
41 puts " area = [Shape_area $o]"
42 puts " perimeter = [Shape_perimeter $o]"
44 # Notice how the Shape_area() and Shape_perimeter() functions really
45 # invoke the appropriate virtual method on each object.
47 # ----- Try to cause a type error -----
49 puts "\nI'm going to try and break the type system"
53 Square_area
$c # Try to invoke Square method on a Circle
57 puts " Well, it didn't work. Good SWIG."
60 # ----- Delete everything -----
62 puts "\nGuess I'll clean up now"
64 # Note: this invokes the virtual destructor
68 puts "$Shape_nshapes shapes remain"