From 2824b0cbb66e715490e1ef13250bd675d87b32d9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Jun 2010 20:53:17 +0000 Subject: rel-2.0.0 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-2.0.0@12089 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- trunk/Examples/php/cpointer/Makefile | 24 +++++++++++++++++++ trunk/Examples/php/cpointer/example.c | 16 +++++++++++++ trunk/Examples/php/cpointer/example.i | 26 ++++++++++++++++++++ trunk/Examples/php/cpointer/runme.php | 45 +++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 trunk/Examples/php/cpointer/Makefile create mode 100644 trunk/Examples/php/cpointer/example.c create mode 100644 trunk/Examples/php/cpointer/example.i create mode 100644 trunk/Examples/php/cpointer/runme.php (limited to 'trunk/Examples/php/cpointer') diff --git a/trunk/Examples/php/cpointer/Makefile b/trunk/Examples/php/cpointer/Makefile new file mode 100644 index 000000000..0862ce5ec --- /dev/null +++ b/trunk/Examples/php/cpointer/Makefile @@ -0,0 +1,24 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +LIBS = +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + php + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static + +clean:: + $(MAKE) -f $(TOP)/Makefile php_clean + rm -f $(TARGET).php + +check: all + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/trunk/Examples/php/cpointer/example.c b/trunk/Examples/php/cpointer/example.c new file mode 100644 index 000000000..3326dec3e --- /dev/null +++ b/trunk/Examples/php/cpointer/example.c @@ -0,0 +1,16 @@ +/* File : example.c */ + +void add(double *x, double *y, double *result) { + *result = *x + *y; +} + +void sub(int *x, int *y, int *result) { + *result = *x - *y; +} + +int divide(int n, int d, int *r) { + int q; + q = n/d; + *r = n - q*d; + return q; +} diff --git a/trunk/Examples/php/cpointer/example.i b/trunk/Examples/php/cpointer/example.i new file mode 100644 index 000000000..52e6df190 --- /dev/null +++ b/trunk/Examples/php/cpointer/example.i @@ -0,0 +1,26 @@ +/* File : example.i */ +%module example + +/* This example illustrates a couple of different techniques + for manipulating C pointers */ + +/* First we'll use the pointer library */ +extern void add(int *x, int *y, int *result); + +%include cpointer.i +%pointer_functions(int, intp); + +/* Next we'll use some typemaps */ + +%include typemaps.i +extern void sub(int *INPUT, int *INPUT, int *OUTPUT); + +/* Next we'll use typemaps and the %apply directive */ + +//%apply int *OUTPUT { int *r }; +//extern int divide(int n, int d, int *r); + + + + + diff --git a/trunk/Examples/php/cpointer/runme.php b/trunk/Examples/php/cpointer/runme.php new file mode 100644 index 000000000..48f0ad631 --- /dev/null +++ b/trunk/Examples/php/cpointer/runme.php @@ -0,0 +1,45 @@ + -- cgit v1.2.1