new example

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@840 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-09-04 15:30:20 +00:00
commit 52386c6406
5 changed files with 48 additions and 0 deletions

View file

@ -9,9 +9,11 @@ public:
nshapes--;
};
double x, y;
char foo[256];
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
char *name() { return "Shape"; }
static int nshapes;
};
@ -24,6 +26,13 @@ public:
virtual double perimeter();
};
class XCircle : public Circle {
public:
XCircle(double r) : Circle(r) { };
virtual double area();
char *name() { return "XCircle"; }
};
class Square : public Shape {
private:
double width;

View file

@ -6,6 +6,9 @@
%}
/* Let's just grab the original header file here */
%typemap(memberin) char [ANY] {
strncpy($target,$source,$dim0);
}
%include "example.h"

View file

@ -0,0 +1,18 @@
TOP = ../..
SWIG = $(TOP)/../swig
SRCS = example.c
TARGET = example
INTERFACE = example.i
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
clean::
rm -f *_wrap* *.o *~ *.so mypython *.pyc .~* core
check: all

View file

@ -0,0 +1,17 @@
/* File : example.c */
int do_op(int a, int b, int (*op)(int,int)) {
return (*op)(a,b);
}
int add(int a, int b) {
return a+b;
}
int sub(int a, int b) {
return a-b;
}
int mul(int a, int b) {
return a*b;
}

View file

@ -21,6 +21,7 @@ certain C declarations are turned into constants.
<li><a href="class/index.html">class</a>. Wrapping a simple C++ class.
<li><a href="reference/index.html">reference</a>. C++ references.
<li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
<li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
</ul>
<h2>Compilation Issues</h2>