From 36b1e5c2ac8b508517ddf4fb41a3b3f08f166130 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 6 Jan 2006 13:58:10 +0000 Subject: [PATCH] cosmetic changes removing unnecessary brackets and empty lines in generated code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8251 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/csharp.swg | 41 +++++++++--------- Lib/csharp/enums.swg | 18 ++++---- Lib/csharp/enumsimple.swg | 18 ++++---- Lib/csharp/enumtypesafe.swg | 18 ++++---- Lib/csharp/std_string.i | 24 +++++------ Lib/java/enums.swg | 14 +++---- Lib/java/enumsimple.swg | 14 +++---- Lib/java/enumtypesafe.swg | 14 +++---- Lib/java/enumtypeunsafe.swg | 14 +++---- Lib/java/java.swg | 65 ++++++++++++++-------------- Lib/java/std_string.i | 84 ++++++++++++++++++------------------- 11 files changed, 150 insertions(+), 174 deletions(-) diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 34c6da407..0b12245d3 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -147,7 +147,7 @@ const float & ($*1_ltype temp), const double & ($*1_ltype temp) %{ temp = ($*1_ltype)$input; -$1 = &temp; %} + $1 = &temp; %} %typemap(out) const bool & %{ $result = *$1; %} %typemap(out) const char & %{ $result = *$1; %} @@ -167,14 +167,14 @@ $1 = &temp; %} /* Default handling. Object passed by value. Convert to a pointer */ %typemap(in, canthrow=1) SWIGTYPE ($&1_type argp) %{ argp = ($&1_ltype)$input; - if (!argp) { - SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); - return $null; - } - $1 = *argp; %} + if (!argp) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0); + return $null; + } + $1 = *argp; %} %typemap(out) SWIGTYPE #ifdef __cplusplus -%{$result = new $1_ltype(($1_ltype &)$1); %} +%{ $result = new $1_ltype(($1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); @@ -292,23 +292,20 @@ $1 = &temp; %} short, unsigned int, unsigned long, - unsigned short { - char error_msg[256]; - sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg); - return $null; -} + unsigned short +%{ char error_msg[256]; + sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1); + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg); + return $null; %} -%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] %{ - (void)$1; - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY] +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} -%typemap(throws, canthrow=1) char * %{ - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1); - return $null; -%} +%typemap(throws, canthrow=1) char * +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1); + return $null; %} /* Typemaps for code generation in proxy classes and C# type wrapper classes */ diff --git a/Lib/csharp/enums.swg b/Lib/csharp/enums.swg index 8c7b90a97..013c23a42 100644 --- a/Lib/csharp/enums.swg +++ b/Lib/csharp/enums.swg @@ -15,11 +15,10 @@ %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" -%typemap(throws, canthrow=1) const enum SWIGTYPE & %{ - (void)$1; - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws, canthrow=1) const enum SWIGTYPE & +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} %typemap(csin) const enum SWIGTYPE & "(int)$csinput" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { @@ -44,11 +43,10 @@ %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" -%typemap(throws, canthrow=1) enum SWIGTYPE %{ - (void)$1; - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws, canthrow=1) enum SWIGTYPE +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} %typemap(csin) enum SWIGTYPE "(int)$csinput" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { diff --git a/Lib/csharp/enumsimple.swg b/Lib/csharp/enumsimple.swg index a4b12e0e6..4350d9d22 100644 --- a/Lib/csharp/enumsimple.swg +++ b/Lib/csharp/enumsimple.swg @@ -17,11 +17,10 @@ %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" -%typemap(throws, canthrow=1) const enum SWIGTYPE & %{ - (void)$1; - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws, canthrow=1) const enum SWIGTYPE & +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} %typemap(csin) const enum SWIGTYPE & "$csinput" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { @@ -46,11 +45,10 @@ %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" -%typemap(throws, canthrow=1) enum SWIGTYPE %{ - (void)$1; - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws, canthrow=1) enum SWIGTYPE +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} %typemap(csin) enum SWIGTYPE "$csinput" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { diff --git a/Lib/csharp/enumtypesafe.swg b/Lib/csharp/enumtypesafe.swg index f0d9f8635..55a9e2ce2 100644 --- a/Lib/csharp/enumtypesafe.swg +++ b/Lib/csharp/enumtypesafe.swg @@ -16,11 +16,10 @@ %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" -%typemap(throws, canthrow=1) const enum SWIGTYPE & %{ - (void)$1; - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws, canthrow=1) const enum SWIGTYPE & +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} %typemap(csin) const enum SWIGTYPE & "$csinput.swigValue" %typemap(csout, excode=SWIGEXCODE) const enum SWIGTYPE & { @@ -45,11 +44,10 @@ %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" -%typemap(throws, canthrow=1) enum SWIGTYPE %{ - (void)$1; - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws, canthrow=1) enum SWIGTYPE +%{ (void)$1; + SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown"); + return $null; %} %typemap(csin) enum SWIGTYPE "$csinput.swigValue" %typemap(csout, excode=SWIGEXCODE) enum SWIGTYPE { diff --git a/Lib/csharp/std_string.i b/Lib/csharp/std_string.i index 65432404f..e7b0e240a 100644 --- a/Lib/csharp/std_string.i +++ b/Lib/csharp/std_string.i @@ -30,8 +30,8 @@ class string; %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; - } - $1 = std::string($input); %} + } + $1 = std::string($input); %} %typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %} %typemap(csin) string "$csinput" @@ -52,10 +52,9 @@ class string; %typemap(typecheck) string = char *; -%typemap(throws, canthrow=1) string %{ - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); - return $null; -%} +%typemap(throws, canthrow=1) string +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); + return $null; %} // const string & %typemap(ctype) const string & "char *" @@ -66,9 +65,9 @@ class string; %{ if (!$input) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0); return $null; - } - std::string $1_str($input); - $1 = &$1_str; %} + } + 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" @@ -89,10 +88,9 @@ class string; %typemap(typecheck) const string & = char *; -%typemap(throws, canthrow=1) const string & %{ - SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); - return $null; -%} +%typemap(throws, canthrow=1) const string & +%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str()); + return $null; %} } diff --git a/Lib/java/enums.swg b/Lib/java/enums.swg index f2f18b65e..1e5bcc1ed 100644 --- a/Lib/java/enums.swg +++ b/Lib/java/enums.swg @@ -24,10 +24,9 @@ %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" -%typemap(throws) const enum SWIGTYPE & %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput.swigValue()" %typemap(javaout) const enum SWIGTYPE & { @@ -50,10 +49,9 @@ %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" -%typemap(throws) enum SWIGTYPE %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput.swigValue()" %typemap(javaout) enum SWIGTYPE { diff --git a/Lib/java/enumsimple.swg b/Lib/java/enumsimple.swg index 9303e6988..8164836d4 100644 --- a/Lib/java/enumsimple.swg +++ b/Lib/java/enumsimple.swg @@ -24,10 +24,9 @@ %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" -%typemap(throws) const enum SWIGTYPE & %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput" %typemap(javaout) const enum SWIGTYPE & { @@ -50,10 +49,9 @@ %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" -%typemap(throws) enum SWIGTYPE %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput" %typemap(javaout) enum SWIGTYPE { diff --git a/Lib/java/enumtypesafe.swg b/Lib/java/enumtypesafe.swg index 41e987778..3e805550f 100644 --- a/Lib/java/enumtypesafe.swg +++ b/Lib/java/enumtypesafe.swg @@ -23,10 +23,9 @@ %typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & "" -%typemap(throws) const enum SWIGTYPE & %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput.swigValue()" %typemap(javaout) const enum SWIGTYPE & { @@ -48,10 +47,9 @@ %typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE "" -%typemap(throws) enum SWIGTYPE %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput.swigValue()" %typemap(javaout) enum SWIGTYPE { diff --git a/Lib/java/enumtypeunsafe.swg b/Lib/java/enumtypeunsafe.swg index ee359cfb3..2b5f73c09 100644 --- a/Lib/java/enumtypeunsafe.swg +++ b/Lib/java/enumtypeunsafe.swg @@ -24,10 +24,9 @@ %typecheck(SWIG_TYPECHECK_INT32) const enum SWIGTYPE & "" -%typemap(throws) const enum SWIGTYPE & %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) const enum SWIGTYPE & +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) const enum SWIGTYPE & "$javainput" %typemap(javaout) const enum SWIGTYPE & { @@ -50,10 +49,9 @@ %typecheck(SWIG_TYPECHECK_INT32) enum SWIGTYPE "" -%typemap(throws) enum SWIGTYPE %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); -%} +%typemap(throws) enum SWIGTYPE +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); %} %typemap(javain) enum SWIGTYPE "$javainput" %typemap(javaout) enum SWIGTYPE { diff --git a/Lib/java/java.swg b/Lib/java/java.swg index 78121f001..2c5b1379c 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -351,7 +351,15 @@ %typemap(javadirectorout) unsigned long long "$javacall" /* char * - treat as String */ -%typemap(in) char * { +%typemap(in, noblock=1) char * { + $1 = 0; + if ($input) { + $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); + if (!$1) return $null; + } +} + +%typemap(directorout, noblock=1) char * { $1 = 0; if ($input) { $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); @@ -359,24 +367,16 @@ } } -%typemap(directorout) char * { - $1 = 0; - if ($input) { - $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); - if (!$1) return $null; - } -} - -%typemap(directorin, descriptor="Ljava/lang/String;") char * { - $input = 0; +%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char * { + $input = 0; if ($1) { $input = JCALL1(NewStringUTF, jenv, $1); if (!$input) return $null; } } -%typemap(freearg) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } -%typemap(out) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } +%typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } +%typemap(out, noblock=1) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } %typemap(javadirectorin) char * "$jniinput" %typemap(javadirectorout) char * "$javacall" @@ -593,7 +593,7 @@ %typemap(out) SWIGTYPE #ifdef __cplusplus -%{*($&1_ltype*)(void *)&$result = new $1_ltype(($1_ltype &)$1); %} +%{ *($&1_ltype*)(void *)&$result = new $1_ltype(($1_ltype &)$1); %} #else { $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); @@ -637,7 +637,7 @@ %typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] "" /* char arrays - treat as String */ -%typemap(in) char[ANY], char[] { +%typemap(in, noblock=1) char[ANY], char[] { $1 = 0; if ($input) { $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); @@ -645,7 +645,7 @@ } } -%typemap(directorout) char[ANY], char[] { +%typemap(directorout, noblock=1) char[ANY], char[] { $1 = 0; if ($input) { $1 = ($1_ltype)JCALL2(GetStringUTFChars, jenv, $input, 0); @@ -653,7 +653,7 @@ } } -%typemap(directorin, descriptor="Ljava/lang/String;") char[ANY], char[] { +%typemap(directorin, descriptor="Ljava/lang/String;", noblock=1) char[ANY], char[] { $input = 0; if ($1) { $input = JCALL1(NewStringUTF, jenv, $1); @@ -662,8 +662,8 @@ } %typemap(argout) char[ANY], char[] "" -%typemap(freearg) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } -%typemap(out) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } +%typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); } +%typemap(out, noblock=1) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, $1); } %typemap(javadirectorin) char[ANY], char[] "$jniinput" %typemap(javadirectorout) char[ANY], char[] "$javacall" @@ -918,23 +918,20 @@ short, unsigned int, unsigned long, - 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; -} + 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; %} -%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] %{ - (void)$1; - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); - return $null; -%} +%typemap(throws) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [], SWIGTYPE [ANY] +%{ (void)$1; + SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown"); + return $null; %} -%typemap(throws) char * %{ - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); - return $null; -%} +%typemap(throws) char * +%{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1); + return $null; %} /* Typemaps for code generation in proxy classes and Java type wrapper classes */ diff --git a/Lib/java/std_string.i b/Lib/java/std_string.i index 086c49348..c24997416 100644 --- a/Lib/java/std_string.i +++ b/Lib/java/std_string.i @@ -30,24 +30,24 @@ class string; %typemap(javadirectorout) string "$javacall" %typemap(in) string -%{if(!$input) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); - return $null; - } - const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); - if (!$1_pstr) return $null; - $1 = std::string($1_pstr); - jenv->ReleaseStringUTFChars($input, $1_pstr); %} +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + $1 = std::string($1_pstr); + jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorout) string -%{if(!$input) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); - return $null; - } - const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); - if (!$1_pstr) return $null; - $1 = std::string($1_pstr); - jenv->ReleaseStringUTFChars($input, $1_pstr); %} +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + $1 = std::string($1_pstr); + jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") string %{ $input = jenv->NewStringUTF($1.c_str()); %} @@ -63,10 +63,9 @@ class string; %typemap(typecheck) string = char *; -%typemap(throws) string %{ - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); - return $null; -%} +%typemap(throws) string +%{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); + return $null; %} // const string & %typemap(jni) const string & "jstring" @@ -76,27 +75,27 @@ class string; %typemap(javadirectorout) const string & "$javacall" %typemap(in) const string & -%{if(!$input) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); - return $null; - } - const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); - if (!$1_pstr) return $null; - std::string $1_str($1_pstr); - $1 = &$1_str; - jenv->ReleaseStringUTFChars($input, $1_pstr); %} +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + std::string $1_str($1_pstr); + $1 = &$1_str; + jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string & -%{if(!$input) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); - return $null; - } - const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); - if (!$1_pstr) return $null; - /* possible thread/reentrant code problem */ - static std::string $1_str($1_pstr); - $1 = &$1_str; - jenv->ReleaseStringUTFChars($input, $1_pstr); %} +%{ if(!$input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null std::string"); + return $null; + } + const char *$1_pstr = (const char *)jenv->GetStringUTFChars($input, 0); + if (!$1_pstr) return $null; + /* possible thread/reentrant code problem */ + static std::string $1_str($1_pstr); + $1 = &$1_str; + jenv->ReleaseStringUTFChars($input, $1_pstr); %} %typemap(directorin,descriptor="Ljava/lang/String;") const string & %{ $input = jenv->NewStringUTF($1.c_str()); %} @@ -112,10 +111,9 @@ class string; %typemap(typecheck) const string & = char *; -%typemap(throws) const string & %{ - SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); - return $null; -%} +%typemap(throws) const string & +%{ SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1.c_str()); + return $null; %} }