OLD | NEW |
(Empty) | |
| 1 /* ----------------------------------------------------------------------------- |
| 2 * See the LICENSE file for information on copyright, usage and redistribution |
| 3 * of SWIG, and the README file for authors - http://www.swig.org/release.html. |
| 4 * |
| 5 * exception.i |
| 6 * |
| 7 * SWIG library file providing language independent exception handling |
| 8 * -----------------------------------------------------------------------------
*/ |
| 9 |
| 10 #if defined(SWIGUTL) |
| 11 #error "This version of exception.i should not be used" |
| 12 #endif |
| 13 |
| 14 |
| 15 %insert("runtime") "swigerrors.swg" |
| 16 |
| 17 |
| 18 #ifdef SWIGPHP |
| 19 %{ |
| 20 #if PHP_MAJOR_VERSION < 5 |
| 21 # define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); } |
| 22 #else |
| 23 # include "zend_exceptions.h" |
| 24 # define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code
TSRMLS_CC); } |
| 25 #endif |
| 26 %} |
| 27 #endif |
| 28 |
| 29 #ifdef SWIGGUILE |
| 30 %{ |
| 31 SWIGINTERN void SWIG_exception_ (int code, const char *msg, |
| 32 const char *subr) { |
| 33 #define ERROR(scmerr) \ |
| 34 scm_error(gh_symbol2scm((char *) (scmerr)), \ |
| 35 (char *) subr, (char *) msg, \ |
| 36 SCM_EOL, SCM_BOOL_F) |
| 37 #define MAP(swigerr, scmerr) \ |
| 38 case swigerr: \ |
| 39 ERROR(scmerr); \ |
| 40 break |
| 41 switch (code) { |
| 42 MAP(SWIG_MemoryError, "swig-memory-error"); |
| 43 MAP(SWIG_IOError, "swig-io-error"); |
| 44 MAP(SWIG_RuntimeError, "swig-runtime-error"); |
| 45 MAP(SWIG_IndexError, "swig-index-error"); |
| 46 MAP(SWIG_TypeError, "swig-type-error"); |
| 47 MAP(SWIG_DivisionByZero, "swig-division-by-zero"); |
| 48 MAP(SWIG_OverflowError, "swig-overflow-error"); |
| 49 MAP(SWIG_SyntaxError, "swig-syntax-error"); |
| 50 MAP(SWIG_ValueError, "swig-value-error"); |
| 51 MAP(SWIG_SystemError, "swig-system-error"); |
| 52 default: |
| 53 ERROR("swig-error"); |
| 54 } |
| 55 #undef ERROR |
| 56 #undef MAP |
| 57 } |
| 58 |
| 59 #define SWIG_exception(a,b) SWIG_exception_(a, b, FUNC_NAME) |
| 60 %} |
| 61 #endif |
| 62 |
| 63 #ifdef SWIGMZSCHEME |
| 64 |
| 65 %{ |
| 66 SWIGINTERN void SWIG_exception_ (int code, const char *msg) { |
| 67 #define ERROR(errname) \ |
| 68 scheme_signal_error(errname " (%s)", msg); |
| 69 #define MAP(swigerr, errname) \ |
| 70 case swigerr: \ |
| 71 ERROR(errname); \ |
| 72 break |
| 73 switch (code) { |
| 74 MAP(SWIG_MemoryError, "swig-memory-error"); |
| 75 MAP(SWIG_IOError, "swig-io-error"); |
| 76 MAP(SWIG_RuntimeError, "swig-runtime-error"); |
| 77 MAP(SWIG_IndexError, "swig-index-error"); |
| 78 MAP(SWIG_TypeError, "swig-type-error"); |
| 79 MAP(SWIG_DivisionByZero, "swig-division-by-zero"); |
| 80 MAP(SWIG_OverflowError, "swig-overflow-error"); |
| 81 MAP(SWIG_SyntaxError, "swig-syntax-error"); |
| 82 MAP(SWIG_ValueError, "swig-value-error"); |
| 83 MAP(SWIG_SystemError, "swig-system-error"); |
| 84 default: |
| 85 ERROR("swig-error"); |
| 86 } |
| 87 #undef ERROR |
| 88 #undef MAP |
| 89 } |
| 90 |
| 91 #define SWIG_exception(a,b) SWIG_exception_(a, b) |
| 92 %} |
| 93 #endif |
| 94 |
| 95 #ifdef SWIGJAVA |
| 96 %{ |
| 97 SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) { |
| 98 SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError; |
| 99 switch(code) { |
| 100 case SWIG_MemoryError: |
| 101 exception_code = SWIG_JavaOutOfMemoryError; |
| 102 break; |
| 103 case SWIG_IOError: |
| 104 exception_code = SWIG_JavaIOException; |
| 105 break; |
| 106 case SWIG_SystemError: |
| 107 case SWIG_RuntimeError: |
| 108 exception_code = SWIG_JavaRuntimeException; |
| 109 break; |
| 110 case SWIG_OverflowError: |
| 111 case SWIG_IndexError: |
| 112 exception_code = SWIG_JavaIndexOutOfBoundsException; |
| 113 break; |
| 114 case SWIG_DivisionByZero: |
| 115 exception_code = SWIG_JavaArithmeticException; |
| 116 break; |
| 117 case SWIG_SyntaxError: |
| 118 case SWIG_ValueError: |
| 119 case SWIG_TypeError: |
| 120 exception_code = SWIG_JavaIllegalArgumentException; |
| 121 break; |
| 122 case SWIG_UnknownError: |
| 123 default: |
| 124 exception_code = SWIG_JavaUnknownError; |
| 125 break; |
| 126 } |
| 127 SWIG_JavaThrowException(jenv, exception_code, msg); |
| 128 } |
| 129 %} |
| 130 |
| 131 #define SWIG_exception(code, msg)\ |
| 132 { SWIG_JavaException(jenv, code, msg); return $null; } |
| 133 #endif // SWIGJAVA |
| 134 |
| 135 #ifdef SWIGOCAML |
| 136 %{ |
| 137 #define OCAML_MSG_BUF_LEN 1024 |
| 138 SWIGINTERN void SWIG_exception_(int code, const char *msg) { |
| 139 char msg_buf[OCAML_MSG_BUF_LEN]; |
| 140 sprintf( msg_buf, "Exception(%d): %s\n", code, msg ); |
| 141 failwith( msg_buf ); |
| 142 } |
| 143 #define SWIG_exception(a,b) SWIG_exception_((a),(b)) |
| 144 %} |
| 145 #endif |
| 146 |
| 147 |
| 148 #ifdef SWIGCHICKEN |
| 149 %{ |
| 150 SWIGINTERN void SWIG_exception_(int code, const char *msg) { |
| 151 C_word *a; |
| 152 C_word scmmsg; |
| 153 C_word list; |
| 154 |
| 155 a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2)); |
| 156 scmmsg = C_string2 (&a, (char *) msg); |
| 157 list = C_list(&a, 2, C_fix(code), scmmsg); |
| 158 SWIG_ThrowException(list); |
| 159 } |
| 160 #define SWIG_exception(a,b) SWIG_exception_((a),(b)) |
| 161 %} |
| 162 #endif |
| 163 |
| 164 #ifdef SWIGCSHARP |
| 165 %{ |
| 166 SWIGINTERN void SWIG_CSharpException(int code, const char *msg) { |
| 167 if (code == SWIG_ValueError) { |
| 168 SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfR
angeException; |
| 169 SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0); |
| 170 } else { |
| 171 SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException; |
| 172 switch(code) { |
| 173 case SWIG_MemoryError: |
| 174 exception_code = SWIG_CSharpOutOfMemoryException; |
| 175 break; |
| 176 case SWIG_IndexError: |
| 177 exception_code = SWIG_CSharpIndexOutOfRangeException; |
| 178 break; |
| 179 case SWIG_DivisionByZero: |
| 180 exception_code = SWIG_CSharpDivideByZeroException; |
| 181 break; |
| 182 case SWIG_IOError: |
| 183 exception_code = SWIG_CSharpIOException; |
| 184 break; |
| 185 case SWIG_OverflowError: |
| 186 exception_code = SWIG_CSharpOverflowException; |
| 187 break; |
| 188 case SWIG_RuntimeError: |
| 189 case SWIG_TypeError: |
| 190 case SWIG_SyntaxError: |
| 191 case SWIG_SystemError: |
| 192 case SWIG_UnknownError: |
| 193 default: |
| 194 exception_code = SWIG_CSharpApplicationException; |
| 195 break; |
| 196 } |
| 197 SWIG_CSharpSetPendingException(exception_code, msg); |
| 198 } |
| 199 } |
| 200 %} |
| 201 |
| 202 #define SWIG_exception(code, msg)\ |
| 203 { SWIG_CSharpException(code, msg); return $null; } |
| 204 #endif // SWIGCSHARP |
| 205 |
| 206 #ifdef SWIGLUA |
| 207 |
| 208 %{ |
| 209 #define SWIG_exception(a,b)\ |
| 210 { lua_pushfstring(L,"%s:%s",#a,b);SWIG_fail; } |
| 211 %} |
| 212 |
| 213 #endif // SWIGLUA |
| 214 |
| 215 #ifdef __cplusplus |
| 216 /* |
| 217 You can use the SWIG_CATCH_STDEXCEPT macro with the %exception |
| 218 directive as follows: |
| 219 |
| 220 %exception { |
| 221 try { |
| 222 $action |
| 223 } |
| 224 catch (my_except& e) { |
| 225 ... |
| 226 } |
| 227 SWIG_CATCH_STDEXCEPT // catch std::exception |
| 228 catch (...) { |
| 229 SWIG_exception(SWIG_UnknownError, "Unknown exception"); |
| 230 } |
| 231 } |
| 232 */ |
| 233 %{ |
| 234 #include <stdexcept> |
| 235 %} |
| 236 %define SWIG_CATCH_STDEXCEPT |
| 237 /* catching std::exception */ |
| 238 catch (std::invalid_argument& e) { |
| 239 SWIG_exception(SWIG_ValueError, e.what() ); |
| 240 } catch (std::domain_error& e) { |
| 241 SWIG_exception(SWIG_ValueError, e.what() ); |
| 242 } catch (std::overflow_error& e) { |
| 243 SWIG_exception(SWIG_OverflowError, e.what() ); |
| 244 } catch (std::out_of_range& e) { |
| 245 SWIG_exception(SWIG_IndexError, e.what() ); |
| 246 } catch (std::length_error& e) { |
| 247 SWIG_exception(SWIG_IndexError, e.what() ); |
| 248 } catch (std::runtime_error& e) { |
| 249 SWIG_exception(SWIG_RuntimeError, e.what() ); |
| 250 } catch (std::exception& e) { |
| 251 SWIG_exception(SWIG_SystemError, e.what() ); |
| 252 } |
| 253 %enddef |
| 254 %define SWIG_CATCH_UNKNOWN |
| 255 catch (std::exception& e) { |
| 256 SWIG_exception(SWIG_SystemError, e.what() ); |
| 257 } |
| 258 catch (...) { |
| 259 SWIG_exception(SWIG_UnknownError, "unknown exception"); |
| 260 } |
| 261 %enddef |
| 262 |
| 263 /* rethrow the unknown exception */ |
| 264 |
| 265 #ifdef SWIGCSHARP |
| 266 %typemap(throws,noblock=1, canthrow=1) (...) { |
| 267 SWIG_exception(SWIG_RuntimeError,"unknown exception"); |
| 268 } |
| 269 #else |
| 270 %typemap(throws,noblock=1) (...) { |
| 271 SWIG_exception(SWIG_RuntimeError,"unknown exception"); |
| 272 } |
| 273 #endif |
| 274 |
| 275 #endif /* __cplusplus */ |
| 276 |
| 277 /* exception.i ends here */ |
OLD | NEW |