diff --git a/Lib/perl5/exception.i b/Lib/perl5/exception.i index 0246cfde8..1e80d96d5 100644 --- a/Lib/perl5/exception.i +++ b/Lib/perl5/exception.i @@ -1 +1,5 @@ %include + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg);)) +} diff --git a/Lib/python/exception.i b/Lib/python/exception.i index 0246cfde8..bb0b15c9d 100644 --- a/Lib/python/exception.i +++ b/Lib/python/exception.i @@ -1 +1,6 @@ %include + + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg); SWIG_fail; )) +} diff --git a/Lib/ruby/exception.i b/Lib/ruby/exception.i index 0246cfde8..1e80d96d5 100644 --- a/Lib/ruby/exception.i +++ b/Lib/ruby/exception.i @@ -1 +1,5 @@ %include + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg);)) +} diff --git a/Lib/ruby/ruby.swg b/Lib/ruby/ruby.swg index d2330e543..5ad5adcf1 100644 --- a/Lib/ruby/ruby.swg +++ b/Lib/ruby/ruby.swg @@ -5,8 +5,9 @@ * ------------------------------------------------------------ */ /* ------------------------------------------------------------ - * The Ruby global rename rules + * The Ruby auto rename rules * ------------------------------------------------------------ */ +#if defined(SWIG_RUBY_AUTORENAME) /* Class names are CamelCase */ %rename("%(camelcase)s", %isclass) ""; @@ -16,7 +17,8 @@ /* Method names should be changed so that they are lower_case_with_underscores */ -%rename("%(undercase)s", %isfunction, %ismember) ""; +%rename("%(undercase)s", %isfunction, %ismember) ""; +#endif /* ------------------------------------------------------------ * Inner macros diff --git a/Lib/tcl/exception.i b/Lib/tcl/exception.i index 0246cfde8..4d22797cc 100644 --- a/Lib/tcl/exception.i +++ b/Lib/tcl/exception.i @@ -1 +1,6 @@ %include + + +%insert("runtime") { + %define_as(SWIG_exception(code, msg), %block(%error(code, msg); return TCL_ERROR;)) +} diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index 96eb1598d..5a4e2ac0b 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -67,7 +67,7 @@ */ #ifndef %attribute_exception -#define %attribute_exception(code,msg) SWIG_exception(code,msg) +#define %attribute_exception(code,msg) SWIG_exception_fail(code,msg) #endif // diff --git a/Lib/typemaps/exception.swg b/Lib/typemaps/exception.swg index cc8b1e6ad..e79564529 100644 --- a/Lib/typemaps/exception.swg +++ b/Lib/typemaps/exception.swg @@ -19,8 +19,7 @@ %insert("runtime") { - %define_as(SWIG_exception(code, msg), - %block(%error(code, msg); SWIG_fail)) + %define_as(SWIG_exception_fail(code, msg), %block(%error(code, msg); SWIG_fail)) %define_as(SWIG_contract_assert(expr, msg), if (!(expr)) { %error(SWIG_RuntimeError, msg); SWIG_fail; } else) @@ -41,7 +40,7 @@ } SWIG_CATCH_STDEXCEPT // catch std::exception catch (...) { - SWIG_exception(SWIG_UnknownError, "Unknown exception"); + SWIG_exception_fail(SWIG_UnknownError, "Unknown exception"); } } */ @@ -51,27 +50,27 @@ %define SWIG_CATCH_STDEXCEPT /* catching std::exception */ catch (std::invalid_argument& e) { - SWIG_exception(SWIG_ValueError, e.what() ); + SWIG_exception_fail(SWIG_ValueError, e.what() ); } catch (std::domain_error& e) { - SWIG_exception(SWIG_ValueError, e.what() ); + SWIG_exception_fail(SWIG_ValueError, e.what() ); } catch (std::overflow_error& e) { - SWIG_exception(SWIG_OverflowError, e.what() ); + SWIG_exception_fail(SWIG_OverflowError, e.what() ); } catch (std::out_of_range& e) { - SWIG_exception(SWIG_IndexError, e.what() ); + SWIG_exception_fail(SWIG_IndexError, e.what() ); } catch (std::length_error& e) { - SWIG_exception(SWIG_IndexError, e.what() ); + SWIG_exception_fail(SWIG_IndexError, e.what() ); } catch (std::runtime_error& e) { - SWIG_exception(SWIG_RuntimeError, e.what() ); + SWIG_exception_fail(SWIG_RuntimeError, e.what() ); } catch (std::exception& e) { - SWIG_exception(SWIG_SystemError, e.what() ); + SWIG_exception_fail(SWIG_SystemError, e.what() ); } %enddef %define SWIG_CATCH_UNKNOWN catch (std::exception& e) { - SWIG_exception(SWIG_SystemError, e.what() ); + SWIG_exception_fail(SWIG_SystemError, e.what() ); } catch (...) { - SWIG_exception(SWIG_UnknownError, "unknown exception"); + SWIG_exception_fail(SWIG_UnknownError, "unknown exception"); } %enddef diff --git a/Lib/typemaps/std_except.swg b/Lib/typemaps/std_except.swg index f04d8b937..3ce479a50 100644 --- a/Lib/typemaps/std_except.swg +++ b/Lib/typemaps/std_except.swg @@ -12,7 +12,7 @@ %exceptionclass Exception; #if !defined(SWIG_STD_EXCEPTIONS_AS_CLASSES) %typemap(throws,noblock=1) Exception { - SWIG_exception(Code, $1.what()); + SWIG_exception_fail(Code, $1.what()); } %ignore Exception; struct Exception { diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index cb88276be..e911b26a5 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -439,7 +439,7 @@ } %typemap(throws,noblock=1) (...) { - SWIG_exception(SWIG_RuntimeError,"unknown exception"); + SWIG_exception_fail(SWIG_RuntimeError,"unknown exception"); } /* ------------------------------------------------------------ diff --git a/Lib/typemaps/swigtypemaps.swg b/Lib/typemaps/swigtypemaps.swg index 7f5a7b015..5ec1c7f5d 100644 --- a/Lib/typemaps/swigtypemaps.swg +++ b/Lib/typemaps/swigtypemaps.swg @@ -133,10 +133,10 @@ #define %error_block(Block...) %block(Block) #define %default_code(code) ((code != SWIG_ERROR) ? code : SWIG_TypeError) -#define %argument_fail(code, type, name, argn) SWIG_exception(%default_code(code), %argfail_fmt(type, name, argn)) -#define %argument_nullref(type, name, argn) SWIG_exception(SWIG_ValueError, %argnullref_fmt(type, name, argn)) -#define %variable_fail(code, type, name) SWIG_exception(%default_code(code), %varfail_fmt(type, name)) -#define %variable_nullref(type, name) SWIG_exception(SWIG_ValueError, %varnullref_fmt(type, name)) +#define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn)) +#define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn)) +#define %variable_fail(code, type, name) SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name)) +#define %variable_nullref(type, name) SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name)) #if defined(SWIG_DIRECTOR_TYPEMAPS) #define %dirout_fail(code, type) SWIG_DirOutFail(%default_code(code), %outfail_fmt(type))