/* -*- c -*- * ----------------------------------------------------------------------- * Lib/guile/guile_gh_run.swg * * Guile GH runtime file * Copyright (C) 2004 John Lenz * ----------------------------------------------------------------------- */ #define SWIGGUILE #include "guile/gh.h" #include #include #include #ifdef __cplusplus extern "C" { #endif typedef SCM (*swig_guile_proc)(); #define SWIG_malloc(size) \ SCM_MUST_MALLOC(size) #define SWIG_free(mem) \ scm_must_free(mem) #define SWIG_ConvertPtr(s, result, type, flags) \ SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags) #define SWIG_MustGetPtr(s, type, argnum, flags) \ SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME) #define SWIG_NewPointerObj(ptr, type, owner) \ SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner) #define SWIG_GetModule(clientdata) SWIG_Guile_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer) /* Ignore object-ownership changes in gh mode */ #define SWIG_Guile_MarkPointerNoncollectable(s) (s) #define SWIG_Guile_MarkPointerDestroyed(s) (s) #define SWIG_contract_assert(expr, msg) \ if (!(expr)) \ scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \ (char *) FUNC_NAME, (char *) msg, \ SCM_EOL, SCM_BOOL_F); else /* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for 1.3.4 compatibility. */ #ifndef SCM_CHAR # define SCM_CHAR SCM_ICHR #endif #ifndef SCM_CHARP # define SCM_CHARP SCM_ICHRP #endif /* This function replaces gh_scm2char, which is broken in Guile 1.4 */ static char GSWIG_scm2char (SCM s) { if (SCM_CHARP(s)) return SCM_CHAR(s); scm_wrong_type_arg(NULL, 0, s); } #define gh_scm2char GSWIG_scm2char /* Interface function */ #define SWIG_scm2str(x) gh_scm2newstr(x, NULL) /* More 1.3.4 compatibility */ #ifndef SCM_INPUT_PORT_P # define SCM_INPUT_PORT_P SCM_INPORTP # define SCM_OUTPUT_PORT_P SCM_OUTPORTP #endif static swig_type_info *SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) { swig_module_info *iter; if (!module) return 0; iter = module; do { if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) { return iter->types[(long) SCM_CAR(s) >> 16]; } iter = iter->next; } while (iter != module); return 0; } #ifdef SWIG_GLOBAL #define SWIG_GUILE_MODULE_STATIC #elif !defined(SWIG_NOINCLUDE) #define SWIG_GUILE_MODULE_STATIC static #endif #ifdef SWIG_GUILE_MODULE_STATIC static swig_module_info *swig_guile_module = 0; SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule() { return swig_guile_module; } SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) { swig_guile_module = pointer; } #else SWIGEXPORT swig_module_info * SWIG_Guile_GetModule(); SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer); #endif static SCM SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, swig_type_info *type, int owner) { unsigned long tag; if (ptr==NULL) return SCM_EOL; if (!module) return SCM_EOL; for (tag = 0; tag < module->size; ++tag) { if (module->types[tag] == type) break; } if (tag >= module->size) return SCM_EOL; SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr); } /* Return 0 if successful. */ static int SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, swig_type_info *type, int flags) { swig_cast_info *cast; swig_type_info *from; if (SCM_NULLP(s)) { *result = NULL; return 0; } else if (SCM_NIMP(s)) { from = SWIG_Guile_LookupType(module, s, 1); if (!from) return 1; if (type) { cast = SWIG_TypeCheckStruct(from, type); if (cast) { *result = SWIG_TypeCast(cast, (void *) SCM_CDR(s)); return 0; } else { return 1; } } else { *result = (void *) SCM_CDR(s); return 0; } } return 1; } static void * SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type, int argnum, int flags, const char *func_name) { void *result; if (SWIG_Guile_ConvertPtr(module, s, &result, type, flags)) { /* type mismatch */ scm_wrong_type_arg((char *) func_name, argnum, s); } return result; } /* Init */ static int print_swig (SCM swig_smob, SCM port, scm_print_state *pstate) { swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1); if (type) { scm_puts((char *) "#str != NULL) scm_puts((char *) type->str, port); else scm_puts((char *) type->name, port); scm_puts((char *) " ", port); scm_intprint((long) SCM_CDR(swig_smob), 16, port); scm_puts((char *) ">", port); /* non-zero means success */ return 1; } else { return 0; } } static SCM equalp_swig (SCM A, SCM B) { if (SCM_CAR(A) == SCM_CAR(B) && SCM_CDR(A) == SCM_CDR(B)) return SCM_BOOL_T; else return SCM_BOOL_F; } static void SWIG_Guile_Init (swig_module_info *module) { *((int *)module->clientdata) = scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig); } static int SWIG_Guile_GetArgs (SCM *dest, SCM rest, int reqargs, int optargs, const char *procname) { int i; int num_args_passed = 0; for (i = 0; i