diff --git a/Examples/python/value/.cvsignore b/Examples/python/value/.cvsignore deleted file mode 100644 index d111f30e8..000000000 --- a/Examples/python/value/.cvsignore +++ /dev/null @@ -1,13 +0,0 @@ -example.py -example.pyc -*_wrap.c -*_wrap.cxx -*.dll -*.dsw -*.exp -*.lib -*.ncb -*.opt -*.plg -Release -Debug diff --git a/Examples/python/value/Makefile b/Examples/python/value/Makefile deleted file mode 100644 index 754c4a029..000000000 --- a/Examples/python/value/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -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:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - -check: all diff --git a/Examples/python/value/example.c b/Examples/python/value/example.c deleted file mode 100644 index 4ed2fe10a..000000000 --- a/Examples/python/value/example.c +++ /dev/null @@ -1,15 +0,0 @@ -/* File : example.c */ - -#include "example.h" - -double dot_product(Vector a, Vector b) { - return (a.x*b.x + a.y*b.y + a.z*b.z); -} - -Vector vector_add(Vector a, Vector b) { - Vector r; - r.x = a.x + b.x; - r.y = a.y + b.y; - r.z = a.z + b.z; - return r; -} diff --git a/Examples/python/value/example.h b/Examples/python/value/example.h deleted file mode 100644 index 212cf4bdb..000000000 --- a/Examples/python/value/example.h +++ /dev/null @@ -1,5 +0,0 @@ -/* File : example.h */ - -typedef struct { - double x, y, z; -} Vector; diff --git a/Examples/python/value/example.i b/Examples/python/value/example.i deleted file mode 100644 index 83c1f9cd6..000000000 --- a/Examples/python/value/example.i +++ /dev/null @@ -1,30 +0,0 @@ -// Tests SWIG's handling of pass-by-value for complex datatypes -%module example - -%{ -#include "example.h" -%} - -/* Some functions that manipulate Vectors by value */ -extern double dot_product(Vector a, Vector b); -extern Vector vector_add(Vector a, Vector b); - -/* Include this because the vector_add() function will leak memory */ -void free(void *); - -/* Some helper functions for our interface */ -%inline %{ - -Vector *new_Vector(double x, double y, double z) { - Vector *v = (Vector *) malloc(sizeof(Vector)); - v->x = x; - v->y = y; - v->z = z; - return v; -} - -void vector_print(Vector *v) { - printf("Vector %x = (%g, %g, %g)\n", v, v->x, v->y, v->z); -} -%} - diff --git a/Examples/python/value/index.html b/Examples/python/value/index.html deleted file mode 100644 index 67870b562..000000000 --- a/Examples/python/value/index.html +++ /dev/null @@ -1,128 +0,0 @@ - -
--Occasionally, a C program will manipulate structures by value such as shown in the -following code: - -
-
-/* File : example.c */
-
-typedef struct Vector {
- double x, y, z;
-} Vector;
-
-double dot_product(Vector a, Vector b) {
- return (a.x*b.x + a.y*b.y + a.z*b.z);
-}
-
-Vector vector_add(Vector a, Vector b) {
- Vector r;
- r.x = a.x + b.x;
- r.y = a.y + b.y;
- r.z = a.z + b.z;
- return r;
-}
-
-
-
-Since SWIG only knows how to manage pointers to structures (not their internal
-representation), the following translations are made when wrappers are
-created:
-
-
-
-double wrap_dot_product(Vector *a, Vector *b) {
- return dot_product(*a,*b);
-}
-
-Vector *wrap_vector_add(Vector *a, Vector *b) {
- Vector *r = (Vector *) malloc(sizeof(Vector));
- *r = vector_add(*a,*b);
- return r;
-}
-
-
-
-The functions are then called using pointers from the scripting language interface.
-It should also be noted that any function that returns a structure by value results
-in an implicit memory allocation. This will be a memory leak unless you take steps
-to free the result (see below).
-
--
-
-Vector *wrap_vector_add(Vector *a, Vector *b) {
- Vector *r = new Vector(vector_add(*a,*b));
- return r;
-}
-
-
-
-Similarly, it would be a mistake to use the free() function from C++. A safer
-approach would be to write a helper function like this:
-
-
-
-%inline %{
- void delete_Vector(Vector *v) {
- delete v;
- }
-%}
-
-
-
--
-
-