]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | /*************************************************************** -*- c -*- |
2 | * python/precommon.swg | |
3 | * | |
4 | * Rename all exported symbols from common.swg, to avoid symbol | |
5 | * clashes if multiple interpreters are included | |
6 | * | |
7 | ************************************************************************/ | |
8 | ||
9 | #define SWIG_TypeRegister SWIG_Python_TypeRegister | |
10 | #define SWIG_TypeCheck SWIG_Python_TypeCheck | |
11 | #define SWIG_TypeCast SWIG_Python_TypeCast | |
12 | #define SWIG_TypeDynamicCast SWIG_Python_TypeDynamicCast | |
13 | #define SWIG_TypeName SWIG_Python_TypeName | |
14 | #define SWIG_TypeQuery SWIG_Python_TypeQuery | |
15 | #define SWIG_TypeClientData SWIG_Python_TypeClientData | |
16 | ||
6bddd8c5 | 17 | /*********************************************************************** |
d14a1e28 RD |
18 | * common.swg |
19 | * | |
20 | * This file contains generic SWIG runtime support for pointer | |
21 | * type checking as well as a few commonly used macros to control | |
22 | * external linkage. | |
6bddd8c5 | 23 | * |
d14a1e28 RD |
24 | * Author : David Beazley (beazley@cs.uchicago.edu) |
25 | * | |
26 | * Copyright (c) 1999-2000, The University of Chicago | |
27 | * | |
28 | * This file may be freely redistributed without license or fee provided | |
29 | * this copyright message remains intact. | |
6bddd8c5 RD |
30 | ************************************************************************/ |
31 | ||
704f9c00 | 32 | #include "Python.h" |
185d7c3e | 33 | #include <string.h> |
d14a1e28 RD |
34 | |
35 | #if defined(_WIN32) || defined(__WIN32__) | |
36 | # if defined(_MSC_VER) | |
37 | # if defined(STATIC_LINKED) | |
38 | # define SWIGEXPORT(a) a | |
39 | # define SWIGIMPORT(a) extern a | |
40 | # else | |
41 | # define SWIGEXPORT(a) __declspec(dllexport) a | |
42 | # define SWIGIMPORT(a) extern a | |
43 | # endif | |
44 | # else | |
45 | # if defined(__BORLANDC__) | |
46 | # define SWIGEXPORT(a) a _export | |
47 | # define SWIGIMPORT(a) a _export | |
48 | # else | |
49 | # define SWIGEXPORT(a) a | |
50 | # define SWIGIMPORT(a) a | |
51 | # endif | |
52 | # endif | |
53 | #else | |
54 | # define SWIGEXPORT(a) a | |
55 | # define SWIGIMPORT(a) a | |
56 | #endif | |
57 | ||
58 | #ifdef SWIG_GLOBAL | |
59 | #define SWIGRUNTIME(a) SWIGEXPORT(a) | |
60 | #else | |
61 | #define SWIGRUNTIME(a) static a | |
62 | #endif | |
185d7c3e | 63 | |
6bddd8c5 RD |
64 | #ifdef __cplusplus |
65 | extern "C" { | |
66 | #endif | |
6bddd8c5 | 67 | |
d14a1e28 RD |
68 | typedef void *(*swig_converter_func)(void *); |
69 | typedef struct swig_type_info *(*swig_dycast_func)(void **); | |
70 | ||
71 | typedef struct swig_type_info { | |
72 | const char *name; | |
73 | swig_converter_func converter; | |
74 | const char *str; | |
75 | void *clientdata; | |
76 | swig_dycast_func dcast; | |
77 | struct swig_type_info *next; | |
78 | struct swig_type_info *prev; | |
79 | } swig_type_info; | |
80 | ||
81 | #ifdef SWIG_NOINCLUDE | |
82 | ||
83 | SWIGIMPORT(swig_type_info *) SWIG_TypeRegister(swig_type_info *); | |
84 | SWIGIMPORT(swig_type_info *) SWIG_TypeCheck(char *c, swig_type_info *); | |
85 | SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info *, void *); | |
86 | SWIGIMPORT(swig_type_info *) SWIG_TypeDynamicCast(swig_type_info *, void **); | |
87 | SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info *); | |
88 | SWIGIMPORT(swig_type_info *) SWIG_TypeQuery(const char *); | |
89 | SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info *, void *); | |
90 | ||
6bddd8c5 | 91 | #else |
d14a1e28 RD |
92 | |
93 | static swig_type_info *swig_type_list = 0; | |
94 | ||
95 | /* Register a type mapping with the type-checking */ | |
96 | SWIGRUNTIME(swig_type_info *) | |
97 | SWIG_TypeRegister(swig_type_info *ti) | |
98 | { | |
99 | swig_type_info *tc, *head, *ret, *next; | |
100 | /* Check to see if this type has already been registered */ | |
101 | tc = swig_type_list; | |
102 | while (tc) { | |
103 | if (strcmp(tc->name, ti->name) == 0) { | |
104 | /* Already exists in the table. Just add additional types to the list */ | |
105 | if (tc->clientdata) ti->clientdata = tc->clientdata; | |
106 | head = tc; | |
107 | next = tc->next; | |
108 | goto l1; | |
109 | } | |
110 | tc = tc->prev; | |
111 | } | |
112 | head = ti; | |
113 | next = 0; | |
114 | ||
115 | /* Place in list */ | |
116 | ti->prev = swig_type_list; | |
117 | swig_type_list = ti; | |
118 | ||
119 | /* Build linked lists */ | |
120 | l1: | |
121 | ret = head; | |
122 | tc = ti + 1; | |
123 | /* Patch up the rest of the links */ | |
124 | while (tc->name) { | |
125 | head->next = tc; | |
126 | tc->prev = head; | |
127 | head = tc; | |
128 | tc++; | |
129 | } | |
130 | if (next) next->prev = head; /**/ | |
131 | head->next = next; | |
132 | return ret; | |
133 | } | |
134 | ||
135 | /* Check the typename */ | |
136 | SWIGRUNTIME(swig_type_info *) | |
137 | SWIG_TypeCheck(char *c, swig_type_info *ty) | |
138 | { | |
139 | swig_type_info *s; | |
140 | if (!ty) return 0; /* Void pointer */ | |
141 | s = ty->next; /* First element always just a name */ | |
142 | do { | |
143 | if (strcmp(s->name,c) == 0) { | |
144 | if (s == ty->next) return s; | |
145 | /* Move s to the top of the linked list */ | |
146 | s->prev->next = s->next; | |
147 | if (s->next) { | |
148 | s->next->prev = s->prev; | |
149 | } | |
150 | /* Insert s as second element in the list */ | |
151 | s->next = ty->next; | |
152 | if (ty->next) ty->next->prev = s; | |
153 | ty->next = s; | |
154 | s->prev = ty; /**/ | |
155 | return s; | |
156 | } | |
157 | s = s->next; | |
158 | } while (s && (s != ty->next)); | |
159 | return 0; | |
160 | } | |
161 | ||
162 | /* Cast a pointer up an inheritance hierarchy */ | |
163 | SWIGRUNTIME(void *) | |
164 | SWIG_TypeCast(swig_type_info *ty, void *ptr) | |
165 | { | |
166 | if ((!ty) || (!ty->converter)) return ptr; | |
167 | return (*ty->converter)(ptr); | |
168 | } | |
169 | ||
170 | /* Dynamic pointer casting. Down an inheritance hierarchy */ | |
171 | SWIGRUNTIME(swig_type_info *) | |
172 | SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) | |
173 | { | |
174 | swig_type_info *lastty = ty; | |
175 | if (!ty || !ty->dcast) return ty; | |
176 | while (ty && (ty->dcast)) { | |
177 | ty = (*ty->dcast)(ptr); | |
178 | if (ty) lastty = ty; | |
179 | } | |
180 | return lastty; | |
181 | } | |
182 | ||
183 | /* Return the name associated with this type */ | |
184 | SWIGRUNTIME(const char *) | |
185 | SWIG_TypeName(const swig_type_info *ty) { | |
186 | return ty->name; | |
187 | } | |
188 | ||
189 | /* Search for a swig_type_info structure */ | |
190 | SWIGRUNTIME(swig_type_info *) | |
191 | SWIG_TypeQuery(const char *name) { | |
192 | swig_type_info *ty = swig_type_list; | |
193 | while (ty) { | |
194 | if (ty->str && (strcmp(name,ty->str) == 0)) return ty; | |
195 | if (ty->name && (strcmp(name,ty->name) == 0)) return ty; | |
196 | ty = ty->prev; | |
197 | } | |
198 | return 0; | |
199 | } | |
200 | ||
201 | /* Set the clientdata field for a type */ | |
202 | SWIGRUNTIME(void) | |
203 | SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { | |
204 | swig_type_info *tc, *equiv; | |
205 | if (ti->clientdata == clientdata) return; | |
206 | ti->clientdata = clientdata; | |
207 | equiv = ti->next; | |
208 | while (equiv) { | |
209 | if (!equiv->converter) { | |
210 | tc = swig_type_list; | |
211 | while (tc) { | |
212 | if ((strcmp(tc->name, equiv->name) == 0)) | |
213 | SWIG_TypeClientData(tc,clientdata); | |
214 | tc = tc->prev; | |
215 | } | |
216 | } | |
217 | equiv = equiv->next; | |
218 | } | |
219 | } | |
6bddd8c5 RD |
220 | #endif |
221 | ||
d14a1e28 RD |
222 | #ifdef __cplusplus |
223 | } | |
224 | ||
225 | #endif | |
226 | /*********************************************************************** | |
227 | * python.swg | |
228 | * | |
229 | * This file contains the runtime support for Python modules | |
230 | * and includes code for managing global variables and pointer | |
231 | * type checking. | |
232 | * | |
233 | * Author : David Beazley (beazley@cs.uchicago.edu) | |
234 | ************************************************************************/ | |
235 | ||
236 | ||
237 | #ifdef __cplusplus | |
238 | extern "C" { | |
6bddd8c5 RD |
239 | #endif |
240 | ||
d14a1e28 RD |
241 | #define SWIG_PY_INT 1 |
242 | #define SWIG_PY_FLOAT 2 | |
243 | #define SWIG_PY_STRING 3 | |
244 | #define SWIG_PY_POINTER 4 | |
245 | #define SWIG_PY_BINARY 5 | |
246 | ||
247 | /* Flags for pointer conversion */ | |
248 | ||
249 | #define SWIG_POINTER_EXCEPTION 0x1 | |
250 | #define SWIG_POINTER_DISOWN 0x2 | |
251 | ||
252 | /* Exception handling in wrappers */ | |
253 | #define SWIG_fail goto fail | |
254 | ||
255 | /* Constant information structure */ | |
256 | typedef struct swig_const_info { | |
257 | int type; | |
258 | char *name; | |
259 | long lvalue; | |
260 | double dvalue; | |
261 | void *pvalue; | |
262 | swig_type_info **ptype; | |
263 | } swig_const_info; | |
264 | ||
265 | /* Common SWIG API */ | |
266 | #define SWIG_ConvertPtr(obj, pp, type, flags) \ | |
267 | SWIG_Python_ConvertPtr(obj, pp, type, flags) | |
268 | #define SWIG_NewPointerObj(p, type, flags) \ | |
269 | SWIG_Python_NewPointerObj(p, type, flags) | |
270 | #define SWIG_MustGetPtr(p, type, argnum, flags) \ | |
271 | SWIG_Python_MustGetPtr(p, type, argnum, flags) | |
272 | ||
273 | /* Python-specific SWIG API */ | |
274 | #define SWIG_newvarlink() \ | |
275 | SWIG_Python_newvarlink() | |
276 | #define SWIG_addvarlink(p, name, get_attr, set_attr) \ | |
277 | SWIG_Python_addvarlink(p, name, get_attr, set_attr) | |
278 | #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \ | |
279 | SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) | |
280 | #define SWIG_PackData(c, ptr, sz) \ | |
281 | SWIG_Python_PackData(c, ptr, sz) | |
282 | #define SWIG_UnpackData(c, ptr, sz) \ | |
283 | SWIG_Python_UnpackData(c, ptr, sz) | |
284 | #define SWIG_NewPackedObj(ptr, sz, type) \ | |
285 | SWIG_Python_NewPackedObj(ptr, sz, type) | |
286 | #define SWIG_InstallConstants(d, constants) \ | |
287 | SWIG_Python_InstallConstants(d, constants) | |
288 | ||
289 | #ifdef SWIG_NOINCLUDE | |
290 | ||
291 | SWIGEXPORT(int) SWIG_Python_ConvertPtr(PyObject *, void **, swig_type_info *, int); | |
292 | SWIGEXPORT(PyObject *) SWIG_Python_NewPointerObj(void *, swig_type_info *,int own); | |
293 | SWIGEXPORT(void *) SWIG_Python_MustGetPtr(PyObject *, swig_type_info *, int, int); | |
294 | ||
295 | SWIGEXPORT(PyObject *) SWIG_Python_newvarlink(void); | |
296 | SWIGEXPORT(void) SWIG_Python_addvarlink(PyObject *, char *, PyObject *(*)(void), int (*)(PyObject *)); | |
297 | SWIGEXPORT(int) SWIG_Python_ConvertPacked(PyObject *, void *, int sz, swig_type_info *, int); | |
298 | SWIGEXPORT(char *) SWIG_Python_PackData(char *c, void *, int); | |
299 | SWIGEXPORT(char *) SWIG_Python_UnpackData(char *c, void *, int); | |
300 | SWIGEXPORT(PyObject *) SWIG_Python_NewPackedObj(void *, int sz, swig_type_info *); | |
301 | SWIGEXPORT(void) SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]); | |
302 | #else | |
303 | ||
304 | /* ----------------------------------------------------------------------------- | |
305 | * global variable support code. | |
306 | * ----------------------------------------------------------------------------- */ | |
307 | ||
308 | typedef struct swig_globalvar { | |
309 | char *name; /* Name of global variable */ | |
310 | PyObject *(*get_attr)(void); /* Return the current value */ | |
311 | int (*set_attr)(PyObject *); /* Set the value */ | |
312 | struct swig_globalvar *next; | |
6bddd8c5 RD |
313 | } swig_globalvar; |
314 | ||
315 | typedef struct swig_varlinkobject { | |
316 | PyObject_HEAD | |
d14a1e28 | 317 | swig_globalvar *vars; |
6bddd8c5 RD |
318 | } swig_varlinkobject; |
319 | ||
6bddd8c5 | 320 | static PyObject * |
d14a1e28 | 321 | swig_varlink_repr(swig_varlinkobject *v) { |
6bddd8c5 RD |
322 | v = v; |
323 | return PyString_FromString("<Global variables>"); | |
324 | } | |
325 | ||
6bddd8c5 | 326 | static int |
d14a1e28 RD |
327 | swig_varlink_print(swig_varlinkobject *v, FILE *fp, int flags) { |
328 | swig_globalvar *var; | |
6bddd8c5 RD |
329 | flags = flags; |
330 | fprintf(fp,"Global variables { "); | |
d14a1e28 RD |
331 | for (var = v->vars; var; var=var->next) { |
332 | fprintf(fp,"%s", var->name); | |
333 | if (var->next) fprintf(fp,", "); | |
6bddd8c5 RD |
334 | } |
335 | fprintf(fp," }\n"); | |
336 | return 0; | |
337 | } | |
338 | ||
6bddd8c5 | 339 | static PyObject * |
d14a1e28 RD |
340 | swig_varlink_getattr(swig_varlinkobject *v, char *n) { |
341 | swig_globalvar *var = v->vars; | |
342 | while (var) { | |
343 | if (strcmp(var->name,n) == 0) { | |
344 | return (*var->get_attr)(); | |
6bddd8c5 | 345 | } |
d14a1e28 | 346 | var = var->next; |
6bddd8c5 | 347 | } |
d14a1e28 | 348 | PyErr_SetString(PyExc_NameError,"Unknown C global variable"); |
6bddd8c5 RD |
349 | return NULL; |
350 | } | |
351 | ||
6bddd8c5 | 352 | static int |
d14a1e28 RD |
353 | swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { |
354 | swig_globalvar *var = v->vars; | |
355 | while (var) { | |
356 | if (strcmp(var->name,n) == 0) { | |
357 | return (*var->set_attr)(p); | |
6bddd8c5 | 358 | } |
d14a1e28 | 359 | var = var->next; |
6bddd8c5 | 360 | } |
d14a1e28 | 361 | PyErr_SetString(PyExc_NameError,"Unknown C global variable"); |
6bddd8c5 RD |
362 | return 1; |
363 | } | |
364 | ||
365 | statichere PyTypeObject varlinktype = { | |
d14a1e28 | 366 | PyObject_HEAD_INIT(0) |
6bddd8c5 | 367 | 0, |
d14a1e28 | 368 | (char *)"swigvarlink", /* Type name */ |
6bddd8c5 RD |
369 | sizeof(swig_varlinkobject), /* Basic size */ |
370 | 0, /* Itemsize */ | |
d14a1e28 | 371 | 0, /* Deallocator */ |
6bddd8c5 RD |
372 | (printfunc) swig_varlink_print, /* Print */ |
373 | (getattrfunc) swig_varlink_getattr, /* get attr */ | |
374 | (setattrfunc) swig_varlink_setattr, /* Set attr */ | |
375 | 0, /* tp_compare */ | |
d14a1e28 | 376 | (reprfunc) swig_varlink_repr, /* tp_repr */ |
6bddd8c5 RD |
377 | 0, /* tp_as_number */ |
378 | 0, /* tp_as_mapping*/ | |
379 | 0, /* tp_hash */ | |
380 | }; | |
381 | ||
382 | /* Create a variable linking object for use later */ | |
d14a1e28 RD |
383 | SWIGRUNTIME(PyObject *) |
384 | SWIG_Python_newvarlink(void) { | |
6bddd8c5 RD |
385 | swig_varlinkobject *result = 0; |
386 | result = PyMem_NEW(swig_varlinkobject,1); | |
387 | varlinktype.ob_type = &PyType_Type; /* Patch varlinktype into a PyType */ | |
388 | result->ob_type = &varlinktype; | |
d14a1e28 | 389 | result->vars = 0; |
6bddd8c5 RD |
390 | result->ob_refcnt = 0; |
391 | Py_XINCREF((PyObject *) result); | |
392 | return ((PyObject*) result); | |
393 | } | |
394 | ||
d14a1e28 RD |
395 | SWIGRUNTIME(void) |
396 | SWIG_Python_addvarlink(PyObject *p, char *name, | |
397 | PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { | |
6bddd8c5 | 398 | swig_varlinkobject *v; |
d14a1e28 | 399 | swig_globalvar *gv; |
6bddd8c5 | 400 | v= (swig_varlinkobject *) p; |
d14a1e28 RD |
401 | gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); |
402 | gv->name = (char *) malloc(strlen(name)+1); | |
403 | strcpy(gv->name,name); | |
404 | gv->get_attr = get_attr; | |
405 | gv->set_attr = set_attr; | |
406 | gv->next = v->vars; | |
407 | v->vars = gv; | |
6bddd8c5 RD |
408 | } |
409 | ||
d14a1e28 RD |
410 | /* Pack binary data into a string */ |
411 | SWIGRUNTIME(char *) | |
412 | SWIG_Python_PackData(char *c, void *ptr, int sz) { | |
413 | static char hex[17] = "0123456789abcdef"; | |
414 | int i; | |
415 | unsigned char *u = (unsigned char *) ptr; | |
416 | register unsigned char uu; | |
417 | for (i = 0; i < sz; i++,u++) { | |
418 | uu = *u; | |
419 | *(c++) = hex[(uu & 0xf0) >> 4]; | |
420 | *(c++) = hex[uu & 0xf]; | |
421 | } | |
422 | return c; | |
1d99702e RD |
423 | } |
424 | ||
d14a1e28 RD |
425 | /* Unpack binary data from a string */ |
426 | SWIGRUNTIME(char *) | |
427 | SWIG_Python_UnpackData(char *c, void *ptr, int sz) { | |
428 | register unsigned char uu = 0; | |
429 | register int d; | |
430 | unsigned char *u = (unsigned char *) ptr; | |
1d99702e | 431 | int i; |
d14a1e28 RD |
432 | for (i = 0; i < sz; i++, u++) { |
433 | d = *(c++); | |
434 | if ((d >= '0') && (d <= '9')) | |
435 | uu = ((d - '0') << 4); | |
436 | else if ((d >= 'a') && (d <= 'f')) | |
437 | uu = ((d - ('a'-10)) << 4); | |
438 | d = *(c++); | |
439 | if ((d >= '0') && (d <= '9')) | |
440 | uu |= (d - '0'); | |
441 | else if ((d >= 'a') && (d <= 'f')) | |
442 | uu |= (d - ('a'-10)); | |
443 | *u = uu; | |
1d99702e | 444 | } |
d14a1e28 RD |
445 | return c; |
446 | } | |
1d99702e | 447 | |
d14a1e28 RD |
448 | /* Convert a pointer value */ |
449 | SWIGRUNTIME(int) | |
450 | SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { | |
451 | swig_type_info *tc; | |
452 | char *c = 0; | |
453 | static PyObject *SWIG_this = 0; | |
454 | int newref = 0; | |
455 | PyObject *pyobj = 0; | |
456 | ||
457 | if (!obj) return 0; | |
458 | if (obj == Py_None) { | |
459 | *ptr = 0; | |
460 | return 0; | |
1d99702e | 461 | } |
d14a1e28 RD |
462 | #ifdef SWIG_COBJECT_TYPES |
463 | if (!(PyCObject_Check(obj))) { | |
464 | if (!SWIG_this) | |
465 | SWIG_this = PyString_FromString("this"); | |
466 | pyobj = obj; | |
467 | obj = PyObject_GetAttr(obj,SWIG_this); | |
468 | newref = 1; | |
469 | if (!obj) goto type_error; | |
470 | if (!PyCObject_Check(obj)) { | |
471 | Py_DECREF(obj); | |
472 | goto type_error; | |
473 | } | |
474 | } | |
475 | *ptr = PyCObject_AsVoidPtr(obj); | |
476 | c = (char *) PyCObject_GetDesc(obj); | |
477 | if (newref) Py_DECREF(obj); | |
478 | goto cobject; | |
479 | #else | |
480 | if (!(PyString_Check(obj))) { | |
481 | if (!SWIG_this) | |
482 | SWIG_this = PyString_FromString("this"); | |
483 | pyobj = obj; | |
484 | obj = PyObject_GetAttr(obj,SWIG_this); | |
485 | newref = 1; | |
486 | if (!obj) goto type_error; | |
487 | if (!PyString_Check(obj)) { | |
488 | Py_DECREF(obj); | |
489 | goto type_error; | |
490 | } | |
491 | } | |
492 | c = PyString_AsString(obj); | |
493 | /* Pointer values must start with leading underscore */ | |
494 | if (*c != '_') { | |
495 | *ptr = (void *) 0; | |
496 | if (strcmp(c,"NULL") == 0) { | |
497 | if (newref) { Py_DECREF(obj); } | |
498 | return 0; | |
499 | } else { | |
500 | if (newref) { Py_DECREF(obj); } | |
501 | goto type_error; | |
1d99702e RD |
502 | } |
503 | } | |
d14a1e28 RD |
504 | c++; |
505 | c = SWIG_UnpackData(c,ptr,sizeof(void *)); | |
506 | if (newref) { Py_DECREF(obj); } | |
507 | #endif | |
508 | ||
509 | #ifdef SWIG_COBJECT_TYPES | |
510 | cobject: | |
511 | #endif | |
512 | ||
513 | if (ty) { | |
514 | tc = SWIG_TypeCheck(c,ty); | |
515 | if (!tc) goto type_error; | |
516 | *ptr = SWIG_TypeCast(tc,(void*) *ptr); | |
1d99702e RD |
517 | } |
518 | ||
d14a1e28 RD |
519 | if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { |
520 | PyObject *zero = PyInt_FromLong(0); | |
521 | PyObject_SetAttrString(pyobj,(char*)"thisown",zero); | |
522 | Py_DECREF(zero); | |
1d99702e | 523 | } |
d14a1e28 | 524 | return 0; |
1d99702e | 525 | |
d14a1e28 RD |
526 | type_error: |
527 | if (flags & SWIG_POINTER_EXCEPTION) { | |
528 | if (ty && c) { | |
529 | char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c)); | |
530 | sprintf(temp,"Type error. Got %s, expected %s", c, ty->name); | |
531 | PyErr_SetString(PyExc_TypeError, temp); | |
532 | free((char *) temp); | |
533 | } else { | |
534 | PyErr_SetString(PyExc_TypeError,"Expected a pointer"); | |
1d99702e | 535 | } |
1d99702e | 536 | } |
d14a1e28 | 537 | return -1; |
1d99702e RD |
538 | } |
539 | ||
d14a1e28 RD |
540 | /* Convert a pointer value, signal an exception on a type mismatch */ |
541 | SWIGRUNTIME(void *) | |
542 | SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) | |
1d99702e | 543 | { |
d14a1e28 RD |
544 | void *result; |
545 | SWIG_Python_ConvertPtr(obj, &result, ty, flags | SWIG_POINTER_EXCEPTION); | |
546 | return result; | |
547 | } | |
1d99702e | 548 | |
d14a1e28 RD |
549 | /* Convert a packed value value */ |
550 | SWIGRUNTIME(int) | |
551 | SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, int sz, swig_type_info *ty, int flags) { | |
552 | swig_type_info *tc; | |
553 | char *c = 0; | |
554 | ||
555 | if ((!obj) || (!PyString_Check(obj))) goto type_error; | |
556 | c = PyString_AsString(obj); | |
1d99702e | 557 | /* Pointer values must start with leading underscore */ |
d14a1e28 | 558 | if (*c != '_') goto type_error; |
1d99702e | 559 | c++; |
d14a1e28 RD |
560 | c = SWIG_UnpackData(c,ptr,sz); |
561 | if (ty) { | |
562 | tc = SWIG_TypeCheck(c,ty); | |
563 | if (!tc) goto type_error; | |
1d99702e | 564 | } |
d14a1e28 RD |
565 | return 0; |
566 | ||
567 | type_error: | |
568 | ||
569 | if (flags) { | |
570 | if (ty && c) { | |
571 | char *temp = (char *) malloc(64+strlen(ty->name)+strlen(c)); | |
572 | sprintf(temp,"Type error. Got %s, expected %s", c, ty->name); | |
573 | PyErr_SetString(PyExc_TypeError, temp); | |
574 | free((char *) temp); | |
575 | } else { | |
576 | PyErr_SetString(PyExc_TypeError,"Expected a pointer"); | |
1d99702e | 577 | } |
1d99702e | 578 | } |
d14a1e28 RD |
579 | return -1; |
580 | } | |
581 | ||
582 | /* Create a new pointer object */ | |
583 | SWIGRUNTIME(PyObject *) | |
584 | SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { | |
585 | PyObject *robj; | |
586 | if (!ptr) { | |
587 | Py_INCREF(Py_None); | |
588 | return Py_None; | |
1d99702e | 589 | } |
d14a1e28 RD |
590 | #ifdef SWIG_COBJECT_TYPES |
591 | robj = PyCObject_FromVoidPtrAndDesc((void *) ptr, (char *) type->name, NULL); | |
592 | #else | |
593 | { | |
594 | char result[1024]; | |
595 | char *r = result; | |
596 | *(r++) = '_'; | |
597 | r = SWIG_PackData(r,&ptr,sizeof(void *)); | |
598 | strcpy(r,type->name); | |
599 | robj = PyString_FromString(result); | |
600 | } | |
601 | #endif | |
602 | if (!robj || (robj == Py_None)) return robj; | |
603 | if (type->clientdata) { | |
604 | PyObject *inst; | |
605 | PyObject *args = Py_BuildValue((char*)"(O)", robj); | |
606 | Py_DECREF(robj); | |
607 | inst = PyObject_CallObject((PyObject *) type->clientdata, args); | |
608 | Py_DECREF(args); | |
609 | if (inst) { | |
610 | if (own) { | |
611 | PyObject *n = PyInt_FromLong(1); | |
612 | PyObject_SetAttrString(inst,(char*)"thisown",n); | |
613 | Py_DECREF(n); | |
1d99702e | 614 | } |
d14a1e28 | 615 | robj = inst; |
1d99702e | 616 | } |
1d99702e | 617 | } |
d14a1e28 | 618 | return robj; |
1afc06c2 | 619 | } |
1d99702e | 620 | |
d14a1e28 RD |
621 | SWIGRUNTIME(PyObject *) |
622 | SWIG_Python_NewPackedObj(void *ptr, int sz, swig_type_info *type) { | |
623 | char result[1024]; | |
624 | char *r = result; | |
625 | if ((2*sz + 1 + strlen(type->name)) > 1000) return 0; | |
626 | *(r++) = '_'; | |
627 | r = SWIG_PackData(r,ptr,sz); | |
628 | strcpy(r,type->name); | |
629 | return PyString_FromString(result); | |
630 | } | |
3628e088 | 631 | |
d14a1e28 RD |
632 | /* Install Constants */ |
633 | SWIGRUNTIME(void) | |
634 | SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { | |
635 | int i; | |
636 | PyObject *obj; | |
637 | for (i = 0; constants[i].type; i++) { | |
638 | switch(constants[i].type) { | |
639 | case SWIG_PY_INT: | |
640 | obj = PyInt_FromLong(constants[i].lvalue); | |
641 | break; | |
642 | case SWIG_PY_FLOAT: | |
643 | obj = PyFloat_FromDouble(constants[i].dvalue); | |
644 | break; | |
645 | case SWIG_PY_STRING: | |
646 | obj = PyString_FromString((char *) constants[i].pvalue); | |
647 | break; | |
648 | case SWIG_PY_POINTER: | |
649 | obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); | |
650 | break; | |
651 | case SWIG_PY_BINARY: | |
652 | obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); | |
653 | break; | |
654 | default: | |
655 | obj = 0; | |
656 | break; | |
657 | } | |
658 | if (obj) { | |
659 | PyDict_SetItemString(d,constants[i].name,obj); | |
660 | Py_DECREF(obj); | |
661 | } | |
1d99702e | 662 | } |
1d99702e RD |
663 | } |
664 | ||
1d99702e | 665 | #endif |
6bddd8c5 | 666 | |
d14a1e28 | 667 | /* Contract support */ |
6bddd8c5 | 668 | |
11188b02 | 669 | #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else |
1b62f00d | 670 | |
d14a1e28 RD |
671 | #ifdef __cplusplus |
672 | } | |
673 | #endif |