import source from 1.3.40
[external/swig.git] / Examples / test-suite / catches.i
1 %module catches
2
3 %{
4 #if defined(_MSC_VER)
5   #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
6 #endif
7 %}
8
9 %include <exception.i> // for throws(...) typemap
10
11 %catches(int, const char *, const ThreeException&) test_catches(int i);
12 %catches(int, ...) test_exception_specification(int i); // override the exception specification
13 %catches(...) test_catches_all(int i);
14
15 %inline %{
16 struct ThreeException {};
17 void test_catches(int i) {
18   if (i == 1) {
19     throw int(1);
20   } else if (i == 2) {
21     throw (const char *)"two";
22   } else if (i == 3) {
23     throw ThreeException();
24   }
25 }
26 void test_exception_specification(int i) throw(int, const char *, const ThreeException&) {
27   test_catches(i);
28 }
29 void test_catches_all(int i) {
30   test_catches(i);
31 }
32 %}
33