new example
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@840 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
2de4df5af5
commit
19f72587d9
5 changed files with 48 additions and 0 deletions
|
|
@ -9,9 +9,11 @@ public:
|
||||||
nshapes--;
|
nshapes--;
|
||||||
};
|
};
|
||||||
double x, y;
|
double x, y;
|
||||||
|
char foo[256];
|
||||||
void move(double dx, double dy);
|
void move(double dx, double dy);
|
||||||
virtual double area() = 0;
|
virtual double area() = 0;
|
||||||
virtual double perimeter() = 0;
|
virtual double perimeter() = 0;
|
||||||
|
char *name() { return "Shape"; }
|
||||||
static int nshapes;
|
static int nshapes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -24,6 +26,13 @@ public:
|
||||||
virtual double perimeter();
|
virtual double perimeter();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class XCircle : public Circle {
|
||||||
|
public:
|
||||||
|
XCircle(double r) : Circle(r) { };
|
||||||
|
virtual double area();
|
||||||
|
char *name() { return "XCircle"; }
|
||||||
|
};
|
||||||
|
|
||||||
class Square : public Shape {
|
class Square : public Shape {
|
||||||
private:
|
private:
|
||||||
double width;
|
double width;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Let's just grab the original header file here */
|
/* Let's just grab the original header file here */
|
||||||
|
%typemap(memberin) char [ANY] {
|
||||||
|
strncpy($target,$source,$dim0);
|
||||||
|
}
|
||||||
|
|
||||||
%include "example.h"
|
%include "example.h"
|
||||||
|
|
||||||
|
|
|
||||||
18
SWIG/Examples/python/funcptr/Makefile
Normal file
18
SWIG/Examples/python/funcptr/Makefile
Normal 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
|
||||||
17
SWIG/Examples/python/funcptr/example.c
Normal file
17
SWIG/Examples/python/funcptr/example.c
Normal 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;
|
||||||
|
}
|
||||||
|
|
@ -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="class/index.html">class</a>. Wrapping a simple C++ class.
|
||||||
<li><a href="reference/index.html">reference</a>. C++ references.
|
<li><a href="reference/index.html">reference</a>. C++ references.
|
||||||
<li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
|
<li><a href="pointer/index.html">pointer</a>. Simple pointer handling.
|
||||||
|
<li><a href="funcptr/index.html">funcptr</a>. Pointers to functions.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h2>Compilation Issues</h2>
|
<h2>Compilation Issues</h2>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue