summaryrefslogtreecommitdiff
path: root/share/swig/2.0.11/go/std_string.i
blob: 9922fbe135a9bd8ee88843fcd84ef583c87a45ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* -----------------------------------------------------------------------------
 * std_string.i
 *
 * Typemaps for std::string and const std::string&
 * These are mapped to a Go string and are passed around by value.
 *
 * To use non-const std::string references use the following %apply.  Note 
 * that they are passed by value.
 * %apply const std::string & {std::string &};
 * ----------------------------------------------------------------------------- */

%{
#include <string>
%}

namespace std {

%naturalvar string;

class string;

%typemap(gotype) string, const string & "string"

%typemap(in) string
%{ $1.assign($input.p, $input.n); %}

%typemap(directorout) string
%{ $result.assign($input.p, $input.n); %}

%typemap(out) string
%{ $result = _swig_makegostring($1.data(), $1.length()); %}

%typemap(directorin) string
%{ $input = _swig_makegostring($1.data(), $1.length()); %}

%typemap(in) const string &
%{
  $*1_ltype $1_str($input.p, $input.n);
  $1 = &$1_str;
%}

%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
%{
  static $*1_ltype $1_str;
  $1_str.assign($input.p, $input.n);
  $result = &$1_str;
%}

%typemap(out) const string &
%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}

%typemap(directorin) const string &
%{ $input = _swig_makegostring($1.data(), $1.length()); %}

}