|
SWIG: std::string returned as reference - solution: msg#00130programming.swig
Nair, Sanjay S writes: > > I've written the following typemap to support returning string as > reference from c++ to perl. > > %typemap(in) std::string*, std::string& ($basetype string_temp) { > if (!SvPOK($input)) { > croak("Argument $argnum is not a string"); > } > $1 = &string_temp; > argvi++; > } > > %typemap(argout) std::string& OUTPUT { > sv_setpv( $input, (*$1).c_str() ); > } > > %apply std::string& OUTPUT { std::string& }; > > I've tested it under windows OS and Active perl. This seem to work fine. > Any one see any issue with this implementation please let me know? > This is different than most OUTPUT typemaps which do not modify their arguments. Use std::string &REFERENCE if you're going to do that (to be consistent with other typemaps that behave in the same way). -- Dave _______________________________________________ Swig maillist - Swig@xxxxxxxxxxxxxxx http://mailman.cs.uchicago.edu/mailman/listinfo/swig |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | SWIG: std::string returned as reference - solution: 00130, Nair, Sanjay S |
|---|---|
| Next by Date: | RE: SWIG: std::string returned as reference - solution: 00130, Nair, Sanjay S |
| Previous by Thread: | SWIG: std::string returned as reference - solutioni: 00130, Nair, Sanjay S |
| Next by Thread: | RE: SWIG: std::string returned as reference - solution: 00130, Nair, Sanjay S |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |