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.

750 lines
34 KiB

  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. * modula3.swg
  6. *
  7. * Modula3 typemaps
  8. * ----------------------------------------------------------------------------- */
  9. %include <modula3head.swg>
  10. /* The ctype, m3rawtype and m3wraptype typemaps work together and so there should be one of each.
  11. * The ctype typemap contains the C type used in the signature of C wrappers for C++ functions.
  12. * The m3rawtype typemap contains the M3 type used in the raw interface.
  13. * The m3rawintype typemap contains the M3 type used as function argument.
  14. * The m3rawrettype typemap contains the M3 type used as return value.
  15. * The m3wraptype typemap contains the M3 type used in the M3 type wrapper classes and module class. */
  16. /* Primitive types */
  17. %typemap(ctype) bool, const bool & "bool"
  18. %typemap(ctype) char, const char & "char"
  19. %typemap(ctype) signed char, const signed char & "signed char"
  20. %typemap(ctype) unsigned char, const unsigned char & "unsigned short"
  21. %typemap(ctype) short, const short & "short"
  22. %typemap(ctype) unsigned short, const unsigned short & "unsigned short"
  23. %typemap(ctype) int, const int & "int"
  24. %typemap(ctype) unsigned int, const unsigned int & "unsigned int"
  25. %typemap(ctype) long, const long & "long"
  26. %typemap(ctype) unsigned long, const unsigned long & "unsigned long"
  27. %typemap(ctype) long long, const long long & "long long"
  28. %typemap(ctype) unsigned long long, const unsigned long long & "unsigned long long"
  29. %typemap(ctype) float, const float & "float"
  30. %typemap(ctype) double, const double & "double"
  31. %typemap(ctype) char * "char *"
  32. %typemap(ctype) void "void"
  33. %typemap(m3rawtype) bool, const bool & "BOOLEAN"
  34. %typemap(m3rawtype) char, const char & "C.char"
  35. %typemap(m3rawtype) signed char, const signed char & "C.signed_char"
  36. %typemap(m3rawtype) unsigned char, const unsigned char & "C.unsigned_char"
  37. %typemap(m3rawtype) short, const short & "C.short"
  38. %typemap(m3rawtype) unsigned short, const unsigned short & "C.unsigned_short"
  39. %typemap(m3rawtype) int, const int & "C.int"
  40. %typemap(m3rawtype) unsigned int, const unsigned int & "C.unsigned_int"
  41. %typemap(m3rawtype) long, const long & "C.long"
  42. %typemap(m3rawtype) unsigned long, const unsigned long & "C.unsigned_long"
  43. %typemap(m3rawtype) long long, const long long & "C.long_long"
  44. %typemap(m3rawtype) unsigned long long, const unsigned long long & "C.unsigned_long_long"
  45. %typemap(m3rawtype) float, const float & "C.float"
  46. %typemap(m3rawtype) double, const double & "C.double"
  47. %typemap(m3rawtype) long double, const long double & "C.long_double"
  48. %typemap(m3rawtype) char * "C.char_star"
  49. %typemap(m3rawtype) void ""
  50. %typemap(m3rawtype) FILE "Cstdio.FILE";
  51. %typemap(m3rawtype) FILE * "Cstdio.FILE_star";
  52. %typemap(m3rawintype) bool *, bool &, bool "BOOLEAN"
  53. %typemap(m3rawintype) char *, char &, char "C.char"
  54. %typemap(m3rawintype) signed char *, signed char &, signed char "C.signed_char"
  55. %typemap(m3rawintype) unsigned char *, unsigned char &, unsigned char "C.unsigned_char"
  56. %typemap(m3rawintype) short *, short &, short "C.short"
  57. %typemap(m3rawintype) unsigned short *, unsigned short &, unsigned short "C.unsigned_short"
  58. %typemap(m3rawintype) int *, int &, int "C.int"
  59. %typemap(m3rawintype) unsigned int *, unsigned int &, unsigned int "C.unsigned_int"
  60. %typemap(m3rawintype) long *, long &, long "C.long"
  61. %typemap(m3rawintype) unsigned long *, unsigned long &, unsigned long "C.unsigned_long"
  62. %typemap(m3rawintype) long long *, long long &, long long "C.long_long"
  63. %typemap(m3rawintype) unsigned long long *, unsigned long long &, unsigned long long "C.unsigned_long_long"
  64. %typemap(m3rawintype) float *, float &, float "C.float"
  65. %typemap(m3rawintype) double *, double &, double "C.double"
  66. %typemap(m3rawintype) long double *, long double &, long double "C.long_double"
  67. %typemap(m3rawintype) char * "C.char_star"
  68. %typemap(m3rawintype) void ""
  69. %typemap(m3rawintype) void * "ADDRESS"
  70. %typemap(m3rawintype) FILE "Cstdio.FILE";
  71. %typemap(m3rawintype) FILE * "Cstdio.FILE_star";
  72. %typemap(m3rawinmode) char *, void *, FILE * ""
  73. %typemap(m3rawrettype) bool, const bool & "BOOLEAN"
  74. %typemap(m3rawrettype) char, const char & "C.char"
  75. %typemap(m3rawrettype) signed char, const signed char & "C.signed_char"
  76. %typemap(m3rawrettype) unsigned char, const unsigned char & "C.unsigned_char"
  77. %typemap(m3rawrettype) short, const short & "C.short"
  78. %typemap(m3rawrettype) unsigned short, const unsigned short & "C.unsigned_short"
  79. %typemap(m3rawrettype) int, const int & "C.int"
  80. %typemap(m3rawrettype) unsigned int, const unsigned int & "C.unsigned_int"
  81. %typemap(m3rawrettype) long, const long & "C.long"
  82. %typemap(m3rawrettype) unsigned long, const unsigned long & "C.unsigned_long"
  83. %typemap(m3rawrettype) long long, const long long & "C.long_long"
  84. %typemap(m3rawrettype) unsigned long long, const unsigned long long & "C.unsigned_long_long"
  85. %typemap(m3rawrettype) float, const float & "C.float"
  86. %typemap(m3rawrettype) double, const double & "C.double"
  87. %typemap(m3rawrettype) long double, const long double & "C.long_double"
  88. %typemap(m3rawrettype) char * "C.char_star"
  89. %typemap(m3rawrettype) void ""
  90. %typemap(m3rawrettype) void * "ADDRESS"
  91. %typemap(m3rawrettype) FILE "Cstdio.FILE";
  92. %typemap(m3rawrettype) FILE * "Cstdio.FILE_star";
  93. %typemap("m3rawtype:import")
  94. char, const char &,
  95. signed char, const signed char &,
  96. unsigned char, const unsigned char &,
  97. short, const short &,
  98. unsigned short, const unsigned short &,
  99. int, const int &,
  100. unsigned int, const unsigned int &,
  101. long, const long &,
  102. unsigned long, const unsigned long &,
  103. long long, const long long &,
  104. unsigned long long, const unsigned long long &,
  105. float, const float &,
  106. double, const double &,
  107. long double, const long double &,
  108. char *
  109. "Ctypes AS C"
  110. %typemap("m3rawintype:import")
  111. char, const char &,
  112. signed char, const signed char &,
  113. unsigned char, const unsigned char &,
  114. short, const short &,
  115. unsigned short, const unsigned short &,
  116. int, const int &,
  117. unsigned int, const unsigned int &,
  118. long, const long &,
  119. unsigned long, const unsigned long &,
  120. long long, const long long &,
  121. unsigned long long, const unsigned long long &,
  122. float, const float &,
  123. double, const double &,
  124. long double, const long double &,
  125. char *
  126. "Ctypes AS C"
  127. %typemap("m3rawrettype:import")
  128. char, const char &,
  129. signed char, const signed char &,
  130. unsigned char, const unsigned char &,
  131. short, const short &,
  132. unsigned short, const unsigned short &,
  133. int, const int &,
  134. unsigned int, const unsigned int &,
  135. long, const long &,
  136. unsigned long, const unsigned long &,
  137. long long, const long long &,
  138. unsigned long long, const unsigned long long &,
  139. float, const float &,
  140. double, const double &,
  141. long double, const long double &,
  142. char *
  143. "Ctypes AS C"
  144. %typemap("m3rawtype:import")
  145. FILE, FILE *
  146. "Cstdio";
  147. %typemap("m3rawintype:import")
  148. FILE, FILE *
  149. "Cstdio";
  150. %typemap("m3rawrettype:import")
  151. FILE, FILE *
  152. "Cstdio";
  153. %typemap(m3wraptype) bool, const bool & "BOOLEAN"
  154. %typemap(m3wraptype) char, const char & "CHAR"
  155. %typemap(m3wraptype) signed char, const signed char & "CHAR"
  156. %typemap(m3wraptype) unsigned char, const unsigned char & "CHAR"
  157. %typemap(m3wraptype) short, const short & "Integer16.T"
  158. %typemap(m3wraptype) unsigned short, const unsigned short & "Cardinal16.T"
  159. %typemap(m3wraptype) int, const int & "INTEGER"
  160. %typemap(m3wraptype) unsigned int, const unsigned int & "CARDINAL"
  161. %typemap(m3wraptype) long, const long & "Integer32.T"
  162. %typemap(m3wraptype) unsigned long, const unsigned long & "Cardinal32.T"
  163. %typemap(m3wraptype) long long, const long long & "Integer64.T"
  164. %typemap(m3wraptype) unsigned long long, const unsigned long long & "Cardinal64.T"
  165. %typemap(m3wraptype) float, const float & "REAL"
  166. %typemap(m3wraptype) double, const double & "LONGREAL"
  167. %typemap(m3wraptype) long double, const long double & "EXTENDED"
  168. %typemap(m3wraptype) char * "TEXT"
  169. %typemap(m3wraptype) void ""
  170. %typemap(m3wraptype) FILE "Cstdio.FILE";
  171. %typemap(m3wraptype) FILE * "Cstdio.FILE_star";
  172. %typemap(m3wrapintype) bool, const bool *, const bool & "BOOLEAN"
  173. %typemap(m3wrapintype) char, const char *, const char & "CHAR"
  174. %typemap(m3wrapintype) signed char, const signed char *, const signed char & "CHAR"
  175. %typemap(m3wrapintype) unsigned char, const unsigned char *, const unsigned char & "CHAR"
  176. %typemap(m3wrapintype) short, const short *, const short & "INTEGER"
  177. %typemap(m3wrapintype) unsigned short, const unsigned short *, const unsigned short & "CARDINAL"
  178. %typemap(m3wrapintype) int, const int *, const int & "INTEGER"
  179. %typemap(m3wrapintype) unsigned int, const unsigned int *, const unsigned int & "CARDINAL"
  180. %typemap(m3wrapintype) long, const long *, const long & "INTEGER"
  181. %typemap(m3wrapintype) unsigned long, const unsigned long *, const unsigned long & "CARDINAL"
  182. %typemap(m3wrapintype) long long, const long long *, const long long & "INTEGER"
  183. %typemap(m3wrapintype) unsigned long long, const unsigned long long *, const unsigned long long & "CARDINAL"
  184. %typemap(m3wrapintype) float, const float *, const float & "REAL"
  185. %typemap(m3wrapintype) double, const double *, const double & "LONGREAL"
  186. %typemap(m3wrapintype) long double, const long double *, const long double & "EXTENDED"
  187. %typemap(m3wrapintype) const char *, const char [] "TEXT"
  188. %typemap(m3wrapintype,numinputs=0) void ""
  189. %typemap(m3wrapintype) FILE "Cstdio.FILE";
  190. %typemap(m3wrapintype) FILE * "Cstdio.FILE_star";
  191. %typemap(m3wrapouttype) bool, bool *, bool & "BOOLEAN"
  192. %typemap(m3wrapouttype) char, char *, char & "CHAR"
  193. %typemap(m3wrapouttype) signed char, signed char *, signed char & "CHAR"
  194. %typemap(m3wrapouttype) unsigned char, unsigned char *, unsigned char & "CHAR"
  195. %typemap(m3wrapouttype) short, short *, short & "INTEGER"
  196. %typemap(m3wrapouttype) unsigned short, unsigned short *, unsigned short & "CARDINAL"
  197. %typemap(m3wrapouttype) int, int *, int & "INTEGER"
  198. %typemap(m3wrapouttype) unsigned int, unsigned int *, unsigned int & "CARDINAL"
  199. %typemap(m3wrapouttype) long, long *, long & "INTEGER"
  200. %typemap(m3wrapouttype) unsigned long, unsigned long *, unsigned long & "CARDINAL"
  201. %typemap(m3wrapouttype) long long, long long *, long long & "INTEGER"
  202. %typemap(m3wrapouttype) unsigned long long, unsigned long long *, unsigned long long & "CARDINAL"
  203. %typemap(m3wrapouttype) float, float *, float & "REAL"
  204. %typemap(m3wrapouttype) double, double *, double & "LONGREAL"
  205. %typemap(m3wrapouttype) long double, long double *, long double & "EXTENDED"
  206. %typemap(m3wrapouttype) char *, char [] "TEXT"
  207. %typemap(m3wrapouttype,numinputs=0) void ""
  208. %typemap(m3wraprettype) bool, const bool & "BOOLEAN"
  209. %typemap(m3wraprettype) char, const char & "CHAR"
  210. %typemap(m3wraprettype) signed char, const signed char & "CHAR"
  211. %typemap(m3wraprettype) unsigned char, const unsigned char & "CHAR"
  212. %typemap(m3wraprettype) short, const short & "INTEGER"
  213. %typemap(m3wraprettype) unsigned short, const unsigned short & "CARDINAL"
  214. %typemap(m3wraprettype) int, const int & "INTEGER"
  215. %typemap(m3wraprettype) unsigned int, const unsigned int & "CARDINAL"
  216. %typemap(m3wraprettype) long, const long & "INTEGER"
  217. %typemap(m3wraprettype) unsigned long, const unsigned long & "CARDINAL"
  218. %typemap(m3wraprettype) long long, const long long & "INTEGER"
  219. %typemap(m3wraprettype) unsigned long long, const unsigned long long & "CARDINAL"
  220. %typemap(m3wraprettype) float, const float & "REAL"
  221. %typemap(m3wraprettype) double, const double & "LONGREAL"
  222. %typemap(m3wraprettype) long double, const long double & "EXTENDED"
  223. %typemap(m3wraprettype) char * "TEXT"
  224. %typemap(m3wraprettype) void ""
  225. %typemap(m3wraprettype) FILE "Cstdio.FILE";
  226. %typemap(m3wraprettype) FILE * "Cstdio.FILE_star";
  227. %typemap(ctype) char[ANY] "char *"
  228. %typemap(m3rawtype) char[ANY] "C.char_star"
  229. %typemap(m3rawintype) char[ANY] "C.char_star"
  230. %typemap(m3rawrettype) char[ANY] "C.char_star"
  231. %typemap(m3wraptype) char[ANY] "TEXT"
  232. %typemap(m3wrapintype) char[ANY] "TEXT"
  233. %typemap(m3wrapouttype) char[ANY] "TEXT"
  234. %typemap(m3wraprettype) char[ANY] "TEXT"
  235. %typemap(m3wrapinmode) const char * %{%}
  236. %typemap(m3wrapargvar) const char * %{$1 : C.char_star;%}
  237. %typemap(m3wrapinconv) const char * %{$1 := M3toC.SharedTtoS($1_name);%}
  238. %typemap(m3wrapfreearg) const char * %{M3toC.FreeSharedS($1_name,$1);%}
  239. %typemap(m3wrapargraw) const char * %{$1%}
  240. %typemap("m3wrapargvar:import") const char * "Ctypes AS C"
  241. %typemap("m3wrapinconv:import") const char * "M3toC"
  242. %typemap("m3wrapfreearg:import") const char * "M3toC"
  243. %typemap(m3wrapretvar) char * %{result : C.char_star;%}
  244. %typemap(m3wrapretraw) char * %{result%}
  245. %typemap(m3wrapretconv) char * %{M3toC.CopyStoT(result)%}
  246. %typemap("m3wrapretvar:import") char * "Ctypes AS C"
  247. %typemap("m3wrapretconv:import") char * "M3toC"
  248. %typemap(m3wrapinmode) FILE * %{%}
  249. %typemap("m3wraptype:import")
  250. FILE, FILE *
  251. "Cstdio";
  252. %typemap("m3wrapintype:import")
  253. FILE, FILE *
  254. "Cstdio";
  255. %typemap("m3wraprettype:import")
  256. FILE, FILE *
  257. "Cstdio";
  258. /* Composed types */
  259. %typemap(ctype) SWIGTYPE "$1_type"
  260. %typemap(m3rawtype) SWIGTYPE "$1_basetype"
  261. %typemap(m3rawrettype) SWIGTYPE "UNTRACED REF $1_basetype"
  262. %typemap(m3wraptype) SWIGTYPE "$1_basetype"
  263. %typemap(m3wrapintype) SWIGTYPE "$1_basetype"
  264. %typemap(m3wrapouttype) SWIGTYPE "$1_basetype"
  265. %typemap(m3wraprettype) SWIGTYPE "$1_basetype"
  266. %typemap(ctype) SWIGTYPE [] "$1_type"
  267. %typemap(m3rawtype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype"
  268. %typemap(m3rawtype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype"
  269. %typemap(m3rawintype) const SWIGTYPE [] "(*ARRAY OF*) $1_basetype"
  270. %typemap(m3rawinmode) const SWIGTYPE [] "READONLY"
  271. %typemap(m3rawintype) SWIGTYPE [] "(*ARRAY OF*) $1_basetype"
  272. %typemap(m3rawinmode) SWIGTYPE [] "VAR"
  273. %typemap(m3rawrettype) const SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype"
  274. %typemap(m3rawrettype) SWIGTYPE [] "UNTRACED REF ARRAY INTEGER OF $1_basetype"
  275. %typemap(m3wraptype) SWIGTYPE [] "$1_basetype"
  276. %typemap(m3wrapintype) const SWIGTYPE [] "ARRAY OF $1_basetype"
  277. %typemap(m3wrapinmode) const SWIGTYPE [] "READONLY"
  278. %typemap(m3wrapintype) SWIGTYPE [] "ARRAY OF $1_basetype"
  279. %typemap(m3wrapinmode) SWIGTYPE [] "VAR"
  280. %typemap(m3wrapouttype) SWIGTYPE [] "ARRAY OF $1_basetype"
  281. %typemap(m3wraprettype) SWIGTYPE [] "REF ARRAY OF $1_basetype"
  282. %typemap(ctype) SWIGTYPE * "$1_type"
  283. %typemap(m3rawtype) const SWIGTYPE * "UNTRACED REF $1_basetype"
  284. %typemap(m3rawtype) SWIGTYPE * "UNTRACED REF $1_basetype"
  285. %typemap(m3rawintype) const SWIGTYPE * "$1_basetype"
  286. %typemap(m3rawinmode) const SWIGTYPE * "READONLY"
  287. %typemap(m3rawintype) SWIGTYPE * "$1_basetype"
  288. %typemap(m3rawinmode) SWIGTYPE * "VAR"
  289. %typemap(m3rawrettype) const SWIGTYPE * "UNTRACED REF $1_basetype"
  290. %typemap(m3rawrettype) SWIGTYPE * "UNTRACED REF $1_basetype"
  291. %typemap(m3wraptype) SWIGTYPE * "$1_basetype"
  292. %typemap(m3wrapintype) const SWIGTYPE * "$1_basetype"
  293. %typemap(m3wrapinmode) const SWIGTYPE * "READONLY"
  294. %typemap(m3wrapintype) SWIGTYPE * "$1_basetype"
  295. %typemap(m3wrapinmode) SWIGTYPE * "VAR"
  296. %typemap(m3wrapouttype) SWIGTYPE * "$1_basetype"
  297. %typemap(m3wraprettype) SWIGTYPE * "UNTRACED REF $1_basetype"
  298. %typemap(ctype) SWIGTYPE & "$1_type"
  299. %typemap(m3rawtype) const SWIGTYPE & "UNTRACED REF $1_basetype"
  300. %typemap(m3rawtype) SWIGTYPE & "UNTRACED REF $1_basetype"
  301. %typemap(m3rawintype) const SWIGTYPE & "$1_basetype"
  302. %typemap(m3rawinmode) const SWIGTYPE & "READONLY"
  303. %typemap(m3rawintype) SWIGTYPE & "$1_basetype"
  304. %typemap(m3rawinmode) SWIGTYPE & "VAR"
  305. %typemap(m3rawrettype) const SWIGTYPE & "UNTRACED REF $1_basetype"
  306. %typemap(m3rawrettype) SWIGTYPE & "UNTRACED REF $1_basetype"
  307. %typemap(m3wraptype) SWIGTYPE & "$1_basetype"
  308. %typemap(m3wrapintype) const SWIGTYPE & "$1_basetype"
  309. %typemap(m3wrapinmode) const SWIGTYPE & "READONLY"
  310. %typemap(m3wrapintype) SWIGTYPE & "$1_basetype"
  311. %typemap(m3wrapinmode) SWIGTYPE & "VAR"
  312. %typemap(m3wrapouttype) SWIGTYPE & "$1_basetype"
  313. %typemap(m3wraprettype) SWIGTYPE & "UNTRACED REF $1_basetype"
  314. %typemap(ctype) enum SWIGTYPE "$1_type"
  315. %typemap(m3rawtype) enum SWIGTYPE "C.int"
  316. %typemap(m3rawintype) enum SWIGTYPE "C.int (* $1_type *)"
  317. %typemap(m3rawrettype) enum SWIGTYPE "C.int"
  318. %typemap(m3wraptype) enum SWIGTYPE "$*1_type"
  319. %typemap(m3wrapintype) enum SWIGTYPE "$1_type"
  320. %typemap(m3wrapouttype) enum SWIGTYPE "$1_type"
  321. %typemap(m3wraprettype) enum SWIGTYPE "$*1_type"
  322. /* pointer to a class member */
  323. %typemap(ctype) SWIGTYPE (CLASS::*) "$1_type"
  324. %typemap(m3rawtype) SWIGTYPE (CLASS::*) "REFANY"
  325. %typemap(m3wraptype) SWIGTYPE (CLASS::*) "$1_basetype"
  326. /* The following are the in, out, freearg, argout typemaps.
  327. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */
  328. /* primitive types */
  329. %typemap(in) bool
  330. %{ $1 = $input ? true : false; %}
  331. %typemap(in) char,
  332. signed char,
  333. unsigned char,
  334. short,
  335. unsigned short,
  336. int,
  337. unsigned int,
  338. long,
  339. unsigned long,
  340. long long,
  341. unsigned long long,
  342. float,
  343. double,
  344. enum SWIGTYPE
  345. %{ $1 = ($1_ltype)$input; %}
  346. %typemap(out) bool %{ $result = $1; %}
  347. %typemap(out) char %{ $result = $1; %}
  348. %typemap(out) signed char %{ $result = $1; %}
  349. %typemap(out) unsigned char %{ $result = $1; %}
  350. %typemap(out) short %{ $result = $1; %}
  351. %typemap(out) unsigned short %{ $result = $1; %}
  352. %typemap(out) int %{ $result = $1; %}
  353. %typemap(out) unsigned int %{ $result = $1; %}
  354. %typemap(out) long %{ $result = $1; %}
  355. %typemap(out) unsigned long %{ $result = $1; %}
  356. %typemap(out) long long %{ $result = $1; %}
  357. %typemap(out) unsigned long long %{ $result = $1; %}
  358. %typemap(out) float %{ $result = $1; %}
  359. %typemap(out) double %{ $result = $1; %}
  360. %typemap(out) enum SWIGTYPE %{ $result = $1; %}
  361. /* char * - treat as String */
  362. %typemap(in) char * {
  363. $1 = $input;
  364. }
  365. //%typemap(freearg) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); }
  366. //%typemap(out) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); }
  367. %typemap(out) void ""
  368. /* primitive types by const reference */
  369. %typemap(in) const bool & (bool temp)
  370. %{ temp = $input ? true : false;
  371. $1 = &temp; %}
  372. %typemap(in) const char & (char temp),
  373. const signed char & (signed char temp),
  374. const unsigned char & (unsigned char temp),
  375. const short & (short temp),
  376. const unsigned short & (unsigned short temp),
  377. const int & (int temp),
  378. const unsigned int & (unsigned int temp),
  379. const long & (long temp),
  380. const unsigned long & (unsigned long temp),
  381. const long long & ($*1_ltype temp),
  382. const unsigned long long & ($*1_ltype temp),
  383. const float & (float temp),
  384. const double & (double temp)
  385. %{ temp = ($*1_ltype)$input;
  386. $1 = &temp; %}
  387. %typemap(out) const bool & %{ $result = *$1; %}
  388. %typemap(out) const char & %{ $result = *$1; %}
  389. %typemap(out) const signed char & %{ $result = *$1; %}
  390. %typemap(out) const unsigned char & %{ $result = *$1; %}
  391. %typemap(out) const short & %{ $result = *$1; %}
  392. %typemap(out) const unsigned short & %{ $result = *$1; %}
  393. %typemap(out) const int & %{ $result = *$1; %}
  394. %typemap(out) const unsigned int & %{ $result = *$1; %}
  395. %typemap(out) const long & %{ $result = *$1; %}
  396. %typemap(out) const unsigned long & %{ $result = *$1; %}
  397. %typemap(out) const long long & %{ $result = *$1; %}
  398. %typemap(out) const unsigned long long & %{ $result = *$1; %}
  399. %typemap(out) const float & %{ $result = *$1; %}
  400. %typemap(out) const double & %{ $result = *$1; %}
  401. /* Default handling. Object passed by value. Convert to a pointer */
  402. %typemap(in) SWIGTYPE ($&1_type argp)
  403. %{ argp = *($&1_ltype*)&$input;
  404. if (!argp) {
  405. // SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
  406. RETURN $null;
  407. }
  408. $1 = *argp; %}
  409. %typemap(out) SWIGTYPE
  410. #ifdef __cplusplus
  411. %{*($&1_ltype*)&$result = new $1_ltype(($1_ltype &)$1); %}
  412. #else
  413. {
  414. $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
  415. memmove($1ptr, &$1, sizeof($1_type));
  416. *($&1_ltype*)&$result = $1ptr;
  417. }
  418. #endif
  419. /* Generic pointers and references */
  420. %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
  421. %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
  422. if(!$1) {
  423. //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
  424. RETURN $null;
  425. } %}
  426. %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %}
  427. /* Default array handling */
  428. %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
  429. %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %}
  430. /* char[ANY] - treat as String */
  431. %typemap(in) char[ANY] {
  432. $1 = $input;
  433. }
  434. %typemap(argout) char[ANY] ""
  435. %typemap(freearg) char[ANY] ""//{ if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); }
  436. %typemap(out) char[ANY] { if($1) $result = $1; }
  437. /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions
  438. * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */
  439. %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */
  440. bool,
  441. const bool &
  442. ""
  443. %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */
  444. char,
  445. const char &
  446. ""
  447. %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */
  448. signed char,
  449. const signed char &
  450. ""
  451. %typecheck(SWIG_TYPECHECK_INT16) /* Java short */
  452. unsigned char,
  453. short,
  454. const unsigned char &,
  455. const short &
  456. ""
  457. %typecheck(SWIG_TYPECHECK_INT32) /* Java int */
  458. unsigned short,
  459. int,
  460. long,
  461. const unsigned short &,
  462. const int &,
  463. const long &,
  464. enum SWIGTYPE
  465. ""
  466. %typecheck(SWIG_TYPECHECK_INT64) /* Java long */
  467. unsigned int,
  468. unsigned long,
  469. long long,
  470. const unsigned int &,
  471. const unsigned long &,
  472. const long long &
  473. ""
  474. %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */
  475. unsigned long long
  476. ""
  477. %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */
  478. float,
  479. const float &
  480. ""
  481. %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */
  482. double,
  483. const double &
  484. ""
  485. %typecheck(SWIG_TYPECHECK_STRING) /* Java String */
  486. char *,
  487. char[ANY]
  488. ""
  489. %typecheck(SWIG_TYPECHECK_POINTER) /* Default */
  490. SWIGTYPE,
  491. SWIGTYPE *,
  492. SWIGTYPE &,
  493. SWIGTYPE [],
  494. SWIGTYPE (CLASS::*)
  495. ""
  496. /* Exception handling */
  497. %typemap(throws) int,
  498. long,
  499. short,
  500. unsigned int,
  501. unsigned long,
  502. unsigned short {
  503. char error_msg[256];
  504. sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
  505. SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg);
  506. RETURN $null;
  507. }
  508. %typemap(throws) SWIGTYPE {
  509. (void)$1;
  510. SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
  511. RETURN $null;
  512. }
  513. %typemap(throws) char * {
  514. SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1);
  515. RETURN $null;
  516. }
  517. /* Typemaps for code generation in proxy classes and C# type wrapper classes */
  518. /* The in typemap is used for converting function parameter types from the type
  519. * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */
  520. %typemap(m3in) bool, const bool &,
  521. char, const char &,
  522. signed char, const signed char &,
  523. unsigned char, const unsigned char &,
  524. short, const short &,
  525. unsigned short, const unsigned short &,
  526. int, const int &,
  527. unsigned int, const unsigned int &,
  528. long, const long &,
  529. unsigned long, const unsigned long &,
  530. long long, const long long &,
  531. unsigned long long, const unsigned long long &,
  532. float, const float &,
  533. double, const double &,
  534. char *,
  535. char[ANY],
  536. enum SWIGTYPE
  537. "$input"
  538. %typemap(m3in) SWIGTYPE "$&*1_type.getCPtr($input)"
  539. %typemap(m3in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "$1_basetype.getCPtr($input)"
  540. /* The m3out typemap is used for converting function return types from the return type
  541. * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. */
  542. %typemap(m3out) bool, const bool &,
  543. char, const char &,
  544. signed char, const signed char &,
  545. unsigned char, const unsigned char &,
  546. short, const short &,
  547. unsigned short, const unsigned short &,
  548. int, const int &,
  549. unsigned int, const unsigned int &,
  550. long, const long &,
  551. unsigned long, const unsigned long &,
  552. long long, const long long &,
  553. unsigned long long, const unsigned long long &,
  554. float, const float &,
  555. double, const double &,
  556. char *,
  557. char[ANY],
  558. enum SWIGTYPE
  559. %{$imcall%}
  560. %typemap(m3out) void %{$imcall%}
  561. %typemap(m3out) SWIGTYPE %{
  562. RETURN NEW(REF $1_basetype, $imcall);
  563. %}
  564. %typemap(m3out) SWIGTYPE & %{
  565. RETURN NEW($1_basetype, $imcall, $owner);
  566. %}
  567. %typemap(m3out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  568. cPtr := $imcall;
  569. RETURN (cPtr = IntPtr.Zero) ? null : NEW($1_basetype, cPtr, $owner);
  570. %}
  571. /* Properties */
  572. %typemap(m3varin) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  573. PROCEDURE Set$var (value: $vartype) =
  574. BEGIN
  575. $imcall;
  576. END Set$var;
  577. %}
  578. %typemap(m3varout) bool, const bool &,
  579. char, const char &,
  580. signed char, const signed char &,
  581. unsigned char, const unsigned char &,
  582. short, const short &,
  583. unsigned short, const unsigned short &,
  584. int, const int &,
  585. unsigned int, const unsigned int &,
  586. long, const long &,
  587. unsigned long, const unsigned long &,
  588. long long, const long long &,
  589. unsigned long long, const unsigned long long &,
  590. float, const float &,
  591. double, const double &,
  592. char *,
  593. char[ANY],
  594. enum SWIGTYPE %{
  595. PROCEDURE Get$var (): $vartype =
  596. BEGIN
  597. RETURN $imcall;
  598. END Get$var;
  599. %}
  600. %typemap(m3varout) void %{
  601. get {
  602. $imcall;
  603. } %}
  604. %typemap(m3varout) SWIGTYPE %{
  605. get {
  606. RETURN new $&*1_mangle($imcall, true);
  607. } %}
  608. %typemap(m3varout) SWIGTYPE & %{
  609. get {
  610. RETURN new $1_basetype($imcall, $owner);
  611. } %}
  612. %typemap(m3varout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  613. get {
  614. IntPtr cPtr = $imcall;
  615. RETURN (cPtr == IntPtr.Zero) ? null : new $1_basetype(cPtr, $owner);
  616. } %}
  617. /* Typemaps used for the generation of proxy and type wrapper class code */
  618. %typemap(m3base) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  619. %typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public"
  620. %typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  621. %typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;"
  622. %typemap(m3interfaces) SWIGTYPE "IDisposable"
  623. %typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  624. %typemap(m3ptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal"
  625. %typemap(m3finalize) SWIGTYPE %{
  626. ~$1_basetype() {
  627. Dispose();
  628. }
  629. %}
  630. %typemap(m3destruct, methodname="Dispose") SWIGTYPE {
  631. if(swigCPtr != IntPtr.Zero && swigCMemOwn) {
  632. $imcall;
  633. swigCMemOwn = false;
  634. }
  635. swigCPtr = IntPtr.Zero;
  636. GC.SuppressFinalize(this);
  637. }
  638. %typemap(m3destruct_derived, methodname="Dispose") SWIGTYPE {
  639. if(swigCPtr != IntPtr.Zero && swigCMemOwn) {
  640. $imcall;
  641. swigCMemOwn = false;
  642. }
  643. swigCPtr = IntPtr.Zero;
  644. GC.SuppressFinalize(this);
  645. base.Dispose();
  646. }
  647. %typemap(m3getcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  648. internal static IntPtr getCPtr($1_basetype obj) {
  649. RETURN (obj == null) ? IntPtr.Zero : obj.swigCPtr;
  650. }
  651. %}
  652. /* M3 specific directives */
  653. #define %m3multiretval %feature("modula3:multiretval")
  654. #define %constnumeric(num) %feature("constnumeric","num")
  655. %pragma(modula3) moduleimports=%{
  656. IMPORT BlaBla;
  657. %}
  658. %pragma(modula3) imclassimports=%{
  659. FROM BlaBla IMPORT Bla;
  660. %}
  661. /* Some ANSI C typemaps */
  662. %apply unsigned long { size_t };