diff options
author | Alistair Delva <adelva@google.com> | 2024-04-10 14:15:29 -0700 |
---|---|---|
committer | Alistair Delva <adelva@google.com> | 2024-04-11 12:58:28 -0700 |
commit | d0f0f90be16c2ac553b5fa08512045273135147a (patch) | |
tree | 5d9ebb7a04807ea8a609ddd18b0162bc87530e4b /Lib/exception.i | |
parent | 6ffc1dbf29ba98c4d8aa71ebc9b484e973fe1030 (diff) | |
download | swig-master.tar.gz |
Change-Id: I47cef2be94299220d80265d949a95b58eee2c23b
Diffstat (limited to 'Lib/exception.i')
-rw-r--r-- | Lib/exception.i | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/exception.i b/Lib/exception.i index ee9ce9bc6..1c00fb3a1 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -12,10 +12,15 @@ %insert("runtime") "swigerrors.swg" -#ifdef SWIGPHP7 +#ifdef SWIGPHP %{ -#include "zend_exceptions.h" -#define SWIG_exception(code, msg) do { zend_throw_exception(NULL, (char*)msg, code); goto thrown; } while (0) +#define SWIG_exception(code, msg) do { zend_throw_exception( \ + code == SWIG_TypeError ? zend_ce_type_error : \ + code == SWIG_ValueError ? zend_ce_value_error : \ + code == SWIG_DivisionByZero ? zend_ce_division_by_zero_error : \ + code == SWIG_SyntaxError ? zend_ce_parse_error : \ + code == SWIG_OverflowError ? zend_ce_arithmetic_error : \ + NULL, msg, code); SWIG_fail; } while (0) %} #endif @@ -24,9 +29,8 @@ SWIGINTERN void SWIG_exception_ (int code, const char *msg, const char *subr) { #define ERROR(scmerr) \ - scm_error(scm_from_locale_string((char *) (scmerr)), \ - (char *) subr, (char *) msg, \ - SCM_EOL, SCM_BOOL_F) + scm_error(scm_from_locale_string(scmerr), \ + subr, msg, SCM_EOL, SCM_BOOL_F) #define MAP(swigerr, scmerr) \ case swigerr: \ ERROR(scmerr); \ |