PageRenderTime 52ms CodeModel.GetById 47ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Lib/std_except.i

#
Swig | 58 lines | 28 code | 7 blank | 23 comment | 0 complexity | b99891cc8edffc673aa99ad1dc2ceb68 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 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 * std_except.i
 6 *
 7 * SWIG library file with typemaps to handle and throw STD exceptions in a
 8 * language and STL independent way, i.e., the target language doesn't
 9 * require to support STL but only the 'exception.i' mechanism.
10 *
11 * These typemaps are used when methods are declared with an STD
12 * exception specification, such as
13 *
14 *   size_t at() const throw (std::out_of_range);
15 *
16 * The typemaps here are based on the language independent
17 * 'exception.i' library. If that is working in your target language,
18 * this file will work.
19 * 
20 * If the target language doesn't implement a robust 'exception.i'
21 * mechanism, or you prefer other ways to map the STD exceptions, write
22 * a new std_except.i file in the target library directory.
23 * ----------------------------------------------------------------------------- */
24
25#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL)
26#error "This version of std_except.i should not be used"
27#endif
28
29%{
30#include <stdexcept>
31%}
32
33%include <exception.i>
34
35
36%define %std_exception_map(Exception, Code)
37  %typemap(throws,noblock=1) Exception {
38    SWIG_exception(Code, $1.what());
39  }
40  %ignore Exception;
41  struct Exception {
42  };
43%enddef
44
45namespace std {
46  %std_exception_map(bad_exception,      SWIG_SystemError);
47  %std_exception_map(domain_error,       SWIG_ValueError);
48  %std_exception_map(exception,          SWIG_SystemError);
49  %std_exception_map(invalid_argument,   SWIG_ValueError);
50  %std_exception_map(length_error,       SWIG_IndexError);
51  %std_exception_map(logic_error,        SWIG_RuntimeError);
52  %std_exception_map(out_of_range,       SWIG_IndexError);
53  %std_exception_map(overflow_error,     SWIG_OverflowError);
54  %std_exception_map(range_error,        SWIG_OverflowError);
55  %std_exception_map(runtime_error,      SWIG_RuntimeError);
56  %std_exception_map(underflow_error,    SWIG_OverflowError);
57}
58