diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-10-14 07:42:37 -0700 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2013-10-14 07:42:37 -0700 |
commit | b2042dbd58c043ab49e9b0dbb51bf8516fe8cea8 (patch) | |
tree | 25c7806d4c9d5fb237c0995b4bd12c4664bf853a /tests | |
parent | 53272534a76a9d8cbee4ee887e1f360c4a99728b (diff) |
Initial attempt to register native C++ class methods directly to PHP
Diffstat (limited to 'tests')
-rw-r--r-- | tests/simple/simple.cpp | 6 | ||||
-rw-r--r-- | tests/simple/simple.php | 75 |
2 files changed, 41 insertions, 40 deletions
diff --git a/tests/simple/simple.cpp b/tests/simple/simple.cpp index 8b50496..b3f30bc 100644 --- a/tests/simple/simple.cpp +++ b/tests/simple/simple.cpp @@ -72,7 +72,6 @@ public: void myMethod(Php::Parameters ¶ms) { - } }; @@ -95,8 +94,9 @@ extern "C" // define classes extension.add("my_class", Php::Class<MyCustomClass>({ - Php::Public("a", 123), - Php::Protected("b", "abc") +// Php::Public("a", 123), +// Php::Protected("b", "abc"), + Php::Public("myMethod", static_cast<Php::method_callback_1>(&MyCustomClass::myMethod)) })); // return the module entry diff --git a/tests/simple/simple.php b/tests/simple/simple.php index f9919be..379f285 100644 --- a/tests/simple/simple.php +++ b/tests/simple/simple.php @@ -1,47 +1,48 @@ <?php -class XXX -{ - public function __toString() - { - return "MyClass"; - } -} - -$myvar = "hoi"; - -class MyClass { - - public function __toString() - { - return "aksjdfhsdfkj"; - } -} - -$g1 = 123; -$g2 = "abc"; - -$result = my_plus(new MyClass(), array(), new MyClass(), $myvar, "blabla", new XXX()); - -echo("myvar = $myvar\n"); - -echo("resultaat: $result\n"); - -echo("g1: $g1\n"); -echo("g2: $g2\n"); -echo("g3: $g3\n"); +//class XXX +//{ +// public function __toString() +// { +// return "MyClass"; +// } +//} +// +//$myvar = "hoi"; +// +//class MyClass { +// +// public function __toString() +// { +// return "aksjdfhsdfkj"; +// } +//} +// +//$g1 = 123; +//$g2 = "abc"; +// +//$result = my_plus(new MyClass(), array(), new MyClass(), $myvar, "blabla", new XXX()); +// +//echo("myvar = $myvar\n"); +// +//echo("resultaat: $result\n"); +// +//echo("g1: $g1\n"); +//echo("g2: $g2\n"); +//echo("g3: $g3\n"); if (class_exists("my_class")) echo("Warempel, de class bestaat\n"); $x = new my_class(); - -echo("my_class::a = ".$x->a."\n"); -echo("my_class::b = ".$x->b."\n"); - -unset($x); - -echo("done\n"); +$x->myMethod(); + +//echo("my_class::a = ".$x->a."\n"); +//echo("my_class::b = ".$x->b."\n"); +// +//unset($x); +// +//echo("done\n"); //$x->my_method(); |