From df2520e4b2c87e2302ee4c6cec1e672091efebfb Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Sun, 8 Sep 2013 16:26:11 -0700 Subject: Refactoring function class, and making it even more easy to directly enable native C functions in PHP --- tests/simple/simple.cpp | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/simple/simple.cpp b/tests/simple/simple.cpp index b0259ca..a33b220 100644 --- a/tests/simple/simple.cpp +++ b/tests/simple/simple.cpp @@ -25,8 +25,11 @@ static std::string my_concat(std::string &a, std::string &b) return a + b; } -Function f({"my_plus", my_plus}); - +class MyCustomFunction : public Php::Function +{ + + +}; // symbols are exported according to the "C" language extern "C" @@ -34,14 +37,25 @@ 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 PhpCpp::Extension extension("simple","1.0", { - {"my_plus", my_plus}, - {"my_concat", my_concat} - }); + 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()); + + cout << "c" << endl; + + // define classes +// extension.add("my_class", MyCustomClass()); // return the module entry - return extension.getEntry(); + return extension.module(); } } -- cgit v1.2.3