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

/tags/rel-1-3-27/SWIG/Lib/chicken/chicken.swg

#
Unknown | 709 lines | 593 code | 116 blank | 0 comment | 0 complexity | d6c59d5e4080b5ae4dcec19af035ceb4 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * chicken.swg
  3. *
  4. * CHICKEN configuration module.
  5. * ----------------------------------------------------------------------------- */
  6. /* chicken.h has to appear first. */
  7. %insert(runtime) %{
  8. #include "chicken.h"
  9. %}
  10. %insert(runtime) "swigrun.swg"; // Common C API type-checking code
  11. %insert(runtime) "chickenrun.swg"; // CHICKEN run-time code
  12. /* -----------------------------------------------------------------------------
  13. * standard typemaps
  14. * ----------------------------------------------------------------------------- */
  15. /*
  16. CHICKEN: C
  17. ----------
  18. fixnum: int, short, unsigned int, unsigned short, unsigned char,
  19. signed char
  20. char: char
  21. bool: bool
  22. flonum: float, double, long, long long, unsigned long, unsigned long
  23. long
  24. */
  25. /* --- Primitive types --- */
  26. %define SIMPLE_TYPEMAP(type_, from_scheme, to_scheme, checker, convtype, storage_)
  27. %typemap(in) type_
  28. %{ if (!checker ($input)) {
  29. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'");
  30. }
  31. $1 = ($1_ltype) from_scheme ($input); %}
  32. /* Const primitive references. Passed by value */
  33. %typemap(in) const type_ & ($*1_ltype temp)
  34. %{ if (!checker ($input)) {
  35. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'type_'");
  36. }
  37. temp = ($*1_ltype) from_scheme ($input);
  38. $1 = &temp; %}
  39. /* --- Variable input --- */
  40. %typemap(varin) type_
  41. %{ if (!checker ($input)) {
  42. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use '$1_ltype' for variable '$name' of type 'type_'");
  43. }
  44. $1 = ($1_ltype) from_scheme ($input); %}
  45. #if "storage_" == "0"
  46. %typemap(out) type_
  47. %{
  48. $result = to_scheme (convtype ($1));
  49. %}
  50. /* References to primitive types. Return by value */
  51. %typemap(out) const type_ &
  52. %{
  53. $result = to_scheme (convtype (*$1));
  54. %}
  55. /* --- Variable output --- */
  56. %typemap(varout) type_
  57. %{
  58. $result = to_scheme (convtype ($varname));
  59. %}
  60. %typemap(throws) type_
  61. %{
  62. SWIG_Chicken_ThrowException(to_scheme ( convtype ($1)));
  63. %}
  64. #else
  65. %typemap(out) type_
  66. %{
  67. {
  68. C_word *space = C_alloc(storage_);
  69. $result = to_scheme (&space, convtype ($1));
  70. }
  71. %}
  72. /* References to primitive types. Return by value */
  73. %typemap(out) const type_ &
  74. %{
  75. {
  76. C_word *space = C_alloc(storage_);
  77. $result = to_scheme (&space, convtype (*$1));
  78. }
  79. %}
  80. /* --- Variable output --- */
  81. %typemap(varout) type_
  82. %{
  83. {
  84. C_word *space = C_alloc(storage_);
  85. $result = to_scheme (&space, convtype ($varname));
  86. }
  87. %}
  88. %typemap(throws) type_
  89. %{
  90. {
  91. C_word *space = C_alloc(storage_);
  92. SWIG_Chicken_ThrowException(to_scheme (&space, convtype ($1)));
  93. }
  94. %}
  95. #endif
  96. /* --- Constants --- */
  97. %typemap(constcode) type_
  98. "static const $1_type $result = $value;"
  99. %enddef
  100. SIMPLE_TYPEMAP(int, C_num_to_int, C_fix, C_swig_is_number, (int), 0);
  101. //SIMPLE_TYPEMAP(enum SWIGTYPE, C_unfix, C_fix, C_swig_is_fixnum, (int), 0);
  102. SIMPLE_TYPEMAP(short, C_num_to_int, C_fix, C_swig_is_number, (int), 0);
  103. SIMPLE_TYPEMAP(long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
  104. SIMPLE_TYPEMAP(long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
  105. SIMPLE_TYPEMAP(unsigned int, C_num_to_unsigned_int, C_fix, C_swig_is_number, (int), 0);
  106. SIMPLE_TYPEMAP(unsigned short, C_num_to_unsigned_int, C_fix, C_swig_is_number, (int), 0);
  107. SIMPLE_TYPEMAP(unsigned long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
  108. SIMPLE_TYPEMAP(unsigned long long, C_num_to_long, C_long_to_num, C_swig_is_long, (long), C_SIZEOF_FLONUM);
  109. SIMPLE_TYPEMAP(unsigned char, C_character_code, C_make_character, C_swig_is_char, (unsigned int), 0);
  110. SIMPLE_TYPEMAP(signed char, C_character_code, C_make_character, C_swig_is_char, (int), 0);
  111. SIMPLE_TYPEMAP(char, C_character_code, C_make_character, C_swig_is_char, (char), 0);
  112. SIMPLE_TYPEMAP(bool, C_truep, C_mk_bool, C_swig_is_bool, (bool), 0);
  113. SIMPLE_TYPEMAP(float, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM);
  114. SIMPLE_TYPEMAP(double, C_c_double, C_flonum, C_swig_is_number, (double), C_SIZEOF_FLONUM);
  115. /* enum SWIGTYPE */
  116. %apply int { enum SWIGTYPE };
  117. %apply const int& { const enum SWIGTYPE& };
  118. %typemap(varin) enum SWIGTYPE
  119. {
  120. if (!C_swig_is_fixnum($input) && sizeof(int) != sizeof($1)) {
  121. swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "enum variable '$name' can not be set");
  122. }
  123. *((int *)(void *)&$1) = C_unfix($input);
  124. }
  125. /* --- Input arguments --- */
  126. /* Strings */
  127. %typemap(in) char *
  128. { if ($input == C_SCHEME_FALSE) {
  129. $1 = NULL;
  130. }
  131. else {
  132. if (!C_swig_is_string ($input)) {
  133. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'char *'");
  134. }
  135. $1 = ($ltype) SWIG_MakeString ($input);
  136. }
  137. }
  138. %typemap(freearg) char * "if ($1 != NULL) { free ($1); }"
  139. /* Pointers, references, and arrays */
  140. %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *, SWIGTYPE [], SWIGTYPE & {
  141. $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, $disown);
  142. }
  143. %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE *DISOWN {
  144. $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, $argnum, SWIG_POINTER_DISOWN);
  145. }
  146. /* Void pointer. Accepts any kind of pointer */
  147. %typemap(in) void * {
  148. $1 = SWIG_MustGetPtr($input, NULL, $argnum, 0);
  149. }
  150. %typemap(varin) SWIGTYPE * {
  151. $1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, SWIG_POINTER_DISOWN);
  152. }
  153. %typemap(varin) SWIGTYPE & {
  154. $1 = *(($1_ltype)SWIG_MustGetPtr($input, $descriptor, 1, 0));
  155. }
  156. %typemap(varin) SWIGTYPE [] {
  157. SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "Type error");
  158. }
  159. %typemap(varin) SWIGTYPE [ANY] {
  160. void *temp;
  161. int ii;
  162. $1_basetype *b = 0;
  163. temp = SWIG_MustGetPtr($input, $1_descriptor, 1, 0);
  164. b = ($1_basetype *) $1;
  165. for (ii = 0; ii < $1_size; ii++) b[ii] = *(($1_basetype *) temp + ii);
  166. }
  167. %typemap(varin) void * {
  168. $1 = SWIG_MustGetPtr($input, NULL, 1, 0);
  169. }
  170. %typemap(out,chickenfastproxy="1") SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
  171. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  172. $result = SWIG_NewPointerObjProxy($1, $descriptor, $owner, $proxy);
  173. }
  174. %typemap(out,chickenfastproxy="1") SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
  175. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  176. swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor,(void **) &$1);
  177. $result = SWIG_NewPointerObjProxy($1, ty, $owner, $proxy);
  178. }
  179. %typemap(varout,chickenfastproxy="1") SWIGTYPE *, SWIGTYPE [] {
  180. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  181. $result = SWIG_NewPointerObjProxy($varname, $descriptor, 0, 0);
  182. }
  183. %typemap(varout,chickenfastproxy="1") SWIGTYPE & {
  184. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  185. $result = SWIG_NewPointerObjProxy((void *) &$varname, $1_descriptor, 0, 0);
  186. }
  187. /* Pass-by-value */
  188. %typemap(in,closcode="(slot-ref $input 'swig-this)") SWIGTYPE($&1_ltype argp) {
  189. argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, $argnum, 0);
  190. $1 = *argp;
  191. }
  192. %typemap(varin) SWIGTYPE {
  193. $&1_ltype argp;
  194. argp = ($&1_ltype)SWIG_MustGetPtr($input, $&1_descriptor, 1, 0);
  195. $1 = *argp;
  196. }
  197. %typemap(out,chickenfastproxy="1") SWIGTYPE
  198. #ifdef __cplusplus
  199. {
  200. $&1_ltype resultptr;
  201. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  202. resultptr = new $1_ltype(($1_ltype &) $1);
  203. $result = SWIG_NewPointerObjProxy(resultptr, $&1_descriptor, 1, $proxy);
  204. }
  205. #else
  206. {
  207. $&1_ltype resultptr;
  208. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  209. resultptr = ($&1_ltype) malloc(sizeof($1_type));
  210. memmove(resultptr, &$1, sizeof($1_type));
  211. $result = SWIG_NewPointerObjProxy(resultptr, $&1_descriptor, 1,$proxy);
  212. }
  213. #endif
  214. %typemap(varout,chickenfastproxy="1") SWIGTYPE
  215. #ifdef __cplusplus
  216. {
  217. $&1_ltype resultptr;
  218. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  219. resultptr = new $1_ltype(($1_ltype&) $1);
  220. $result = SWIG_NewPointerObjProxy(resultptr, $&1_descriptor, 0, 0);
  221. }
  222. #else
  223. {
  224. $&1_ltype resultptr;
  225. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  226. resultptr = ($&1_ltype) malloc(sizeof($1_type));
  227. memmove(resultptr, &$1, sizeof($1_type));
  228. $result = SWIG_NewPointerObjProxy(resultptr, $&1_descriptor, 0, 0);
  229. }
  230. #endif
  231. /* --- Output values --- */
  232. /* Strings */
  233. %typemap(out)
  234. char *
  235. { char *s = (char*) $1;
  236. if ($1 == NULL) {
  237. $result = C_SCHEME_FALSE;
  238. }
  239. else {
  240. int string_len = strlen ($1);
  241. C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
  242. $result = C_string (&string_space, string_len, s);
  243. }
  244. }
  245. %typemap(varout)
  246. char *
  247. { char *s = (char*) $varname;
  248. if ($varname == NULL) {
  249. $result = C_SCHEME_FALSE;
  250. }
  251. else {
  252. int string_len = strlen ($varname);
  253. C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
  254. $result = C_string (&string_space, string_len, s);
  255. }
  256. }
  257. %typemap(throws) char *
  258. {
  259. if ($1 == NULL) {
  260. SWIG_Chicken_ThrowException(C_SCHEME_FALSE);
  261. } else {
  262. int string_len = strlen($1);
  263. C_word *string_space = C_alloc(C_SIZEOF_STRING(string_len));
  264. SWIG_Chicken_ThrowException(C_string(&string_space, string_len, (char *) $1));
  265. }
  266. }
  267. /* Void */
  268. %typemap(out) void
  269. %{
  270. $result = C_SCHEME_UNDEFINED;
  271. %}
  272. /* Special typemap for character array return values */
  273. %typemap(out)
  274. char [ANY], const char [ANY]
  275. %{ if ($1 == NULL) {
  276. $result = C_SCHEME_FALSE;
  277. }
  278. else {
  279. const int string_len = strlen ($1);
  280. C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
  281. $result = C_string (&string_space, string_len, $1);
  282. } %}
  283. /* Primitive types--return by value */
  284. /* --- Variable input --- */
  285. /* A string */
  286. #ifdef __cplusplus
  287. %typemap(varin) char * {
  288. if ($input == C_SCHEME_FALSE) {
  289. $1 = NULL;
  290. }
  291. else if (!C_swig_is_string ($input)) {
  292. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
  293. }
  294. else {
  295. char *temp = C_c_string ($input);
  296. int len = C_header_size ($input);
  297. if ($1) delete [] $1;
  298. $1 = ($type) new char[len+1];
  299. strncpy((char*)$1, temp, len);
  300. ((char*)$1) [len] = 0;
  301. }
  302. }
  303. %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * {
  304. if ($input == C_SCHEME_FALSE) {
  305. $1 = NULL;
  306. }
  307. else if (!C_swig_is_string ($input)) {
  308. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
  309. }
  310. else {
  311. char *temp = C_c_string ($input);
  312. int len = C_header_size ($input);
  313. $1 = ($type) new char[len+1];
  314. strncpy((char*)$1,temp,len);
  315. ((char*)$1) [len] = 0;
  316. }
  317. }
  318. #else
  319. %typemap(varin) char * {
  320. if ($input == C_SCHEME_FALSE) {
  321. $1 = NULL;
  322. }
  323. else if (!C_swig_is_string ($input)) {
  324. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
  325. }
  326. else {
  327. char *temp = C_c_string ($input);
  328. int len = C_header_size ($input);
  329. if ($1) free((char*) $1);
  330. $1 = ($type) malloc(len+1);
  331. strncpy((char*)$1,temp,len);
  332. ((char*)$1) [len] = 0;
  333. }
  334. }
  335. %typemap(varin,warning="451:Setting const char * variable may leak memory") const char * {
  336. if ($input == C_SCHEME_FALSE) {
  337. $1 = NULL;
  338. }
  339. else if (!C_swig_is_string ($input)) {
  340. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
  341. }
  342. else {
  343. char *temp = C_c_string ($input);
  344. int len = C_header_size ($input);
  345. $1 = ($type) malloc(len+1);
  346. strncpy((char*)$1,temp,len);
  347. ((char*)$1) [len] = 0;
  348. }
  349. }
  350. #endif
  351. %typemap(varin) char [] {
  352. swig_barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, "C/C++ variable '$name' is read-only");
  353. }
  354. /* Special case for string array variables */
  355. %typemap(varin) char [ANY] {
  356. if ($input == C_SCHEME_FALSE) {
  357. memset($1,0,$1_dim0*sizeof(char));
  358. }
  359. else if (!C_swig_is_string ($input)) {
  360. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "C variable '$name ($1_ltype)'");
  361. }
  362. else {
  363. char *temp = C_c_string ($input);
  364. strncpy($1,temp,$1_dim0*sizeof(char));
  365. }
  366. }
  367. /* --- Variable output --- */
  368. /* Void */
  369. %typemap(varout) void "$result = C_SCHEME_UNDEFINED;";
  370. /* Special typemap for character array return values */
  371. %typemap(varout) char [ANY], const char [ANY]
  372. %{ if ($varname == NULL) {
  373. $result = C_SCHEME_FALSE;
  374. }
  375. else {
  376. const int string_len = strlen ($varname);
  377. C_word *string_space = C_alloc (C_SIZEOF_STRING (string_len));
  378. $result = C_string (&string_space, string_len, (char *) $varname);
  379. }
  380. %}
  381. /* --- Constants --- */
  382. %typemap(constcode) char *
  383. "static const char *$result = $value;"
  384. %typemap(constcode) SWIGTYPE *, SWIGTYPE &, SWIGTYPE []
  385. "static const void *$result = (void*) $value;"
  386. %typemap(constcode) SWIGTYPE (CLASS::*)
  387. "static const void *$result = (void*) &$value;"
  388. /* ------------------------------------------------------------
  389. * String & length
  390. * ------------------------------------------------------------ */
  391. %typemap(in) (char *STRING, int LENGTH) {
  392. if ($input == C_SCHEME_FALSE) {
  393. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use a null/#f string for a char*, int arguments");
  394. }
  395. else if (C_swig_is_string ($input)) {
  396. $1 = ($1_ltype) C_c_string ($input);
  397. $2 = ($2_ltype) C_header_size ($input);
  398. }
  399. else {
  400. swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument #$argnum is not of type 'string'");
  401. }
  402. }
  403. /* ------------------------------------------------------------
  404. * CHICKEN types
  405. * ------------------------------------------------------------ */
  406. %typemap(in) C_word "$1 = $input;";
  407. %typemap(out) C_word "$result = $1;";
  408. /* ------------------------------------------------------------
  409. * Typechecking rules
  410. * ------------------------------------------------------------ */
  411. %typecheck(SWIG_TYPECHECK_INTEGER)
  412. bool, const bool &
  413. {
  414. $1 = C_swig_is_bool ($input);
  415. }
  416. %typecheck(SWIG_TYPECHECK_INTEGER)
  417. int, short,
  418. unsigned int, unsigned short,
  419. signed char, unsigned char,
  420. const int &, const short &,
  421. const unsigned int &, const unsigned short &,
  422. enum SWIGTYPE
  423. {
  424. $1 = C_swig_is_fixnum ($input);
  425. }
  426. %typecheck(SWIG_TYPECHECK_INTEGER)
  427. long,
  428. unsigned long,
  429. long long, unsigned long long,
  430. const long &,
  431. const unsigned long &,
  432. const long long &, const unsigned long long &
  433. {
  434. $1 = (C_swig_is_bool ($input) ||
  435. C_swig_is_fixnum ($input) ||
  436. C_swig_is_flonum ($input)) ? 1 : 0;
  437. }
  438. %typecheck(SWIG_TYPECHECK_DOUBLE)
  439. float, double,
  440. const float &, const double &
  441. {
  442. $1 = C_swig_is_flonum ($input);
  443. }
  444. %typecheck(SWIG_TYPECHECK_CHAR) char {
  445. $1 = C_swig_is_string ($input);
  446. }
  447. %typecheck(SWIG_TYPECHECK_STRING) char * {
  448. $1 = C_swig_is_string ($input);
  449. }
  450. %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
  451. void *ptr;
  452. $1 = !SWIG_ConvertPtr($input, &ptr, $1_descriptor, 0);
  453. }
  454. %typecheck(SWIG_TYPECHECK_VOIDPTR) void * {
  455. void *ptr;
  456. $1 = !SWIG_ConvertPtr($input, &ptr, 0, 0);
  457. }
  458. %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE &
  459. {
  460. void *ptr = 0;
  461. if (SWIG_ConvertPtr($input, &ptr, $descriptor, 0)) {
  462. /* error */
  463. $1 = 0;
  464. } else {
  465. $1 = (ptr != 0);
  466. }
  467. }
  468. %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
  469. {
  470. void *ptr = 0;
  471. if (SWIG_ConvertPtr($input, &ptr, $&descriptor, 0)) {
  472. /* error */
  473. $1 = 0;
  474. } else {
  475. $1 = (ptr != 0);
  476. }
  477. }
  478. /* ------------------------------------------------------------
  479. * Exception handling
  480. * ------------------------------------------------------------ */
  481. /* ------------------------------------------------------------
  482. * --- Exception handling ---
  483. * ------------------------------------------------------------ */
  484. %typemap(throws) SWIGTYPE {
  485. $&ltype temp = new $ltype($1);
  486. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  487. C_word ptr = SWIG_NewPointerObj(temp, $&descriptor,1);
  488. SWIG_Chicken_ThrowException(ptr);
  489. }
  490. %typemap(throws) SWIGTYPE * {
  491. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  492. C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0);
  493. SWIG_Chicken_ThrowException(ptr);
  494. }
  495. %typemap(throws) SWIGTYPE [ANY] {
  496. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  497. C_word ptr = SWIG_NewPointerObj((void *) $1, $descriptor, 0);
  498. SWIG_Chicken_ThrowException(ptr);
  499. }
  500. %typemap(throws) SWIGTYPE & {
  501. C_word *known_space = C_alloc(C_SIZEOF_SWIG_POINTER);
  502. C_word ptr = SWIG_NewPointerObj((void *)&($1),$descriptor,0);
  503. SWIG_Chicken_ThrowException(ptr);
  504. }
  505. /* ------------------------------------------------------------
  506. * ANSI C typemaps
  507. * ------------------------------------------------------------ */
  508. %apply unsigned long { size_t };
  509. /* ------------------------------------------------------------
  510. * Overloaded operator support
  511. * ------------------------------------------------------------ */
  512. #ifdef __cplusplus
  513. %rename(__add__) *::operator+;
  514. %rename(__pos__) *::operator+();
  515. %rename(__pos__) *::operator+() const;
  516. %rename(__sub__) *::operator-;
  517. %rename(__neg__) *::operator-();
  518. %rename(__neg__) *::operator-() const;
  519. %rename(__mul__) *::operator*;
  520. %rename(__div__) *::operator/;
  521. %rename(__mod__) *::operator%;
  522. %rename(__lshift__) *::operator<<;
  523. %rename(__rshift__) *::operator>>;
  524. %rename(__and__) *::operator&;
  525. %rename(__or__) *::operator|;
  526. %rename(__xor__) *::operator^;
  527. %rename(__invert__) *::operator~;
  528. %rename(__iadd__) *::operator+=;
  529. %rename(__isub__) *::operator-=;
  530. %rename(__imul__) *::operator*=;
  531. %rename(__idiv__) *::operator/=;
  532. %rename(__imod__) *::operator%=;
  533. %rename(__ilshift__) *::operator<<=;
  534. %rename(__irshift__) *::operator>>=;
  535. %rename(__iand__) *::operator&=;
  536. %rename(__ior__) *::operator|=;
  537. %rename(__ixor__) *::operator^=;
  538. %rename(__lt__) *::operator<;
  539. %rename(__le__) *::operator<=;
  540. %rename(__gt__) *::operator>;
  541. %rename(__ge__) *::operator>=;
  542. %rename(__eq__) *::operator==;
  543. %rename(__ne__) *::operator!=;
  544. /* Special cases */
  545. %rename(__call__) *::operator();
  546. /* Ignored operators */
  547. %ignorewarn("362:operator= ignored") operator=;
  548. %ignorewarn("383:operator++ ignored") operator++;
  549. %ignorewarn("384:operator-- ignored") operator--;
  550. %ignorewarn("381:operator&& ignored") operator&&;
  551. %ignorewarn("382:operator|| ignored") operator||;
  552. %ignorewarn("386:operator->* ignored") operator->*;
  553. %ignorewarn("389:operator[] ignored (consider using %extend)") operator[];
  554. #endif
  555. /* Warnings for certain CHICKEN keywords */
  556. %include "chickenkw.swg"
  557. /* TinyCLOS <--> Low-level CHICKEN */
  558. %typemap("clos_in") SIMPLE_CLOS_OBJECT * "(slot-ref $input (quote this))"
  559. %typemap("clos_out") SIMPLE_CLOS_OBJECT * "(make $class (quote this) $1)"
  560. %insert(header) %{
  561. #ifdef __cplusplus
  562. extern "C" {
  563. #endif
  564. /* Chicken initialization function */
  565. SWIGEXPORT void SWIG_init(C_word, C_word, C_word) C_noret;
  566. #ifdef __cplusplus
  567. }
  568. #endif
  569. %}
  570. %insert(closprefix) "swigclosprefix.scm"
  571. %insert(init) "swiginit.swg"
  572. %insert(init) %{
  573. /* CHICKEN initialization function */
  574. #ifdef __cplusplus
  575. extern "C" {
  576. #endif
  577. SWIGEXPORT void SWIG_init(C_word argc, C_word closure, C_word continuation) {
  578. int i;
  579. C_word sym;
  580. C_word tmp;
  581. C_word *a;
  582. C_word ret;
  583. C_word *return_vec;
  584. SWIG_InitializeModule(0);
  585. SWIG_PropagateClientData();
  586. ret = C_SCHEME_TRUE;
  587. #if $veclength
  588. return_vec = C_alloc(C_SIZEOF_VECTOR($veclength));
  589. ret = (C_word) return_vec;
  590. *(return_vec++) = C_VECTOR_TYPE | $veclength;
  591. #endif
  592. a = C_alloc(2*$nummethods$symsize);
  593. %}