annotate lib/swig/swigwin-2.0.11/Lib/std_except.i @ 1983:5cd26f2c6904

small fix
author Ritor1
date Fri, 01 Nov 2013 17:29:49 +0600
parents b3009adc0e2f
children
rev   line source
1899
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
1 /* -----------------------------------------------------------------------------
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
2 * std_except.i
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
3 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
4 * SWIG library file with typemaps to handle and throw STD exceptions in a
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
5 * language and STL independent way, i.e., the target language doesn't
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
6 * require to support STL but only the 'exception.i' mechanism.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
7 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
8 * These typemaps are used when methods are declared with an STD
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
9 * exception specification, such as
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
10 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
11 * size_t at() const throw (std::out_of_range);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
12 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
13 * The typemaps here are based on the language independent
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
14 * 'exception.i' library. If that is working in your target language,
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
15 * this file will work.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
16 *
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
17 * If the target language doesn't implement a robust 'exception.i'
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
18 * mechanism, or you prefer other ways to map the STD exceptions, write
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
19 * a new std_except.i file in the target library directory.
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
20 * ----------------------------------------------------------------------------- */
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
21
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
22 #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL) || defined(SWIGD)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
23 #error "This version of std_except.i should not be used"
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
24 #endif
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
25
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
26 %{
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
27 #include <stdexcept>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
28 %}
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
29
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
30 %include <exception.i>
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
31
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
32
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
33 %define %std_exception_map(Exception, Code)
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
34 %typemap(throws,noblock=1) Exception {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
35 SWIG_exception(Code, $1.what());
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
36 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
37 %ignore Exception;
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
38 struct Exception {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
39 };
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
40 %enddef
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
41
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
42 namespace std {
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
43 %std_exception_map(bad_exception, SWIG_SystemError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
44 %std_exception_map(domain_error, SWIG_ValueError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
45 %std_exception_map(exception, SWIG_SystemError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
46 %std_exception_map(invalid_argument, SWIG_ValueError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
47 %std_exception_map(length_error, SWIG_IndexError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
48 %std_exception_map(logic_error, SWIG_RuntimeError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
49 %std_exception_map(out_of_range, SWIG_IndexError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
50 %std_exception_map(overflow_error, SWIG_OverflowError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
51 %std_exception_map(range_error, SWIG_OverflowError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
52 %std_exception_map(runtime_error, SWIG_RuntimeError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
53 %std_exception_map(underflow_error, SWIG_OverflowError);
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
54 }
b3009adc0e2f Adding swig, gitignore, hgignore
Nomad
parents:
diff changeset
55