summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Beazley <dave-swig@dabeaz.com>2000-09-04 15:30:20 +0000
committerDave Beazley <dave-swig@dabeaz.com>2000-09-04 15:30:20 +0000
commit52386c64067bde49115424f365f03fb7604acfe6 (patch)
tree33a34d3004d901884b7ce677cdb55aa0c3c9c8f1
parentf15486f6c48f640b24ac8b7781dd2c12e54f7da9 (diff)
downloadswig-52386c64067bde49115424f365f03fb7604acfe6.tar.gz
new example
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@840 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Examples/python/class/example.h9
-rw-r--r--Examples/python/class/example.i3
-rw-r--r--Examples/python/funcptr/Makefile18
-rw-r--r--Examples/python/funcptr/example.c17
-rw-r--r--Examples/python/index.html1
5 files changed, 48 insertions, 0 deletions
diff --git a/Examples/python/class/example.h b/Examples/python/class/example.h
index 849071dd3..b01e8bb0a 100644
--- a/Examples/python/class/example.h
+++ b/Examples/python/class/example.h
@@ -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;
diff --git a/Examples/python/class/example.i b/Examples/python/class/example.i
index 23ee8a822..3cd206c26 100644
--- a/Examples/python/class/example.i
+++ b/Examples/python/class/example.i
@@ -6,6 +6,9 @@
%}
/* Let's just grab the original header file here */
+%typemap(memberin) char [ANY] {
+ strncpy($target,$source,$dim0);
+}
%include "example.h"
diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile
new file mode 100644
index 000000000..e495cfa9a
--- /dev/null
+++ b/Examples/python/funcptr/Makefile
@@ -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
diff --git a/Examples/python/funcptr/example.c b/Examples/python/funcptr/example.c
new file mode 100644
index 000000000..99583b72e
--- /dev/null
+++ b/Examples/python/funcptr/example.c
@@ -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;
+}
diff --git a/Examples/python/index.html b/Examples/python/index.html
index c11247421..fcf607895 100644
--- a/Examples/python/index.html
+++ b/Examples/python/index.html
@@ -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>