Home | History | Annotate | Download | only in go
      1 /* -----------------------------------------------------------------------------
      2  * std_string.i
      3  *
      4  * Typemaps for std::string and const std::string&
      5  * These are mapped to a Go string and are passed around by value.
      6  *
      7  * To use non-const std::string references use the following %apply.  Note
      8  * that they are passed by value.
      9  * %apply const std::string & {std::string &};
     10  * ----------------------------------------------------------------------------- */
     11 
     12 %{
     13 #include <string>
     14 %}
     15 
     16 namespace std {
     17 
     18 %naturalvar string;
     19 
     20 class string;
     21 
     22 %typemap(gotype) string, const string & "string"
     23 
     24 %typemap(in) string
     25 %{ $1.assign($input.p, $input.n); %}
     26 
     27 %typemap(directorout) string
     28 %{ $result.assign($input.p, $input.n); %}
     29 
     30 %typemap(out) string
     31 %{ $result = _swig_makegostring($1.data(), $1.length()); %}
     32 
     33 %typemap(directorin) string
     34 %{ $input = _swig_makegostring($1.data(), $1.length()); %}
     35 
     36 %typemap(in) const string &
     37 %{
     38   $*1_ltype $1_str($input.p, $input.n);
     39   $1 = &$1_str;
     40 %}
     41 
     42 %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
     43 %{
     44   static $*1_ltype $1_str;
     45   $1_str.assign($input.p, $input.n);
     46   $result = &$1_str;
     47 %}
     48 
     49 %typemap(out) const string &
     50 %{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}
     51 
     52 %typemap(directorin) const string &
     53 %{ $input = _swig_makegostring($1.data(), $1.length()); %}
     54 
     55 }
     56