shadow->proxy terminology update
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10400 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
33e41c1070
commit
e0889b6121
11 changed files with 1 additions and 172 deletions
|
|
@ -10,7 +10,7 @@ overloading
|
||||||
pointer
|
pointer
|
||||||
pragmas
|
pragmas
|
||||||
reference
|
reference
|
||||||
shadow
|
proxy
|
||||||
simple
|
simple
|
||||||
sync
|
sync
|
||||||
value
|
value
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
TOP = ../..
|
|
||||||
SWIG = $(TOP)/../preinst-swig
|
|
||||||
CXXSRCS = example.cxx
|
|
||||||
TARGET = example
|
|
||||||
INTERFACE = example.i
|
|
||||||
LIBS = -lm
|
|
||||||
SWIGOPT =
|
|
||||||
|
|
||||||
all::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
|
|
||||||
|
|
||||||
static::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
|
||||||
SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
|
||||||
|
|
||||||
clean::
|
|
||||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
|
||||||
rm -f $(TARGET).py
|
|
||||||
|
|
||||||
check: all
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
/* File : example.c */
|
|
||||||
|
|
||||||
#include "example.h"
|
|
||||||
#include <math.h>
|
|
||||||
#ifndef M_PI
|
|
||||||
# define M_PI 3.14159265358979323846
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,39 +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();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
/* File : example.i */
|
|
||||||
%module example
|
|
||||||
|
|
||||||
%{
|
|
||||||
#include "example.h"
|
|
||||||
%}
|
|
||||||
|
|
||||||
/* Let's just grab the original header file here */
|
|
||||||
%include "example.h"
|
|
||||||
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>SWIG:Examples:python:proxy</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body bgcolor="#ffffff">
|
|
||||||
|
|
||||||
|
|
||||||
<tt>SWIG/Examples/python/proxy/</tt>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<H2>Wrapping a simple C++ class</H2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
This example illustrates the wrapping of some C++ classes by proxy classes.
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
# file: runme.py
|
|
||||||
|
|
||||||
# This file illustrates the proxy class C++ interface generated
|
|
||||||
# by SWIG.
|
|
||||||
|
|
||||||
import example
|
|
||||||
|
|
||||||
# ----- Object creation -----
|
|
||||||
|
|
||||||
print "Creating some objects:"
|
|
||||||
c = example.Circle(10)
|
|
||||||
print " Created circle", c
|
|
||||||
s = example.Square(10)
|
|
||||||
print " Created square", s
|
|
||||||
|
|
||||||
# ----- Access a static member -----
|
|
||||||
|
|
||||||
print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
|
|
||||||
|
|
||||||
# ----- Member data access -----
|
|
||||||
|
|
||||||
# Set the location of the object
|
|
||||||
|
|
||||||
c.x = 20
|
|
||||||
c.y = 30
|
|
||||||
|
|
||||||
s.x = -10
|
|
||||||
s.y = 5
|
|
||||||
|
|
||||||
print "\nHere is their current position:"
|
|
||||||
print " Circle = (%f, %f)" % (c.x,c.y)
|
|
||||||
print " Square = (%f, %f)" % (s.x,s.y)
|
|
||||||
|
|
||||||
# ----- Call some methods -----
|
|
||||||
|
|
||||||
print "\nHere are some properties of the shapes:"
|
|
||||||
for o in [c,s]:
|
|
||||||
print " ", o
|
|
||||||
print " area = ", o.area()
|
|
||||||
print " perimeter = ", o.perimeter()
|
|
||||||
|
|
||||||
print "\nGuess I'll clean up now"
|
|
||||||
|
|
||||||
# Note: this invokes the virtual destructor
|
|
||||||
del c
|
|
||||||
del s
|
|
||||||
|
|
||||||
s = 3
|
|
||||||
print example.cvar.Shape_nshapes,"shapes remain"
|
|
||||||
print "Goodbye"
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue