Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / share / swig / 1.3.26 / guile / guile_gh_run.swg
CommitLineData
920dae64
AT
1/* -*- c -*-
2 * -----------------------------------------------------------------------
3 * Lib/guile/guile_gh_run.swg
4 *
5 * Guile GH runtime file
6 * Copyright (C) 2004 John Lenz <lenz@cs.wisc.edu>
7 * ----------------------------------------------------------------------- */
8
9#define SWIGGUILE
10#include "guile/gh.h"
11#include <stdio.h>
12#include <string.h>
13#include <stdlib.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19typedef SCM (*swig_guile_proc)();
20
21#define SWIG_malloc(size) \
22 SCM_MUST_MALLOC(size)
23#define SWIG_free(mem) \
24 scm_must_free(mem)
25#define SWIG_ConvertPtr(s, result, type, flags) \
26 SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags)
27#define SWIG_MustGetPtr(s, type, argnum, flags) \
28 SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME)
29#define SWIG_NewPointerObj(ptr, type, owner) \
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)
33
34/* Ignore object-ownership changes in gh mode */
35#define SWIG_Guile_MarkPointerNoncollectable(s) (s)
36#define SWIG_Guile_MarkPointerDestroyed(s) (s)
37
38#define SWIG_contract_assert(expr, msg) \
39 if (!(expr)) \
40 scm_error(gh_symbol2scm("swig-contract-assertion-failed"), \
41 (char *) FUNC_NAME, (char *) msg, \
42 SCM_EOL, SCM_BOOL_F); else
43
44/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for
45 1.3.4 compatibility. */
46#ifndef SCM_CHAR
47# define SCM_CHAR SCM_ICHR
48#endif
49#ifndef SCM_CHARP
50# define SCM_CHARP SCM_ICHRP
51#endif
52
53/* This function replaces gh_scm2char, which is broken in Guile 1.4 */
54static char
55GSWIG_scm2char (SCM s)
56{
57 if (SCM_CHARP(s)) return SCM_CHAR(s);
58 scm_wrong_type_arg(NULL, 0, s);
59}
60#define gh_scm2char GSWIG_scm2char
61
62/* Interface function */
63#define SWIG_scm2str(x) gh_scm2newstr(x, NULL)
64
65/* More 1.3.4 compatibility */
66#ifndef SCM_INPUT_PORT_P
67# define SCM_INPUT_PORT_P SCM_INPORTP
68# define SCM_OUTPUT_PORT_P SCM_OUTPORTP
69#endif
70
71static 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
92static swig_module_info *swig_guile_module = 0;
93SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule() {
94 return swig_guile_module;
95}
96SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) {
97 swig_guile_module = pointer;
98}
99#else
100SWIGEXPORT swig_module_info * SWIG_Guile_GetModule();
101SWIGEXPORT void SWIG_Guile_SetModule(swig_module_info *pointer);
102#endif
103
104static SCM
105SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, swig_type_info *type, int owner)
106{
107 unsigned long tag;
108 if (ptr==NULL) return SCM_EOL;
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);
119}
120
121/* Return 0 if successful. */
122static int
123SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, swig_type_info *type, int flags)
124{
125 swig_cast_info *cast;
126 swig_type_info *from;
127 if (SCM_NULLP(s)) {
128 *result = NULL;
129 return 0;
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 {
142 *result = (void *) SCM_CDR(s);
143 return 0;
144 }
145 }
146 return 1;
147}
148
149static void *
150SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type,
151 int argnum, int flags, const char *func_name)
152{
153 void *result;
154 if (SWIG_Guile_ConvertPtr(module, s, &result, type, flags)) {
155 /* type mismatch */
156 scm_wrong_type_arg((char *) func_name, argnum, s);
157 }
158 return result;
159}
160
161/* Init */
162
163static int
164print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
165{
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 }
181}
182
183static SCM
184equalp_swig (SCM A, SCM B)
185{
186 if (SCM_CAR(A) == SCM_CAR(B)
187 && SCM_CDR(A) == SCM_CDR(B))
188 return SCM_BOOL_T;
189 else return SCM_BOOL_F;
190}
191
192static void
193SWIG_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
199static int
200SWIG_Guile_GetArgs (SCM *dest, SCM rest,
201 int reqargs, int optargs,
202 const char *procname)
203{
204 int i;
205 int num_args_passed = 0;
206 for (i = 0; i<reqargs; i++) {
207 if (!SCM_CONSP(rest))
208 scm_wrong_num_args(gh_str02scm((char *) procname));
209 *dest++ = SCM_CAR(rest);
210 rest = SCM_CDR(rest);
211 num_args_passed++;
212 }
213 for (i = 0; i<optargs && SCM_CONSP(rest); i++) {
214 *dest++ = SCM_CAR(rest);
215 rest = SCM_CDR(rest);
216 num_args_passed++;
217 }
218 for (; i<optargs; i++)
219 *dest++ = SCM_UNDEFINED;
220 if (!SCM_NULLP(rest))
221 scm_wrong_num_args(gh_str02scm((char *) procname));
222 return num_args_passed;
223}
224
225#ifdef __cplusplus
226}
227#endif
228
229/* guile.swg ends here */