summaryrefslogtreecommitdiff
path: root/Lib/csharp/std_string.i
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2005-02-02 22:44:32 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2005-02-02 22:44:32 +0000
commitbac8f43f79c77660a94ba4d8b62103fe31efde26 (patch)
tree1343a145750ca906f635219b729fd5b2bfe2db25 /Lib/csharp/std_string.i
parentdf49ff9f1e63f107b96c90acbad57aabbbf657fa (diff)
downloadswig-bac8f43f79c77660a94ba4d8b62103fe31efde26.tar.gz
C# exception handling improvements - they are robust and don't leak anymore. Requires typemap modifications using attribute canthrow in any unmanaged code typemaps that throw an exception and excode attribute in csout and csconstruct typemaps.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6934 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/csharp/std_string.i')
-rw-r--r--Lib/csharp/std_string.i18
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/csharp/std_string.i b/Lib/csharp/std_string.i
index c8eb38bcd..e4cb26e0a 100644
--- a/Lib/csharp/std_string.i
+++ b/Lib/csharp/std_string.i
@@ -26,14 +26,15 @@ class string;
%typemap(imtype) string "string"
%typemap(cstype) string "string"
-%typemap(in) string
+%typemap(in, canthrow=1) string
%{ if (!$input) SWIG_CSharpThrowException(SWIG_CSharpNullReferenceException, "null string");
$1 = std::string($input); %}
%typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %}
%typemap(csin) string "$csinput"
-%typemap(csout) string {
- return $imcall;
+%typemap(csout, excode=SWIGEXCODE) string {
+ string ret = $imcall;$excode
+ return ret;
}
%typemap(csvarin) string %{
@@ -47,7 +48,7 @@ class string;
%typemap(typecheck) string = char *;
-%typemap(throws) string %{
+%typemap(throws, canthrow=1) string %{
SWIG_CSharpThrowException(SWIG_CSharpException, $1.c_str());
%}
@@ -56,15 +57,16 @@ class string;
%typemap(imtype) const string & "string"
%typemap(cstype) const string & "string"
-%typemap(in) const string &
+%typemap(in, canthrow=1) const string &
%{ if (!$input) SWIG_CSharpThrowException(SWIG_CSharpNullReferenceException, "null string");
std::string $1_str($input);
$1 = &$1_str; %}
%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
%typemap(csin) const string & "$csinput"
-%typemap(csout) const string & {
- return $imcall;
+%typemap(csout, excode=SWIGEXCODE) const string & {
+ string ret = $imcall;$excode
+ return ret;
}
%typemap(csvarin) const string & %{
@@ -78,7 +80,7 @@ class string;
%typemap(typecheck) const string & = char *;
-%typemap(throws) const string & %{
+%typemap(throws, canthrow=1) const string & %{
SWIG_CSharpThrowException(SWIG_CSharpException, $1.c_str());
%}