From 562ad889354898d25f5d87b0600fc522a4a47de7 Mon Sep 17 00:00:00 2001 From: Toon Schoenmakers Date: Fri, 10 Jun 2016 10:49:58 +0200 Subject: [PATCH] Updated examples to the latest api --- Examples/CallPhpFunctions/callphpfunction.cpp | 2 +- Examples/CppClassesInPhp/cppclassinphp.cpp | 8 ++++---- Examples/DlUnrestricted/dlunrestricted.cpp | 2 +- Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp | 2 +- Examples/Exceptions/ExceptionThrow/exceptionThrow.cpp | 2 +- Examples/FunctionNoParameters/functionnoparameters.cpp | 2 +- Examples/FunctionReturnValue/functionreturnvalue.cpp | 2 +- Examples/FunctionVoid/functionvoid.cpp | 2 +- .../FunctionWithParameters/functionwithparameters.cpp | 10 +++++----- Examples/Globals/globals.cpp | 2 +- Examples/ReturnObject/main.cpp | 2 +- Examples/simple/simple.cpp | 8 ++++---- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Examples/CallPhpFunctions/callphpfunction.cpp b/Examples/CallPhpFunctions/callphpfunction.cpp index 9190065..db112c7 100644 --- a/Examples/CallPhpFunctions/callphpfunction.cpp +++ b/Examples/CallPhpFunctions/callphpfunction.cpp @@ -42,7 +42,7 @@ extern "C" static Php::Extension extension("call_php_function","1.0"); // add function to extension - extension.add("call_php_function", call_php_function, { + extension.add("call_php_function", { Php::ByVal("addFunc", Php::Type::Callable), Php::ByVal("x", Php::Type::Numeric) }); diff --git a/Examples/CppClassesInPhp/cppclassinphp.cpp b/Examples/CppClassesInPhp/cppclassinphp.cpp index 9a4e130..22ed4b8 100644 --- a/Examples/CppClassesInPhp/cppclassinphp.cpp +++ b/Examples/CppClassesInPhp/cppclassinphp.cpp @@ -131,15 +131,15 @@ extern "C" Php::Class customClass("MyClass"); // add methods to it - customClass.method("myMethod", &MyCustomClass::myMethod, Php::Final, {}); - customClass.method("myMethod2", &MyCustomClass::myMethod); + customClass.method<&MyCustomClass::myMethod>("myMethod", Php::Final, {}); + customClass.method<&MyCustomClass::myMethod>("myMethod2"); customClass.property("property1", "prop1"); customClass.property("property2", "prop2", Php::Protected); - customClass.method("loopArray", &MyCustomClass::loop, { + customClass.method<&MyCustomClass::loop>("loopArray", { Php::ByVal("arr", Php::Type::Array) }); - customClass.method("loopObject", &MyCustomClass::loop, { + customClass.method<&MyCustomClass::loop>("loopObject", { Php::ByVal("obj", Php::Type::Object) }); diff --git a/Examples/DlUnrestricted/dlunrestricted.cpp b/Examples/DlUnrestricted/dlunrestricted.cpp index a7ec7ed..a64c118 100644 --- a/Examples/DlUnrestricted/dlunrestricted.cpp +++ b/Examples/DlUnrestricted/dlunrestricted.cpp @@ -51,7 +51,7 @@ extern "C" { static Php::Extension myExtension("dl_unrestricted", "1.0"); // the extension has one method - myExtension.add("dl_unrestricted", dl_unrestricted, { + myExtension.add("dl_unrestricted", { Php::ByVal("pathname", Php::Type::String) }); diff --git a/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp b/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp index 9efdf93..9168d47 100644 --- a/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp +++ b/Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp @@ -56,7 +56,7 @@ extern "C" static Php::Extension extension("my_exception_catch","1.0"); // add function to extension - extension.add("my_catch_exception_function", my_catch_exception_function); + extension.add("my_catch_exception_function"); // return the extension module return extension.module(); diff --git a/Examples/Exceptions/ExceptionThrow/exceptionThrow.cpp b/Examples/Exceptions/ExceptionThrow/exceptionThrow.cpp index d104047..998ea0d 100644 --- a/Examples/Exceptions/ExceptionThrow/exceptionThrow.cpp +++ b/Examples/Exceptions/ExceptionThrow/exceptionThrow.cpp @@ -37,7 +37,7 @@ extern "C" static Php::Extension extension("my_exception_throw","1.0"); // add function to extension - extension.add("my_throw_exception_function", my_throw_exception_function); + extension.add("my_throw_exception_function"); // return the extension module return extension.module(); diff --git a/Examples/FunctionNoParameters/functionnoparameters.cpp b/Examples/FunctionNoParameters/functionnoparameters.cpp index d41b681..56ddff0 100644 --- a/Examples/FunctionNoParameters/functionnoparameters.cpp +++ b/Examples/FunctionNoParameters/functionnoparameters.cpp @@ -35,7 +35,7 @@ extern "C" static Php::Extension extension("my_function_no_parameters","1.0"); // add function to extension - extension.add("my_no_parameters_function", my_no_parameters_function); + extension.add("my_no_parameters_function"); // return the extension module return extension.module(); diff --git a/Examples/FunctionReturnValue/functionreturnvalue.cpp b/Examples/FunctionReturnValue/functionreturnvalue.cpp index a107fe7..5d2c006 100644 --- a/Examples/FunctionReturnValue/functionreturnvalue.cpp +++ b/Examples/FunctionReturnValue/functionreturnvalue.cpp @@ -35,7 +35,7 @@ extern "C" static Php::Extension extension("my_function_return_value","1.0"); // add function to extension - extension.add("my_return_value_function", my_return_value_function); + extension.add("my_return_value_function"); // return the extension module return extension.module(); diff --git a/Examples/FunctionVoid/functionvoid.cpp b/Examples/FunctionVoid/functionvoid.cpp index 91b7bb3..e2a3768 100644 --- a/Examples/FunctionVoid/functionvoid.cpp +++ b/Examples/FunctionVoid/functionvoid.cpp @@ -35,7 +35,7 @@ extern "C" static Php::Extension extension("my_function_void","1.0"); // add function to extension - extension.add("my_void_function", my_function_void); + extension.add("my_void_function"); // return the extension module return extension.module(); diff --git a/Examples/FunctionWithParameters/functionwithparameters.cpp b/Examples/FunctionWithParameters/functionwithparameters.cpp index 2600bad..12fed94 100644 --- a/Examples/FunctionWithParameters/functionwithparameters.cpp +++ b/Examples/FunctionWithParameters/functionwithparameters.cpp @@ -95,26 +95,26 @@ extern "C" static Php::Extension extension("my_function_with_parameters","1.0"); // add function, with undefined parameters, to extension - extension.add("my_with_undefined_parameters_function", my_with_undefined_parameters_function); + extension.add("my_with_undefined_parameters_function"); // add function, with defined numeric parameters, to extension - extension.add("my_with_defined_parameters_function", my_with_defined_parameters_function, { + extension.add("my_with_defined_parameters_function", { Php::ByVal("x", Php::Type::Numeric), Php::ByVal("y", Php::Type::Numeric) }); // add function, with defined parameter by reference, to extension - extension.add("my_with_defined_parameters_reference_function", my_with_defined_parameters_reference_function, { + extension.add("my_with_defined_parameters_reference_function", { Php::ByRef("string", Php::Type::String) }); // add function, with defined array parameter, to extension - extension.add("my_with_defined_array_parameters_function", my_with_defined_array_parameters_function, { + extension.add("my_with_defined_array_parameters_function", { Php::ByVal("array", Php::Type::Array) }); // add function, with defined object parameter, to extension - extension.add("my_with_defined_object_parameters_function", my_with_defined_object_parameters_function, { + extension.add("my_with_defined_object_parameters_function", { Php::ByVal("myClassObjVar", "MyPhpClass") }); diff --git a/Examples/Globals/globals.cpp b/Examples/Globals/globals.cpp index 98bcfd8..1812acf 100644 --- a/Examples/Globals/globals.cpp +++ b/Examples/Globals/globals.cpp @@ -58,7 +58,7 @@ extern "C" static Php::Extension extension("globals","1.0"); // add function to extension - extension.add("process_globals", process_globals); + extension.add("process_globals"); // return the extension module return extension.module(); diff --git a/Examples/ReturnObject/main.cpp b/Examples/ReturnObject/main.cpp index 6ad3552..96fb4ec 100644 --- a/Examples/ReturnObject/main.cpp +++ b/Examples/ReturnObject/main.cpp @@ -25,7 +25,7 @@ extern "C" { Php::Class child("child"); // the master class has one method - to return a child - master.method("child", &Master::child); + master.method<&Master::child>("child"); // add all classes to the extension extension.add(master); diff --git a/Examples/simple/simple.cpp b/Examples/simple/simple.cpp index bfbcfab..d9836ab 100644 --- a/Examples/simple/simple.cpp +++ b/Examples/simple/simple.cpp @@ -160,19 +160,19 @@ extern "C" static Php::Extension extension("simple","1.0"); // define the functions - extension.add("my_plus", my_plus, { + extension.add("my_plus", { Php::ByVal("a", Php::Type::Numeric), Php::ByVal("b", Php::Type::Numeric), Php::ByVal("c", "MyClass"), Php::ByRef("d", Php::Type::String) }); - extension.add("bubblesort", bubblesort); + extension.add("bubblesort"); // define classes Php::Class myCustomClass("my_class"); - myCustomClass.method("mymethod", &MyCustomClass::myMethod); - myCustomClass.method("__construct", &MyCustomClass::__construct); + myCustomClass.method<&MyCustomClass::myMethod>("mymethod"); + myCustomClass.method<&MyCustomClass::__construct>("__construct"); // add to extension extension.add(myCustomClass);