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@5018 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
255f6cae9e
commit
4c995939ca
1 changed files with 5 additions and 10 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue