Skip to content

Commit

Permalink
Updated examples to the latest api
Browse files Browse the repository at this point in the history
  • Loading branch information
Toon Schoenmakers committed Jun 10, 2016
1 parent 7b58cff commit 562ad88
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Examples/CallPhpFunctions/callphpfunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("call_php_function", {
Php::ByVal("addFunc", Php::Type::Callable),
Php::ByVal("x", Php::Type::Numeric)
});
Expand Down
8 changes: 4 additions & 4 deletions Examples/CppClassesInPhp/cppclassinphp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ extern "C"
Php::Class<MyCustomClass> 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)
});

Expand Down
2 changes: 1 addition & 1 deletion Examples/DlUnrestricted/dlunrestricted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("dl_unrestricted", {
Php::ByVal("pathname", Php::Type::String)
});

Expand Down
2 changes: 1 addition & 1 deletion Examples/Exceptions/ExceptionCatch/exceptionCatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("my_catch_exception_function");

// return the extension module
return extension.module();
Expand Down
2 changes: 1 addition & 1 deletion Examples/Exceptions/ExceptionThrow/exceptionThrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("my_throw_exception_function");

// return the extension module
return extension.module();
Expand Down
2 changes: 1 addition & 1 deletion Examples/FunctionNoParameters/functionnoparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("my_no_parameters_function");

// return the extension module
return extension.module();
Expand Down
2 changes: 1 addition & 1 deletion Examples/FunctionReturnValue/functionreturnvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("my_return_value_function");

// return the extension module
return extension.module();
Expand Down
2 changes: 1 addition & 1 deletion Examples/FunctionVoid/functionvoid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_function_void>("my_void_function");

// return the extension module
return extension.module();
Expand Down
10 changes: 5 additions & 5 deletions Examples/FunctionWithParameters/functionwithparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("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>("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>("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>("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>("my_with_defined_object_parameters_function", {
Php::ByVal("myClassObjVar", "MyPhpClass")
});

Expand Down
2 changes: 1 addition & 1 deletion Examples/Globals/globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("process_globals");

// return the extension module
return extension.module();
Expand Down
2 changes: 1 addition & 1 deletion Examples/ReturnObject/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {
Php::Class<Child> 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);
Expand Down
8 changes: 4 additions & 4 deletions Examples/simple/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>("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>("bubblesort");

// define classes
Php::Class<MyCustomClass> 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);
Expand Down

0 comments on commit 562ad88

Please sign in to comment.