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.

485 lines
14 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_scm_run.swg
  6. * ----------------------------------------------------------------------------- */
  7. #include <libguile.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. typedef SCM (*guile_destructor)(SCM);
  17. typedef struct swig_guile_clientdata {
  18. guile_destructor destroy;
  19. SCM goops_class;
  20. } swig_guile_clientdata;
  21. #define SWIG_scm2str(s) \
  22. SWIG_Guile_scm2newstr(s, NULL)
  23. #define SWIG_malloc(size) \
  24. SCM_MUST_MALLOC(size)
  25. #define SWIG_free(mem) \
  26. scm_must_free(mem)
  27. #define SWIG_ConvertPtr(s, result, type, flags) \
  28. SWIG_Guile_ConvertPtr(s, result, type, flags)
  29. #define SWIG_MustGetPtr(s, type, argnum, flags) \
  30. SWIG_Guile_MustGetPtr(s, type, argnum, flags, FUNC_NAME)
  31. #define SWIG_NewPointerObj(ptr, type, owner) \
  32. SWIG_Guile_NewPointerObj((void*)ptr, type, owner)
  33. #define SWIG_PointerAddress(object) \
  34. SWIG_Guile_PointerAddress(object)
  35. #define SWIG_PointerType(object) \
  36. SWIG_Guile_PointerType(object)
  37. #define SWIG_IsPointerOfType(object, type) \
  38. SWIG_Guile_IsPointerOfType(object, type)
  39. #define SWIG_IsPointer(object) \
  40. SWIG_Guile_IsPointer(object)
  41. #define SWIG_contract_assert(expr, msg) \
  42. if (!(expr)) \
  43. scm_error(scm_str2symbol("swig-contract-assertion-failed"), \
  44. (char *) FUNC_NAME, (char *) msg, \
  45. SCM_EOL, SCM_BOOL_F); else
  46. /* for C++ member pointers, ie, member methods */
  47. #define SWIG_ConvertMember(obj, ptr, sz, ty) \
  48. SWIG_Guile_ConvertMember(obj, ptr, sz, ty, FUNC_NAME)
  49. #define SWIG_NewMemberObj(ptr, sz, type) \
  50. SWIG_Guile_NewMemberObj(ptr, sz, type, FUNC_NAME)
  51. /* Runtime API */
  52. static swig_module_info *SWIG_Guile_GetModule(void);
  53. #define SWIG_GetModule(clientdata) SWIG_Guile_GetModule()
  54. #define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
  55. SWIGINTERN char *
  56. SWIG_Guile_scm2newstr(SCM str, size_t *len) {
  57. #define FUNC_NAME "SWIG_Guile_scm2newstr"
  58. char *ret;
  59. size_t l;
  60. SCM_ASSERT (SCM_STRINGP(str), str, 1, FUNC_NAME);
  61. l = SCM_STRING_LENGTH(str);
  62. ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
  63. if (!ret) return NULL;
  64. memcpy(ret, SCM_STRING_CHARS(str), l);
  65. ret[l] = '\0';
  66. if (len) *len = l;
  67. return ret;
  68. #undef FUNC_NAME
  69. }
  70. static int swig_initialized = 0;
  71. static scm_t_bits swig_tag = 0;
  72. static scm_t_bits swig_collectable_tag = 0;
  73. static scm_t_bits swig_destroyed_tag = 0;
  74. static scm_t_bits swig_member_function_tag = 0;
  75. static SCM swig_make_func = SCM_EOL;
  76. static SCM swig_keyword = SCM_EOL;
  77. static SCM swig_symbol = SCM_EOL;
  78. #define SWIG_Guile_GetSmob(x) \
  79. ( SCM_NNULLP(x) && SCM_INSTANCEP(x) && SCM_NFALSEP(scm_slot_exists_p(x, swig_symbol)) \
  80. ? scm_slot_ref(x, swig_symbol) : (x) )
  81. SWIGINTERN SCM
  82. SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner)
  83. {
  84. if (ptr == NULL)
  85. return SCM_EOL;
  86. else {
  87. SCM smob;
  88. swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata;
  89. if (owner)
  90. SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type);
  91. else
  92. SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type);
  93. if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) {
  94. return smob;
  95. } else {
  96. /* the scm_make() C function only handles the creation of gf,
  97. methods and classes (no instances) the (make ...) function is
  98. later redefined in goops.scm. So we need to call that
  99. Scheme function. */
  100. return scm_apply(swig_make_func,
  101. scm_list_3(cdata->goops_class,
  102. swig_keyword,
  103. smob),
  104. SCM_EOL);
  105. }
  106. }
  107. }
  108. SWIGINTERN unsigned long
  109. SWIG_Guile_PointerAddress(SCM object)
  110. {
  111. SCM smob = SWIG_Guile_GetSmob(object);
  112. if (SCM_NULLP(smob)) return 0;
  113. else if (SCM_SMOB_PREDICATE(swig_tag, smob)
  114. || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)
  115. || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) {
  116. return (unsigned long) (void *) SCM_CELL_WORD_1(smob);
  117. }
  118. else scm_wrong_type_arg("SWIG-Guile-PointerAddress", 1, object);
  119. }
  120. SWIGINTERN swig_type_info *
  121. SWIG_Guile_PointerType(SCM object)
  122. {
  123. SCM smob = SWIG_Guile_GetSmob(object);
  124. if (SCM_NULLP(smob)) return NULL;
  125. else if (SCM_SMOB_PREDICATE(swig_tag, smob)
  126. || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)
  127. || SCM_SMOB_PREDICATE(swig_destroyed_tag, smob)) {
  128. return (swig_type_info *) SCM_CELL_WORD_2(smob);
  129. }
  130. else scm_wrong_type_arg("SWIG-Guile-PointerType", 1, object);
  131. }
  132. SWIGINTERN int
  133. SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags)
  134. {
  135. swig_cast_info *cast;
  136. swig_type_info *from;
  137. SCM smob = SWIG_Guile_GetSmob(s);
  138. if (SCM_NULLP(smob)) {
  139. *result = NULL;
  140. return SWIG_OK;
  141. } else if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) {
  142. /* we do not accept smobs representing destroyed pointers */
  143. from = (swig_type_info *) SCM_CELL_WORD_2(smob);
  144. if (!from) return SWIG_ERROR;
  145. if (type) {
  146. cast = SWIG_TypeCheckStruct(from, type);
  147. if (cast) {
  148. int newmemory = 0;
  149. *result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(smob), &newmemory);
  150. assert(!newmemory); /* newmemory handling not yet implemented */
  151. return SWIG_OK;
  152. } else {
  153. return SWIG_ERROR;
  154. }
  155. } else {
  156. *result = (void *) SCM_CELL_WORD_1(smob);
  157. return SWIG_OK;
  158. }
  159. }
  160. return SWIG_ERROR;
  161. }
  162. SWIGINTERNINLINE void *
  163. SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
  164. int argnum, int flags, const char *func_name)
  165. {
  166. void *result;
  167. int res = SWIG_Guile_ConvertPtr(s, &result, type, flags);
  168. if (!SWIG_IsOK(res)) {
  169. /* type mismatch */
  170. scm_wrong_type_arg((char *) func_name, argnum, s);
  171. }
  172. return result;
  173. }
  174. SWIGINTERNINLINE int
  175. SWIG_Guile_IsPointerOfType (SCM s, swig_type_info *type)
  176. {
  177. void *result;
  178. if (SWIG_Guile_ConvertPtr(s, &result, type, 0)) {
  179. /* type mismatch */
  180. return 0;
  181. }
  182. else return 1;
  183. }
  184. SWIGINTERNINLINE int
  185. SWIG_Guile_IsPointer (SCM s)
  186. {
  187. /* module might not be initialized yet, so initialize it */
  188. SWIG_Guile_GetModule();
  189. return SWIG_Guile_IsPointerOfType (s, NULL);
  190. }
  191. /* Mark a pointer object non-collectable */
  192. SWIGINTERN void
  193. SWIG_Guile_MarkPointerNoncollectable(SCM s)
  194. {
  195. SCM smob = SWIG_Guile_GetSmob(s);
  196. if (!SCM_NULLP(smob)) {
  197. if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) {
  198. SCM_SET_CELL_TYPE(smob, swig_tag);
  199. }
  200. else scm_wrong_type_arg(NULL, 0, s);
  201. }
  202. }
  203. /* Mark a pointer object destroyed */
  204. SWIGINTERN void
  205. SWIG_Guile_MarkPointerDestroyed(SCM s)
  206. {
  207. SCM smob = SWIG_Guile_GetSmob(s);
  208. if (!SCM_NULLP(smob)) {
  209. if (SCM_SMOB_PREDICATE(swig_tag, smob) || SCM_SMOB_PREDICATE(swig_collectable_tag, smob)) {
  210. SCM_SET_CELL_TYPE(smob, swig_destroyed_tag);
  211. }
  212. else scm_wrong_type_arg(NULL, 0, s);
  213. }
  214. }
  215. /* Member functions */
  216. SWIGINTERN SCM
  217. SWIG_Guile_NewMemberObj(void *ptr, size_t sz, swig_type_info *type,
  218. const char *func_name)
  219. {
  220. SCM smob;
  221. void *copy = malloc(sz);
  222. memcpy(copy, ptr, sz);
  223. SCM_NEWSMOB2(smob, swig_member_function_tag, copy, (void *) type);
  224. return smob;
  225. }
  226. SWIGINTERN int
  227. SWIG_Guile_ConvertMember(SCM smob, void *ptr, size_t sz, swig_type_info *type,
  228. const char *func_name)
  229. {
  230. swig_cast_info *cast;
  231. swig_type_info *from;
  232. if (SCM_SMOB_PREDICATE(swig_member_function_tag, smob)) {
  233. from = (swig_type_info *) SCM_CELL_WORD_2(smob);
  234. if (!from) return SWIG_ERROR;
  235. if (type) {
  236. cast = SWIG_TypeCheckStruct(from, type);
  237. if (!cast) return SWIG_ERROR;
  238. }
  239. memcpy(ptr, (void *) SCM_CELL_WORD_1(smob), sz);
  240. return SWIG_OK;
  241. }
  242. return SWIG_ERROR;
  243. }
  244. /* Init */
  245. SWIGINTERN int
  246. print_swig_aux (SCM swig_smob, SCM port, scm_print_state *pstate,
  247. const char *attribute)
  248. {
  249. swig_type_info *type;
  250. type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob);
  251. if (type) {
  252. scm_puts((char *) "#<", port);
  253. scm_puts((char *) attribute, port);
  254. scm_puts((char *) "swig-pointer ", port);
  255. scm_puts((char *) SWIG_TypePrettyName(type), port);
  256. scm_puts((char *) " ", port);
  257. scm_intprint((long) SCM_CELL_WORD_1(swig_smob), 16, port);
  258. scm_puts((char *) ">", port);
  259. /* non-zero means success */
  260. return 1;
  261. } else {
  262. return 0;
  263. }
  264. }
  265. SWIGINTERN int
  266. print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
  267. {
  268. return print_swig_aux(swig_smob, port, pstate, "");
  269. }
  270. SWIGINTERN int
  271. print_collectable_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
  272. {
  273. return print_swig_aux(swig_smob, port, pstate, "collectable-");
  274. }
  275. SWIGINTERN int
  276. print_destroyed_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
  277. {
  278. return print_swig_aux(swig_smob, port, pstate, "destroyed-");
  279. }
  280. SWIGINTERN int
  281. print_member_function_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
  282. {
  283. swig_type_info *type;
  284. type = (swig_type_info *) SCM_CELL_WORD_2(swig_smob);
  285. if (type) {
  286. scm_puts((char *) "#<", port);
  287. scm_puts((char *) "swig-member-function-pointer ", port);
  288. scm_puts((char *) SWIG_TypePrettyName(type), port);
  289. scm_puts((char *) " >", port);
  290. /* non-zero means success */
  291. return 1;
  292. } else {
  293. return 0;
  294. }
  295. }
  296. SWIGINTERN SCM
  297. equalp_swig (SCM A, SCM B)
  298. {
  299. if (SCM_CELL_WORD_0(A) == SCM_CELL_WORD_0(B) && SCM_CELL_WORD_1(A) == SCM_CELL_WORD_1(B)
  300. && SCM_CELL_WORD_2(A) == SCM_CELL_WORD_2(B))
  301. return SCM_BOOL_T;
  302. else return SCM_BOOL_F;
  303. }
  304. SWIGINTERN size_t
  305. free_swig(SCM A)
  306. {
  307. swig_type_info *type = (swig_type_info *) SCM_CELL_WORD_2(A);
  308. if (type) {
  309. if (type->clientdata && ((swig_guile_clientdata *)type->clientdata)->destroy)
  310. ((swig_guile_clientdata *)type->clientdata)->destroy(A);
  311. }
  312. return 0;
  313. }
  314. SWIGINTERN size_t
  315. free_swig_member_function(SCM A)
  316. {
  317. free((swig_type_info *) SCM_CELL_WORD_1(A));
  318. return 0;
  319. }
  320. SWIGINTERN int
  321. ensure_smob_tag(SCM swig_module,
  322. scm_t_bits *tag_variable,
  323. const char *smob_name,
  324. const char *scheme_variable_name)
  325. {
  326. SCM variable = scm_sym2var(scm_str2symbol(scheme_variable_name),
  327. scm_module_lookup_closure(swig_module),
  328. SCM_BOOL_T);
  329. if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
  330. *tag_variable = scm_make_smob_type((char*)scheme_variable_name, 0);
  331. SCM_VARIABLE_SET(variable,
  332. scm_ulong2num(*tag_variable));
  333. return 1;
  334. }
  335. else {
  336. *tag_variable = scm_num2ulong(SCM_VARIABLE_REF(variable), 0,
  337. "SWIG_Guile_Init");
  338. return 0;
  339. }
  340. }
  341. SWIGINTERN SCM
  342. SWIG_Guile_Init ()
  343. {
  344. static SCM swig_module;
  345. if (swig_initialized) return swig_module;
  346. swig_initialized = 1;
  347. swig_module = scm_c_resolve_module("Swig swigrun");
  348. if (ensure_smob_tag(swig_module, &swig_tag,
  349. "swig-pointer", "swig-pointer-tag")) {
  350. scm_set_smob_print(swig_tag, print_swig);
  351. scm_set_smob_equalp(swig_tag, equalp_swig);
  352. }
  353. if (ensure_smob_tag(swig_module, &swig_collectable_tag,
  354. "collectable-swig-pointer", "collectable-swig-pointer-tag")) {
  355. scm_set_smob_print(swig_collectable_tag, print_collectable_swig);
  356. scm_set_smob_equalp(swig_collectable_tag, equalp_swig);
  357. scm_set_smob_free(swig_collectable_tag, free_swig);
  358. }
  359. if (ensure_smob_tag(swig_module, &swig_destroyed_tag,
  360. "destroyed-swig-pointer", "destroyed-swig-pointer-tag")) {
  361. scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig);
  362. scm_set_smob_equalp(swig_destroyed_tag, equalp_swig);
  363. }
  364. if (ensure_smob_tag(swig_module, &swig_member_function_tag,
  365. "swig-member-function-pointer", "swig-member-function-pointer-tag")) {
  366. scm_set_smob_print(swig_member_function_tag, print_member_function_swig);
  367. scm_set_smob_free(swig_member_function_tag, free_swig_member_function);
  368. }
  369. swig_make_func = scm_permanent_object(
  370. scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make")));
  371. swig_keyword = scm_permanent_object(scm_c_make_keyword((char*) "init-smob"));
  372. swig_symbol = scm_permanent_object(scm_str2symbol("swig-smob"));
  373. #ifdef SWIG_INIT_RUNTIME_MODULE
  374. SWIG_INIT_RUNTIME_MODULE
  375. #endif
  376. return swig_module;
  377. }
  378. SWIGINTERN swig_module_info *
  379. SWIG_Guile_GetModule(void)
  380. {
  381. SCM module;
  382. SCM variable;
  383. module = SWIG_Guile_Init();
  384. variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
  385. scm_module_lookup_closure(module),
  386. SCM_BOOL_T);
  387. if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
  388. return NULL;
  389. } else {
  390. return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init");
  391. }
  392. }
  393. SWIGINTERN void
  394. SWIG_Guile_SetModule(swig_module_info *swig_module)
  395. {
  396. SCM module;
  397. SCM variable;
  398. module = SWIG_Guile_Init();
  399. variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
  400. scm_module_lookup_closure(module),
  401. SCM_BOOL_T);
  402. SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module));
  403. }
  404. SWIGINTERN int
  405. SWIG_Guile_GetArgs (SCM *dest, SCM rest,
  406. int reqargs, int optargs,
  407. const char *procname)
  408. {
  409. int i;
  410. int num_args_passed = 0;
  411. for (i = 0; i<reqargs; i++) {
  412. if (!SCM_CONSP(rest))
  413. scm_wrong_num_args(scm_makfrom0str((char *) procname));
  414. *dest++ = SCM_CAR(rest);
  415. rest = SCM_CDR(rest);
  416. num_args_passed++;
  417. }
  418. for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
  419. *dest++ = SCM_CAR(rest);
  420. rest = SCM_CDR(rest);
  421. num_args_passed++;
  422. }
  423. for (; i<optargs; i++)
  424. *dest++ = SCM_UNDEFINED;
  425. if (!SCM_NULLP(rest))
  426. scm_wrong_num_args(scm_makfrom0str((char *) procname));
  427. return num_args_passed;
  428. }
  429. #ifdef __cplusplus
  430. }
  431. #endif