PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Lib/go/std_string.i

#
Swig | 55 lines | 31 code | 14 blank | 10 comment | 0 complexity | fa0efa8dec007f9b63911293d0bafe13 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  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. #include <string>
  13. %}
  14. namespace std {
  15. %naturalvar string;
  16. class string;
  17. %typemap(gotype) string, const string & "string"
  18. %typemap(in) string
  19. %{ $1.assign($input.p, $input.n); %}
  20. %typemap(directorout) string
  21. %{ $result.assign($input.p, $input.n); %}
  22. %typemap(out) string
  23. %{ $result = _swig_makegostring($1.data(), $1.length()); %}
  24. %typemap(directorin) string
  25. %{ $input = _swig_makegostring($1.data(), $1.length()); %}
  26. %typemap(in) const string &
  27. %{
  28. std::string $1_str($input.p, $input.n);
  29. $1 = &$1_str;
  30. %}
  31. %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
  32. %{
  33. static std::string $1_str;
  34. $1_str.assign($input.p, $input.n);
  35. $result = &$1_str;
  36. %}
  37. %typemap(out) const string &
  38. %{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}
  39. %typemap(directorin) const string &
  40. %{ $input = _swig_makegostring($1.data(), $1.length()); %}
  41. }