Various and sundry updates for the Pike module.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4758 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7ac6270fb8
commit
c478c13cf0
6 changed files with 147 additions and 59 deletions
|
|
@ -6,55 +6,47 @@ int main()
|
|||
|
||||
write("Creating some objects:\n");
|
||||
Circle c = Circle(10.0);
|
||||
// write(" Created circle " + (string) c + ".\n");
|
||||
write(" Created circle.\n");
|
||||
Square s = Square(10.0);
|
||||
// write(" Created square " + (string) s + ".\n");
|
||||
write(" Created square.\n");
|
||||
|
||||
// ----- Access a static member -----
|
||||
|
||||
// write("\nA total of " + Shape->nshapes + " shapes were created\n");
|
||||
write("\nA total of " + Shape_nshapes_get() + " shapes were created\n");
|
||||
|
||||
// ----- Member data access -----
|
||||
|
||||
// Set the location of the object
|
||||
|
||||
// c->x = 20.0;
|
||||
// c->y = 30.0;
|
||||
c->x_set(20.0);
|
||||
c->y_set(30.0);
|
||||
|
||||
// s->x = -10.0;
|
||||
// s->y = 5.0;
|
||||
s->x_set(-10.0);
|
||||
s->y_set(5.0);
|
||||
|
||||
write("\nHere is their current position:\n");
|
||||
// write(sprintf(" Circle = (%f, %f)\n", c->x, c->y));
|
||||
// write(sprintf(" Square = (%f, %f)\n", s->x, s->y));
|
||||
write(sprintf(" Circle = (%f, %f)\n", c->x_get(), c->y_get()));
|
||||
write(sprintf(" Square = (%f, %f)\n", s->x_get(), s->y_get()));
|
||||
write(" Circle = (%f, %f)\n", c->x_get(), c->y_get());
|
||||
write(" Square = (%f, %f)\n", s->x_get(), s->y_get());
|
||||
|
||||
// ----- Call some methods -----
|
||||
|
||||
write("\nHere are some properties of the shapes:\n");
|
||||
write(" The circle:\n");
|
||||
write(sprintf(" area = %f.\n", c->area()));
|
||||
write(sprintf(" perimeter = %f.\n", c->perimeter()));
|
||||
// write(" " + (string) s + ".\n");
|
||||
write(" area = %f.\n", c->area());
|
||||
write(" perimeter = %f.\n", c->perimeter());
|
||||
write(" The square:\n");
|
||||
write(sprintf(" area = %f.\n", s->area()));
|
||||
write(sprintf(" perimeter = %f.\n", s->perimeter()));
|
||||
write(" area = %f.\n", s->area());
|
||||
write(" perimeter = %f.\n", s->perimeter());
|
||||
|
||||
write("\nGuess I'll clean up now\n");
|
||||
|
||||
// Note: this invokes the virtual destructor
|
||||
// del c;
|
||||
// del s;
|
||||
|
||||
// s = 3;
|
||||
// write(sprintf("%d shapes remain\n", Shape->nshapes));
|
||||
/* See if we can force 's' to be garbage-collected */
|
||||
s = 0;
|
||||
|
||||
/* Now we should be down to only 1 shape */
|
||||
write("%d shapes remain\n", Shape_nshapes_get());
|
||||
|
||||
/* Done */
|
||||
write("Goodbye\n");
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue