PageRenderTime 118ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/guile/guile_gh_run.swg

#
Unknown | 258 lines | 230 code | 28 blank | 0 comment | 0 complexity | 2bf42423173bf5f38e946211f0231912 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * guile_gh_run.swg
  3. *
  4. * Guile GH runtime file
  5. * ----------------------------------------------------------------------------- */
  6. #define SWIGGUILE
  7. #include "guile/gh.h"
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <stdlib.h>
  11. #include <assert.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. typedef SCM (*swig_guile_proc)();
  16. #define SWIG_malloc(size) \
  17. SCM_MUST_MALLOC(size)
  18. #define SWIG_free(mem) \
  19. scm_must_free(mem)
  20. #define SWIG_ConvertPtr(s, result, type, flags) \
  21. SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags)
  22. #define SWIG_MustGetPtr(s, type, argnum, flags) \
  23. SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME)
  24. #define SWIG_NewPointerObj(ptr, type, owner) \
  25. SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner)
  26. #define SWIG_GetModule(clientdata) SWIG_Guile_GetModule()
  27. #define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
  28. /* Ignore object-ownership changes in gh mode */
  29. #define SWIG_Guile_MarkPointerNoncollectable(s) (s)
  30. #define SWIG_Guile_MarkPointerDestroyed(s) (s)
  31. #define SWIG_contract_assert(expr, msg) \
  32. if (!(expr)) \
  33. scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \
  34. (char *) FUNC_NAME, (char *) msg, \
  35. SCM_EOL, SCM_BOOL_F); else
  36. /* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for
  37. 1.3.4 compatibility. */
  38. #ifndef SCM_CHAR
  39. # define SCM_CHAR SCM_ICHR
  40. #endif
  41. #ifndef SCM_CHARP
  42. # define SCM_CHARP SCM_ICHRP
  43. #endif
  44. /* This function replaces gh_scm2char, which is broken in Guile 1.4 */
  45. SWIGINTERN char
  46. GSWIG_scm2char (SCM s)
  47. {
  48. if (SCM_CHARP(s)) return SCM_CHAR(s);
  49. scm_wrong_type_arg(NULL, 0, s);
  50. }
  51. #define gh_scm2char GSWIG_scm2char
  52. /* Interface function */
  53. #define SWIG_scm2str(x) gh_scm2newstr(x, NULL)
  54. /* More 1.3.4 compatibility */
  55. #ifndef SCM_INPUT_PORT_P
  56. # define SCM_INPUT_PORT_P SCM_INPORTP
  57. # define SCM_OUTPUT_PORT_P SCM_OUTPORTP
  58. #endif
  59. SWIGINTERN long
  60. SWIG_convert_integer(SCM o,
  61. long lower_bound, long upper_bound,
  62. const char *func_name, int argnum)
  63. {
  64. long value = gh_scm2long(o);
  65. if (value < lower_bound || value > upper_bound)
  66. scm_wrong_type_arg((char *) func_name, argnum, o);
  67. return value;
  68. }
  69. SWIGINTERN unsigned long
  70. SWIG_convert_unsigned_integer(SCM o,
  71. unsigned long lower_bound,
  72. unsigned long upper_bound,
  73. const char *func_name, int argnum)
  74. {
  75. unsigned long value = gh_scm2ulong(o);
  76. if (value < lower_bound || value > upper_bound)
  77. scm_wrong_type_arg((char *) func_name, argnum, o);
  78. return value;
  79. }
  80. SWIGINTERN swig_type_info *
  81. SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal)
  82. {
  83. swig_module_info *iter;
  84. if (!module) return 0;
  85. iter = module;
  86. do {
  87. if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) {
  88. return iter->types[(long) SCM_CAR(s) >> 16];
  89. }
  90. iter = iter->next;
  91. } while (iter != module);
  92. return 0;
  93. }
  94. #ifdef SWIG_GLOBAL
  95. #define SWIG_GUILE_MODULE_STATIC
  96. #elif !defined(SWIG_NOINCLUDE)
  97. #define SWIG_GUILE_MODULE_STATIC static
  98. #endif
  99. #ifdef SWIG_GUILE_MODULE_STATIC
  100. static swig_module_info *swig_guile_module = 0;
  101. SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule(void) {
  102. return swig_guile_module;
  103. }
  104. SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) {
  105. swig_guile_module = pointer;
  106. }
  107. #else
  108. SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(void);
  109. SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer);
  110. #endif
  111. SWIGINTERN SCM
  112. SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr,
  113. swig_type_info *type, int owner)
  114. {
  115. unsigned long tag;
  116. if (ptr==NULL) return SCM_EOL;
  117. if (!module) return SCM_EOL;
  118. for (tag = 0; tag < module->size; ++tag) {
  119. if (module->types[tag] == type)
  120. break;
  121. }
  122. if (tag >= module->size)
  123. return SCM_EOL;
  124. SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr);
  125. }
  126. /* Return 0 if successful. */
  127. SWIGINTERN int
  128. SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result,
  129. swig_type_info *type, int flags)
  130. {
  131. swig_cast_info *cast;
  132. swig_type_info *from;
  133. if (SCM_NULLP(s)) {
  134. *result = NULL;
  135. return SWIG_OK;
  136. } else if (SCM_NIMP(s)) {
  137. from = SWIG_Guile_LookupType(module, s, 1);
  138. if (!from) return SWIG_ERROR;
  139. if (type) {
  140. cast = SWIG_TypeCheckStruct(from, type);
  141. if (cast) {
  142. int newmemory = 0;
  143. *result = SWIG_TypeCast(cast, (void *) SCM_CDR(s), &newmemory);
  144. assert(!newmemory); /* newmemory handling not yet implemented */
  145. return SWIG_OK;
  146. } else {
  147. return SWIG_ERROR;
  148. }
  149. } else {
  150. *result = (void *) SCM_CDR(s);
  151. return SWIG_OK;
  152. }
  153. }
  154. return SWIG_ERROR;
  155. }
  156. SWIGINTERN void *
  157. SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type,
  158. int argnum, int flags, const char *func_name)
  159. {
  160. void *result;
  161. int res = SWIG_Guile_ConvertPtr(module, s, &result, type, flags);
  162. if (!SWIG_IsOK(res)) {
  163. /* type mismatch */
  164. scm_wrong_type_arg((char *) func_name, argnum, s);
  165. }
  166. return result;
  167. }
  168. /* Init */
  169. SWIGINTERN int
  170. print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
  171. {
  172. swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1);
  173. if (type) {
  174. scm_puts((char *) "#<swig ", port);
  175. if (type->str != NULL)
  176. scm_puts((char *) type->str, port);
  177. else
  178. scm_puts((char *) type->name, port);
  179. scm_puts((char *) " ", port);
  180. scm_intprint((long) SCM_CDR(swig_smob), 16, port);
  181. scm_puts((char *) ">", port);
  182. /* non-zero means success */
  183. return 1;
  184. } else {
  185. return 0;
  186. }
  187. }
  188. SWIGINTERN SCM
  189. equalp_swig (SCM A, SCM B)
  190. {
  191. if (SCM_CAR(A) == SCM_CAR(B)
  192. && SCM_CDR(A) == SCM_CDR(B))
  193. return SCM_BOOL_T;
  194. else return SCM_BOOL_F;
  195. }
  196. SWIGINTERN void
  197. SWIG_Guile_Init (swig_module_info *module)
  198. {
  199. *((int *)module->clientdata) =
  200. scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig);
  201. }
  202. SWIGINTERN int
  203. SWIG_Guile_GetArgs (SCM *dest, SCM rest,
  204. int reqargs, int optargs,
  205. const char *procname)
  206. {
  207. int i;
  208. int num_args_passed = 0;
  209. for (i = 0; i<reqargs; i++) {
  210. if (!SCM_CONSP(rest))
  211. scm_wrong_num_args(gh_str02scm((char *) procname));
  212. *dest++ = SCM_CAR(rest);
  213. rest = SCM_CDR(rest);
  214. num_args_passed++;
  215. }
  216. for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
  217. *dest++ = SCM_CAR(rest);
  218. rest = SCM_CDR(rest);
  219. num_args_passed++;
  220. }
  221. for (; i<optargs; i++)
  222. *dest++ = SCM_UNDEFINED;
  223. if (!SCM_NULLP(rest))
  224. scm_wrong_num_args(gh_str02scm((char *) procname));
  225. return num_args_passed;
  226. }
  227. #ifdef __cplusplus
  228. }
  229. #endif
  230. /* guile.swg ends here */