PageRenderTime 51ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/csharp/csharp.swg

#
Unknown | 1013 lines | 890 code | 123 blank | 0 comment | 0 complexity | 76b2c50125d1739afa7faacd173595a5 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * csharp.swg
  3. *
  4. * C# typemaps
  5. * ----------------------------------------------------------------------------- */
  6. %include <csharphead.swg>
  7. /* The ctype, imtype and cstype typemaps work together and so there should be one of each.
  8. * The ctype typemap contains the PInvoke type used in the PInvoke (C/C++) code.
  9. * The imtype typemap contains the C# type used in the intermediary class.
  10. * The cstype typemap contains the C# type used in the C# proxy classes, type wrapper classes and module class. */
  11. /* Fragments */
  12. %fragment("SWIG_PackData", "header") {
  13. /* Pack binary data into a string */
  14. SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
  15. static const char hex[17] = "0123456789abcdef";
  16. register const unsigned char *u = (unsigned char *) ptr;
  17. register const unsigned char *eu = u + sz;
  18. for (; u != eu; ++u) {
  19. register unsigned char uu = *u;
  20. *(c++) = hex[(uu & 0xf0) >> 4];
  21. *(c++) = hex[uu & 0xf];
  22. }
  23. return c;
  24. }
  25. }
  26. %fragment("SWIG_UnPackData", "header") {
  27. /* Unpack binary data from a string */
  28. SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
  29. register unsigned char *u = (unsigned char *) ptr;
  30. register const unsigned char *eu = u + sz;
  31. for (; u != eu; ++u) {
  32. register char d = *(c++);
  33. register unsigned char uu;
  34. if ((d >= '0') && (d <= '9'))
  35. uu = ((d - '0') << 4);
  36. else if ((d >= 'a') && (d <= 'f'))
  37. uu = ((d - ('a'-10)) << 4);
  38. else
  39. return (char *) 0;
  40. d = *(c++);
  41. if ((d >= '0') && (d <= '9'))
  42. uu |= (d - '0');
  43. else if ((d >= 'a') && (d <= 'f'))
  44. uu |= (d - ('a'-10));
  45. else
  46. return (char *) 0;
  47. *u = uu;
  48. }
  49. return c;
  50. }
  51. }
  52. /* Primitive types */
  53. %typemap(ctype) bool, const bool & "unsigned int"
  54. %typemap(ctype) char, const char & "char"
  55. %typemap(ctype) signed char, const signed char & "signed char"
  56. %typemap(ctype) unsigned char, const unsigned char & "unsigned char"
  57. %typemap(ctype) short, const short & "short"
  58. %typemap(ctype) unsigned short, const unsigned short & "unsigned short"
  59. %typemap(ctype) int, const int & "int"
  60. %typemap(ctype) unsigned int, const unsigned int & "unsigned int"
  61. %typemap(ctype) long, const long & "long"
  62. %typemap(ctype) unsigned long, const unsigned long & "unsigned long"
  63. %typemap(ctype) long long, const long long & "long long"
  64. %typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long"
  65. %typemap(ctype) float, const float & "float"
  66. %typemap(ctype) double, const double & "double"
  67. %typemap(ctype) void "void"
  68. %typemap(imtype) bool, const bool & "bool"
  69. %typemap(imtype) char, const char & "char"
  70. %typemap(imtype) signed char, const signed char & "sbyte"
  71. %typemap(imtype) unsigned char, const unsigned char & "byte"
  72. %typemap(imtype) short, const short & "short"
  73. %typemap(imtype) unsigned short, const unsigned short & "ushort"
  74. %typemap(imtype) int, const int & "int"
  75. %typemap(imtype) unsigned int, const unsigned int & "uint"
  76. %typemap(imtype) long, const long & "int"
  77. %typemap(imtype) unsigned long, const unsigned long & "uint"
  78. %typemap(imtype) long long, const long long & "long"
  79. %typemap(imtype) unsigned long long, const unsigned long long & "ulong"
  80. %typemap(imtype) float, const float & "float"
  81. %typemap(imtype) double, const double & "double"
  82. %typemap(imtype) void "void"
  83. %typemap(cstype) bool, const bool & "bool"
  84. %typemap(cstype) char, const char & "char"
  85. %typemap(cstype) signed char, const signed char & "sbyte"
  86. %typemap(cstype) unsigned char, const unsigned char & "byte"
  87. %typemap(cstype) short, const short & "short"
  88. %typemap(cstype) unsigned short, const unsigned short & "ushort"
  89. %typemap(cstype) int, const int & "int"
  90. %typemap(cstype) unsigned int, const unsigned int & "uint"
  91. %typemap(cstype) long, const long & "int"
  92. %typemap(cstype) unsigned long, const unsigned long & "uint"
  93. %typemap(cstype) long long, const long long & "long"
  94. %typemap(cstype) unsigned long long, const unsigned long long & "ulong"
  95. %typemap(cstype) float, const float & "float"
  96. %typemap(cstype) double, const double & "double"
  97. %typemap(cstype) void "void"
  98. %typemap(ctype) char *, char *&, char[ANY], char[] "char *"
  99. %typemap(imtype) char *, char *&, char[ANY], char[] "string"
  100. %typemap(cstype) char *, char *&, char[ANY], char[] "string"
  101. /* Non primitive types */
  102. %typemap(ctype) SWIGTYPE "void *"
  103. %typemap(imtype, out="IntPtr") SWIGTYPE "HandleRef"
  104. %typemap(cstype) SWIGTYPE "$&csclassname"
  105. %typemap(ctype) SWIGTYPE [] "void *"
  106. %typemap(imtype, out="IntPtr") SWIGTYPE [] "HandleRef"
  107. %typemap(cstype) SWIGTYPE [] "$csclassname"
  108. %typemap(ctype) SWIGTYPE * "void *"
  109. %typemap(imtype, out="IntPtr") SWIGTYPE * "HandleRef"
  110. %typemap(cstype) SWIGTYPE * "$csclassname"
  111. %typemap(ctype) SWIGTYPE & "void *"
  112. %typemap(imtype, out="IntPtr") SWIGTYPE & "HandleRef"
  113. %typemap(cstype) SWIGTYPE & "$csclassname"
  114. /* pointer to a class member */
  115. %typemap(ctype) SWIGTYPE (CLASS::*) "char *"
  116. %typemap(imtype) SWIGTYPE (CLASS::*) "string"
  117. %typemap(cstype) SWIGTYPE (CLASS::*) "$csclassname"
  118. /* The following are the in and out typemaps. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */
  119. /* primitive types */
  120. %typemap(in) bool
  121. %{ $1 = $input ? true : false; %}
  122. %typemap(directorout) bool
  123. %{ $result = $input ? true : false; %}
  124. %typemap(csdirectorin) bool "$iminput"
  125. %typemap(csdirectorout) bool "$cscall"
  126. %typemap(in) char,
  127. signed char,
  128. unsigned char,
  129. short,
  130. unsigned short,
  131. int,
  132. unsigned int,
  133. long,
  134. unsigned long,
  135. long long,
  136. unsigned long long,
  137. float,
  138. double
  139. %{ $1 = ($1_ltype)$input; %}
  140. %typemap(directorout) char,
  141. signed char,
  142. unsigned char,
  143. short,
  144. unsigned short,
  145. int,
  146. unsigned int,
  147. long,
  148. unsigned long,
  149. long long,
  150. unsigned long long,
  151. float,
  152. double
  153. %{ $result = ($1_ltype)$input; %}
  154. %typemap(directorin) bool "$input = $1;"
  155. %typemap(directorin) char "$input = $1;"
  156. %typemap(directorin) signed char "$input = $1;"
  157. %typemap(directorin) unsigned char "$input = $1;"
  158. %typemap(directorin) short "$input = $1;"
  159. %typemap(directorin) unsigned short "$input = $1;"
  160. %typemap(directorin) int "$input = $1;"
  161. %typemap(directorin) unsigned int "$input = $1;"
  162. %typemap(directorin) long "$input = $1;"
  163. %typemap(directorin) unsigned long "$input = $1;"
  164. %typemap(directorin) long long "$input = $1;"
  165. %typemap(directorin) unsigned long long "$input = $1;"
  166. %typemap(directorin) float "$input = $1;"
  167. %typemap(directorin) double "$input = $1;"
  168. %typemap(csdirectorin) char,
  169. signed char,
  170. unsigned char,
  171. short,
  172. unsigned short,
  173. int,
  174. unsigned int,
  175. long,
  176. unsigned long,
  177. long long,
  178. unsigned long long,
  179. float,
  180. double
  181. "$iminput"
  182. %typemap(csdirectorout) char,
  183. signed char,
  184. unsigned char,
  185. short,
  186. unsigned short,
  187. int,
  188. unsigned int,
  189. long,
  190. unsigned long,
  191. long long,
  192. unsigned long long,
  193. float,
  194. double
  195. "$cscall"
  196. %typemap(out) bool %{ $result = $1; %}
  197. %typemap(out) char %{ $result = $1; %}
  198. %typemap(out) signed char %{ $result = $1; %}
  199. %typemap(out) unsigned char %{ $result = $1; %}
  200. %typemap(out) short %{ $result = $1; %}
  201. %typemap(out) unsigned short %{ $result = $1; %}
  202. %typemap(out) int %{ $result = $1; %}
  203. %typemap(out) unsigned int %{ $result = $1; %}
  204. %typemap(out) long %{ $result = $1; %}
  205. %typemap(out) unsigned long %{ $result = (unsigned long)$1; %}
  206. %typemap(out) long long %{ $result = $1; %}
  207. %typemap(out) unsigned long long %{ $result = $1; %}
  208. %typemap(out) float %{ $result = $1; %}
  209. %typemap(out) double %{ $result = $1; %}
  210. /* char * - treat as String */
  211. %typemap(in) char * %{ $1 = ($1_ltype)$input; %}
  212. %typemap(out) char * %{ $result = SWIG_csharp_string_callback((const char *)$1); %}
  213. %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %}
  214. %typemap(directorin) char * %{ $input = SWIG_csharp_string_callback((const char *)$1); %}
  215. %typemap(csdirectorin) char * "$iminput"
  216. %typemap(csdirectorout) char * "$cscall"
  217. /* char *& - treat as String */
  218. %typemap(in) char *& ($*1_ltype temp = 0) %{
  219. temp = ($*1_ltype)$input;
  220. $1 = &temp;
  221. %}
  222. %typemap(out) char *& %{ if ($1) $result = SWIG_csharp_string_callback((const char *)*$1); %}
  223. %typemap(out, null="") void ""
  224. %typemap(csdirectorin) void "$iminput"
  225. %typemap(csdirectorout) void "$cscall"
  226. %typemap(directorin) void ""
  227. /* primitive types by const reference */
  228. %typemap(in) const bool & ($*1_ltype temp)
  229. %{ temp = $input ? true : false;
  230. $1 = &temp; %}
  231. %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool &
  232. %{ static $*1_ltype temp;
  233. temp = $input ? true : false;
  234. $result = &temp; %}
  235. %typemap(csdirectorin) const bool & "$iminput"
  236. %typemap(csdirectorout) const bool & "$cscall"
  237. %typemap(in) const char & ($*1_ltype temp),
  238. const signed char & ($*1_ltype temp),
  239. const unsigned char & ($*1_ltype temp),
  240. const short & ($*1_ltype temp),
  241. const unsigned short & ($*1_ltype temp),
  242. const int & ($*1_ltype temp),
  243. const unsigned int & ($*1_ltype temp),
  244. const long & ($*1_ltype temp),
  245. const unsigned long & ($*1_ltype temp),
  246. const long long & ($*1_ltype temp),
  247. const unsigned long long & ($*1_ltype temp),
  248. const float & ($*1_ltype temp),
  249. const double & ($*1_ltype temp)
  250. %{ temp = ($*1_ltype)$input;
  251. $1 = &temp; %}
  252. %typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const char &,
  253. const signed char &,
  254. const unsigned char &,
  255. const short &,
  256. const unsigned short &,
  257. const int &,
  258. const unsigned int &,
  259. const long &,
  260. const unsigned long &,
  261. const long long &,
  262. const float &,
  263. const double &
  264. %{ static $*1_ltype temp;
  265. temp = ($*1_ltype)$input;
  266. $result = &temp; %}
  267. %typemap(directorin) const bool & "$input = $1;"
  268. %typemap(directorin) const char & "$input = $1;"
  269. %typemap(directorin) const signed char & "$input = $1;"
  270. %typemap(directorin) const unsigned char & "$input = $1;"
  271. %typemap(directorin) const short & "$input = $1;"
  272. %typemap(directorin) const unsigned short & "$input = $1;"
  273. %typemap(directorin) const int & "$input = $1;"
  274. %typemap(directorin) const unsigned int & "$input = $1;"
  275. %typemap(directorin) const long & "$input = $1;"
  276. %typemap(directorin) const unsigned long & "$input = $1;"
  277. %typemap(directorin) const long long & "$input = $1;"
  278. %typemap(directorin) const float & "$input = $1;"
  279. %typemap(directorin) const double & "$input = $1;"
  280. %typemap(csdirectorin) const char & ($*1_ltype temp),
  281. const signed char & ($*1_ltype temp),
  282. const unsigned char & ($*1_ltype temp),
  283. const short & ($*1_ltype temp),
  284. const unsigned short & ($*1_ltype temp),
  285. const int & ($*1_ltype temp),
  286. const unsigned int & ($*1_ltype temp),
  287. const long & ($*1_ltype temp),
  288. const unsigned long & ($*1_ltype temp),
  289. const long long & ($*1_ltype temp),
  290. const float & ($*1_ltype temp),
  291. const double & ($*1_ltype temp)
  292. "$iminput"
  293. %typemap(csdirectorout) const char & ($*1_ltype temp),
  294. const signed char & ($*1_ltype temp),
  295. const unsigned char & ($*1_ltype temp),
  296. const short & ($*1_ltype temp),
  297. const unsigned short & ($*1_ltype temp),
  298. const int & ($*1_ltype temp),
  299. const unsigned int & ($*1_ltype temp),
  300. const long & ($*1_ltype temp),
  301. const unsigned long & ($*1_ltype temp),
  302. const long long & ($*1_ltype temp),
  303. const float & ($*1_ltype temp),
  304. const double & ($*1_ltype temp)
  305. "$cscall"
  306. %typemap(out) const bool & %{ $result = *$1; %}
  307. %typemap(out) const char & %{ $result = *$1; %}
  308. %typemap(out) const signed char & %{ $result = *$1; %}
  309. %typemap(out) const unsigned char & %{ $result = *$1; %}
  310. %typemap(out) const short & %{ $result = *$1; %}
  311. %typemap(out) const unsigned short & %{ $result = *$1; %}
  312. %typemap(out) const int & %{ $result = *$1; %}
  313. %typemap(out) const unsigned int & %{ $result = *$1; %}
  314. %typemap(out) const long & %{ $result = *$1; %}
  315. %typemap(out) const unsigned long & %{ $result = (unsigned long)*$1; %}
  316. %typemap(out) const long long & %{ $result = *$1; %}
  317. %typemap(out) const unsigned long long & %{ $result = *$1; %}
  318. %typemap(out) const float & %{ $result = *$1; %}
  319. %typemap(out) const double & %{ $result = *$1; %}
  320. /* Default handling. Object passed by value. Convert to a pointer */
  321. %typemap(in, canthrow=1) SWIGTYPE ($&1_type argp)
  322. %{ argp = ($&1_ltype)$input;
  323. if (!argp) {
  324. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null $1_type", 0);
  325. return $null;
  326. }
  327. $1 = *argp; %}
  328. %typemap(directorout) SWIGTYPE
  329. %{ if (!$input) {
  330. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0);
  331. return $null;
  332. }
  333. $result = *($&1_ltype)$input; %}
  334. %typemap(out) SWIGTYPE
  335. #ifdef __cplusplus
  336. %{ $result = new $1_ltype((const $1_ltype &)$1); %}
  337. #else
  338. {
  339. $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
  340. memmove($1ptr, &$1, sizeof($1_type));
  341. $result = $1ptr;
  342. }
  343. #endif
  344. %typemap(directorin) SWIGTYPE
  345. %{ $input = (void *)&$1; %}
  346. %typemap(csdirectorin) SWIGTYPE "new $&csclassname($iminput, false)"
  347. %typemap(csdirectorout) SWIGTYPE "$&csclassname.getCPtr($cscall).Handle"
  348. /* Generic pointers and references */
  349. %typemap(in) SWIGTYPE * %{ $1 = ($1_ltype)$input; %}
  350. %typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{
  351. SWIG_UnpackData($input, (void *)&$1, sizeof($1));
  352. %}
  353. %typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
  354. if (!$1) {
  355. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
  356. return $null;
  357. } %}
  358. %typemap(out) SWIGTYPE * %{ $result = (void *)$1; %}
  359. %typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
  360. char buf[128];
  361. char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
  362. *data = '\0';
  363. $result = SWIG_csharp_string_callback(buf);
  364. %}
  365. %typemap(out) SWIGTYPE & %{ $result = (void *)$1; %}
  366. %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
  367. %{ $result = ($1_ltype)$input; %}
  368. %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
  369. %{ $result = ($1_ltype)$input; %}
  370. %typemap(directorin) SWIGTYPE *
  371. %{ $input = (void *) $1; %}
  372. %typemap(directorin) SWIGTYPE (CLASS::*)
  373. %{ $input = (void *) $1; %}
  374. %typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
  375. %{ if (!$input) {
  376. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Unexpected null return for type $1_type", 0);
  377. return $null;
  378. }
  379. $result = ($1_ltype)$input; %}
  380. %typemap(directorin) SWIGTYPE &
  381. %{ $input = ($1_ltype) &$1; %}
  382. %typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)"
  383. %typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)"
  384. %typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle"
  385. /* Default array handling */
  386. %typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %}
  387. %typemap(out) SWIGTYPE [] %{ $result = $1; %}
  388. /* char arrays - treat as String */
  389. %typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %}
  390. %typemap(out) char[ANY], char[] %{ $result = SWIG_csharp_string_callback((const char *)$1); %}
  391. %typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %}
  392. %typemap(directorin) char[ANY], char[] %{ $input = SWIG_csharp_string_callback((const char *)$1); %}
  393. %typemap(csdirectorin) char[ANY], char[] "$iminput"
  394. %typemap(csdirectorout) char[ANY], char[] "$cscall"
  395. /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions
  396. * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */
  397. %typecheck(SWIG_TYPECHECK_BOOL)
  398. bool,
  399. const bool &
  400. ""
  401. %typecheck(SWIG_TYPECHECK_CHAR)
  402. char,
  403. const char &
  404. ""
  405. %typecheck(SWIG_TYPECHECK_INT8)
  406. signed char,
  407. const signed char &
  408. ""
  409. %typecheck(SWIG_TYPECHECK_UINT8)
  410. unsigned char,
  411. const unsigned char &
  412. ""
  413. %typecheck(SWIG_TYPECHECK_INT16)
  414. short,
  415. const short &
  416. ""
  417. %typecheck(SWIG_TYPECHECK_UINT16)
  418. unsigned short,
  419. const unsigned short &
  420. ""
  421. %typecheck(SWIG_TYPECHECK_INT32)
  422. int,
  423. long,
  424. const int &,
  425. const long &
  426. ""
  427. %typecheck(SWIG_TYPECHECK_UINT32)
  428. unsigned int,
  429. unsigned long,
  430. const unsigned int &,
  431. const unsigned long &
  432. ""
  433. %typecheck(SWIG_TYPECHECK_INT64)
  434. long long,
  435. const long long &
  436. ""
  437. %typecheck(SWIG_TYPECHECK_UINT64)
  438. unsigned long long,
  439. const unsigned long long &
  440. ""
  441. %typecheck(SWIG_TYPECHECK_FLOAT)
  442. float,
  443. const float &
  444. ""
  445. %typecheck(SWIG_TYPECHECK_DOUBLE)
  446. double,
  447. const double &
  448. ""
  449. %typecheck(SWIG_TYPECHECK_STRING)
  450. char *,
  451. char *&,
  452. char[ANY],
  453. char[]
  454. ""
  455. %typecheck(SWIG_TYPECHECK_POINTER)
  456. SWIGTYPE,
  457. SWIGTYPE *,
  458. SWIGTYPE &,
  459. SWIGTYPE *const&,
  460. SWIGTYPE [],
  461. SWIGTYPE (CLASS::*)
  462. ""
  463. /* Exception handling */
  464. %typemap(throws, canthrow=1) int,
  465. long,
  466. short,
  467. unsigned int,
  468. unsigned long,
  469. unsigned short
  470. %{ char error_msg[256];
  471. sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
  472. SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, error_msg);
  473. return $null; %}
  474. %typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY]
  475. %{ (void)$1;
  476. SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, "C++ $1_type exception thrown");
  477. return $null; %}
  478. %typemap(throws, canthrow=1) char *
  479. %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1);
  480. return $null; %}
  481. /* Typemaps for code generation in proxy classes and C# type wrapper classes */
  482. /* The csin typemap is used for converting function parameter types from the type
  483. * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */
  484. %typemap(csin) bool, const bool &,
  485. char, const char &,
  486. signed char, const signed char &,
  487. unsigned char, const unsigned char &,
  488. short, const short &,
  489. unsigned short, const unsigned short &,
  490. int, const int &,
  491. unsigned int, const unsigned int &,
  492. long, const long &,
  493. unsigned long, const unsigned long &,
  494. long long, const long long &,
  495. unsigned long long, const unsigned long long &,
  496. float, const float &,
  497. double, const double &
  498. "$csinput"
  499. %typemap(csin) char *, char *&, char[ANY], char[] "$csinput"
  500. %typemap(csin) SWIGTYPE "$&csclassname.getCPtr($csinput)"
  501. %typemap(csin) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] "$csclassname.getCPtr($csinput)"
  502. %typemap(csin) SWIGTYPE (CLASS::*) "$csclassname.getCMemberPtr($csinput)"
  503. /* The csout typemap is used for converting function return types from the return type
  504. * used in the PInvoke class to the type returned by the proxy, module or type wrapper class.
  505. * The $excode special variable is replaced by the excode typemap attribute code if the
  506. * method can throw any exceptions from unmanaged code, otherwise replaced by nothing. */
  507. // Macro used by the $excode special variable
  508. %define SWIGEXCODE "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef
  509. %define SWIGEXCODE2 "\n if ($imclassname.SWIGPendingException.Pending) throw $imclassname.SWIGPendingException.Retrieve();" %enddef
  510. %typemap(csout, excode=SWIGEXCODE) bool, const bool & {
  511. bool ret = $imcall;$excode
  512. return ret;
  513. }
  514. %typemap(csout, excode=SWIGEXCODE) char, const char & {
  515. char ret = $imcall;$excode
  516. return ret;
  517. }
  518. %typemap(csout, excode=SWIGEXCODE) signed char, const signed char & {
  519. sbyte ret = $imcall;$excode
  520. return ret;
  521. }
  522. %typemap(csout, excode=SWIGEXCODE) unsigned char, const unsigned char & {
  523. byte ret = $imcall;$excode
  524. return ret;
  525. }
  526. %typemap(csout, excode=SWIGEXCODE) short, const short & {
  527. short ret = $imcall;$excode
  528. return ret;
  529. }
  530. %typemap(csout, excode=SWIGEXCODE) unsigned short, const unsigned short & {
  531. ushort ret = $imcall;$excode
  532. return ret;
  533. }
  534. %typemap(csout, excode=SWIGEXCODE) int, const int & {
  535. int ret = $imcall;$excode
  536. return ret;
  537. }
  538. %typemap(csout, excode=SWIGEXCODE) unsigned int, const unsigned int & {
  539. uint ret = $imcall;$excode
  540. return ret;
  541. }
  542. %typemap(csout, excode=SWIGEXCODE) long, const long & {
  543. int ret = $imcall;$excode
  544. return ret;
  545. }
  546. %typemap(csout, excode=SWIGEXCODE) unsigned long, const unsigned long & {
  547. uint ret = $imcall;$excode
  548. return ret;
  549. }
  550. %typemap(csout, excode=SWIGEXCODE) long long, const long long & {
  551. long ret = $imcall;$excode
  552. return ret;
  553. }
  554. %typemap(csout, excode=SWIGEXCODE) unsigned long long, const unsigned long long & {
  555. ulong ret = $imcall;$excode
  556. return ret;
  557. }
  558. %typemap(csout, excode=SWIGEXCODE) float, const float & {
  559. float ret = $imcall;$excode
  560. return ret;
  561. }
  562. %typemap(csout, excode=SWIGEXCODE) double, const double & {
  563. double ret = $imcall;$excode
  564. return ret;
  565. }
  566. %typemap(csout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] {
  567. string ret = $imcall;$excode
  568. return ret;
  569. }
  570. %typemap(csout, excode=SWIGEXCODE) void {
  571. $imcall;$excode
  572. }
  573. %typemap(csout, excode=SWIGEXCODE) SWIGTYPE {
  574. $&csclassname ret = new $&csclassname($imcall, true);$excode
  575. return ret;
  576. }
  577. %typemap(csout, excode=SWIGEXCODE) SWIGTYPE & {
  578. $csclassname ret = new $csclassname($imcall, $owner);$excode
  579. return ret;
  580. }
  581. %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *, SWIGTYPE [] {
  582. IntPtr cPtr = $imcall;
  583. $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
  584. return ret;
  585. }
  586. %typemap(csout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
  587. string cMemberPtr = $imcall;
  588. $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode
  589. return ret;
  590. }
  591. /* Properties */
  592. %typemap(csvarin, excode=SWIGEXCODE2) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  593. set {
  594. $imcall;$excode
  595. } %}
  596. %typemap(csvarin, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{
  597. set {
  598. $imcall;$excode
  599. } %}
  600. %typemap(csvarout, excode=SWIGEXCODE2) bool, const bool & %{
  601. get {
  602. bool ret = $imcall;$excode
  603. return ret;
  604. } %}
  605. %typemap(csvarout, excode=SWIGEXCODE2) char, const char & %{
  606. get {
  607. char ret = $imcall;$excode
  608. return ret;
  609. } %}
  610. %typemap(csvarout, excode=SWIGEXCODE2) signed char, const signed char & %{
  611. get {
  612. sbyte ret = $imcall;$excode
  613. return ret;
  614. } %}
  615. %typemap(csvarout, excode=SWIGEXCODE2) unsigned char, const unsigned char & %{
  616. get {
  617. byte ret = $imcall;$excode
  618. return ret;
  619. } %}
  620. %typemap(csvarout, excode=SWIGEXCODE2) short, const short & %{
  621. get {
  622. short ret = $imcall;$excode
  623. return ret;
  624. } %}
  625. %typemap(csvarout, excode=SWIGEXCODE2) unsigned short, const unsigned short & %{
  626. get {
  627. ushort ret = $imcall;$excode
  628. return ret;
  629. } %}
  630. %typemap(csvarout, excode=SWIGEXCODE2) int, const int & %{
  631. get {
  632. int ret = $imcall;$excode
  633. return ret;
  634. } %}
  635. %typemap(csvarout, excode=SWIGEXCODE2) unsigned int, const unsigned int & %{
  636. get {
  637. uint ret = $imcall;$excode
  638. return ret;
  639. } %}
  640. %typemap(csvarout, excode=SWIGEXCODE2) long, const long & %{
  641. get {
  642. int ret = $imcall;$excode
  643. return ret;
  644. } %}
  645. %typemap(csvarout, excode=SWIGEXCODE2) unsigned long, const unsigned long & %{
  646. get {
  647. uint ret = $imcall;$excode
  648. return ret;
  649. } %}
  650. %typemap(csvarout, excode=SWIGEXCODE2) long long, const long long & %{
  651. get {
  652. long ret = $imcall;$excode
  653. return ret;
  654. } %}
  655. %typemap(csvarout, excode=SWIGEXCODE2) unsigned long long, const unsigned long long & %{
  656. get {
  657. ulong ret = $imcall;$excode
  658. return ret;
  659. } %}
  660. %typemap(csvarout, excode=SWIGEXCODE2) float, const float & %{
  661. get {
  662. float ret = $imcall;$excode
  663. return ret;
  664. } %}
  665. %typemap(csvarout, excode=SWIGEXCODE2) double, const double & %{
  666. get {
  667. double ret = $imcall;$excode
  668. return ret;
  669. } %}
  670. %typemap(csvarout, excode=SWIGEXCODE2) char *, char *&, char[ANY], char[] %{
  671. get {
  672. string ret = $imcall;$excode
  673. return ret;
  674. } %}
  675. %typemap(csvarout, excode=SWIGEXCODE2) void %{
  676. get {
  677. $imcall;$excode
  678. } %}
  679. %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE %{
  680. get {
  681. $&csclassname ret = new $&csclassname($imcall, true);$excode
  682. return ret;
  683. } %}
  684. %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE & %{
  685. get {
  686. $csclassname ret = new $csclassname($imcall, $owner);$excode
  687. return ret;
  688. } %}
  689. %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE *, SWIGTYPE [] %{
  690. get {
  691. IntPtr cPtr = $imcall;
  692. $csclassname ret = (cPtr == IntPtr.Zero) ? null : new $csclassname(cPtr, $owner);$excode
  693. return ret;
  694. } %}
  695. %typemap(csvarout, excode=SWIGEXCODE2) SWIGTYPE (CLASS::*) %{
  696. get {
  697. string cMemberPtr = $imcall;
  698. $csclassname ret = (cMemberPtr == null) ? null : new $csclassname(cMemberPtr, $owner);$excode
  699. return ret;
  700. } %}
  701. /* Pointer reference typemaps */
  702. %typemap(ctype) SWIGTYPE *const& "void *"
  703. %typemap(imtype, out="IntPtr") SWIGTYPE *const& "HandleRef"
  704. %typemap(cstype) SWIGTYPE *const& "$*csclassname"
  705. %typemap(csin) SWIGTYPE *const& "$*csclassname.getCPtr($csinput)"
  706. %typemap(csout, excode=SWIGEXCODE) SWIGTYPE *const& {
  707. IntPtr cPtr = $imcall;
  708. $*csclassname ret = (cPtr == IntPtr.Zero) ? null : new $*csclassname(cPtr, $owner);$excode
  709. return ret;
  710. }
  711. %typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
  712. %{ temp = ($*1_ltype)$input;
  713. $1 = ($1_ltype)&temp; %}
  714. %typemap(out) SWIGTYPE *const&
  715. %{ $result = (void *)*$1; %}
  716. /* Marshal C/C++ pointer to IntPtr */
  717. %typemap(ctype) void *VOID_INT_PTR "void *"
  718. %typemap(imtype) void *VOID_INT_PTR "IntPtr"
  719. %typemap(cstype) void *VOID_INT_PTR "IntPtr"
  720. %typemap(in) void *VOID_INT_PTR %{ $1 = ($1_ltype)$input; %}
  721. %typemap(out) void *VOID_INT_PTR %{ $result = (void *)$1; %}
  722. %typemap(csin) void *VOID_INT_PTR "$csinput"
  723. %typemap(csout, excode=SWIGEXCODE) void *VOID_INT_PTR {
  724. IntPtr ret = $imcall;$excode
  725. return ret;
  726. }
  727. /* Typemaps used for the generation of proxy and type wrapper class code */
  728. %typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  729. %typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
  730. %typemap(cscode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  731. %typemap(csimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "\nusing System;\nusing System.Runtime.InteropServices;\n"
  732. %typemap(csinterfaces) SWIGTYPE "IDisposable"
  733. %typemap(csinterfaces) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  734. %typemap(csinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  735. // csbody typemaps... these are in macros so that the visibility of the methods can be easily changed by users.
  736. %define SWIG_CSBODY_PROXY(PTRCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
  737. // Proxy classes (base classes, ie, not derived classes)
  738. %typemap(csbody) TYPE %{
  739. private HandleRef swigCPtr;
  740. protected bool swigCMemOwn;
  741. PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) {
  742. swigCMemOwn = cMemoryOwn;
  743. swigCPtr = new HandleRef(this, cPtr);
  744. }
  745. CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
  746. return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  747. }
  748. %}
  749. // Derived proxy classes
  750. %typemap(csbody_derived) TYPE %{
  751. private HandleRef swigCPtr;
  752. PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($imclassname.$csclazznameSWIGUpcast(cPtr), cMemoryOwn) {
  753. swigCPtr = new HandleRef(this, cPtr);
  754. }
  755. CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
  756. return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  757. }
  758. %}
  759. %enddef
  760. %define SWIG_CSBODY_TYPEWRAPPER(PTRCTOR_VISIBILITY, DEFAULTCTOR_VISIBILITY, CPTR_VISIBILITY, TYPE...)
  761. // Typewrapper classes
  762. %typemap(csbody) TYPE *, TYPE &, TYPE [] %{
  763. private HandleRef swigCPtr;
  764. PTRCTOR_VISIBILITY $csclassname(IntPtr cPtr, bool futureUse) {
  765. swigCPtr = new HandleRef(this, cPtr);
  766. }
  767. DEFAULTCTOR_VISIBILITY $csclassname() {
  768. swigCPtr = new HandleRef(null, IntPtr.Zero);
  769. }
  770. CPTR_VISIBILITY static HandleRef getCPtr($csclassname obj) {
  771. return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
  772. }
  773. %}
  774. %typemap(csbody) TYPE (CLASS::*) %{
  775. private string swigCMemberPtr;
  776. PTRCTOR_VISIBILITY $csclassname(string cMemberPtr, bool futureUse) {
  777. swigCMemberPtr = cMemberPtr;
  778. }
  779. DEFAULTCTOR_VISIBILITY $csclassname() {
  780. swigCMemberPtr = null;
  781. }
  782. CPTR_VISIBILITY static string getCMemberPtr($csclassname obj) {
  783. return obj.swigCMemberPtr;
  784. }
  785. %}
  786. %enddef
  787. /* Set the default csbody typemaps to use internal visibility.
  788. Use the macros to change to public if using multiple modules. */
  789. SWIG_CSBODY_PROXY(internal, internal, SWIGTYPE)
  790. SWIG_CSBODY_TYPEWRAPPER(internal, protected, internal, SWIGTYPE)
  791. %typemap(csfinalize) SWIGTYPE %{
  792. ~$csclassname() {
  793. Dispose();
  794. }
  795. %}
  796. %typemap(csconstruct, excode=SWIGEXCODE,directorconnect="\n SwigDirectorConnect();") SWIGTYPE %{: this($imcall, true) {$excode$directorconnect
  797. }
  798. %}
  799. %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
  800. lock(this) {
  801. if (swigCPtr.Handle != IntPtr.Zero) {
  802. if (swigCMemOwn) {
  803. swigCMemOwn = false;
  804. $imcall;
  805. }
  806. swigCPtr = new HandleRef(null, IntPtr.Zero);
  807. }
  808. GC.SuppressFinalize(this);
  809. }
  810. }
  811. %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
  812. lock(this) {
  813. if (swigCPtr.Handle != IntPtr.Zero) {
  814. if (swigCMemOwn) {
  815. swigCMemOwn = false;
  816. $imcall;
  817. }
  818. swigCPtr = new HandleRef(null, IntPtr.Zero);
  819. }
  820. GC.SuppressFinalize(this);
  821. base.Dispose();
  822. }
  823. }
  824. %typemap(directordisconnect, methodname="swigDirectorDisconnect") SWIGTYPE %{
  825. protected void $methodname() {
  826. swigCMemOwn = false;
  827. $imcall;
  828. }
  829. %}
  830. /* C# specific directives */
  831. #define %csconst(flag) %feature("cs:const","flag")
  832. #define %csconstvalue(value) %feature("cs:constvalue",value)
  833. #define %csenum(wrapapproach) %feature("cs:enum","wrapapproach")
  834. #define %csmethodmodifiers %feature("cs:methodmodifiers")
  835. #define %csnothrowexception %feature("except")
  836. #define %csattributes %feature("cs:attributes")
  837. %pragma(csharp) imclassclassmodifiers="class"
  838. %pragma(csharp) moduleclassmodifiers="public class"
  839. %pragma(csharp) moduleimports=%{
  840. using System;
  841. using System.Runtime.InteropServices;
  842. %}
  843. %pragma(csharp) imclassimports=%{
  844. using System;
  845. using System.Runtime.InteropServices;
  846. %}
  847. /* Some ANSI C typemaps */
  848. %apply unsigned long { size_t };
  849. %apply const unsigned long & { const size_t & };
  850. /* Array reference typemaps */
  851. %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
  852. /* const pointers */
  853. %apply SWIGTYPE * { SWIGTYPE *const }
  854. /* csharp keywords */
  855. %include <csharpkw.swg>
  856. // Default enum handling
  857. %include <enums.swg>
  858. // For vararg handling in macros, from swigmacros.swg
  859. #define %arg(X...) X
  860. /*
  861. // Alternative char * typemaps.
  862. %pragma(csharp) imclasscode=%{
  863. public class SWIGStringMarshal : IDisposable {
  864. public readonly HandleRef swigCPtr;
  865. public SWIGStringMarshal(string str) {
  866. swigCPtr = new HandleRef(this, System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(str));
  867. }
  868. public virtual void Dispose() {
  869. System.Runtime.InteropServices.Marshal.FreeHGlobal(swigCPtr.Handle);
  870. GC.SuppressFinalize(this);
  871. }
  872. }
  873. %}
  874. %typemap(imtype, out="IntPtr") char *, char[ANY], char[] "HandleRef"
  875. %typemap(out) char *, char[ANY], char[] %{ $result = $1; %}
  876. %typemap(csin) char *, char[ANY], char[] "new $imclassname.SWIGStringMarshal($csinput).swigCPtr"
  877. %typemap(csout, excode=SWIGEXCODE) char *, char[ANY], char[] {
  878. string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
  879. return ret;
  880. }
  881. %typemap(csvarin, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
  882. set {
  883. $imcall;$excode
  884. } %}
  885. %typemap(csvarout, excode=SWIGEXCODE2) char *, char[ANY], char[] %{
  886. get {
  887. string ret = System.Runtime.InteropServices.Marshal.PtrToStringAnsi($imcall);$excode
  888. return ret;
  889. } %}
  890. */