~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Lib/exception.i

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#ifdef SWIGTCL8
23
23
%{
24
 
#define SWIG_exception(a,b)   { Tcl_SetResult(interp,b,TCL_VOLATILE); SWIG_fail; }
 
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; }
25
30
%}
26
31
#else
27
32
#ifdef SWIGTCL
28
33
%{
29
 
#define SWIG_exception(a,b)   { Tcl_SetResult(interp,b,TCL_VOLATILE); return TCL_ERROR; }
 
34
#define SWIG_exception(a,b)   { Tcl_SetResult(interp,(char *)b,TCL_VOLATILE); return TCL_ERROR; }
30
35
%}
31
36
#endif
32
37
#endif
46
51
 
47
52
#ifdef SWIGPYTHON
48
53
%{
49
 
static void SWIG_exception_(int code, const char *msg) {
 
54
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
50
55
  switch(code) {
51
56
  case SWIG_MemoryError:
52
57
    PyErr_SetString(PyExc_MemoryError,msg);
90
95
 
91
96
#ifdef SWIGGUILE
92
97
%{
93
 
  static void SWIG_exception_ (int code, const char *msg,
 
98
  SWIGINTERN void SWIG_exception_ (int code, const char *msg,
94
99
                               const char *subr) {
95
100
#define ERROR(scmerr)                                   \
96
101
        scm_error(gh_symbol2scm((char *) (scmerr)),     \
125
130
#ifdef SWIGMZSCHEME
126
131
 
127
132
%{
128
 
  static void SWIG_exception_ (int code, const char *msg) {
 
133
SWIGINTERN void SWIG_exception_ (int code, const char *msg) {
129
134
#define ERROR(errname)                          \
130
135
        scheme_signal_error(errname " (%s)", msg);
131
136
#define MAP(swigerr, errname)                   \
156
161
 
157
162
#ifdef SWIGJAVA
158
163
%{
159
 
static void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
 
164
SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
160
165
  SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError;
161
166
  switch(code) {
162
167
  case SWIG_MemoryError:
188
193
  }
189
194
  SWIG_JavaThrowException(jenv, exception_code, msg);
190
195
}
191
 
#define SWIG_exception(code, msg) { SWIG_JavaException(jenv, code, msg); }
192
196
%}
 
197
 
 
198
%define SWIG_exception(code, msg)
 
199
{
 
200
  SWIG_JavaException(jenv, code, msg);
 
201
  return $null;
 
202
}
 
203
%enddef
193
204
#endif // SWIGJAVA
194
205
 
195
206
#ifdef SWIGOCAML
196
207
%{
197
208
#define OCAML_MSG_BUF_LEN 1024
198
 
static void SWIG_exception_(int code, const char *msg) {
 
209
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
199
210
  char msg_buf[OCAML_MSG_BUF_LEN];
200
211
  sprintf( msg_buf, "Exception(%d): %s\n", code, msg );
201
 
  failwith( msg_buf );  
 
212
  failwith( msg_buf );
202
213
}
203
214
#define SWIG_exception(a,b) SWIG_exception_((a),(b))
204
215
%}
206
217
 
207
218
#ifdef SWIGRUBY
208
219
%{
209
 
static void SWIG_exception_(int code, const char *msg) {
 
220
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
210
221
    switch (code) {
211
222
        case SWIG_MemoryError:
212
223
            rb_raise(rb_eNoMemError, msg);
252
263
 
253
264
#ifdef SWIGCHICKEN
254
265
%{
255
 
#define CHICKEN_MSG_BUF_LEN 1024
256
 
static void SWIG_exception_(int code, const char *msg) {
257
 
  char msg_buf[CHICKEN_MSG_BUF_LEN];
 
266
SWIGINTERN void SWIG_exception_(int code, const char *msg) {
258
267
  C_word *a;
259
268
  C_word scmmsg;
260
 
 
261
 
  sprintf (msg_buf, "Exception(%d): %.950s\n", code, msg);
262
 
 
263
 
  a = C_alloc (C_SIZEOF_STRING (strlen (msg_buf)));
264
 
  scmmsg = C_string2 (&a, msg_buf);
265
 
  C_halt (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);
266
275
}
267
276
#define SWIG_exception(a,b) SWIG_exception_((a),(b))
268
277
%}
270
279
 
271
280
#ifdef SWIGCSHARP
272
281
%{
273
 
static void SWIG_exception(int code, const char *msg) {
274
 
  SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpException;
275
 
  switch(code) {
276
 
  case SWIG_MemoryError:
277
 
    exception_code = SWIG_CSharpOutOfMemoryException;
278
 
    break;
279
 
  case SWIG_IndexError:
280
 
    exception_code = SWIG_CSharpIndexOutOfRangeException;
281
 
    break;
282
 
  case SWIG_DivisionByZero:
283
 
    exception_code = SWIG_CSharpDivideByZeroException;
284
 
    break;
285
 
  case SWIG_ValueError:
286
 
    exception_code = SWIG_CSharpArgumentOutOfRangeException;
287
 
    break;
288
 
  case SWIG_IOError:
289
 
  case SWIG_RuntimeError:
290
 
  case SWIG_TypeError:
291
 
  case SWIG_OverflowError:
292
 
  case SWIG_SyntaxError:
293
 
  case SWIG_SystemError:
294
 
  case SWIG_UnknownError:
295
 
  default:
296
 
    exception_code = SWIG_CSharpException;
297
 
    break;
 
282
SWIGINTERN 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);
298
314
  }
299
 
  SWIG_CSharpThrowException(exception_code, msg);
300
315
}
301
316
%}
 
317
 
 
318
%define SWIG_exception(code, msg)
 
319
{
 
320
  SWIG_CSharpException(code, msg);
 
321
  return $null;
 
322
}
 
323
%enddef
302
324
#endif // SWIGCSHARP
303
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
 
304
335
#ifdef __cplusplus
305
336
/*
306
337
  You can use the SWIG_CATCH_STDEXCEPT macro with the %exception
313
344
    catch (my_except& e) {
314
345
      ...
315
346
    }
316
 
    SWIG_CATCH_STDEXCEPT // catch std::exception 
 
347
    SWIG_CATCH_STDEXCEPT // catch std::exception
317
348
    catch (...) {
318
349
     SWIG_exception(SWIG_UnknownError, "Unknown exception");
319
350
    }
320
 
  }  
 
351
  }
321
352
*/
322
353
%{
323
354
#include <stdexcept>