|
From: Mark D. <Mar...@sl...> - 2006-10-31 00:28:00
|
Hi
I guess (but my C++ knowledge is limited) because the return is
a string reference (const string &), so they need to keep a copy
around (which one in the c++ code hopefully copies away).
Regards
Mark
On Oct 30, 2006, at 4:10 PM, Sohail Somani wrote:
>> -----Original Message-----
>> From: swi...@li...
>> [mailto:swi...@li...] On Behalf Of
>> Mark Donszelmann
>
>>
>>
>> %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MS
>> G) 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);
>> $result = &$1_str;
>> jenv->ReleaseStringUTFChars($input, $1_pstr); %}
>
> Unrelated to your post (sorry), but why is that using static?!!! It
> appears to be alright to just use a stack variable in this case...
>
> TIA!
>
> Sohail
|