Support for throwing C# exceptions from C/C++

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5019 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-08-29 20:05:15 +00:00
commit dbb7096b05

View file

@ -268,4 +268,37 @@ static void _SWIG_exception(int code, const char *msg) {
%}
#endif
#ifdef SWIGCSHARP
%{
static void SWIG_exception(int code, const char *msg) {
SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpException;
switch(code) {
case SWIG_MemoryError:
exception_code = SWIG_CSharpOutOfMemoryException;
break;
case SWIG_IndexError:
exception_code = SWIG_CSharpIndexOutOfRangeException;
break;
case SWIG_DivisionByZero:
exception_code = SWIG_CSharpDivideByZeroException;
break;
case SWIG_ValueError:
exception_code = SWIG_CSharpArgumentOutOfRangeException;
break;
case SWIG_IOError:
case SWIG_RuntimeError:
case SWIG_TypeError:
case SWIG_OverflowError:
case SWIG_SyntaxError:
case SWIG_SystemError:
case SWIG_UnknownError:
default:
exception_code = SWIG_CSharpException;
break;
}
SWIG_CSharpThrowException(exception_code, msg);
}
%}
#endif // SWIGCSHARP
/* exception.i ends here */