PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/trunk/Lib/modula3/modula3.swg

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