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.

76 lines
2.3 KiB

  1. /**
  2. * @file rubywstrings.swg
  3. * @author
  4. * @date Fri May 4 17:49:40 2007
  5. *
  6. * @brief Currently, Ruby does not support Unicode or WChar properly, so these
  7. * are still treated as char arrays for now.
  8. * There are other libraries available that add support to this in
  9. * ruby including WString, FXString, etc.
  10. *
  11. *
  12. */
  13. /* ------------------------------------------------------------
  14. * utility methods for wchar_t strings
  15. * ------------------------------------------------------------ */
  16. %fragment("SWIG_AsWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
  17. SWIGINTERN int
  18. SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc)
  19. {
  20. return SWIG_AsCharPtrAndSize( obj, (char**)cptr, psize, alloc);
  21. // VALUE tmp = 0;
  22. // bool ok = false;
  23. // if ( TYPE(obj) == T_STRING ) {
  24. // if (cptr) {
  25. // obj = tmp = SWIG_Unicode_FromObject(obj);
  26. // ok = true;
  27. // }
  28. // }
  29. // if (ok) {
  30. // int len = PyUnicode_GetSize(obj);
  31. // rb_notimplement();
  32. // if (cptr) {
  33. // *cptr = %new_array(len + 1, wchar_t);
  34. // SWIG_Unicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
  35. // (*cptr)[len] = 0;
  36. // }
  37. // if (psize) *psize = (size_t) len + 1;
  38. // if (alloc) *alloc = cptr ? SWIG_NEWOBJ : 0;
  39. // return SWIG_OK;
  40. // } else {
  41. // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
  42. // if (pwchar_descriptor) {
  43. // void * vptr = 0;
  44. // if (SWIG_ConvertPtr(obj, &vptr, pwchar_descriptor, 0) == SWIG_OK) {
  45. // if (cptr) *cptr = (wchar_t *)vptr;
  46. // if (psize) *psize = vptr ? (wcslen((wchar_t *)vptr) + 1) : 0;
  47. // return SWIG_OK;
  48. // }
  49. // }
  50. // }
  51. // return SWIG_TypeError;
  52. }
  53. }
  54. %fragment("SWIG_FromWCharPtrAndSize","header",fragment="<wchar.h>",fragment="SWIG_pwchar_descriptor") {
  55. SWIGINTERNINLINE VALUE
  56. SWIG_FromWCharPtrAndSize(const wchar_t * carray, size_t size)
  57. {
  58. return SWIG_FromCharPtrAndSize( (const char*)carray, size);
  59. // if (carray) {
  60. // if (size > INT_MAX) {
  61. // swig_type_info* pwchar_descriptor = SWIG_pwchar_descriptor();
  62. // return pwchar_descriptor ?
  63. // SWIG_NewPointerObj(%const_cast(carray,wchar_t *), pwchar_descriptor, 0) : Qnil;
  64. // } else {
  65. // return SWIG_Unicode_FromWideChar(carray, %numeric_cast(size,int));
  66. // }
  67. // } else {
  68. // return Qnil;
  69. // }
  70. }
  71. }