Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / share / swig / 1.3.26 / exception.i
CommitLineData
920dae64
AT
1//
2// exception.i
3// Dave Beazley
4// April 14, 1997
5//
6// This SWIG library file provides language independent exception handling
7
8%{
9#define SWIG_MemoryError 1
10#define SWIG_IOError 2
11#define SWIG_RuntimeError 3
12#define SWIG_IndexError 4
13#define SWIG_TypeError 5
14#define SWIG_DivisionByZero 6
15#define SWIG_OverflowError 7
16#define SWIG_SyntaxError 8
17#define SWIG_ValueError 9
18#define SWIG_SystemError 10
19#define SWIG_UnknownError 99
20%}
21
22#ifdef SWIGTCL8
23%{
24/* We cast from 'const char*' to 'char*' since TCL_VOLATILE ensure
25 that an internal copy of the strng will be stored.
26
27 NOTE: Later use const_cast<char*> via SWIG_const_cast or so.
28*/
29#define SWIG_exception(a,b) { Tcl_SetResult(interp,(char *)b,TCL_VOLATILE); SWIG_fail; }
30%}
31#else
32#ifdef SWIGTCL
33%{
34#define SWIG_exception(a,b) { Tcl_SetResult(interp,(char *)b,TCL_VOLATILE); return TCL_ERROR; }
35%}
36#endif
37#endif
38
39#ifdef SWIGPERL5
40%{
41#define SWIG_exception(a,b) SWIG_croak(b)
42%}
43#endif
44
45#ifdef SWIGPHP4
46%{
47/* We should make use of "code" if we can */
48#define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); }
49%}
50#endif
51
52#ifdef SWIGPYTHON
53%{
54SWIGINTERN void SWIG_exception_(int code, const char *msg) {
55 switch(code) {
56 case SWIG_MemoryError:
57 PyErr_SetString(PyExc_MemoryError,msg);
58 break;
59 case SWIG_IOError:
60 PyErr_SetString(PyExc_IOError,msg);
61 break;
62 case SWIG_RuntimeError:
63 PyErr_SetString(PyExc_RuntimeError,msg);
64 break;
65 case SWIG_IndexError:
66 PyErr_SetString(PyExc_IndexError,msg);
67 break;
68 case SWIG_TypeError:
69 PyErr_SetString(PyExc_TypeError,msg);
70 break;
71 case SWIG_DivisionByZero:
72 PyErr_SetString(PyExc_ZeroDivisionError,msg);
73 break;
74 case SWIG_OverflowError:
75 PyErr_SetString(PyExc_OverflowError,msg);
76 break;
77 case SWIG_SyntaxError:
78 PyErr_SetString(PyExc_SyntaxError,msg);
79 break;
80 case SWIG_ValueError:
81 PyErr_SetString(PyExc_ValueError,msg);
82 break;
83 case SWIG_SystemError:
84 PyErr_SetString(PyExc_SystemError,msg);
85 break;
86 default:
87 PyErr_SetString(PyExc_RuntimeError,msg);
88 break;
89 }
90}
91
92#define SWIG_exception(a,b) { SWIG_exception_(a,b); SWIG_fail; }
93%}
94#endif
95
96#ifdef SWIGGUILE
97%{
98 SWIGINTERN void SWIG_exception_ (int code, const char *msg,
99 const char *subr) {
100#define ERROR(scmerr) \
101 scm_error(gh_symbol2scm((char *) (scmerr)), \
102 (char *) subr, (char *) msg, \
103 SCM_EOL, SCM_BOOL_F)
104#define MAP(swigerr, scmerr) \
105 case swigerr: \
106 ERROR(scmerr); \
107 break
108 switch (code) {
109 MAP(SWIG_MemoryError, "swig-memory-error");
110 MAP(SWIG_IOError, "swig-io-error");
111 MAP(SWIG_RuntimeError, "swig-runtime-error");
112 MAP(SWIG_IndexError, "swig-index-error");
113 MAP(SWIG_TypeError, "swig-type-error");
114 MAP(SWIG_DivisionByZero, "swig-division-by-zero");
115 MAP(SWIG_OverflowError, "swig-overflow-error");
116 MAP(SWIG_SyntaxError, "swig-syntax-error");
117 MAP(SWIG_ValueError, "swig-value-error");
118 MAP(SWIG_SystemError, "swig-system-error");
119 default:
120 ERROR("swig-error");
121 }
122#undef ERROR
123#undef MAP
124 }
125
126#define SWIG_exception(a,b) SWIG_exception_(a, b, FUNC_NAME)
127%}
128#endif
129
130#ifdef SWIGMZSCHEME
131
132%{
133SWIGINTERN void SWIG_exception_ (int code, const char *msg) {
134#define ERROR(errname) \
135 scheme_signal_error(errname " (%s)", msg);
136#define MAP(swigerr, errname) \
137 case swigerr: \
138 ERROR(errname); \
139 break
140 switch (code) {
141 MAP(SWIG_MemoryError, "swig-memory-error");
142 MAP(SWIG_IOError, "swig-io-error");
143 MAP(SWIG_RuntimeError, "swig-runtime-error");
144 MAP(SWIG_IndexError, "swig-index-error");
145 MAP(SWIG_TypeError, "swig-type-error");
146 MAP(SWIG_DivisionByZero, "swig-division-by-zero");
147 MAP(SWIG_OverflowError, "swig-overflow-error");
148 MAP(SWIG_SyntaxError, "swig-syntax-error");
149 MAP(SWIG_ValueError, "swig-value-error");
150 MAP(SWIG_SystemError, "swig-system-error");
151 default:
152 ERROR("swig-error");
153 }
154#undef ERROR
155#undef MAP
156 }
157
158#define SWIG_exception(a,b) SWIG_exception_(a, b)
159%}
160#endif
161
162#ifdef SWIGJAVA
163%{
164SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
165 SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError;
166 switch(code) {
167 case SWIG_MemoryError:
168 exception_code = SWIG_JavaOutOfMemoryError;
169 break;
170 case SWIG_IOError:
171 exception_code = SWIG_JavaIOException;
172 break;
173 case SWIG_SystemError:
174 case SWIG_RuntimeError:
175 exception_code = SWIG_JavaRuntimeException;
176 break;
177 case SWIG_OverflowError:
178 case SWIG_IndexError:
179 exception_code = SWIG_JavaIndexOutOfBoundsException;
180 break;
181 case SWIG_DivisionByZero:
182 exception_code = SWIG_JavaArithmeticException;
183 break;
184 case SWIG_SyntaxError:
185 case SWIG_ValueError:
186 case SWIG_TypeError:
187 exception_code = SWIG_JavaIllegalArgumentException;
188 break;
189 case SWIG_UnknownError:
190 default:
191 exception_code = SWIG_JavaUnknownError;
192 break;
193 }
194 SWIG_JavaThrowException(jenv, exception_code, msg);
195}
196%}
197
198%define SWIG_exception(code, msg)
199{
200 SWIG_JavaException(jenv, code, msg);
201 return $null;
202}
203%enddef
204#endif // SWIGJAVA
205
206#ifdef SWIGOCAML
207%{
208#define OCAML_MSG_BUF_LEN 1024
209SWIGINTERN void SWIG_exception_(int code, const char *msg) {
210 char msg_buf[OCAML_MSG_BUF_LEN];
211 sprintf( msg_buf, "Exception(%d): %s\n", code, msg );
212 failwith( msg_buf );
213}
214#define SWIG_exception(a,b) SWIG_exception_((a),(b))
215%}
216#endif
217
218#ifdef SWIGRUBY
219%{
220SWIGINTERN void SWIG_exception_(int code, const char *msg) {
221 switch (code) {
222 case SWIG_MemoryError:
223 rb_raise(rb_eNoMemError, msg);
224 break;
225 case SWIG_IOError:
226 rb_raise(rb_eIOError, msg);
227 break;
228 case SWIG_RuntimeError:
229 rb_raise(rb_eRuntimeError, msg);
230 break;
231 case SWIG_IndexError:
232 rb_raise(rb_eIndexError, msg);
233 break;
234 case SWIG_TypeError:
235 rb_raise(rb_eTypeError, msg);
236 break;
237 case SWIG_DivisionByZero:
238 rb_raise(rb_eZeroDivError, msg);
239 break;
240 case SWIG_OverflowError:
241 rb_raise(rb_eRangeError, msg);
242 break;
243 case SWIG_SyntaxError:
244 rb_raise(rb_eSyntaxError, msg);
245 break;
246 case SWIG_ValueError:
247 rb_raise(rb_eArgError, msg);
248 break;
249 case SWIG_SystemError:
250 rb_raise(rb_eFatal, msg);
251 break;
252 case SWIG_UnknownError:
253 rb_raise(rb_eRuntimeError, msg);
254 break;
255 default:
256 break;
257 }
258}
259
260#define SWIG_exception(a, b) SWIG_exception_((a), (b))
261%}
262#endif
263
264#ifdef SWIGCHICKEN
265%{
266SWIGINTERN void SWIG_exception_(int code, const char *msg) {
267 C_word *a;
268 C_word scmmsg;
269 C_word list;
270
271 a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2));
272 scmmsg = C_string2 (&a, (char *) msg);
273 list = C_list(&a, 2, C_fix(code), scmmsg);
274 SWIG_ThrowException(list);
275}
276#define SWIG_exception(a,b) SWIG_exception_((a),(b))
277%}
278#endif
279
280#ifdef SWIGCSHARP
281%{
282SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
283 if (code == SWIG_ValueError) {
284 SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfRangeException;
285 SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0);
286 } else {
287 SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException;
288 switch(code) {
289 case SWIG_MemoryError:
290 exception_code = SWIG_CSharpOutOfMemoryException;
291 break;
292 case SWIG_IndexError:
293 exception_code = SWIG_CSharpIndexOutOfRangeException;
294 break;
295 case SWIG_DivisionByZero:
296 exception_code = SWIG_CSharpDivideByZeroException;
297 break;
298 case SWIG_IOError:
299 exception_code = SWIG_CSharpIOException;
300 break;
301 case SWIG_OverflowError:
302 exception_code = SWIG_CSharpOverflowException;
303 break;
304 case SWIG_RuntimeError:
305 case SWIG_TypeError:
306 case SWIG_SyntaxError:
307 case SWIG_SystemError:
308 case SWIG_UnknownError:
309 default:
310 exception_code = SWIG_CSharpApplicationException;
311 break;
312 }
313 SWIG_CSharpSetPendingException(exception_code, msg);
314 }
315}
316%}
317
318%define SWIG_exception(code, msg)
319{
320 SWIG_CSharpException(code, msg);
321 return $null;
322}
323%enddef
324#endif // SWIGCSHARP
325
326#ifdef SWIGLUA
327
328%{
329#define SWIG_exception(a,b)\
330{ lua_pushfstring(L,"%s:%s",#a,b);SWIG_fail; }
331%}
332
333#endif // SWIGLUA
334
335#ifdef __cplusplus
336/*
337 You can use the SWIG_CATCH_STDEXCEPT macro with the %exception
338 directive as follows:
339
340 %exception {
341 try {
342 $action
343 }
344 catch (my_except& e) {
345 ...
346 }
347 SWIG_CATCH_STDEXCEPT // catch std::exception
348 catch (...) {
349 SWIG_exception(SWIG_UnknownError, "Unknown exception");
350 }
351 }
352*/
353%{
354#include <stdexcept>
355%}
356%define SWIG_CATCH_STDEXCEPT
357 /* catching std::exception */
358 catch (std::invalid_argument& e) {
359 SWIG_exception(SWIG_ValueError, e.what() );
360 } catch (std::domain_error& e) {
361 SWIG_exception(SWIG_ValueError, e.what() );
362 } catch (std::overflow_error& e) {
363 SWIG_exception(SWIG_OverflowError, e.what() );
364 } catch (std::out_of_range& e) {
365 SWIG_exception(SWIG_IndexError, e.what() );
366 } catch (std::length_error& e) {
367 SWIG_exception(SWIG_IndexError, e.what() );
368 } catch (std::runtime_error& e) {
369 SWIG_exception(SWIG_RuntimeError, e.what() );
370 } catch (std::exception& e) {
371 SWIG_exception(SWIG_SystemError, e.what() );
372 }
373%enddef
374%define SWIG_CATCH_UNKNOWN
375 catch (std::exception& e) {
376 SWIG_exception(SWIG_SystemError, e.what() );
377 }
378 catch (...) {
379 SWIG_exception(SWIG_UnknownError, "unknown exception");
380 }
381%enddef
382
383
384#endif /* __cplusplus */
385
386/* exception.i ends here */