From 578829d48e9eadf8d29bcf847cb09e90940d36cc Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Wed, 1 Sep 2004 22:23:05 +0000 Subject: [PATCH] add std_except.i git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6203 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/python/std_excepttest.i | 22 +++++++ SWIG/Lib/python/std_except.i | 63 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 SWIG/Examples/test-suite/python/std_excepttest.i create mode 100644 SWIG/Lib/python/std_except.i diff --git a/SWIG/Examples/test-suite/python/std_excepttest.i b/SWIG/Examples/test-suite/python/std_excepttest.i new file mode 100644 index 000000000..79ae1039b --- /dev/null +++ b/SWIG/Examples/test-suite/python/std_excepttest.i @@ -0,0 +1,22 @@ +%module std_execpt + +%include "std_except.i" + + +%inline %{ + struct E1 : public std::exception + { + }; + + struct E2 + { + }; + + struct Test { + + int foo1() throw(std::exception) { return 0; } + int foo2() throw(std::logic_error) { return 0; } + int foo3() throw(E1) { return 0; } + int foo4() throw(E2) { return 0; } + }; +%} \ No newline at end of file diff --git a/SWIG/Lib/python/std_except.i b/SWIG/Lib/python/std_except.i new file mode 100644 index 000000000..af812d8b0 --- /dev/null +++ b/SWIG/Lib/python/std_except.i @@ -0,0 +1,63 @@ +%include +%include + +%{ +#include +%} + +namespace std { + struct exception + { + virtual ~exception() throw(); + virtual const char* what() const throw(); + }; + + struct bad_exception : exception + { + }; + + struct logic_error : exception + { + explicit logic_error(const string& msg); + }; + + struct domain_error : logic_error + { + explicit domain_error(const string& msg); + }; + + struct invalid_argument : logic_error + { + explicit invalid_argument(const string& msg); + }; + + struct length_error : logic_error + { + explicit length_error(const string& msg); + }; + + struct out_of_range : logic_error + { + explicit out_of_range(const string& msg); + }; + + struct runtime_error : exception + { + explicit runtime_error(const string& msg); + }; + + struct range_error : runtime_error + { + explicit range_error(const string& msg); + }; + + struct overflow_error : runtime_error + { + explicit overflow_error(const string& msg); + }; + + struct underflow_error : runtime_error + { + explicit underflow_error(const string& msg); + }; +}