summaryrefslogtreecommitdiff
path: root/Examples/test-suite/exception_order.i
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2009-08-18 20:56:02 +0000
committerLorry <lorry@roadtrain.codethink.co.uk>2012-09-25 16:59:08 +0000
commit9f8a09ed743cedd9547bf0661d518647966ab114 (patch)
tree9c7803d3b27a8ec22e91792ac7f7932efa128b20 /Examples/test-suite/exception_order.i
downloadswig-tarball-master.tar.gz
Imported from /srv/lorry/lorry-area/swig-tarball/swig-1.3.40.tar.gz.HEADswig-1.3.40master
Diffstat (limited to 'Examples/test-suite/exception_order.i')
-rw-r--r--Examples/test-suite/exception_order.i111
1 files changed, 111 insertions, 0 deletions
diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i
new file mode 100644
index 0000000..45a87e0
--- /dev/null
+++ b/Examples/test-suite/exception_order.i
@@ -0,0 +1,111 @@
+%module exception_order
+
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
+
+%include "exception.i"
+
+%{
+#if defined(_MSC_VER)
+ #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
+#endif
+%}
+
+/*
+ last resource, catch everything but don't override
+ user's throw declarations.
+*/
+
+#if defined(SWIGUTL)
+%exception {
+ try {
+ $action
+ } catch(...) {
+ SWIG_exception_fail(SWIG_RuntimeError,"postcatch unknown");
+ }
+}
+#else
+%exception {
+ try {
+ $action
+ } catch(...) {
+ SWIG_exception(SWIG_RuntimeError,"postcatch unknown");
+ }
+}
+#endif
+
+%catches(E1,E2*,ET<int>,ET<double>,...) A::barfoo(int i);
+
+
+%allowexception efoovar;
+%allowexception A::efoovar;
+
+%inline %{
+ int efoovar;
+ int foovar;
+ const int cfoovar = 1;
+
+ struct E1
+ {
+ };
+
+ struct E2
+ {
+ };
+
+ struct E3
+ {
+ };
+
+ template <class T>
+ struct ET
+ {
+ };
+
+ struct A
+ {
+ static int sfoovar;
+ static const int CSFOOVAR = 1;
+ int foovar;
+ int efoovar;
+
+ /* caught by the user's throw definition */
+ int foo() throw(E1)
+ {
+ throw E1();
+ return 0;
+ }
+
+ int bar() throw(E2)
+ {
+ throw E2();
+ return 0;
+ }
+
+ /* caught by %postexception */
+ int foobar()
+ {
+ throw E3();
+ return 0;
+ }
+
+
+ int barfoo(int i)
+ {
+ if (i == 1) {
+ throw E1();
+ } else if (i == 2) {
+ static E2 *ep = new E2();
+ throw ep;
+ } else if (i == 3) {
+ throw ET<int>();
+ } else {
+ throw ET<double>();
+ }
+ return 0;
+ }
+ };
+ int A::sfoovar = 1;
+%}
+
+%template(ET_i) ET<int>;
+%template(ET_d) ET<double>;