Merge pull request #793 from q-p/bad_cast
Add std::bad_cast to std_except.i
This commit is contained in:
commit
5b8e8fa107
12 changed files with 24 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ public class li_std_except_runme {
|
||||||
|
|
||||||
public static void Main() {
|
public static void Main() {
|
||||||
Test test = new Test();
|
Test test = new Test();
|
||||||
|
try { test.throw_bad_cast(); throw new Exception("throw_bad_cast failed"); } catch (InvalidCastException) {}
|
||||||
try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
|
try { test.throw_bad_exception(); throw new Exception("throw_bad_exception failed"); } catch (ApplicationException) {}
|
||||||
try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
|
try { test.throw_domain_error(); throw new Exception("throw_domain_error failed"); } catch (ApplicationException) {}
|
||||||
try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}
|
try { test.throw_exception(); throw new Exception("throw_exception failed"); } catch (ApplicationException) {}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
int foo3() throw(E1) { return 0; }
|
int foo3() throw(E1) { return 0; }
|
||||||
int foo4() throw(E2) { return 0; }
|
int foo4() throw(E2) { return 0; }
|
||||||
// all the STL exceptions...
|
// all the STL exceptions...
|
||||||
|
void throw_bad_cast() throw(std::bad_cast) { throw std::bad_cast(); }
|
||||||
void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); }
|
void throw_bad_exception() throw(std::bad_exception) { throw std::bad_exception(); }
|
||||||
void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); }
|
void throw_domain_error() throw(std::domain_error) { throw std::domain_error("oops"); }
|
||||||
void throw_exception() throw(std::exception) { throw std::exception(); }
|
void throw_exception() throw(std::exception) { throw std::exception(); }
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -16,6 +17,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws, canthrow=1) std::bad_cast "SWIG_CSharpSetPendingException(SWIG_CSharpInvalidCastException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::bad_exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::domain_error "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::exception "SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.what());\n return $null;"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -16,6 +17,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws, canthrow=1) std::bad_cast "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
%typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
%typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,7 @@ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
%define SWIG_CATCH_STDEXCEPT
|
%define SWIG_CATCH_STDEXCEPT
|
||||||
|
|
@ -274,6 +275,8 @@ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
|
||||||
SWIG_exception(SWIG_IndexError, e.what() );
|
SWIG_exception(SWIG_IndexError, e.what() );
|
||||||
} catch (std::runtime_error& e) {
|
} catch (std::runtime_error& e) {
|
||||||
SWIG_exception(SWIG_RuntimeError, e.what() );
|
SWIG_exception(SWIG_RuntimeError, e.what() );
|
||||||
|
} catch (std::bad_cast& e) {
|
||||||
|
SWIG_exception(SWIG_TypeError, e.what() );
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
SWIG_exception(SWIG_SystemError, e.what() );
|
SWIG_exception(SWIG_SystemError, e.what() );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -16,6 +17,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws) std::bad_cast %{_swig_gopanic($1.what());%}
|
||||||
%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%}
|
%typemap(throws) std::bad_exception %{_swig_gopanic($1.what());%}
|
||||||
%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%}
|
%typemap(throws) std::domain_error %{_swig_gopanic($1.what());%}
|
||||||
%typemap(throws) std::exception %{_swig_gopanic($1.what());%}
|
%typemap(throws) std::exception %{_swig_gopanic($1.what());%}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// TODO: STL exception handling
|
// TODO: STL exception handling
|
||||||
// Note that the generic std_except.i file did not work
|
// Note that the generic std_except.i file did not work
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -16,6 +17,7 @@ namespace std
|
||||||
struct exception {};
|
struct exception {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%typemap(throws) std::bad_cast "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
%typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
%typemap(throws) std::bad_exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
%typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
%typemap(throws) std::domain_error "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
%typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
%typemap(throws) std::exception "SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.what());\n return $null;"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
%include <exception.i>
|
%include <exception.i>
|
||||||
|
|
@ -27,6 +28,7 @@ namespace std
|
||||||
// normally objects which are thrown are returned to the interpreter as errors
|
// normally objects which are thrown are returned to the interpreter as errors
|
||||||
// (which potentially may have problems if they are not copied)
|
// (which potentially may have problems if they are not copied)
|
||||||
// therefore all classes based upon std::exception are converted to their strings & returned as errors
|
// therefore all classes based upon std::exception are converted to their strings & returned as errors
|
||||||
|
%typemap(throws) std::bad_cast "SWIG_exception(SWIG_TypeError, $1.what());"
|
||||||
%typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());"
|
%typemap(throws) std::bad_exception "SWIG_exception(SWIG_RuntimeError, $1.what());"
|
||||||
%typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());"
|
%typemap(throws) std::domain_error "SWIG_exception(SWIG_ValueError, $1.what());"
|
||||||
%typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());"
|
%typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -15,6 +16,10 @@ namespace std {
|
||||||
virtual const char* what() const throw();
|
virtual const char* what() const throw();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct bad_cast : exception
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
struct bad_exception : exception
|
struct bad_exception : exception
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
#include <typeinfo>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -40,6 +41,7 @@
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
%std_exception_map(bad_cast, SWIG_TypeError);
|
||||||
%std_exception_map(bad_exception, SWIG_SystemError);
|
%std_exception_map(bad_exception, SWIG_SystemError);
|
||||||
%std_exception_map(domain_error, SWIG_ValueError);
|
%std_exception_map(domain_error, SWIG_ValueError);
|
||||||
%std_exception_map(exception, SWIG_SystemError);
|
%std_exception_map(exception, SWIG_SystemError);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
%std_exception_map(bad_cast, SWIG_TypeError);
|
||||||
%std_exception_map(bad_exception, SWIG_SystemError);
|
%std_exception_map(bad_exception, SWIG_SystemError);
|
||||||
%std_exception_map(domain_error, SWIG_ValueError);
|
%std_exception_map(domain_error, SWIG_ValueError);
|
||||||
%std_exception_map(exception, SWIG_SystemError);
|
%std_exception_map(exception, SWIG_SystemError);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue