~ubuntu-branches/ubuntu/edgy/swig1.3/edgy

« back to all changes in this revision

Viewing changes to Lib/guile/guile_gh_run.swg

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * Lib/guile/guile_gh_run.swg
4
4
 *
5
5
 * Guile GH runtime file
6
 
 * Copyright (C) 2000 Matthias Koeppe
 
6
 * Copyright (C) 2004 John Lenz <lenz@cs.wisc.edu>
7
7
 * ----------------------------------------------------------------------- */
8
8
 
 
9
#define SWIGGUILE
9
10
#include "guile/gh.h"
10
11
#include <stdio.h>
11
12
#include <string.h>
15
16
extern "C" {
16
17
#endif
17
18
 
 
19
typedef SCM (*swig_guile_proc)();
 
20
 
18
21
#define SWIG_malloc(size) \
19
22
  SCM_MUST_MALLOC(size)
20
23
#define SWIG_free(mem) \
21
24
  scm_must_free(mem)
22
25
#define SWIG_ConvertPtr(s, result, type, flags) \
23
 
  SWIG_Guile_GetPtr(s, result, type)
 
26
  SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags)
24
27
#define SWIG_MustGetPtr(s, type, argnum, flags) \
25
 
  SWIG_Guile_MustGetPtr(s, type, argnum, FUNC_NAME)
 
28
  SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME)
26
29
#define SWIG_NewPointerObj(ptr, type, owner) \
27
 
  SWIG_Guile_MakePtr((void*)ptr, type)
 
30
  SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner)
 
31
#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule()
 
32
#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
28
33
 
29
34
/* Ignore object-ownership changes in gh mode */
30
35
#define SWIG_Guile_MarkPointerNoncollectable(s) (s)
36
41
              (char *) FUNC_NAME, (char *) msg,                 \
37
42
              SCM_EOL, SCM_BOOL_F); else
38
43
 
39
 
#if defined(SWIG_NOINCLUDE)
40
 
#       define SWIGSTATIC
41
 
#elif defined(SWIG_GLOBAL)
42
 
#       define SWIGSTATIC
43
 
#else
44
 
#       define SWIGSTATIC static
45
 
#endif
46
 
 
47
 
#define GH_NOT_PASSED    SCM_UNDEFINED
48
 
#define GH_UNSPECIFIED   SCM_UNSPECIFIED
49
 
 
50
 
#define SWIG_APPEND_VALUE(object)                                               \
51
 
    if (gswig_result == GH_UNSPECIFIED)                                         \
52
 
        gswig_result = object;                                                  \
53
 
    else {                                                                      \
54
 
        if (!gswig_list_p) {                                                    \
55
 
            gswig_list_p = 1;                                                   \
56
 
            gswig_result = gh_list(gswig_result, object, GH_NOT_PASSED);        \
57
 
        }                                                                       \
58
 
        else                                                                    \
59
 
            gswig_result = gh_append2(gswig_result,                             \
60
 
                                      gh_list(object, GH_NOT_PASSED));          \
61
 
    }
62
 
 
63
 
#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE
64
 
  
65
 
/* scm_values was implemented on C level in 1.4.1, and the prototype
66
 
   is not included in libguile.h, so play safe and lookup `values'... */
67
 
#define GUILE_MAYBE_VALUES                                              \
68
 
    if (gswig_list_p)                                                   \
69
 
        gswig_result = gh_apply(gh_lookup("values"), gswig_result);
70
 
    
71
 
#define GUILE_MAYBE_VECTOR                              \
72
 
    if (gswig_list_p)                                   \
73
 
        gswig_result = gh_list_to_vector(gswig_result);
74
 
 
75
 
static char *
76
 
SWIG_scm2str (SCM s)
77
 
{
78
 
  return gh_scm2newstr (s, NULL);
79
 
}
80
 
 
81
 
#define GSWIG_scm2str SWIG_scm2str
82
 
 
83
44
/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for
84
45
   1.3.4 compatibility. */
85
46
#ifndef SCM_CHAR
98
59
}
99
60
#define gh_scm2char GSWIG_scm2char
100
61
 
 
62
/* Interface function */
 
63
#define SWIG_scm2str(x) gh_scm2newstr(x, NULL)
 
64
 
101
65
/* More 1.3.4 compatibility */
102
66
#ifndef SCM_INPUT_PORT_P
103
67
#  define SCM_INPUT_PORT_P SCM_INPORTP
104
68
#  define SCM_OUTPUT_PORT_P SCM_OUTPORTP
105
69
#endif
106
70
 
107
 
/* Type system */
108
 
 
109
 
typedef void *(*swig_converter_func)(void *);
110
 
typedef struct swig_type_info *(*swig_dycast_func)(void **);
111
 
 
112
 
typedef struct SwigPtrType SwigPtrType;
113
 
 
114
 
typedef struct swig_type_info {
115
 
  const char  *name;
116
 
  swig_converter_func converter;
117
 
  const char  *str;
118
 
  void        *clientdata;
119
 
  swig_dycast_func        dcast;
120
 
  size_t tag;
121
 
  int dummy;
122
 
} swig_type_info;
123
 
 
124
 
SWIGSTATIC void
125
 
SWIG_Guile_RegisterTypes (swig_type_info **table,
126
 
                          swig_type_info **init);
127
 
 
128
 
/* Register a new type-mapping with the type-checker.  origtype is the
129
 
   original datatype and newtype is an equivalent type.  cast is optional
130
 
   pointer to a function to cast pointer values between types (this is
131
 
   typically used to cast pointers from derived classes to base classes in
132
 
   C++).  */
133
 
 
134
 
SWIGSTATIC void
135
 
SWIG_RegisterMapping (const char *origtype, const char *newtype,
136
 
                      swig_converter_func cast);
137
 
 
138
 
 
139
 
/* Dynamic pointer casting. Down an inheritance hierarchy */
140
 
SWIGSTATIC swig_type_info * 
141
 
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr);
142
 
 
143
 
/* Register SWIG smobs with Guile.  */
144
 
SWIGSTATIC void
145
 
SWIG_Guile_Init();
146
 
 
147
 
/* Initialization function for this SWIG module; actually renamed by a
148
 
   #define */
149
 
/* extern void SWIG_init(); */
150
 
 
151
 
/* Get a pointer value from a smob.  If there is a type-mismatch,
152
 
   return nonzero; on success, return 0.  */
153
 
SWIGSTATIC int
154
 
SWIG_Guile_GetPtr (SCM s, void **result, swig_type_info *type);
155
 
 
156
 
/* Get a pointer value from a smob.  If there is a type-mismatch,
157
 
   signal a wrong-type-arg error for the given argument number. */
158
 
SWIGSTATIC void *
159
 
SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
160
 
                       int argnum, const char *func_name);
161
 
 
162
 
/* Make a smob from a pointer and typeinfo.  */
163
 
SWIGSTATIC SCM
164
 
SWIG_Guile_MakePtr (void *ptr, swig_type_info *type);
165
 
 
166
 
/* Get arguments from an argument list */
167
 
SWIGSTATIC int
168
 
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
169
 
                    int reqargs, int optargs,
170
 
                    const char *procname);
171
 
 
172
 
typedef SCM (*swig_guile_proc)();
173
 
 
174
 
#ifdef __cplusplus
175
 
}
176
 
#endif
177
 
 
178
 
/* guiledec.swg ends here */
179
 
 
180
 
#ifndef SWIG_NOINCLUDE
181
 
/* SWIG pointer structure */
182
 
 
183
 
#ifdef __cplusplus
184
 
extern "C" {
185
 
#endif
186
 
 
187
 
struct SwigCast {
188
 
  unsigned short      type;               /* Index into SwigPtrTbl          */
189
 
  void               *(*cast)(void *);    /* Pointer casting function       */
190
 
  struct SwigCast    *next;               /* Linked list pointer            */
191
 
};
192
 
 
193
 
struct SwigPtrType {
194
 
  const char         *name;               /* Datatype name                  */
195
 
  const char         *prettyname;         /* Pretty datatype name           */
196
 
  unsigned short      tag;                /* Index in SwigPtrTable          */
197
 
  struct SwigCast    *cast;               /* List of compatible types       */
198
 
};
199
 
 
200
 
/* Some variables  */
201
 
 
202
 
static int SwigPtrMax  = 64;            /* Max entries that can be held */
203
 
                                        /* (may be adjusted dynamically) */
204
 
static int SwigPtrN    = 0;             /* Current number of entries */
205
 
static int SwigPtrSort = 0;             /* Status flag indicating sort */
206
 
 
207
 
/* Pointer table */
208
 
static SwigPtrType *SwigPtrList = 0;    /* Table containing types and
209
 
                                           equivalences; items will only
210
 
                                           be appended */
211
 
static size_t *SwigPtrTbl = 0;          /* Sorted indirect table; items will
212
 
                                           be inserted */
213
 
 
214
 
/* Sort comparison function */
215
 
static int
216
 
swigsort (const void *data1, const void *data2)
217
 
{
218
 
  size_t index1 = * (size_t *) data1;
219
 
  size_t index2 = * (size_t *) data2;
220
 
  return strcmp(SwigPtrList[index1].name, SwigPtrList[index2].name);
221
 
}
222
 
 
223
 
/* Register a new datatype with the type-checker */
224
 
SWIGSTATIC size_t
225
 
SWIG_RegisterType (const char *type, const char *prettyname)
226
 
{
227
 
  int i;
228
 
 
229
 
  /* Allocate the pointer table if necessary */
230
 
  if (!SwigPtrList) {
231
 
    SwigPtrList = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType));
232
 
    SwigPtrTbl = (size_t *) malloc(SwigPtrMax*sizeof(size_t));
233
 
    SwigPtrN = 0;
234
 
  }
235
 
  /* Grow the table if necessary */
236
 
  if (SwigPtrN >= SwigPtrMax) {
237
 
    SwigPtrMax = 2*SwigPtrMax;
238
 
    SwigPtrList = (SwigPtrType *) realloc((char *) SwigPtrList,
239
 
                                          SwigPtrMax*sizeof(SwigPtrType));
240
 
    SwigPtrTbl = (size_t *) realloc((char *) SwigPtrTbl,
241
 
                                    SwigPtrMax*sizeof(size_t));
242
 
  }
243
 
  /* Look up type */
244
 
  for (i = 0; i < SwigPtrN; i++)
245
 
    if (strcmp(SwigPtrList[i].name,type) == 0) {
246
 
      if (prettyname!=NULL)
247
 
        SwigPtrList[i].prettyname = prettyname;
248
 
      return i;
249
 
    }
250
 
  {
251
 
    struct SwigPtrType *t;
252
 
    size_t tag;
253
 
#if 0
254
 
    fprintf(stderr, "New type: %s\n", type);
255
 
#endif
256
 
    tag = SwigPtrTbl[SwigPtrN] = SwigPtrN;
257
 
    t = &SwigPtrList[tag];
258
 
    t->name = type;
259
 
    t->prettyname = prettyname;
260
 
    t->tag = SwigPtrN;
261
 
    t->cast = NULL;
262
 
    SwigPtrN++;
263
 
    SwigPtrSort = 0; 
264
 
    return tag;
265
 
  }
266
 
}
267
 
 
268
 
/* Register two data types and their mapping with the type checker. */
269
 
SWIGSTATIC void
270
 
SWIG_RegisterMapping (const char *origtype, const char *newtype,
271
 
                      swig_converter_func cast)
272
 
{
273
 
  size_t t = SWIG_RegisterType(origtype, NULL);
274
 
 
275
 
  if (newtype!=NULL) {
276
 
    size_t t1 = SWIG_RegisterType(newtype, NULL);
277
 
    struct SwigCast *c;
278
 
    /* Check for existing cast */
279
 
    for (c = SwigPtrList[t].cast; c && c->type!=t1; c=c->next) /* nothing */;
280
 
    if (c) {
281
 
      if (cast) c->cast = cast;
282
 
    }
283
 
    else {
284
 
      c = (struct SwigCast *) malloc(sizeof(struct SwigCast));
285
 
      c->type = t1;
286
 
      c->cast = cast;
287
 
      c->next = SwigPtrList[t].cast;
288
 
      SwigPtrList[t].cast = c;
289
 
    }
290
 
  }
291
 
}
292
 
 
293
 
/* Sort table */
294
 
 
295
 
static void
296
 
SWIG_SortTable (void)
297
 
{
298
 
  qsort ((void *) SwigPtrTbl, SwigPtrN, sizeof(size_t), swigsort);
299
 
  /* Indicate that everything is sorted */
300
 
  SwigPtrSort = 1;
301
 
}
302
 
 
303
 
/* Look up pointer-type entry in table */
304
 
 
305
 
static int
306
 
swigcmp (const void *key, const void *data)
307
 
{
308
 
  char *k = (char *) key;
309
 
  size_t index = *(size_t *)data;
310
 
  return strcmp(k, SwigPtrList[index].name);
311
 
}
312
 
 
313
 
static SwigPtrType *
314
 
SWIG_GetPtrType (const char *_t)
315
 
{
316
 
  size_t *result;
317
 
  if (!SwigPtrSort) SWIG_SortTable();
318
 
  result = (size_t *) bsearch(_t, SwigPtrTbl, SwigPtrN, sizeof(size_t), swigcmp);
319
 
  if (result!=NULL) return SwigPtrList+*result;
320
 
  else return NULL;
321
 
}
322
 
 
323
 
/* Cast a pointer if possible; returns 1 if successful */
324
 
 
325
 
static int
326
 
SWIG_Cast (void *source, size_t source_type,
327
 
           void **ptr, size_t dest_type)
328
 
{
329
 
  if (dest_type != source_type) {
330
 
    /* We have a type mismatch.  Will have to look through our type
331
 
       mapping table to figure out whether or not we can accept this
332
 
       datatype.  */
333
 
    struct SwigCast *c;
334
 
    for (c = SwigPtrList[dest_type].cast;
335
 
         c && c->type!=source_type; c = c->next) /* nothing */;
336
 
    if (c) {
337
 
      /* Get pointer value. */
338
 
      if (c->cast) *ptr = (*(c->cast))(source);
339
 
      else *ptr = source;
340
 
      return 1;
341
 
    }
342
 
    /* Didn't find any sort of match for this data.
343
 
       Get the pointer value and return false.  */
344
 
    *ptr = source;
345
 
    return 0;
346
 
  } else {
347
 
    /* Found a match on the first try.  Return pointer value.  */
348
 
    *ptr = source;
349
 
    return 1;
350
 
  }
351
 
}
352
 
 
353
 
/* Dynamic pointer casting. Down an inheritance hierarchy */
354
 
SWIGSTATIC swig_type_info * 
355
 
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) 
356
 
{
357
 
  swig_type_info *lastty = ty;
358
 
  if (!ty || !ty->dcast) return ty;
359
 
  while (ty && (ty->dcast)) {
360
 
     ty = (*ty->dcast)(ptr);
361
 
     if (ty) lastty = ty;
362
 
  }
363
 
  return lastty;
364
 
}
365
 
 
366
 
/* Function for getting a pointer value */
367
 
 
368
 
static unsigned long swig_tag = 0;
369
 
 
370
 
SWIGSTATIC SCM
371
 
SWIG_Guile_MakePtr (void *ptr, swig_type_info *type)
372
 
{
 
71
static swig_type_info *SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) {
 
72
  swig_module_info *iter;
 
73
  if (!module) return 0;
 
74
  iter = module;
 
75
  do {
 
76
    if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) {
 
77
        
 
78
      return iter->types[(long) SCM_CAR(s) >> 16];
 
79
    }
 
80
    iter = iter->next;
 
81
  } while (iter != module);
 
82
  return 0;
 
83
}
 
84
 
 
85
#ifdef SWIG_GLOBAL
 
86
#define SWIG_GUILE_MODULE_STATIC
 
87
#elif !defined(SWIG_NOINCLUDE)
 
88
#define SWIG_GUILE_MODULE_STATIC static
 
89
#endif
 
90
 
 
91
#ifdef SWIG_GUILE_MODULE_STATIC
 
92
static swig_module_info *swig_guile_module = 0;
 
93
SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule() {
 
94
  return swig_guile_module;
 
95
}
 
96
SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) {
 
97
  swig_guile_module = pointer;
 
98
}
 
99
#else
 
100
SWIGEXPORT swig_module_info * SWIG_Guile_GetModule();
 
101
SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer);
 
102
#endif
 
103
 
 
104
static SCM
 
105
SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, swig_type_info *type, int owner)
 
106
{
 
107
  unsigned long tag;
373
108
  if (ptr==NULL) return SCM_EOL;
374
 
  SCM_RETURN_NEWSMOB((((unsigned long)type->tag << 16) | swig_tag),
375
 
                     ptr);
 
109
  if (!module) return SCM_EOL;
 
110
  for (tag = 0; tag < module->size; ++tag) {
 
111
    if (module->types[tag] == type)
 
112
      break;
 
113
  }
 
114
  if (tag >= module->size)
 
115
    return SCM_EOL;
 
116
    
 
117
 
 
118
  SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr);
376
119
}
377
120
 
378
121
/* Return 0 if successful. */
379
 
SWIGSTATIC int
380
 
SWIG_Guile_GetPtr(SCM s, void **result, swig_type_info *type)
 
122
static int
 
123
SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, swig_type_info *type, int flags)
381
124
{
 
125
  swig_cast_info *cast;
 
126
  swig_type_info *from;
382
127
  if (SCM_NULLP(s)) {
383
128
    *result = NULL;
384
129
    return 0;
385
 
  }
386
 
  else if (SCM_NIMP(s)
387
 
           && (unsigned long) SCM_TYP16(s) == swig_tag) {
388
 
    if (type) 
389
 
      return !SWIG_Cast((void *) SCM_CDR(s),
390
 
                        (long) SCM_CAR(s) >> 16,
391
 
                        result, type->tag);
392
 
    else {
 
130
  } else if (SCM_NIMP(s)) {
 
131
    from = SWIG_Guile_LookupType(module, s, 1);
 
132
    if (!from) return 1;
 
133
    if (type) {
 
134
      cast = SWIG_TypeCheckStruct(from, type);
 
135
      if (cast) {
 
136
        *result = SWIG_TypeCast(cast, (void *) SCM_CDR(s));
 
137
        return 0;
 
138
      } else {
 
139
        return 1;
 
140
      }
 
141
    } else {
393
142
      *result = (void *) SCM_CDR(s);
394
143
      return 0;
395
144
    }
397
146
  return 1;
398
147
}
399
148
 
400
 
SWIGSTATIC void *
401
 
SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
402
 
                       int argnum, const char *func_name)
 
149
static void *
 
150
SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type,
 
151
                       int argnum, int flags, const char *func_name)
403
152
{
404
153
  void *result;
405
 
  if (SWIG_Guile_GetPtr(s, &result, type)) {
 
154
  if (SWIG_Guile_ConvertPtr(module, s, &result, type, flags)) {
406
155
    /* type mismatch */
407
156
    scm_wrong_type_arg((char *) func_name, argnum, s);
408
157
  }
414
163
static int
415
164
print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
416
165
{
417
 
  scm_puts((char *) "#<swig ", port);
418
 
  if (SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].prettyname != NULL)
419
 
    scm_puts((char*) SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].prettyname, port);
420
 
  else scm_puts((char*) SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].name, port);
421
 
  scm_puts((char *) " ", port);
422
 
  scm_intprint((long) SCM_CDR(swig_smob), 16, port);
423
 
  scm_puts((char *) ">", port);
424
 
  /* non-zero means success */
425
 
  return 1;
 
166
  swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1);
 
167
  if (type) {
 
168
    scm_puts((char *) "#<swig ", port);
 
169
    if (type->str != NULL)
 
170
      scm_puts((char *) type->str, port);
 
171
    else 
 
172
      scm_puts((char *) type->name, port);
 
173
    scm_puts((char *) " ", port);
 
174
    scm_intprint((long) SCM_CDR(swig_smob), 16, port);
 
175
    scm_puts((char *) ">", port);
 
176
    /* non-zero means success */
 
177
    return 1;
 
178
  } else {
 
179
    return 0;
 
180
  }
426
181
}
427
182
 
428
183
static SCM
434
189
  else return SCM_BOOL_F;
435
190
}
436
191
 
437
 
SWIGSTATIC void
438
 
SWIG_Guile_Init (void)
439
 
{
440
 
  if (swig_tag == 0) {
441
 
    swig_tag = scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL,
442
 
                                       print_swig, equalp_swig);
443
 
  }
444
 
}
445
 
 
446
 
/* Convert datatype table */
447
 
 
448
 
SWIGSTATIC
449
 
void SWIG_Guile_RegisterTypes(swig_type_info **table,
450
 
                              swig_type_info **init)
451
 
{
452
 
  for (; *init; table++, init++) {
453
 
    swig_type_info *type = *table = *init;
454
 
    const char *origname = type->name;
455
 
    /* Register datatype itself and store pointer back */
456
 
    type->tag = SWIG_RegisterType(origname, type->str);
457
 
    /* Register compatible types */
458
 
    for (type++; type->name; type++)
459
 
      SWIG_RegisterMapping(origname, type->name, type->converter);
460
 
  }    
461
 
}
462
 
 
463
 
SWIGSTATIC int
 
192
static void
 
193
SWIG_Guile_Init (swig_module_info *module)
 
194
{
 
195
    *((int *)module->clientdata) = 
 
196
         scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig);
 
197
}
 
198
 
 
199
static int
464
200
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
465
201
                    int reqargs, int optargs,
466
202
                    const char *procname)
480
216
    num_args_passed++;
481
217
  }
482
218
  for (; i<optargs; i++)
483
 
    *dest++ = GH_NOT_PASSED;
 
219
    *dest++ = SCM_UNDEFINED;
484
220
  if (!SCM_NULLP(rest))
485
221
    scm_wrong_num_args(gh_str02scm((char *) procname));
486
222
  return num_args_passed;
491
227
#endif
492
228
 
493
229
/* guile.swg ends here */
494
 
 
495
 
#endif