summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-10-15 05:54:52 -0700
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-10-15 05:54:52 -0700
commit61ba30d716dab670a5f2ed0ee2f6650375b2058d (patch)
tree711db9359015de260071088ef027b020cd95d4b3 /tests
parentb2042dbd58c043ab49e9b0dbb51bf8516fe8cea8 (diff)
Calling custom member methods is now functional
Diffstat (limited to 'tests')
-rw-r--r--tests/simple/simple.cpp28
-rw-r--r--tests/simple/simple.php19
2 files changed, 36 insertions, 11 deletions
diff --git a/tests/simple/simple.cpp b/tests/simple/simple.cpp
index b3f30bc..e90fe55 100644
--- a/tests/simple/simple.cpp
+++ b/tests/simple/simple.cpp
@@ -23,8 +23,9 @@ using namespace std;
*/
static Php::Value my_plus(Php::Environment &env, Php::Parameters &params)
{
- string p1 = params[0];
- string p2 = params[1];
+ int p1 = params[0];
+ int p2 = params[1];
+ return p1 + p2;
cout << "global g1: " << env["g1"].stringValue() << endl;
cout << "global g2: " << env["g2"].stringValue() << endl;
@@ -53,6 +54,8 @@ public:
{
_x = 3;
cout << "MyCustomClass::MyCustomClass" << endl;
+ cout << this << endl;
+ cout << _x << endl;
}
virtual ~MyCustomClass()
@@ -72,6 +75,10 @@ public:
void myMethod(Php::Parameters &params)
{
+ cout << "myMethod GETS CALLED!!!!" << endl;
+ cout << this << endl;
+ cout << _x << endl;
+
}
};
@@ -86,17 +93,20 @@ extern "C"
// define the functions
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)
+ Php::ByVal("a", Php::longType),
+ Php::ByVal("b", Php::longType)
+// Php::ByVal("c", "MyClass"),
+// Php::ByRef("d", Php::stringType)
});
+ Php::Method<MyCustomClass> x(&MyCustomClass::myMethod);
+
// define classes
extension.add("my_class", Php::Class<MyCustomClass>({
-// Php::Public("a", 123),
-// Php::Protected("b", "abc"),
- Php::Public("myMethod", static_cast<Php::method_callback_1>(&MyCustomClass::myMethod))
+ Php::Public("a", 123),
+ Php::Protected("b", "abc"),
+ Php::Protected("myMethod", Php::Method<MyCustomClass>(&MyCustomClass::myMethod)),
+ Php::Public("__construct", Php::Method<MyCustomClass>(&MyCustomClass::__construct))
}));
// return the module entry
diff --git a/tests/simple/simple.php b/tests/simple/simple.php
index 379f285..345c139 100644
--- a/tests/simple/simple.php
+++ b/tests/simple/simple.php
@@ -34,8 +34,23 @@
if (class_exists("my_class")) echo("Warempel, de class bestaat\n");
-$x = new my_class();
-$x->myMethod();
+class my_extended_class extends my_class
+{
+ public function myMethod($val)
+ {
+ echo($this->a."\n");
+ echo($this->b."\n");
+ echo("hoi\n");
+
+ parent::myMethod($val);
+ }
+
+}
+
+$x = new my_extended_class();
+$x->myMethod(123);
+
+my_plus(1,2,3,4);
//echo("my_class::a = ".$x->a."\n");
//echo("my_class::b = ".$x->b."\n");