PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/rel-1-3-27/SWIG/Lib/python/cwstring.i

#
Swig | 137 lines | 8 code | 13 blank | 116 comment | 0 complexity | ff755e6fe5961bd22711e36278b1e4b8 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /*
  2. * cstring.i
  3. * $Header$
  4. *
  5. * This file provides typemaps and macros for dealing with various forms
  6. * of C character string handling. The primary use of this module
  7. * is in returning character data that has been allocated or changed in
  8. * some way.
  9. */
  10. /*
  11. * %cwstring_input_binary(TYPEMAP, SIZE)
  12. *
  13. * Macro makes a function accept binary string data along with
  14. * a size.
  15. */
  16. /*
  17. * %cwstring_bounded_output(TYPEMAP, MAX)
  18. *
  19. * This macro is used to return a NULL-terminated output string of
  20. * some maximum length. For example:
  21. *
  22. * %cwstring_bounded_output(wchar_t *outx, 512);
  23. * void foo(wchar_t *outx) {
  24. * sprintf(outx,"blah blah\n");
  25. * }
  26. *
  27. */
  28. /*
  29. * %cwstring_chunk_output(TYPEMAP, SIZE)
  30. *
  31. * This macro is used to return a chunk of binary string data.
  32. * Embedded NULLs are okay. For example:
  33. *
  34. * %cwstring_chunk_output(wchar_t *outx, 512);
  35. * void foo(wchar_t *outx) {
  36. * memmove(outx, somedata, 512);
  37. * }
  38. *
  39. */
  40. /*
  41. * %cwstring_bounded_mutable(TYPEMAP, SIZE)
  42. *
  43. * This macro is used to wrap a string that's going to mutate.
  44. *
  45. * %cwstring_bounded_mutable(wchar_t *in, 512);
  46. * void foo(in *x) {
  47. * while (*x) {
  48. * *x = toupper(*x);
  49. * x++;
  50. * }
  51. * }
  52. *
  53. */
  54. /*
  55. * %cwstring_mutable(TYPEMAP [, expansion])
  56. *
  57. * This macro is used to wrap a string that will mutate in place.
  58. * It may change size up to a user-defined expansion.
  59. *
  60. * %cwstring_mutable(wchar_t *in);
  61. * void foo(in *x) {
  62. * while (*x) {
  63. * *x = toupper(*x);
  64. * x++;
  65. * }
  66. * }
  67. *
  68. */
  69. /*
  70. * %cwstring_output_maxsize(TYPEMAP, SIZE)
  71. *
  72. * This macro returns data in a string of some user-defined size.
  73. *
  74. * %cwstring_output_maxsize(wchar_t *outx, int max) {
  75. * void foo(wchar_t *outx, int max) {
  76. * sprintf(outx,"blah blah\n");
  77. * }
  78. */
  79. /*
  80. * %cwstring_output_withsize(TYPEMAP, SIZE)
  81. *
  82. * This macro is used to return wchar_tacter data along with a size
  83. * parameter.
  84. *
  85. * %cwstring_output_maxsize(wchar_t *outx, int *max) {
  86. * void foo(wchar_t *outx, int *max) {
  87. * sprintf(outx,"blah blah\n");
  88. * *max = strlen(outx);
  89. * }
  90. */
  91. /*
  92. * %cwstring_output_allocate(TYPEMAP, RELEASE)
  93. *
  94. * This macro is used to return wchar_tacter data that was
  95. * allocated with new or malloc.
  96. *
  97. * %cwstring_output_allocated(wchar_t **outx, free($1));
  98. * void foo(wchar_t **outx) {
  99. * *outx = (wchar_t *) malloc(512);
  100. * sprintf(outx,"blah blah\n");
  101. * }
  102. */
  103. /*
  104. * %cwstring_output_allocate_size(TYPEMAP, SIZE, RELEASE)
  105. *
  106. * This macro is used to return wchar_tacter data that was
  107. * allocated with new or malloc.
  108. *
  109. * %cwstring_output_allocated(wchar_t **outx, int *sz, free($1));
  110. * void foo(wchar_t **outx, int *sz) {
  111. * *outx = (wchar_t *) malloc(512);
  112. * sprintf(outx,"blah blah\n");
  113. * *sz = strlen(outx);
  114. * }
  115. */
  116. %include <pywstrings.swg>
  117. %include <cstrbase.swg>
  118. %typemap_cstrings(%cwstring,
  119. wchar_t,
  120. SWIG_AsWCharPtr,
  121. SWIG_AsWCharPtrAndSize,
  122. SWIG_FromWCharPtr,
  123. SWIG_FromWCharArray);