From: Sohail S. <s.s...@fi...> - 2006-10-31 00:32:56
|
You're right... That is weird though.=20 > -----Original Message----- > From: Mark Donszelmann [mailto:Mar...@sl...]=20 > Sent: Monday, October 30, 2006 4:29 PM > To: Sohail Somani > Cc: swi...@li... > Subject: Re: [Swig-user] Generated code for std::string=20 > director seems wrong forjava... >=20 > Hi >=20 > 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). >=20 > Regards > Mark >=20 >=20 > On Oct 30, 2006, at 4:10 PM, Sohail Somani wrote: >=20 > >> -----Original Message----- > >> From: swi...@li... > >> [mailto:swi...@li...] On Behalf Of > >> Mark Donszelmann > > > >> > >> > >> %typemap(directorout,warning=3DSWIGWARN_TYPEMAP_THREAD_UNSAFE_MS > >> G) const string & > >> %{ if(!$input) { > >> SWIG_JavaThrowException(jenv, > >> SWIG_JavaNullPointerException, "null std::string$ > >> return $null; > >> } > >> const char *$1_pstr =3D (const char > >> *)jenv->GetStringUTFChars($input, 0); > >> if (!$1_pstr) return $null; > >> /* possible thread/reentrant code problem */ > >> static std::string $1_str($1_pstr); > >> $result =3D &$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 >=20 >=20 |