diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/exception.cpp | 18 | ||||
-rw-r--r-- | src/function.cpp | 12 | ||||
-rw-r--r-- | src/includes.h | 4 | ||||
-rwxr-xr-x | src/libphpcpp.so | bin | 132258 -> 132689 bytes |
4 files changed, 31 insertions, 3 deletions
diff --git a/src/exception.cpp b/src/exception.cpp new file mode 100644 index 0000000..f60f27c --- /dev/null +++ b/src/exception.cpp @@ -0,0 +1,18 @@ +/** + * Exception.cpp + * Implementation of Php Exceptions. + * + * @author Jasper van Eck <jasper.vaneck@copernica.com> + * @copyright 2013 Copernica BV + */ + +#include "includes.h" + +/** + * Set up namespace + */ +namespace Php { + + + +} diff --git a/src/function.cpp b/src/function.cpp index a4b3fdd..ef9cf78 100644 --- a/src/function.cpp +++ b/src/function.cpp @@ -37,8 +37,16 @@ void invoke_function(INTERNAL_FUNCTION_PARAMETERS) // construct parameters Parameters params(this_ptr, ZEND_NUM_ARGS()); - // get the result - result = function->invoke(*PHPCPP_G(environment), params); + // the function could throw an exception + try + { + // get the result + result = function->invoke(*PHPCPP_G(environment), params); + } + catch (Php::Exception &exception) + { + zend_throw_exception(zend_exception_get_default(), (char*)exception.message().c_str(), 0 TSRMLS_CC); + } } /** diff --git a/src/includes.h b/src/includes.h index 87b5d64..ac99950 100644 --- a/src/includes.h +++ b/src/includes.h @@ -17,6 +17,7 @@ #include <map> #include <memory> #include <set> +#include <exception> // for debugging #include <iostream> @@ -25,7 +26,7 @@ * PHP includes */ #include <php.h> - +#include "zend_exceptions.h" /** * Macro to convert results to success status */ @@ -55,6 +56,7 @@ #include "../include/class.h" #include "../include/classinfo.h" #include "../include/extension.h" +#include "../include/exception.h" #include "../include/globals.h" /** diff --git a/src/libphpcpp.so b/src/libphpcpp.so Binary files differindex 2c5827d..2b81ba7 100755 --- a/src/libphpcpp.so +++ b/src/libphpcpp.so |