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.

117 lines
3.6 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_wstring.i
  6. *
  7. * Typemaps for std::wstring and const std::wstring&
  8. * These are mapped to a C# String and are passed around by value.
  9. *
  10. * To use non-const std::wstring references use the following %apply. Note
  11. * that they are passed by value.
  12. * %apply const std::wstring & {std::wstring &};
  13. * ----------------------------------------------------------------------------- */
  14. %include <wchar.i>
  15. %{
  16. #include <string>
  17. %}
  18. namespace std {
  19. %naturalvar wstring;
  20. class wstring;
  21. // wstring
  22. %typemap(ctype, out="void *") wstring "wchar_t *"
  23. %typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") wstring "string"
  24. %typemap(cstype) wstring "string"
  25. %typemap(csdirectorin) wstring "$iminput"
  26. %typemap(csdirectorout) wstring "$cscall"
  27. %typemap(in, canthrow=1) wstring
  28. %{ if (!$input) {
  29. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
  30. return $null;
  31. }
  32. $1.assign($input); %}
  33. %typemap(out) wstring %{ $result = SWIG_csharp_wstring_callback($1.c_str()); %}
  34. %typemap(directorout, canthrow=1) wstring
  35. %{ if (!$input) {
  36. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
  37. return $null;
  38. }
  39. $result.assign($input); %}
  40. %typemap(directorin) wstring %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %}
  41. %typemap(csin) wstring "$csinput"
  42. %typemap(csout, excode=SWIGEXCODE) wstring {
  43. string ret = $imcall;$excode
  44. return ret;
  45. }
  46. %typemap(typecheck) wstring = wchar_t *;
  47. %typemap(throws, canthrow=1) wstring
  48. %{ std::string message($1.begin(), $1.end());
  49. SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str());
  50. return $null; %}
  51. // const wstring &
  52. %typemap(ctype, out="void *") const wstring & "wchar_t *"
  53. %typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]") const wstring & "string"
  54. %typemap(cstype) const wstring & "string"
  55. %typemap(csdirectorin) const wstring & "$iminput"
  56. %typemap(csdirectorout) const wstring & "$cscall"
  57. %typemap(in, canthrow=1) const wstring &
  58. %{ if (!$input) {
  59. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
  60. return $null;
  61. }
  62. std::wstring $1_str($input);
  63. $1 = &$1_str; %}
  64. %typemap(out) const wstring & %{ $result = SWIG_csharp_wstring_callback($1->c_str()); %}
  65. %typemap(csin) const wstring & "$csinput"
  66. %typemap(csout, excode=SWIGEXCODE) const wstring & {
  67. string ret = $imcall;$excode
  68. return ret;
  69. }
  70. %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const wstring &
  71. %{ if (!$input) {
  72. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null wstring", 0);
  73. return $null;
  74. }
  75. /* possible thread/reentrant code problem */
  76. static std::wstring $1_str;
  77. $1_str = $input;
  78. $result = &$1_str; %}
  79. %typemap(directorin) const wstring & %{ $input = SWIG_csharp_wstring_callback($1.c_str()); %}
  80. %typemap(csvarin, excode=SWIGEXCODE2) const wstring & %{
  81. set {
  82. $imcall;$excode
  83. } %}
  84. %typemap(csvarout, excode=SWIGEXCODE2) const wstring & %{
  85. get {
  86. string ret = $imcall;$excode
  87. return ret;
  88. } %}
  89. %typemap(typecheck) const wstring & = wchar_t *;
  90. %typemap(throws, canthrow=1) const wstring &
  91. %{ std::string message($1.begin(), $1.end());
  92. SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, message.c_str());
  93. return $null; %}
  94. }