From f574a34155e4ede49b1b023494e0a1637ab89f8f Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 11 May 2014 23:21:10 +0200 Subject: Allow examples and test-suite to be built out of source tree - Examples/Makefile.in rules use SRCDIR as the relative source directory - ./config.status replicates Examples/ source directory tree in build directory, and copies each Makefile to build directory, prefixed with a header which sets SRCDIR to source directory - Examples/test-suite/.../Makefile.in set SRCDIR from Autoconf-set srcdir - Examples/test-suite/errors/Makefile.in needs to filter out source directory from SWIG error messages - Lua: embedded interpreters are passed location of run-time test - Python: copy run-time scripts to build directory because of 2to3 conversion; import_packages example copies __init__.py from source directory; test-suite sets SCRIPTDIR to location of run-time tests - Javascript: binding.gyp renamed to binding.gyp.in so that $srcdir can be substituted with SRCDIR; removed './' from require() statements so that NODE_PATH can be used to point Node.js to build directory --- Examples/php/reference/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Examples/php/reference') diff --git a/Examples/php/reference/Makefile b/Examples/php/reference/Makefile index cefd81f78..8b2b340e9 100644 --- a/Examples/php/reference/Makefile +++ b/Examples/php/reference/Makefile @@ -7,17 +7,17 @@ LIBS = SWIGOPT = check: build - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_run build: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ php_cpp static: - $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ php_cpp_static clean: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' php_clean -- cgit v1.2.1 From f39ed94419e4a30b8b2ba1d49c138fd245010262 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 May 2014 00:14:01 +0100 Subject: Fix compiler warnings in examples when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type --- Examples/php/reference/example.cxx | 10 +++++----- Examples/php/reference/example.i | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'Examples/php/reference') diff --git a/Examples/php/reference/example.cxx b/Examples/php/reference/example.cxx index 13e47eade..7ead7fbf6 100644 --- a/Examples/php/reference/example.cxx +++ b/Examples/php/reference/example.cxx @@ -19,23 +19,23 @@ Vector operator+(const Vector &a, const Vector &b) { char *Vector::as_string() { static char temp[512]; - sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); + sprintf(temp,"Vector %p (%g,%g,%g)", (void *)this, x,y,z); return temp; } VectorArray::VectorArray(int size) { items = new Vector[size]; maxsize = size; - printf("VectorArray new: self=%p\n",this); + printf("VectorArray new: self=%p\n", (void *)this); } VectorArray::~VectorArray() { - printf("VectorArray delete: self=%p\n",this); + printf("VectorArray delete: self=%p\n", (void *)this); delete [] items; } Vector &VectorArray::operator[](int index) { - printf("VectorArray: read[%d] self=%p\n",index,this); + printf("VectorArray: read[%d] self=%p\n", index, (void *)this); if ((index < 0) || (index >= maxsize)) { printf("Panic! Array index out of bounds.\n"); exit(1); @@ -44,6 +44,6 @@ Vector &VectorArray::operator[](int index) { } int VectorArray::size() { - printf("VectorArray: size %d self=%p\n",maxsize,this); + printf("VectorArray: size %d self=%p\n", maxsize, (void *)this); return maxsize; } diff --git a/Examples/php/reference/example.i b/Examples/php/reference/example.i index d6122866b..a372439b1 100644 --- a/Examples/php/reference/example.i +++ b/Examples/php/reference/example.i @@ -37,7 +37,7 @@ public: /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { - printf("VectorArray extended get: %p %d\n",$self,index); + printf("VectorArray extended get: %p %d\n", (void *)$self, index); return (*$self)[index]; } void set(int index, Vector &a) { -- cgit v1.2.1 From 37cd1474b563d413c3ae7df254d9d22b9c6086b8 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 5 Nov 2014 10:42:12 +1300 Subject: Remove bogus ; after } in examples --- Examples/php/reference/example.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Examples/php/reference') diff --git a/Examples/php/reference/example.h b/Examples/php/reference/example.h index 1b88cbf5c..d9daee89c 100644 --- a/Examples/php/reference/example.h +++ b/Examples/php/reference/example.h @@ -4,8 +4,8 @@ class Vector { private: double x,y,z; public: - Vector() : x(0), y(0), z(0) { }; - Vector(double x, double y, double z) : x(x), y(y), z(z) { }; + Vector() : x(0), y(0), z(0) { } + Vector(double x, double y, double z) : x(x), y(y), z(z) { } friend Vector operator+(const Vector &a, const Vector &b); char *as_string(); }; -- cgit v1.2.1 From ac1f067ce983e40591461f768df8914b01b5505d Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 5 Nov 2014 10:43:42 +1300 Subject: Eliminate trivial differences between the reference examples --- Examples/php/reference/example.h | 4 ---- Examples/php/reference/example.i | 10 +++------- 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'Examples/php/reference') diff --git a/Examples/php/reference/example.h b/Examples/php/reference/example.h index d9daee89c..353b88835 100644 --- a/Examples/php/reference/example.h +++ b/Examples/php/reference/example.h @@ -20,7 +20,3 @@ public: Vector &operator[](int); int size(); }; - - - - diff --git a/Examples/php/reference/example.i b/Examples/php/reference/example.i index a372439b1..df1459921 100644 --- a/Examples/php/reference/example.i +++ b/Examples/php/reference/example.i @@ -1,10 +1,6 @@ /* File : example.i */ -/* This example has nothing to do with references but the name is used by all - * the other languages so it's hard to rename to something more meaningful. - * - * Mostly it shows how to use %extend. - */ +/* This file has a few "typical" uses of C++ references. */ %module example @@ -33,8 +29,8 @@ public: VectorArray(int maxsize); ~VectorArray(); int size(); - - /* This wrapper provides an alternative to the [] operator */ + + /* This wrapper provides an alternative to the [] operator */ %extend { Vector &get(int index) { printf("VectorArray extended get: %p %d\n", (void *)$self, index); -- cgit v1.2.1