summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-25 14:59:58 -0700
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-25 14:59:58 -0700
commitffdaa0590d33ea89d116f6c56df2474cc0675ec9 (patch)
tree6b0d71337879892b43a4af90e6757d53ecc77853 /tests
parent753402a84b40ff4dc9697dea1d2d4aa037ea7624 (diff)
{auto} PHP objects can now be implemented in C++. Constructors and destructors get called at the appropriate time, but not yet any of the other methods
Diffstat (limited to 'tests')
-rw-r--r--tests/simple/simple.cpp30
-rw-r--r--tests/simple/simple.php13
2 files changed, 25 insertions, 18 deletions
diff --git a/tests/simple/simple.cpp b/tests/simple/simple.cpp
index 39e615a..e8558a0 100644
--- a/tests/simple/simple.cpp
+++ b/tests/simple/simple.cpp
@@ -51,26 +51,30 @@ private:
public:
MyCustomClass()
{
+ _x = 3;
+ cout << "MyCustomClass::MyCustomClass" << endl;
}
- virtual void __construct()
+ virtual ~MyCustomClass()
{
+ cout << "MyCustomClass::~MyCustomClass" << endl;
+ }
+
+ virtual void __construct()
+ {
+ cout << "MyCustomClass::__construct" << endl;
}
virtual void __destruct()
{
-
-
+ cout << "MyCustomClass::__destruct" << endl;
}
void myMethod(Php::Parameters &params)
{
-
-
- }
-
+ }
};
// symbols are exported according to the "C" language
@@ -84,12 +88,12 @@ extern "C"
// 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)
- });
-
+ Php::ByVal("a", Php::stringType),
+ Php::ByVal("b", Php::arrayType),
+ Php::ByVal("c", "MyClass"),
+ Php::ByRef("d", Php::stringType)
+ });
+
// define classes
extension.add("my_class", Php::Class<MyCustomClass>());
diff --git a/tests/simple/simple.php b/tests/simple/simple.php
index 10cb603..07e3f78 100644
--- a/tests/simple/simple.php
+++ b/tests/simple/simple.php
@@ -12,10 +12,10 @@ $myvar = "hoi";
class MyClass {
- public function __toString()
- {
- return "aksjdfhsdfkj";
- }
+ public function __toString()
+ {
+ return "aksjdfhsdfkj";
+ }
}
$g1 = 123;
@@ -35,7 +35,10 @@ echo("g3: $g3\n");
if (class_exists("my_class")) echo("Warempel, de class bestaat\n");
$x = new my_class();
+unset($x);
+
+echo("done\n");
-$x->my_method();
+//$x->my_method();