PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/guile/guile_gh_run.swg

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