summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 09:54:14 -0700
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-10 09:54:14 -0700
commit37c38c70de43d9d9ee3c9f0e2f175e19bcc0b485 (patch)
tree29cf02cfabad5eb22306ac05eaee96efbdb79cd9 /tests
parent85507088051bdfabf8bc71346290949b78c3c914 (diff)
When registering functions, it now is also possible to specify the signature of the parameters
Diffstat (limited to 'tests')
-rw-r--r--tests/simple/simple.cpp28
-rw-r--r--tests/simple/simple.php10
2 files changed, 25 insertions, 13 deletions
diff --git a/tests/simple/simple.cpp b/tests/simple/simple.cpp
index 954bfa9..2ab177f 100644
--- a/tests/simple/simple.cpp
+++ b/tests/simple/simple.cpp
@@ -17,16 +17,8 @@ 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;
}
@@ -35,9 +27,15 @@ class MyCustomFunction : public Php::Function
public:
MyCustomFunction(const char *name) : Function(name) {}
+
};
+
+
+
+
+
// symbols are exported according to the "C" language
extern "C"
{
@@ -47,13 +45,19 @@ extern "C"
// create extension
static Php::Extension extension("simple","1.0");
- // define the functions
- extension.add("my_plus", my_plus);
- extension.add("my_concat", my_concat);
+ // define the functionsnm
+ extension.add("my_plus", my_plus, {
+ Php::ByVal("a", Php::stringType),
+ Php::ByVal("b", Php::arrayType),
+ Php::ByVal("c", "MyClass"),
+ Php::ByRef("d", Php::stringType)
+ });
+
+// extension.add("my_concat", my_concat);
extension.add(new MyCustomFunction("my_custom"));
// define classes
-// extension.add("my_class", MyCustomClass());
+// extension.add("my_class", MyCustomClass());
// return the module entry
return extension.module();
diff --git a/tests/simple/simple.php b/tests/simple/simple.php
index a6bf7f5..6f70a7a 100644
--- a/tests/simple/simple.php
+++ b/tests/simple/simple.php
@@ -10,7 +10,15 @@ class XXX
$myvar = "hoi";
-$result = my_plus($myvar, 1, 2, 3, "blabla", new XXX());
+class MyClass {
+
+ public function __toString()
+ {
+ return "aksjdfhsdfkj";
+ }
+}
+
+$result = my_plus(new MyClass(), array(), new MyClass(), $myvar, "blabla", new XXX());
echo("myvar = $myvar\n");