From f2a45a16d7825e1268b979968e6c6527f4c1ba62 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Aug 2003 20:03:26 +0000 Subject: [PATCH] Support for throwing C# exceptions from C/C++: - throws typemaps implemented. - SWIGTYPE& and SWIGTYPE typemaps throw a NullReferenceException if a C# null is passed as a parameter git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5018 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/csharp.swg | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 5e4fa12cb..ad041b84e 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -180,8 +180,7 @@ $1 = &temp; %} %typemap(in) SWIGTYPE ($&1_type argp) %{ argp = *($&1_ltype*)&$input; if (!argp) { -// SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); - return $null; + SWIG_CSharpThrowException(SWIG_CSharpNullReferenceException, "Attempt to dereference null $1_type"); } $1 = *argp; %} %typemap(out) SWIGTYPE @@ -199,8 +198,7 @@ $1 = &temp; %} %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %} %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; if(!$1) { - //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); - return $null; + SWIG_CSharpThrowException(SWIG_CSharpNullReferenceException, "$1_type reference is null"); } %} %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %} @@ -300,18 +298,15 @@ $1 = &temp; %} unsigned short { char error_msg[256]; sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg); - return $null; + SWIG_CSharpThrowException(SWIG_CSharpException, error_msg); } %typemap(throws) SWIGTYPE { - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); - return $null; + SWIG_CSharpThrowException(SWIG_CSharpException, "C++ $1_type exception thrown"); } %typemap(throws) char * { - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); - return $null; + SWIG_CSharpThrowException(SWIG_CSharpException, $1); }