summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 05:21:18 -0700
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 05:21:18 -0700
commit85507088051bdfabf8bc71346290949b78c3c914 (patch)
treed3503b8d28ccac78c5b209bea97a094b4a54aeb7 /tests
parente220af8dc07d845efb81082f3159460406ece9ca (diff)
Fixed various crashes because hidden pointers were not persistently stored
Copying the result value of a function has been fixed New C++ nullptr type is supported for Php::Value
Diffstat (limited to 'tests')
-rw-r--r--tests/simple/simple.cpp19
-rw-r--r--tests/simple/simple.php1
2 files changed, 11 insertions, 9 deletions
diff --git a/tests/simple/simple.cpp b/tests/simple/simple.cpp
index 311ce4c..954bfa9 100644
--- a/tests/simple/simple.cpp
+++ b/tests/simple/simple.cpp
@@ -17,14 +17,23 @@ using namespace std;
static Php::Value my_plus(Php::Parameters &params)
{
+ cout << "my_plus called" << endl;
+
+ cout << "params: " << params.size() << endl;
+
string p1 = params[0];
string p2 = params[1];
+ cout << "p1: " << p1 << endl;
+ cout << "p2: " << p2 << endl;
+
return p1 + p2;
}
class MyCustomFunction : public Php::Function
{
+public:
+ MyCustomFunction(const char *name) : Function(name) {}
};
@@ -35,20 +44,14 @@ extern "C"
// export the "get_module" function that will be called by the Zend engine
PHPCPP_EXPORT void *get_module()
{
- cout << "a" << endl;
-
// create extension
static Php::Extension extension("simple","1.0");
- cout << "b" << endl;
-
// define the functions
extension.add("my_plus", my_plus);
-// extension.add("my_concat", my_concat);
- extension.add("my_custom", MyCustomFunction());
+ extension.add("my_concat", my_concat);
+ extension.add(new MyCustomFunction("my_custom"));
- cout << "c" << endl;
-
// define classes
// extension.add("my_class", MyCustomClass());
diff --git a/tests/simple/simple.php b/tests/simple/simple.php
index fc552fd..a6bf7f5 100644
--- a/tests/simple/simple.php
+++ b/tests/simple/simple.php
@@ -18,4 +18,3 @@ echo("resultaat: $result\n");
print_r($result);
-?>