1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
//
// except.i
// Dave Beazley
// April 14, 1997
//
// This SWIG library file provides language independent exception handling
#ifdef AUTODOC
%section "Exception Handling Library",info,after,pre,nosort,skip=1,chop_left=3,chop_right=0,chop_top=0,chop_bottom=0
%text %{
%include exception.i
This library provides language independent support for raising scripting
language exceptions in SWIG generated wrapper code. Normally, this is
used in conjunction with the %except directive.
To raise an exception, use the following function call :
SWIG_exception(int exctype, char *msg);
'exctype' is an exception type code and may be one of the following :
SWIG_MemoryError
SWIG_IOError
SWIG_RuntimeError
SWIG_IndexError
SWIG_TypeError
SWIG_DivisionByZero
SWIG_OverflowError
SWIG_SyntaxError
SWIG_ValueError
SWIG_SystemError
SWIG_UnknownError
'msg' is an error string that should be reported to the user.
The library is normally used in conjunction with the %except directive
as follows :
%except {
try {
$function
} catch RangeError {
SWIG_exception(SWIG_IndexError,"Array index out of bounds");
} catch(...) {
SWIG_exception(SWIG_UnknownError,"Uncaught exception");
}
}
It is important to note that the SWIG_exception() function is only available
to the C code generated by SWIG. It is not available in the scripting language
interface itself.
%}
#endif
%{
#define SWIG_MemoryError 1
#define SWIG_IOError 2
#define SWIG_RuntimeError 3
#define SWIG_IndexError 4
#define SWIG_TypeError 5
#define SWIG_DivisionByZero 6
#define SWIG_OverflowError 7
#define SWIG_SyntaxError 8
#define SWIG_ValueError 9
#define SWIG_SystemError 10
#define SWIG_UnknownError 99
%}
#ifdef SWIGTCL8
%{
#define SWIG_exception(a,b) { Tcl_SetResult(interp,b,TCL_VOLATILE); return TCL_ERROR; }
%}
#else
#ifdef SWIGTCL
%{
#define SWIG_exception(a,b) { Tcl_SetResult(interp,b,TCL_VOLATILE); return TCL_ERROR; }
%}
#endif
#endif
#ifdef SWIGPERL5
%{
#define SWIG_exception(a,b) croak(b)
%}
#endif
#ifdef SWIGPERL4
%{
#define SWIG_exception(a,b) fatal(b)
%}
#endif
#ifdef SWIGPYTHON
%{
static void _SWIG_exception(int code, char *msg) {
switch(code) {
case SWIG_MemoryError:
PyErr_SetString(PyExc_MemoryError,msg);
break;
case SWIG_IOError:
PyErr_SetString(PyExc_IOError,msg);
break;
case SWIG_RuntimeError:
PyErr_SetString(PyExc_RuntimeError,msg);
break;
case SWIG_IndexError:
PyErr_SetString(PyExc_IndexError,msg);
break;
case SWIG_TypeError:
PyErr_SetString(PyExc_TypeError,msg);
break;
case SWIG_DivisionByZero:
PyErr_SetString(PyExc_ZeroDivisionError,msg);
break;
case SWIG_OverflowError:
PyErr_SetString(PyExc_OverflowError,msg);
break;
case SWIG_SyntaxError:
PyErr_SetString(PyExc_SyntaxError,msg);
break;
case SWIG_ValueError:
PyErr_SetString(PyExc_ValueError,msg);
break;
case SWIG_SystemError:
PyErr_SetString(PyExc_SystemError,msg);
break;
default:
PyErr_SetString(PyExc_RuntimeError,msg);
break;
}
}
#define SWIG_exception(a,b) { _SWIG_exception(a,b); return NULL; }
%}
#endif
#ifdef SWIGGUILE
%{
static void _SWIG_exception (int code, const char *msg,
const char *subr) {
#define ERROR(scmerr) \
scm_error(gh_symbol2scm((char *) (scmerr)), \
(char *) subr, (char *) msg, \
SCM_EOL, SCM_BOOL_F)
#define MAP(swigerr, scmerr) \
case swigerr: \
ERROR(scmerr); \
break
switch (code) {
MAP(SWIG_MemoryError, "swig-memory-error");
MAP(SWIG_IOError, "swig-io-error");
MAP(SWIG_RuntimeError, "swig-runtime-error");
MAP(SWIG_IndexError, "swig-index-error");
MAP(SWIG_TypeError, "swig-type-error");
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
MAP(SWIG_OverflowError, "swig-overflow-error");
MAP(SWIG_SyntaxError, "swig-syntax-error");
MAP(SWIG_ValueError, "swig-value-error");
MAP(SWIG_SystemError, "swig-system-error");
default:
ERROR("swig-error");
}
#undef ERROR
#undef MAP
}
#define SWIG_exception(a,b) _SWIG_exception(a, b, FUNC_NAME)
%}
#endif
#ifdef SWIGMZSCHEME
%{
static void _SWIG_exception (int code, const char *msg) {
#define ERROR(errname) \
scheme_signal_error(errname " (%s)", msg);
#define MAP(swigerr, errname) \
case swigerr: \
ERROR(errname); \
break
switch (code) {
MAP(SWIG_MemoryError, "swig-memory-error");
MAP(SWIG_IOError, "swig-io-error");
MAP(SWIG_RuntimeError, "swig-runtime-error");
MAP(SWIG_IndexError, "swig-index-error");
MAP(SWIG_TypeError, "swig-type-error");
MAP(SWIG_DivisionByZero, "swig-division-by-zero");
MAP(SWIG_OverflowError, "swig-overflow-error");
MAP(SWIG_SyntaxError, "swig-syntax-error");
MAP(SWIG_ValueError, "swig-value-error");
MAP(SWIG_SystemError, "swig-system-error");
default:
ERROR("swig-error");
}
#undef ERROR
#undef MAP
}
#define SWIG_exception(a,b) _SWIG_exception(a, b)
%}
#endif
#ifdef SWIGJAVA
%{
static void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError;
switch(code) {
case SWIG_MemoryError:
exception_code = SWIG_JavaOutOfMemoryError;
break;
case SWIG_IOError:
exception_code = SWIG_JavaIOException;
break;
case SWIG_SystemError:
case SWIG_RuntimeError:
exception_code = SWIG_JavaRuntimeException;
break;
case SWIG_OverflowError:
case SWIG_IndexError:
exception_code = SWIG_JavaIndexOutOfBoundsException;
break;
case SWIG_DivisionByZero:
exception_code = SWIG_JavaArithmeticException;
break;
case SWIG_SyntaxError:
case SWIG_ValueError:
case SWIG_TypeError:
exception_code = SWIG_JavaIllegalArgumentException;
break;
case SWIG_UnknownError:
default:
exception_code = SWIG_JavaUnknownError;
break;
}
SWIG_JavaThrowException(jenv, exception_code, msg);
}
#define SWIG_exception(code, msg) { SWIG_JavaException(jenv, code, msg); }
%}
#endif // SWIGJAVA
/* exception.i ends here */
|