PageRenderTime 55ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Lib/csharp/csharp.swg

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