diff options
Diffstat (limited to 'Examples/pike/class')
-rw-r--r-- | Examples/pike/class/Makefile | 23 | ||||
-rw-r--r-- | Examples/pike/class/example.cxx | 28 | ||||
-rw-r--r-- | Examples/pike/class/example.h | 34 | ||||
-rw-r--r-- | Examples/pike/class/example.i | 9 | ||||
-rw-r--r-- | Examples/pike/class/runme.pike | 53 |
5 files changed, 0 insertions, 147 deletions
diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile deleted file mode 100644 index e5319dbe2..000000000 --- a/Examples/pike/class/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -TOP = ../.. -SWIGEXE = $(TOP)/../swig -SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib -CXXSRCS = example.cxx -TARGET = example -INTERFACE = example.i -LIBS = -lm - -check: build - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_run - -build: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike_cpp - -static: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' \ - SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_cpp_static - -clean: - $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' pike_clean diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx deleted file mode 100644 index 046304519..000000000 --- a/Examples/pike/class/example.cxx +++ /dev/null @@ -1,28 +0,0 @@ -/* File : example.cxx */ - -#include "example.h" -#define M_PI 3.14159265358979323846 - -/* Move the shape to a new location */ -void Shape::move(double dx, double dy) { - x += dx; - y += dy; -} - -int Shape::nshapes = 0; - -double Circle::area() { - return M_PI*radius*radius; -} - -double Circle::perimeter() { - return 2*M_PI*radius; -} - -double Square::area() { - return width*width; -} - -double Square::perimeter() { - return 4*width; -} diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h deleted file mode 100644 index 0dff185b2..000000000 --- a/Examples/pike/class/example.h +++ /dev/null @@ -1,34 +0,0 @@ -/* File : example.h */ - -class Shape { -public: - Shape() { - nshapes++; - } - virtual ~Shape() { - nshapes--; - } - double x, y; - void move(double dx, double dy); - virtual double area() = 0; - virtual double perimeter() = 0; - static int nshapes; -}; - -class Circle : public Shape { -private: - double radius; -public: - Circle(double r) : radius(r) { } - virtual double area(); - virtual double perimeter(); -}; - -class Square : public Shape { -private: - double width; -public: - Square(double w) : width(w) { } - virtual double area(); - virtual double perimeter(); -}; diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i deleted file mode 100644 index fbdf7249f..000000000 --- a/Examples/pike/class/example.i +++ /dev/null @@ -1,9 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" diff --git a/Examples/pike/class/runme.pike b/Examples/pike/class/runme.pike deleted file mode 100644 index a6377600e..000000000 --- a/Examples/pike/class/runme.pike +++ /dev/null @@ -1,53 +0,0 @@ -import .example; - -int main() -{ - // ----- Object creation ----- - - write("Creating some objects:\n"); - Circle c = Circle(10.0); - write(" Created circle.\n"); - Square s = Square(10.0); - write(" Created square.\n"); - - // ----- Access a static member ----- - - write("\nA total of " + Shape_nshapes_get() + " shapes were created\n"); - - // ----- Member data access ----- - - // Set the location of the object - - c->x_set(20.0); - c->y_set(30.0); - - s->x_set(-10.0); - s->y_set(5.0); - - write("\nHere is their current position:\n"); - 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(" area = %f.\n", c->area()); - write(" perimeter = %f.\n", c->perimeter()); - write(" The square:\n"); - write(" area = %f.\n", s->area()); - write(" perimeter = %f.\n", s->perimeter()); - - write("\nGuess I'll clean up now\n"); - - /* 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; -} |