We do the same thing here, we just use basic in/out typemaps. E.g.
%typemap(out) YString { $result = PyString_FromString((char *)static_cast<const char *>($1)); } %typemap(in) const YString & { $1 = new YString(PyString_AsString($input)); } -----Original Message----- From: Alexey Sokolov [mailto:ale...@asokolov.org] Sent: Thursday, May 24, 2012 2:46 PM To: swig-u...@lists.sourceforge.net; 672...@bugs.debian.org Subject: [Swig-user] Using own string class Hello! At ZNC we have an own string class CString, which is inherited from std::string. The goal is to use it as a just string in target languages. How to do that properly? When I was writing modperl and modpython ZNC modules, I used an approach described at http://old.nabble.com/Forward-declaration-error--td24064356.html Used "swig -E" on std_string.i, got a long file as a result, cleaned it up and changed all occurences of std::string to CString. It worked fine before SWIG 2.0.5, but in 2.0.5 it started to give errors while generating sources for modpython: /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (directorout) std::pair< CString,CString > = std::pair< CString,CString > &DIRECTOROUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (in) std::pair< CString,CString > *INPUT = std::pair< CString,CString > *INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (in) std::pair< CString,CString > &INPUT = std::pair< CString,CString > &INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (typecheck) std::pair< CString,CString > *INPUT = std::pair< CString,CString > *INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (typecheck) std::pair< CString,CString > &INPUT = std::pair< CString,CString > &INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (argout) std::pair< CString,CString > *OUTPUT = std::pair< CString,CString > *INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (argout) std::pair< CString,CString > &OUTPUT = std::pair< CString,CString > &INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (typecheck) std::pair< CString,CString > *INPUT = std::pair< CString,CString > *INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (typecheck) std::pair< CString,CString > &INPUT = std::pair< CString,CString > &INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (freearg) std::pair< CString,CString > *INPUT = std::pair< CString,CString > *INOUT /usr/share/swig/2.0.6/std/std_pair.i:31: Error: Can't copy typemap (freearg) std::pair< CString,CString > &INPUT = std::pair< CString,CString > &INOUT Sending copy of the letter to 672...@bugs.debian.org Also there is related issue #174 on github/znc. -- Best regards, Alexey "DarthGandalf" Sokolov 'Like' us on Facebook for exclusive content and other resources on all Barracuda Networks solutions. Visit http://barracudanetworks.com/facebook