csharp.i 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* File : csharp.i
  2. * http://www.swig.org/Doc1.3/CSharp.html
  3. */
  4. %define %cs_marshal_array(TYPE, CSTYPE)
  5. %typemap(ctype) TYPE[] "void*"
  6. %typemap(imtype,
  7. inattributes="[MarshalAs(UnmanagedType.LPArray)]") TYPE[] "CSTYPE[]"
  8. %typemap(cstype) TYPE[] "CSTYPE[]"
  9. %typemap(in) TYPE[] %{ $1 = (TYPE*)$input; %}
  10. %typemap(csin) TYPE[] "$csinput"
  11. %enddef
  12. // Mapping void* as IntPtr
  13. %typemap(ctype) void * "void *"
  14. %typemap(imtype) void * "IntPtr"
  15. %typemap(cstype) void * "IntPtr"
  16. %typemap(csin) void * "$csinput"
  17. %typemap(in) void * %{ $1 = $input; %}
  18. %typemap(out) void * %{ $result = $1; %}
  19. %typemap(csout) void * { return $imcall; }
  20. %typemap(csdirectorin) void * "$iminput"
  21. //======== SipMessage ========//
  22. %typemap(cscode) SipMessage %{
  23. public byte[] getSipContent() {
  24. uint clen = this.getSipContentLength();
  25. if(clen>0){
  26. IntPtr ptr = Marshal.AllocHGlobal((int)clen);
  27. this.getSipContent(ptr, clen);
  28. byte[] bytes = new byte[clen];
  29. Marshal.Copy(ptr, bytes, 0, bytes.Length);
  30. Marshal.FreeHGlobal(ptr);
  31. return bytes;
  32. }
  33. return null;
  34. }
  35. %}
  36. //======== MessagingSession ========//
  37. %typemap(cscode) MessagingSession %{
  38. public bool send(byte[] buffer) {
  39. IntPtr ptr = Marshal.AllocHGlobal(buffer.Length);
  40. Marshal.Copy(buffer, 0, ptr, buffer.Length);
  41. bool ret = this.send(ptr, (uint)buffer.Length);
  42. Marshal.FreeHGlobal(ptr);
  43. return ret;
  44. }
  45. %}
  46. //======== InfoSession ========//
  47. %typemap(cscode) InfoSession %{
  48. public bool send(byte[] buffer, ActionConfig config) {
  49. IntPtr ptr = Marshal.AllocHGlobal(buffer.Length);
  50. Marshal.Copy(buffer, 0, ptr, buffer.Length);
  51. bool ret = this.send(ptr, (uint)buffer.Length, config);
  52. Marshal.FreeHGlobal(ptr);
  53. return ret;
  54. }
  55. %}
  56. //======= MediaContent ========//
  57. %typemap(cscode) MediaContent %{
  58. public byte[] getPayload() {
  59. uint clen = this.getPayloadLength();
  60. if(clen>0){
  61. IntPtr ptr = Marshal.AllocHGlobal((int)clen);
  62. this.getPayload(ptr, clen);
  63. byte[] bytes = new byte[clen];
  64. Marshal.Copy(ptr, bytes, 0, bytes.Length);
  65. Marshal.FreeHGlobal(ptr);
  66. return bytes;
  67. }
  68. return null;
  69. }
  70. %}
  71. //======= SMSData ========//
  72. %typemap(cscode) SMSData %{
  73. public byte[] getPayload() {
  74. uint clen = this.getPayloadLength();
  75. if(clen>0){
  76. IntPtr ptr = Marshal.AllocHGlobal((int)clen);
  77. this.getPayload(ptr, clen);
  78. byte[] bytes = new byte[clen];
  79. Marshal.Copy(ptr, bytes, 0, bytes.Length);
  80. Marshal.FreeHGlobal(ptr);
  81. return bytes;
  82. }
  83. return null;
  84. }
  85. %}
  86. //======= RPMessage ========//
  87. %typemap(cscode) RPMessage %{
  88. public byte[] getPayload() {
  89. uint clen = this.getPayloadLength();
  90. if(clen>0){
  91. IntPtr ptr = Marshal.AllocHGlobal((int)clen);
  92. this.getPayload(ptr, clen);
  93. byte[] bytes = new byte[clen];
  94. Marshal.Copy(ptr, bytes, 0, bytes.Length);
  95. Marshal.FreeHGlobal(ptr);
  96. return bytes;
  97. }
  98. return null;
  99. }
  100. %}
  101. //======== XcapStack ========//
  102. %typemap(cscode) XcapStack %{
  103. public bool putElement(string url, byte[] payload) {
  104. IntPtr ptr = Marshal.AllocHGlobal(payload.Length);
  105. Marshal.Copy(payload, 0, ptr, payload.Length);
  106. bool ret = this.putElement(url, ptr, (uint)payload.Length);
  107. Marshal.FreeHGlobal(ptr);
  108. return ret;
  109. }
  110. public bool putAttribute(string url, byte[] payload) {
  111. IntPtr ptr = Marshal.AllocHGlobal(payload.Length);
  112. Marshal.Copy(payload, 0, ptr, payload.Length);
  113. bool ret = this.putAttribute(url, ptr, (uint)payload.Length);
  114. Marshal.FreeHGlobal(ptr);
  115. return ret;
  116. }
  117. public bool putDocument(string url, byte[] payload, string contentType) {
  118. IntPtr ptr = Marshal.AllocHGlobal(payload.Length);
  119. Marshal.Copy(payload, 0, ptr, payload.Length);
  120. bool ret = this.putDocument(url, ptr, (uint)payload.Length, contentType);
  121. Marshal.FreeHGlobal(ptr);
  122. return ret;
  123. }
  124. %}
  125. //======== Deprecated ========//
  126. // @deprecated: to be replaced by "tmedia_codec_id_t" in Doubango 3.0
  127. %typemap(csattributes) tdav_codec_id_e "[System.Obsolete(\"Deprecated and replaced by 'tmedia_codec_id_t'. Will be removed in Doubango 3.0.\", false)]"
  128. %include ../_common/tinyWRAP.i