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 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ namespace std
|
|||
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::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;"
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ namespace std
|
|||
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::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;"
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
|
|||
}
|
||||
*/
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
%define SWIG_CATCH_STDEXCEPT
|
||||
|
|
@ -274,6 +275,8 @@ SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
|
|||
SWIG_exception(SWIG_IndexError, e.what() );
|
||||
} catch (std::runtime_error& e) {
|
||||
SWIG_exception(SWIG_RuntimeError, e.what() );
|
||||
} catch (std::bad_cast& e) {
|
||||
SWIG_exception(SWIG_TypeError, e.what() );
|
||||
} catch (std::exception& e) {
|
||||
SWIG_exception(SWIG_SystemError, e.what() );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ namespace std
|
|||
struct exception {};
|
||||
}
|
||||
|
||||
%typemap(throws) std::bad_cast %{_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::exception %{_swig_gopanic($1.what());%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// TODO: STL exception handling
|
||||
// Note that the generic std_except.i file did not work
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ namespace std
|
|||
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::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;"
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
%include <exception.i>
|
||||
|
|
@ -27,6 +28,7 @@ namespace std
|
|||
// normally objects which are thrown are returned to the interpreter as errors
|
||||
// (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
|
||||
%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::domain_error "SWIG_exception(SWIG_ValueError, $1.what());"
|
||||
%typemap(throws) std::exception "SWIG_exception(SWIG_SystemError, $1.what());"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#endif
|
||||
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
|
@ -15,6 +16,10 @@ namespace std {
|
|||
virtual const char* what() const throw();
|
||||
};
|
||||
|
||||
struct bad_cast : exception
|
||||
{
|
||||
};
|
||||
|
||||
struct bad_exception : exception
|
||||
{
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#endif
|
||||
|
||||
%{
|
||||
#include <typeinfo>
|
||||
#include <stdexcept>
|
||||
%}
|
||||
|
||||
|
|
@ -40,6 +41,7 @@
|
|||
%enddef
|
||||
|
||||
namespace std {
|
||||
%std_exception_map(bad_cast, SWIG_TypeError);
|
||||
%std_exception_map(bad_exception, SWIG_SystemError);
|
||||
%std_exception_map(domain_error, SWIG_ValueError);
|
||||
%std_exception_map(exception, SWIG_SystemError);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
%enddef
|
||||
|
||||
namespace std {
|
||||
%std_exception_map(bad_cast, SWIG_TypeError);
|
||||
%std_exception_map(bad_exception, SWIG_SystemError);
|
||||
%std_exception_map(domain_error, SWIG_ValueError);
|
||||
%std_exception_map(exception, SWIG_SystemError);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue