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

« back to all changes in this revision

Viewing changes to Examples/php4/class/runme.php3

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Landschoff
  • Date: 2002-03-29 01:56:07 UTC
  • Revision ID: james.westby@ubuntu.com-20020329015607-c0wt03xu8oy9ioj7
Tags: upstream-1.3.11
ImportĀ upstreamĀ versionĀ 1.3.11

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?
 
2
 
 
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.
 
6
 
 
7
dl("libexample.so");
 
8
 
 
9
# ----- Object creation -----
 
10
 
 
11
print "Creating some objects:\n";
 
12
$c = new_Circle(10);
 
13
print "    Created circle $c\n";
 
14
$s = new_Square(10);
 
15
print "    Created square $s\n";
 
16
 
 
17
# ----- Access a static member -----
 
18
 
 
19
print "\nA total of " . nshapes() . " shapes were created\n";
 
20
 
 
21
# ----- Member data access -----
 
22
 
 
23
# Set the location of the object.
 
24
# Note: methods in the base class Shape are used since
 
25
# x and y are defined there.
 
26
 
 
27
Shape_x_set($c, 20);
 
28
Shape_y_set($c, 30);
 
29
Shape_x_set($s,-10);
 
30
Shape_y_set($s,5);
 
31
 
 
32
print "\nHere is their current position:\n";
 
33
print "    Circle = (" . Shape_x_get($c) . "," .  Shape_y_get($c) . ")\n";
 
34
print "    Square = (" . Shape_x_get($s) . "," .  Shape_y_get($s) . ")\n";
 
35
 
 
36
# ----- Call some methods -----
 
37
 
 
38
print "\nHere are some properties of the shapes:\n";
 
39
foreach (array($c,$s) as $o) {
 
40
      print "    $o\n";
 
41
      print "        area      = " .  Shape_area($o) .  "\n";
 
42
      print "        perimeter = " .  Shape_perimeter($o) . "\n";
 
43
  }
 
44
# Notice how the Shape_area() and Shape_perimeter() functions really
 
45
# invoke the appropriate virtual method on each object.
 
46
 
 
47
# ----- Delete everything -----
 
48
 
 
49
print "\nGuess I'll clean up now\n";
 
50
 
 
51
# Note: this invokes the virtual destructor
 
52
delete_Shape($c);
 
53
delete_Shape($s);
 
54
 
 
55
print nshapes() . " shapes remain\n";
 
56
print "Goodbye\n";
 
57
 
 
58
?>