Added LocalRefGuard for wstrings
This commit is contained in:
parent
a147e7bf5a
commit
26293546a6
1 changed files with 14 additions and 12 deletions
|
|
@ -59,15 +59,16 @@ class wstring;
|
|||
jenv->ReleaseStringChars($input, $1_pstr);
|
||||
%}
|
||||
|
||||
%typemap(directorin,descriptor="Ljava/lang/String;") wstring {
|
||||
%typemap(directorin,descriptor="Ljava/lang/String;") wstring %{
|
||||
jsize $1_len = $1.length();
|
||||
jchar *conv_buf = new jchar[$1_len];
|
||||
jchar *$1_conv_buf = new jchar[$1_len];
|
||||
for (jsize i = 0; i < $1_len; ++i) {
|
||||
conv_buf[i] = (jchar)$1[i];
|
||||
$1_conv_buf[i] = (jchar)$1[i];
|
||||
}
|
||||
$input = jenv->NewString(conv_buf, $1_len);
|
||||
delete [] conv_buf;
|
||||
}
|
||||
$input = jenv->NewString($1_conv_buf, $1_len);
|
||||
Swig::LocalRefGuard $1_refguard(jenv, $input);
|
||||
delete [] $1_conv_buf;
|
||||
%}
|
||||
|
||||
%typemap(out) wstring
|
||||
%{jsize $1_len = $1.length();
|
||||
|
|
@ -136,15 +137,16 @@ class wstring;
|
|||
$result = &$1_str;
|
||||
jenv->ReleaseStringChars($input, $1_pstr); %}
|
||||
|
||||
%typemap(directorin,descriptor="Ljava/lang/String;") const wstring & {
|
||||
%typemap(directorin,descriptor="Ljava/lang/String;") const wstring & %{
|
||||
jsize $1_len = $1.length();
|
||||
jchar *conv_buf = new jchar[$1_len];
|
||||
jchar *$1_conv_buf = new jchar[$1_len];
|
||||
for (jsize i = 0; i < $1_len; ++i) {
|
||||
conv_buf[i] = (jchar)($1)[i];
|
||||
$1_conv_buf[i] = (jchar)($1)[i];
|
||||
}
|
||||
$input = jenv->NewString(conv_buf, $1_len);
|
||||
delete [] conv_buf;
|
||||
}
|
||||
$input = jenv->NewString($1_conv_buf, $1_len);
|
||||
Swig::LocalRefGuard $1_refguard(jenv, $input);
|
||||
delete [] $1_conv_buf;
|
||||
%}
|
||||
|
||||
%typemap(out) const wstring &
|
||||
%{jsize $1_len = $1->length();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue