Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
6.8 KiB

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