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

« back to all changes in this revision

Viewing changes to Examples/php4/proxy/runme.php4

  • 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
<?php
 
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
include("example.php");
 
8
 
 
9
# ----- Object creation -----
 
10
 
 
11
print "Creating some objects:\n";
 
12
$c = CircleFactory(10);
 
13
print "    Created circle $c with area ". $c->area() ."\n";
 
14
$s = new Square(10);
 
15
print "    Created square $s\n";
 
16
 
 
17
# ----- Access a static member -----
 
18
 
 
19
print "\nA total of " . Shape::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
$c->x = 20;
 
28
$c->y = 30;
 
29
$s->x = -10;
 
30
$s->y = 5;
 
31
 
 
32
print "\nHere is their current position:\n";
 
33
print "    Circle = (" . $c->x . "," . $c->y . ")\n";
 
34
print "    Square = (" . $s->x . "," . $s->y . ")\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 "    ".get_class($o)." $o\n";
 
41
      print "        x         = " .  $o->x . "\n";
 
42
      print "        y         = " .  $o->y . "\n";
 
43
      print "        area      = " .  $o->area() . "\n";
 
44
      print "        perimeter = " .  $o->perimeter() . "\n";
 
45
  }
 
46
 
 
47
# Need to unset($o) or else we hang on to a reference to the Square object.
 
48
unset($o);
 
49
 
 
50
# ----- Delete everything -----
 
51
 
 
52
print "\nGuess I'll clean up now\n";
 
53
 
 
54
# Note: this invokes the virtual destructor
 
55
unset($c);
 
56
$s = 42;
 
57
 
 
58
print Shape::nshapes() . " shapes remain\n";
 
59
 
 
60
print "Manually setting nshapes\n";
 
61
 
 
62
Shape::nshapes(42);
 
63
 
 
64
print Shape::get_nshapes() ." == 42\n";
 
65
 
 
66
print "Goodbye\n";
 
67
 
 
68
?>