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.
7 * ----------------------------------------------------------------------------- */
14 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM)
16 # define snprintf _snprintf
24 #define SWIG_malloc(size) \
26 #define SWIG_free(mem) \
28 #define SWIG_MakeString(c) \
29 SWIG_Chicken_MakeString(c)
30 #define SWIG_ConvertPtr(s, result, type, flags) \
31 SWIG_Chicken_ConvertPtr(s, result, type, flags)
32 #define SWIG_MustGetPtr(s, type, argnum, flags) \
33 SWIG_Chicken_MustGetPtr(s, type, argnum, flags)
34 #define SWIG_NewPointerObj(ptr, type, owner) \
35 SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space)
36 #define swig_barf SWIG_Chicken_Barf
37 #define SWIG_ThrowException(val) SWIG_Chicken_ThrowException(val)
39 #define SWIG_contract_assert(expr, message) if (!(expr)) { \
40 SWIG_Chicken_Barf(SWIG_BARF1_CONTRACT_ASSERT, C_text(message)); } else
43 #define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule()
44 #define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer)
46 #define C_swig_is_bool(x) C_truep (C_booleanp (x))
47 #define C_swig_is_char(x) C_truep (C_charp (x))
48 #define C_swig_is_fixnum(x) C_truep (C_fixnump (x))
49 #define C_swig_is_flonum(x) (C_truep (C_blockp (x)) && C_truep (C_flonump (x)))
50 #define C_swig_is_string(x) (C_truep (C_blockp (x)) && C_truep (C_stringp (x)))
51 #define C_swig_is_vector(x) (C_truep (C_blockp (x)) && C_truep (C_vectorp (x)))
52 #define C_swig_is_list(x) (C_truep (C_i_listp (x)))
53 #define C_swig_is_pair(x) (C_truep (C_blockp(x)) && C_truep (C_pairp(x)))
54 #define C_swig_is_ptr(x) (C_truep (C_blockp (x)) && C_truep (C_pointerp (x)))
55 #define C_swig_is_swigpointer(x) (C_truep (C_blockp(x)) && C_truep (C_swigpointerp(x)))
56 #define C_swig_is_closurep(x) (C_truep (C_blockp(x)) && C_truep(C_closurep(x)))
57 #define C_swig_is_number(x) (C_swig_is_fixnum(x) || C_swig_is_flonum(x))
58 #define C_swig_is_long(x) C_swig_is_number(x)
60 #define C_swig_sizeof_closure(num) (num+1)
62 #define SWIG_Chicken_SetupArgout { \
63 C_word *a = C_alloc(C_swig_sizeof_closure(2)); \
64 C_word *closure = a; \
65 *(a++)=C_CLOSURE_TYPE|2; \
66 *(a++)=(C_word)SWIG_Chicken_ApplyResults; \
67 *(a++)=continuation; \
68 continuation=(C_word)closure; \
71 #define SWIG_APPEND_VALUE(obj) { \
72 C_word val = (C_word)(obj); \
73 if (val != C_SCHEME_UNDEFINED) { \
74 C_word *a = C_alloc(C_swig_sizeof_closure(3)); \
75 C_word *closure = a; \
76 *(a++)=C_CLOSURE_TYPE|3; \
77 *(a++)=(C_word)SWIG_Chicken_MultiResultBuild; \
78 *(a++)=(C_word)continuation; \
80 continuation=(C_word)closure; \
83 #define SWIG_Chicken_FindCreateProxy(func,obj) \
84 if (C_swig_is_swigpointer(obj)) { \
85 swig_type_info *t = (swig_type_info *) C_block_item(obj, 1); \
86 if (t && t->clientdata && ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create) { \
87 func = CHICKEN_gc_root_ref( ((swig_chicken_clientdata *)t->clientdata)->gc_proxy_create); \
89 func = C_SCHEME_FALSE; \
92 func = C_SCHEME_FALSE; \
97 SWIG_BARF1_BAD_ARGUMENT_TYPE /* 1 arg */,
98 SWIG_BARF1_ARGUMENT_NULL /* 1 arg */,
99 SWIG_BARF1_CONTRACT_ASSERT /* 1 arg */,
102 typedef C_word (*swig_chicken_destructor)(C_word,C_word,C_word,C_word);
103 typedef struct swig_chicken_clientdata {
104 void *gc_proxy_create;
105 swig_chicken_destructor destroy;
106 } swig_chicken_clientdata;
109 SWIG_Chicken_MakeString(C_word str) {
113 l = C_header_size(str);
114 ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
115 if (!ret) return NULL;
117 memcpy(ret, C_c_string(str), l);
122 static C_word SWIG_Chicken_LookupSymbol(char *name, C_SYMBOL_TABLE *stable) {
123 C_word *a = C_alloc(C_SIZEOF_STRING (strlen (name)));
124 C_word n = C_string2(&a, name);
125 C_word sym = C_find_symbol(n, stable);
127 return C_symbol_value(sym);
129 return C_SCHEME_FALSE;
133 /* Just a helper function. Do not export it */
134 static void SWIG_Chicken_Panic (C_char *) C_noret;
135 static void SWIG_Chicken_Panic (C_char *msg)
137 C_word *a = C_alloc (C_SIZEOF_STRING (strlen (msg)));
138 C_word scmmsg = C_string2 (&a, msg);
140 exit (5); /* should never get here */
144 SWIG_Chicken_Barf(int code, C_char *msg, ...) C_noret;
146 SWIG_Chicken_Barf(int code, C_char *msg, ...)
148 char *errorhook = C_text("\003syserror-hook");
149 C_word *a = C_alloc (C_SIZEOF_STRING (strlen (errorhook)));
150 C_word err = C_intern2 (&a, errorhook);
156 C_temporary_stack = C_temporary_stack_bottom;
157 err = C_block_item(err, 0);
159 if(C_immediatep (err))
160 SWIG_Chicken_Panic (C_text ("`##sys#error-hook' is not defined"));
163 case SWIG_BARF1_BAD_ARGUMENT_TYPE:
164 barfval = C_BAD_ARGUMENT_TYPE_ERROR;
167 case SWIG_BARF1_ARGUMENT_NULL:
168 barfval = C_BAD_ARGUMENT_TYPE_ERROR;
171 case SWIG_BARF1_CONTRACT_ASSERT:
172 barfval = C_BAD_ARGUMENT_TYPE_ERROR;
176 SWIG_Chicken_Panic (C_text (msg));
179 if(c > 0 && !C_immediatep (err)) {
180 C_save (C_fix (barfval));
184 C_word *b = C_alloc (C_SIZEOF_STRING (strlen (msg)));
185 C_word scmmsg = C_string2 (&b, msg);
193 C_save (va_arg (v, C_word));
196 C_do_apply (c + 1, err,
197 C_SCHEME_UNDEFINED); /* <- no continuation is passed:
198 '##sys#error-hook' may not
202 SWIG_Chicken_Panic (msg);
205 SWIG_Chicken_Panic (C_text ("unspecified panic"));
209 static void SWIG_Chicken_ThrowException(C_word value) C_noret;
210 static void SWIG_Chicken_ThrowException(C_word value)
212 char *aborthook = C_text("\003sysabort");
213 C_word *a = C_alloc(C_SIZEOF_STRING(strlen(aborthook)));
214 C_word abort = C_intern2(&a, aborthook);
216 abort = C_block_item(abort, 0);
217 if (C_immediatep(abort))
218 SWIG_Chicken_Panic(C_text("`##sys#abort' is not defined"));
221 C_do_apply(1, abort, C_SCHEME_UNDEFINED);
225 SWIG_Chicken_Finalizer(C_word argc, C_word closure, C_word continuation, C_word s)
227 swig_type_info *type;
228 swig_chicken_clientdata *cdata;
230 if (argc == 3 && s != C_SCHEME_FALSE && C_swig_is_swigpointer(s)) {
231 type = (swig_type_info *) C_block_item(s, 1);
233 cdata = (swig_chicken_clientdata *) type->clientdata;
234 if (cdata && cdata->destroy) {
235 /* this will not return, but will continue correctly */
236 cdata->destroy(3,closure,continuation,s);
240 C_kontinue(continuation, C_SCHEME_UNDEFINED);
242 static C_word finalizer_obj[2] = {(C_word) (C_CLOSURE_TYPE|1), (C_word) SWIG_Chicken_Finalizer};
245 SWIG_Chicken_NewPointerObj(void *ptr, swig_type_info *type, int owner, C_word **data)
247 swig_chicken_clientdata *cdata = (swig_chicken_clientdata *) type->clientdata;
250 return C_SCHEME_FALSE;
252 C_word cptr = C_swigmpointer(data, ptr, type);
253 /* add finalizer to object */
254 #ifndef SWIG_CHICKEN_NO_COLLECTION
256 C_do_register_finalizer(cptr, (C_word) finalizer_obj);
263 /* Return 0 if successful. */
265 SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags)
267 swig_cast_info *cast;
268 swig_type_info *from;
270 if (s == C_SCHEME_FALSE) {
272 } else if (C_swig_is_swigpointer(s)) {
273 /* try and convert type */
274 from = (swig_type_info *) C_block_item(s, 1);
277 cast = SWIG_TypeCheckStruct(from, type);
280 *result = SWIG_TypeCast(cast, (void *) C_block_item(s, 0), &newmemory);
281 assert(!newmemory); /* newmemory handling not yet implemented */
286 *result = (void *) C_block_item(s, 0);
289 /* check if we are disowning this object */
290 if (flags & SWIG_POINTER_DISOWN) {
291 C_do_unregister_finalizer(s);
300 static SWIGINLINE void *
301 SWIG_Chicken_MustGetPtr (C_word s, swig_type_info *type, int argnum, int flags)
305 if (SWIG_Chicken_ConvertPtr(s, &result, type, flags)) {
307 snprintf(err_msg, sizeof(err_msg), "Type error in argument #%i: expected %s", argnum, (type->str ? type->str : type->name));
308 SWIG_Chicken_Barf(SWIG_BARF1_BAD_ARGUMENT_TYPE, err_msg);
313 static char *chicken_runtimevar_name = "type_pointer" SWIG_TYPE_TABLE_NAME;
315 static swig_module_info *
316 SWIG_Chicken_GetModule() {
317 swig_module_info *ret = 0;
320 /* lookup the type pointer... it is stored in it's own symbol table */
321 C_SYMBOL_TABLE *stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION);
322 if (stable != NULL) {
323 sym = SWIG_Chicken_LookupSymbol(chicken_runtimevar_name, stable);
324 if (C_truep(sym) && C_swig_is_ptr(sym)) {
325 ret = (swig_module_info *) C_block_item(sym, 0);
333 SWIG_Chicken_SetModule(swig_module_info *module) {
335 C_SYMBOL_TABLE *stable;
338 static C_word *space = 0;
340 /* type pointer is stored in it's own symbol table */
341 stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION);
342 if (stable == NULL) {
343 stable = C_new_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION, 16);
347 space = (C_word *) C_malloc((C_SIZEOF_POINTER + C_SIZEOF_INTERNED_SYMBOL(C_strlen(chicken_runtimevar_name))) * sizeof(C_word));
350 pointer = C_mpointer(&a, (void *) module);
351 sym = C_intern_in(&a, C_strlen(chicken_runtimevar_name), chicken_runtimevar_name, stable);
352 C_set_block_item(sym, 0, pointer);
355 static C_word SWIG_Chicken_MultiResultBuild(C_word num, C_word closure, C_word lst) {
356 C_word cont = C_block_item(closure,1);
357 C_word obj = C_block_item(closure,2);
360 SWIG_Chicken_FindCreateProxy(func,obj);
362 if (C_swig_is_closurep(func)) {
363 ((C_proc4)(void *)C_block_item(func, 0))(4,func,cont,obj,lst);
365 C_word *a = C_alloc(C_SIZEOF_PAIR);
366 C_kontinue(cont,C_pair(&a,obj,lst));
368 return C_SCHEME_UNDEFINED; /* never reached */
371 static C_word SWIG_Chicken_ApplyResults(C_word num, C_word closure, C_word result) {
372 C_apply_values(3,C_SCHEME_UNDEFINED,C_block_item(closure,1),result);
373 return C_SCHEME_UNDEFINED; /* never reached */