Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.3 KiB

  1. /* -----------------------------------------------------------------------------
  2. * See the LICENSE file for information on copyright, usage and redistribution
  3. * of SWIG, and the README file for authors - http://www.swig.org/release.html.
  4. *
  5. * std_string.i
  6. *
  7. * Typemaps for std::string and const std::string&
  8. * These are mapped to a C# String and are passed around by value.
  9. *
  10. * To use non-const std::string references use the following %apply. Note
  11. * that they are passed by value.
  12. * %apply const std::string & {std::string &};
  13. * ----------------------------------------------------------------------------- */
  14. %{
  15. #include <string>
  16. %}
  17. namespace std {
  18. %naturalvar string;
  19. class string;
  20. // string
  21. %typemap(ctype) string "char *"
  22. %typemap(imtype) string "string"
  23. %typemap(cstype) string "string"
  24. %typemap(csdirectorin) string "$iminput"
  25. %typemap(csdirectorout) string "$cscall"
  26. %typemap(in, canthrow=1) string
  27. %{ if (!$input) {
  28. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  29. return $null;
  30. }
  31. $1.assign($input); %}
  32. %typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %}
  33. %typemap(directorout, canthrow=1) string
  34. %{ if (!$input) {
  35. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  36. return $null;
  37. }
  38. $result.assign($input); %}
  39. %typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %}
  40. %typemap(csin) string "$csinput"
  41. %typemap(csout, excode=SWIGEXCODE) string {
  42. string ret = $imcall;$excode
  43. return ret;
  44. }
  45. %typemap(typecheck) string = char *;
  46. %typemap(throws, canthrow=1) string
  47. %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
  48. return $null; %}
  49. // const string &
  50. %typemap(ctype) const string & "char *"
  51. %typemap(imtype) const string & "string"
  52. %typemap(cstype) const string & "string"
  53. %typemap(csdirectorin) const string & "$iminput"
  54. %typemap(csdirectorout) const string & "$cscall"
  55. %typemap(in, canthrow=1) const string &
  56. %{ if (!$input) {
  57. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  58. return $null;
  59. }
  60. std::string $1_str($input);
  61. $1 = &$1_str; %}
  62. %typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
  63. %typemap(csin) const string & "$csinput"
  64. %typemap(csout, excode=SWIGEXCODE) const string & {
  65. string ret = $imcall;$excode
  66. return ret;
  67. }
  68. %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
  69. %{ if (!$input) {
  70. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  71. return $null;
  72. }
  73. /* possible thread/reentrant code problem */
  74. static std::string $1_str;
  75. $1_str = $input;
  76. $result = &$1_str; %}
  77. %typemap(directorin) const string & %{ $input = SWIG_csharp_string_callback($1.c_str()); %}
  78. %typemap(csvarin, excode=SWIGEXCODE2) const string & %{
  79. set {
  80. $imcall;$excode
  81. } %}
  82. %typemap(csvarout, excode=SWIGEXCODE2) const string & %{
  83. get {
  84. string ret = $imcall;$excode
  85. return ret;
  86. } %}
  87. %typemap(typecheck) const string & = char *;
  88. %typemap(throws, canthrow=1) const string &
  89. %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
  90. return $null; %}
  91. }