PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/go/std_string.i

#
Swig | 55 lines | 31 code | 14 blank | 10 comment | 0 complexity | fa0efa8dec007f9b63911293d0bafe13 MD5 | raw file
 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
16namespace std {
17
18%naturalvar string;
19
20class 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  std::string $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 std::string $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}