modula3.swg 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  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) SWIGTYPE && "$1_type"
  312. %typemap(m3rawtype) const SWIGTYPE && "UNTRACED REF $1_basetype"
  313. %typemap(m3rawtype) SWIGTYPE && "UNTRACED REF $1_basetype"
  314. %typemap(m3rawintype) const SWIGTYPE && "$1_basetype"
  315. %typemap(m3rawinmode) const SWIGTYPE && "READONLY"
  316. %typemap(m3rawintype) SWIGTYPE && "$1_basetype"
  317. %typemap(m3rawinmode) SWIGTYPE && "VAR"
  318. %typemap(m3rawrettype) const SWIGTYPE && "UNTRACED REF $1_basetype"
  319. %typemap(m3rawrettype) SWIGTYPE && "UNTRACED REF $1_basetype"
  320. %typemap(m3wraptype) SWIGTYPE && "$1_basetype"
  321. %typemap(m3wrapintype) const SWIGTYPE && "$1_basetype"
  322. %typemap(m3wrapinmode) const SWIGTYPE && "READONLY"
  323. %typemap(m3wrapintype) SWIGTYPE && "$1_basetype"
  324. %typemap(m3wrapinmode) SWIGTYPE && "VAR"
  325. %typemap(m3wrapouttype) SWIGTYPE && "$1_basetype"
  326. %typemap(m3wraprettype) SWIGTYPE && "UNTRACED REF $1_basetype"
  327. %typemap(ctype) enum SWIGTYPE "$1_type"
  328. %typemap(m3rawtype) enum SWIGTYPE "C.int"
  329. %typemap(m3rawintype) enum SWIGTYPE "C.int (* $1_type *)"
  330. %typemap(m3rawrettype) enum SWIGTYPE "C.int"
  331. %typemap(m3wraptype) enum SWIGTYPE "$*1_type"
  332. %typemap(m3wrapintype) enum SWIGTYPE "$1_type"
  333. %typemap(m3wrapouttype) enum SWIGTYPE "$1_type"
  334. %typemap(m3wraprettype) enum SWIGTYPE "$*1_type"
  335. /* pointer to a class member */
  336. %typemap(ctype) SWIGTYPE (CLASS::*) "$1_type"
  337. %typemap(m3rawtype) SWIGTYPE (CLASS::*) "REFANY"
  338. %typemap(m3wraptype) SWIGTYPE (CLASS::*) "$1_basetype"
  339. /* The following are the in, out, freearg, argout typemaps.
  340. These are the PInvoke code generating typemaps for converting from C# to C and visa versa. */
  341. /* primitive types */
  342. %typemap(in) bool
  343. %{ $1 = $input ? true : false; %}
  344. %typemap(in) char,
  345. signed char,
  346. unsigned char,
  347. short,
  348. unsigned short,
  349. int,
  350. unsigned int,
  351. long,
  352. unsigned long,
  353. long long,
  354. unsigned long long,
  355. float,
  356. double,
  357. enum SWIGTYPE
  358. %{ $1 = ($1_ltype)$input; %}
  359. %typemap(out) bool %{ $result = $1; %}
  360. %typemap(out) char %{ $result = $1; %}
  361. %typemap(out) signed char %{ $result = $1; %}
  362. %typemap(out) unsigned char %{ $result = $1; %}
  363. %typemap(out) short %{ $result = $1; %}
  364. %typemap(out) unsigned short %{ $result = $1; %}
  365. %typemap(out) int %{ $result = $1; %}
  366. %typemap(out) unsigned int %{ $result = $1; %}
  367. %typemap(out) long %{ $result = $1; %}
  368. %typemap(out) unsigned long %{ $result = $1; %}
  369. %typemap(out) long long %{ $result = $1; %}
  370. %typemap(out) unsigned long long %{ $result = $1; %}
  371. %typemap(out) float %{ $result = $1; %}
  372. %typemap(out) double %{ $result = $1; %}
  373. %typemap(out) enum SWIGTYPE %{ $result = $1; %}
  374. /* char * - treat as String */
  375. %typemap(in) char * {
  376. $1 = $input;
  377. }
  378. //%typemap(freearg) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); }
  379. //%typemap(out) char * { if($1) $result = JCALL1(NewStringUTF, jenv, $1); }
  380. %typemap(out) void ""
  381. /* primitive types by const reference */
  382. %typemap(in) const bool & (bool temp)
  383. %{ temp = $input ? true : false;
  384. $1 = &temp; %}
  385. %typemap(in) const char & (char temp),
  386. const signed char & (signed char temp),
  387. const unsigned char & (unsigned char temp),
  388. const short & (short temp),
  389. const unsigned short & (unsigned short temp),
  390. const int & (int temp),
  391. const unsigned int & (unsigned int temp),
  392. const long & (long temp),
  393. const unsigned long & (unsigned long temp),
  394. const long long & ($*1_ltype temp),
  395. const unsigned long long & ($*1_ltype temp),
  396. const float & (float temp),
  397. const double & (double temp)
  398. %{ temp = ($*1_ltype)$input;
  399. $1 = &temp; %}
  400. %typemap(out) const bool & %{ $result = *$1; %}
  401. %typemap(out) const char & %{ $result = *$1; %}
  402. %typemap(out) const signed char & %{ $result = *$1; %}
  403. %typemap(out) const unsigned char & %{ $result = *$1; %}
  404. %typemap(out) const short & %{ $result = *$1; %}
  405. %typemap(out) const unsigned short & %{ $result = *$1; %}
  406. %typemap(out) const int & %{ $result = *$1; %}
  407. %typemap(out) const unsigned int & %{ $result = *$1; %}
  408. %typemap(out) const long & %{ $result = *$1; %}
  409. %typemap(out) const unsigned long & %{ $result = *$1; %}
  410. %typemap(out) const long long & %{ $result = *$1; %}
  411. %typemap(out) const unsigned long long & %{ $result = *$1; %}
  412. %typemap(out) const float & %{ $result = *$1; %}
  413. %typemap(out) const double & %{ $result = *$1; %}
  414. /* Default handling. Object passed by value. Convert to a pointer */
  415. %typemap(in) SWIGTYPE ($&1_type argp)
  416. %{ argp = *($&1_ltype*)&$input;
  417. if (!argp) {
  418. // SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
  419. RETURN $null;
  420. }
  421. $1 = *argp; %}
  422. %typemap(out) SWIGTYPE
  423. #ifdef __cplusplus
  424. %{*($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); %}
  425. #else
  426. {
  427. $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
  428. memmove($1ptr, &$1, sizeof($1_type));
  429. *($&1_ltype*)&$result = $1ptr;
  430. }
  431. #endif
  432. /* Generic pointers and references */
  433. %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
  434. %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
  435. if(!$1) {
  436. //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
  437. RETURN $null;
  438. } %}
  439. %typemap(in) SWIGTYPE && %{ $1 = *($&1_ltype)&$input;
  440. if(!$1) {
  441. //SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
  442. RETURN $null;
  443. } %}
  444. %typemap(out) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE (CLASS::*) %{ *($&1_ltype)&$result = $1; %}
  445. /* Default array handling */
  446. %typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
  447. %typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %}
  448. /* char[ANY] - treat as String */
  449. %typemap(in) char[ANY] {
  450. $1 = $input;
  451. }
  452. %typemap(argout) char[ANY] ""
  453. %typemap(freearg) char[ANY] ""//{ if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, $1); }
  454. %typemap(out) char[ANY] { if($1) $result = $1; }
  455. /* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions
  456. * that cannot be overloaded in C# as more than one C++ type maps to a single C# type */
  457. %typecheck(SWIG_TYPECHECK_BOOL) /* Java boolean */
  458. bool,
  459. const bool &
  460. ""
  461. %typecheck(SWIG_TYPECHECK_CHAR) /* Java char */
  462. char,
  463. const char &
  464. ""
  465. %typecheck(SWIG_TYPECHECK_INT8) /* Java byte */
  466. signed char,
  467. const signed char &
  468. ""
  469. %typecheck(SWIG_TYPECHECK_INT16) /* Java short */
  470. unsigned char,
  471. short,
  472. const unsigned char &,
  473. const short &
  474. ""
  475. %typecheck(SWIG_TYPECHECK_INT32) /* Java int */
  476. unsigned short,
  477. int,
  478. long,
  479. const unsigned short &,
  480. const int &,
  481. const long &,
  482. enum SWIGTYPE
  483. ""
  484. %typecheck(SWIG_TYPECHECK_INT64) /* Java long */
  485. unsigned int,
  486. unsigned long,
  487. long long,
  488. const unsigned int &,
  489. const unsigned long &,
  490. const long long &
  491. ""
  492. %typecheck(SWIG_TYPECHECK_INT128) /* Java BigInteger */
  493. unsigned long long
  494. ""
  495. %typecheck(SWIG_TYPECHECK_FLOAT) /* Java float */
  496. float,
  497. const float &
  498. ""
  499. %typecheck(SWIG_TYPECHECK_DOUBLE) /* Java double */
  500. double,
  501. const double &
  502. ""
  503. %typecheck(SWIG_TYPECHECK_STRING) /* Java String */
  504. char *,
  505. char[ANY]
  506. ""
  507. %typecheck(SWIG_TYPECHECK_POINTER) /* Default */
  508. SWIGTYPE,
  509. SWIGTYPE *,
  510. SWIGTYPE &,
  511. SWIGTYPE &&,
  512. SWIGTYPE [],
  513. SWIGTYPE (CLASS::*)
  514. ""
  515. /* Exception handling */
  516. %typemap(throws) int,
  517. long,
  518. short,
  519. unsigned int,
  520. unsigned long,
  521. unsigned short {
  522. char error_msg[256];
  523. sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
  524. SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, error_msg);
  525. RETURN $null;
  526. }
  527. %typemap(throws) SWIGTYPE {
  528. (void)$1;
  529. SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, "C++ $1_type exception thrown");
  530. RETURN $null;
  531. }
  532. %typemap(throws) char * {
  533. SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, $1);
  534. RETURN $null;
  535. }
  536. /* Typemaps for code generation in proxy classes and C# type wrapper classes */
  537. /* The in typemap is used for converting function parameter types from the type
  538. * used in the proxy, module or type wrapper class to the type used in the PInvoke class. */
  539. %typemap(m3in) 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. "$input"
  557. %typemap(m3in) SWIGTYPE "$&*1_type.getCPtr($input)"
  558. %typemap(m3in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "$1_basetype.getCPtr($input)"
  559. /* The m3out typemap is used for converting function return types from the return type
  560. * used in the PInvoke class to the type returned by the proxy, module or type wrapper class. */
  561. %typemap(m3out) bool, const bool &,
  562. char, const char &,
  563. signed char, const signed char &,
  564. unsigned char, const unsigned char &,
  565. short, const short &,
  566. unsigned short, const unsigned short &,
  567. int, const int &,
  568. unsigned int, const unsigned int &,
  569. long, const long &,
  570. unsigned long, const unsigned long &,
  571. long long, const long long &,
  572. unsigned long long, const unsigned long long &,
  573. float, const float &,
  574. double, const double &,
  575. char *,
  576. char[ANY],
  577. enum SWIGTYPE
  578. %{$imcall%}
  579. %typemap(m3out) void %{$imcall%}
  580. %typemap(m3out) SWIGTYPE %{
  581. RETURN NEW(REF $1_basetype, $imcall);
  582. %}
  583. %typemap(m3out) SWIGTYPE & %{
  584. RETURN NEW($1_basetype, $imcall, $owner);
  585. %}
  586. %typemap(m3out) SWIGTYPE && %{
  587. RETURN NEW($1_basetype, $imcall, $owner);
  588. %}
  589. %typemap(m3out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  590. cPtr := $imcall;
  591. RETURN (cPtr = IntPtr.Zero) ? null : NEW($1_basetype, cPtr, $owner);
  592. %}
  593. /* Properties */
  594. %typemap(m3varin) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  595. PROCEDURE Set$var (value: $vartype) =
  596. BEGIN
  597. $imcall;
  598. END Set$var;
  599. %}
  600. %typemap(m3varout) bool, const bool &,
  601. char, const char &,
  602. signed char, const signed char &,
  603. unsigned char, const unsigned char &,
  604. short, const short &,
  605. unsigned short, const unsigned short &,
  606. int, const int &,
  607. unsigned int, const unsigned int &,
  608. long, const long &,
  609. unsigned long, const unsigned long &,
  610. long long, const long long &,
  611. unsigned long long, const unsigned long long &,
  612. float, const float &,
  613. double, const double &,
  614. char *,
  615. char[ANY],
  616. enum SWIGTYPE %{
  617. PROCEDURE Get$var (): $vartype =
  618. BEGIN
  619. RETURN $imcall;
  620. END Get$var;
  621. %}
  622. %typemap(m3varout) void %{
  623. get {
  624. $imcall;
  625. } %}
  626. %typemap(m3varout) SWIGTYPE %{
  627. get {
  628. RETURN new $&*1_mangle($imcall, true);
  629. } %}
  630. %typemap(m3varout) SWIGTYPE & %{
  631. get {
  632. RETURN new $1_basetype($imcall, $owner);
  633. } %}
  634. %typemap(m3varout) SWIGTYPE && %{
  635. get {
  636. RETURN new $1_basetype($imcall, $owner);
  637. } %}
  638. %typemap(m3varout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  639. get {
  640. IntPtr cPtr = $imcall;
  641. RETURN (cPtr == IntPtr.Zero) ? null : new $1_basetype(cPtr, $owner);
  642. } %}
  643. /* Typemaps used for the generation of proxy and type wrapper class code */
  644. %typemap(m3base) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  645. %typemap(m3classmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "public"
  646. %typemap(m3code) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  647. %typemap(m3imports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "using System;"
  648. %typemap(m3interfaces) SWIGTYPE "IDisposable"
  649. %typemap(m3interfaces_derived) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
  650. %typemap(m3ptrconstructormodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) "internal"
  651. %typemap(m3finalize) SWIGTYPE %{
  652. ~$1_basetype() {
  653. Dispose();
  654. }
  655. %}
  656. %typemap(m3destruct, methodname="Dispose") SWIGTYPE {
  657. if(swigCPtr != IntPtr.Zero && swigCMemOwn) {
  658. $imcall;
  659. swigCMemOwn = false;
  660. }
  661. swigCPtr = IntPtr.Zero;
  662. GC.SuppressFinalize(this);
  663. }
  664. %typemap(m3destruct_derived, methodname="Dispose") SWIGTYPE {
  665. if(swigCPtr != IntPtr.Zero && swigCMemOwn) {
  666. $imcall;
  667. swigCMemOwn = false;
  668. }
  669. swigCPtr = IntPtr.Zero;
  670. GC.SuppressFinalize(this);
  671. base.Dispose();
  672. }
  673. %typemap(m3getcptr) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
  674. internal static IntPtr getCPtr($1_basetype obj) {
  675. RETURN (obj == null) ? IntPtr.Zero : obj.swigCPtr;
  676. }
  677. %}
  678. /* M3 specific directives */
  679. #define %m3multiretval %feature("modula3:multiretval")
  680. #define %constnumeric(num) %feature("constnumeric","num")
  681. %pragma(modula3) moduleimports=%{
  682. IMPORT BlaBla;
  683. %}
  684. %pragma(modula3) imclassimports=%{
  685. FROM BlaBla IMPORT Bla;
  686. %}
  687. /* Some ANSI C typemaps */
  688. %apply unsigned long { size_t };
  689. /* Array reference typemaps */
  690. %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
  691. %apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) }
  692. /* const pointers */
  693. %apply SWIGTYPE * { SWIGTYPE *const }