diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2009-08-18 20:56:02 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-25 16:59:08 +0000 |
commit | 9f8a09ed743cedd9547bf0661d518647966ab114 (patch) | |
tree | 9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/php/sync | |
download | swig-tarball-master.tar.gz |
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/php/sync')
-rw-r--r-- | Examples/php/sync/Makefile | 24 | ||||
-rw-r--r-- | Examples/php/sync/example.cxx | 13 | ||||
-rw-r--r-- | Examples/php/sync/example.h | 9 | ||||
-rw-r--r-- | Examples/php/sync/example.i | 7 | ||||
-rw-r--r-- | Examples/php/sync/runme.php | 15 |
5 files changed, 68 insertions, 0 deletions
diff --git a/Examples/php/sync/Makefile b/Examples/php/sync/Makefile new file mode 100644 index 0000000..1bc0bea --- /dev/null +++ b/Examples/php/sync/Makefile @@ -0,0 +1,24 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +CXXSRCS = example.cxx +TARGET = example +INTERFACE = example.i +LIBS = +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + php_cpp + +static:: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static + +clean:: + $(MAKE) -f $(TOP)/Makefile php_clean + rm -f $(TARGET).php + +check: all + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/sync/example.cxx b/Examples/php/sync/example.cxx new file mode 100644 index 0000000..31ed202 --- /dev/null +++ b/Examples/php/sync/example.cxx @@ -0,0 +1,13 @@ +#include "example.h" +#include <stdio.h> + +int x = 42; +char *s = (char *)"Test"; + +void Sync::printer(void) { + + printf("The value of global s is %s\n", s); + printf("The value of global x is %d\n", x); + printf("The value of class s is %s\n", s); + printf("The value of class x is %d\n", x); +}; diff --git a/Examples/php/sync/example.h b/Examples/php/sync/example.h new file mode 100644 index 0000000..d67ec21 --- /dev/null +++ b/Examples/php/sync/example.h @@ -0,0 +1,9 @@ +extern char *s; +extern int x; + +class Sync { + public: + int x; + char *s; + void printer(void); +}; diff --git a/Examples/php/sync/example.i b/Examples/php/sync/example.i new file mode 100644 index 0000000..17ff87c --- /dev/null +++ b/Examples/php/sync/example.i @@ -0,0 +1,7 @@ +%module example + +%{ +#include "example.h" +%} + +%include "example.h" diff --git a/Examples/php/sync/runme.php b/Examples/php/sync/runme.php new file mode 100644 index 0000000..a7c4347 --- /dev/null +++ b/Examples/php/sync/runme.php @@ -0,0 +1,15 @@ +<? + +// Load module and PHP classes. +include("example.php"); + +echo "Got new object\n"; +echo "Got string $s and value $x \n"; + +$s = new Sync(); +echo "Got new object\n"; + +$s->printer(); + +?> + |