From 815ad7ce6e7b129c52891446d1ecf10390b34dac Mon Sep 17 00:00:00 2001 From: JasperVanEck Date: Thu, 28 Nov 2013 10:02:43 +0100 Subject: Moved tests to Examples --- Examples/Makefile | 5 ++ Examples/simple/Makefile | 22 ++++++ Examples/simple/simple.cpp | 184 +++++++++++++++++++++++++++++++++++++++++++++ Examples/simple/simple.php | 99 ++++++++++++++++++++++++ PHP-CPP | 1 + src/argument.o | Bin 0 -> 5384 bytes src/base.o | Bin 0 -> 2048 bytes src/class.o | Bin 0 -> 2048 bytes src/classinfo.o | Bin 0 -> 8288 bytes src/environment.o | Bin 0 -> 11784 bytes src/extension.o | Bin 0 -> 23640 bytes src/function.o | Bin 0 -> 15408 bytes src/global.o | Bin 0 -> 2456 bytes src/hashmember.o | Bin 0 -> 3720 bytes src/libphpcpp.so | Bin 0 -> 132258 bytes src/member.o | Bin 0 -> 40808 bytes src/members.o | Bin 0 -> 6504 bytes src/parameters.o | Bin 0 -> 11680 bytes src/value.o | Bin 0 -> 68296 bytes tests/Makefile | 5 -- tests/simple/Makefile | 22 ------ tests/simple/simple.cpp | 184 --------------------------------------------- tests/simple/simple.php | 99 ------------------------ 23 files changed, 311 insertions(+), 310 deletions(-) create mode 100644 Examples/Makefile create mode 100644 Examples/simple/Makefile create mode 100644 Examples/simple/simple.cpp create mode 100644 Examples/simple/simple.php create mode 160000 PHP-CPP create mode 100644 src/argument.o create mode 100644 src/base.o create mode 100644 src/class.o create mode 100644 src/classinfo.o create mode 100644 src/environment.o create mode 100644 src/extension.o create mode 100644 src/function.o create mode 100644 src/global.o create mode 100644 src/hashmember.o create mode 100755 src/libphpcpp.so create mode 100644 src/member.o create mode 100644 src/members.o create mode 100644 src/parameters.o create mode 100644 src/value.o delete mode 100644 tests/Makefile delete mode 100644 tests/simple/Makefile delete mode 100644 tests/simple/simple.cpp delete mode 100644 tests/simple/simple.php diff --git a/Examples/Makefile b/Examples/Makefile new file mode 100644 index 0000000..2f74b32 --- /dev/null +++ b/Examples/Makefile @@ -0,0 +1,5 @@ +all: + cd simple; $(MAKE) + +clean: + cd simple; $(MAKE) clean diff --git a/Examples/simple/Makefile b/Examples/simple/Makefile new file mode 100644 index 0000000..e60be3a --- /dev/null +++ b/Examples/simple/Makefile @@ -0,0 +1,22 @@ +CPP = g++ +RM = rm -f +CPP_FLAGS = -Wall -c -I. -O2 -std=c++11 + +LD = g++ +LD_FLAGS = -Wall -shared -O2 +RESULT = simple.so + +SOURCES = $(wildcard *.cpp) +OBJECTS = $(SOURCES:%.cpp=%.o) + +all: ${OBJECTS} ${RESULT} + +${RESULT}: ${OBJECTS} + ${LD} ${LD_FLAGS} -o $@ ${OBJECTS} -lphpcpp + +clean: + ${RM} *.obj *~* ${OBJECTS} ${RESULT} + +${OBJECTS}: + ${CPP} ${CPP_FLAGS} -fpic -o $@ ${@:%.o=%.cpp} + diff --git a/Examples/simple/simple.cpp b/Examples/simple/simple.cpp new file mode 100644 index 0000000..7942a3c --- /dev/null +++ b/Examples/simple/simple.cpp @@ -0,0 +1,184 @@ +/** + * Simple.h + * + * A very simple extension that does almost nothing + * + * @author Emiel Bruijntjes + * @copyright 2013 Copernica BV + */ +#include +#include +#include + +/** + * Namespace to use + */ +using namespace std; + + +Php::Value bubblesort(Php::Parameters ¶ms) +{ + cout << "start bubblesort" << endl; + + // the array that was passed + Php::Value array(params[0]); + + cout << "go return" << endl; + + return array; + + // size of the array + int size = array.size(); + + cout << "convert to native" << endl; + + int *x = new int[size]; + for (int i=0; i x(&MyCustomClass::myMethod); + + // define classes + extension.add("my_class", Php::Class({ + Php::Public("a", 123), + Php::Protected("b", "abc"), + Php::Protected("myMethod", Php::Method(&MyCustomClass::myMethod)), + Php::Public("__construct", Php::Method(&MyCustomClass::__construct)) + })); + + // return the module entry + return extension.module(); + } +} + diff --git a/Examples/simple/simple.php b/Examples/simple/simple.php new file mode 100644 index 0000000..3abaa77 --- /dev/null +++ b/Examples/simple/simple.php @@ -0,0 +1,99 @@ +a."\n"); +// echo($this->b."\n"); +// echo("hoi\n"); +// +// parent::myMethod($val); +// } +// +//} +// +//$x = new my_extended_class(); +//$x->myMethod(123); + +$x = new my_class(); +$x->myMethod(); + + +//echo(my_plus(1,2,3,4)."\n"); + +$array = array(); +for ($i=0; $i<10000; $i++) $array[] = rand(); + +//$array = array(1,2,3); + +//print_r($array); +//bubblesort($array); + +//print_r($array); + + +//echo("my_class::a = ".$x->a."\n"); +//echo("my_class::b = ".$x->b."\n"); +// +//unset($x); +// +//echo("done\n"); + +//$x->my_method(); + + diff --git a/PHP-CPP b/PHP-CPP new file mode 160000 index 0000000..4d85e02 --- /dev/null +++ b/PHP-CPP @@ -0,0 +1 @@ +Subproject commit 4d85e028c2f05ea1dfc8c5797db4703deb6c698e diff --git a/src/argument.o b/src/argument.o new file mode 100644 index 0000000..bd3b044 Binary files /dev/null and b/src/argument.o differ diff --git a/src/base.o b/src/base.o new file mode 100644 index 0000000..0428dad Binary files /dev/null and b/src/base.o differ diff --git a/src/class.o b/src/class.o new file mode 100644 index 0000000..7214a7e Binary files /dev/null and b/src/class.o differ diff --git a/src/classinfo.o b/src/classinfo.o new file mode 100644 index 0000000..f398863 Binary files /dev/null and b/src/classinfo.o differ diff --git a/src/environment.o b/src/environment.o new file mode 100644 index 0000000..c9fbb95 Binary files /dev/null and b/src/environment.o differ diff --git a/src/extension.o b/src/extension.o new file mode 100644 index 0000000..852a1a6 Binary files /dev/null and b/src/extension.o differ diff --git a/src/function.o b/src/function.o new file mode 100644 index 0000000..f8c9241 Binary files /dev/null and b/src/function.o differ diff --git a/src/global.o b/src/global.o new file mode 100644 index 0000000..363c024 Binary files /dev/null and b/src/global.o differ diff --git a/src/hashmember.o b/src/hashmember.o new file mode 100644 index 0000000..250f0dd Binary files /dev/null and b/src/hashmember.o differ diff --git a/src/libphpcpp.so b/src/libphpcpp.so new file mode 100755 index 0000000..2c5827d Binary files /dev/null and b/src/libphpcpp.so differ diff --git a/src/member.o b/src/member.o new file mode 100644 index 0000000..a9fc97d Binary files /dev/null and b/src/member.o differ diff --git a/src/members.o b/src/members.o new file mode 100644 index 0000000..362a672 Binary files /dev/null and b/src/members.o differ diff --git a/src/parameters.o b/src/parameters.o new file mode 100644 index 0000000..38a0b2f Binary files /dev/null and b/src/parameters.o differ diff --git a/src/value.o b/src/value.o new file mode 100644 index 0000000..ef461dd Binary files /dev/null and b/src/value.o differ diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 2f74b32..0000000 --- a/tests/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -all: - cd simple; $(MAKE) - -clean: - cd simple; $(MAKE) clean diff --git a/tests/simple/Makefile b/tests/simple/Makefile deleted file mode 100644 index e60be3a..0000000 --- a/tests/simple/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -CPP = g++ -RM = rm -f -CPP_FLAGS = -Wall -c -I. -O2 -std=c++11 - -LD = g++ -LD_FLAGS = -Wall -shared -O2 -RESULT = simple.so - -SOURCES = $(wildcard *.cpp) -OBJECTS = $(SOURCES:%.cpp=%.o) - -all: ${OBJECTS} ${RESULT} - -${RESULT}: ${OBJECTS} - ${LD} ${LD_FLAGS} -o $@ ${OBJECTS} -lphpcpp - -clean: - ${RM} *.obj *~* ${OBJECTS} ${RESULT} - -${OBJECTS}: - ${CPP} ${CPP_FLAGS} -fpic -o $@ ${@:%.o=%.cpp} - diff --git a/tests/simple/simple.cpp b/tests/simple/simple.cpp deleted file mode 100644 index 7942a3c..0000000 --- a/tests/simple/simple.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/** - * Simple.h - * - * A very simple extension that does almost nothing - * - * @author Emiel Bruijntjes - * @copyright 2013 Copernica BV - */ -#include -#include -#include - -/** - * Namespace to use - */ -using namespace std; - - -Php::Value bubblesort(Php::Parameters ¶ms) -{ - cout << "start bubblesort" << endl; - - // the array that was passed - Php::Value array(params[0]); - - cout << "go return" << endl; - - return array; - - // size of the array - int size = array.size(); - - cout << "convert to native" << endl; - - int *x = new int[size]; - for (int i=0; i x(&MyCustomClass::myMethod); - - // define classes - extension.add("my_class", Php::Class({ - Php::Public("a", 123), - Php::Protected("b", "abc"), - Php::Protected("myMethod", Php::Method(&MyCustomClass::myMethod)), - Php::Public("__construct", Php::Method(&MyCustomClass::__construct)) - })); - - // return the module entry - return extension.module(); - } -} - diff --git a/tests/simple/simple.php b/tests/simple/simple.php deleted file mode 100644 index 3abaa77..0000000 --- a/tests/simple/simple.php +++ /dev/null @@ -1,99 +0,0 @@ -a."\n"); -// echo($this->b."\n"); -// echo("hoi\n"); -// -// parent::myMethod($val); -// } -// -//} -// -//$x = new my_extended_class(); -//$x->myMethod(123); - -$x = new my_class(); -$x->myMethod(); - - -//echo(my_plus(1,2,3,4)."\n"); - -$array = array(); -for ($i=0; $i<10000; $i++) $array[] = rand(); - -//$array = array(1,2,3); - -//print_r($array); -//bubblesort($array); - -//print_r($array); - - -//echo("my_class::a = ".$x->a."\n"); -//echo("my_class::b = ".$x->b."\n"); -// -//unset($x); -// -//echo("done\n"); - -//$x->my_method(); - - -- cgit v1.2.3