1 /*************************************************************** -*- c -*-
4 * Rename all exported symbols from common.swg, to avoid symbol
5 * clashes if multiple interpreters are included
7 ************************************************************************/
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
17 /***********************************************************************
20 * This file contains generic SWIG runtime support for pointer
21 * type checking as well as a few commonly used macros to control
24 * Author : David Beazley (beazley@cs.uchicago.edu)
26 * Copyright (c) 1999-2000, The University of Chicago
28 * This file may be freely redistributed without license or fee provided
29 * this copyright message remains intact.
30 ************************************************************************/
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
41 # define SWIGEXPORT(a) __declspec(dllexport) a
42 # define SWIGIMPORT(a) extern a
45 # if defined(__BORLANDC__)
46 # define SWIGEXPORT(a) a _export
47 # define SWIGIMPORT(a) a _export
49 # define SWIGEXPORT(a) a
50 # define SWIGIMPORT(a) a
54 # define SWIGEXPORT(a) a
55 # define SWIGIMPORT(a) a
59 #define SWIGRUNTIME(a) SWIGEXPORT(a)
61 #define SWIGRUNTIME(a) static a
68 typedef void *(*swig_converter_func
)(void *);
69 typedef struct swig_type_info
*(*swig_dycast_func
)(void **);
71 typedef struct swig_type_info
{
73 swig_converter_func converter
;
76 swig_dycast_func dcast
;
77 struct swig_type_info
*next
;
78 struct swig_type_info
*prev
;
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 *);
93 static swig_type_info
*swig_type_list
= 0;
95 /* Register a type mapping with the type-checking */
96 SWIGRUNTIME(swig_type_info
*)
97 SWIG_TypeRegister(swig_type_info
*ti
)
99 swig_type_info
*tc
, *head
, *ret
, *next
;
100 /* Check to see if this type has already been registered */
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
;
116 ti
->prev
= swig_type_list
;
119 /* Build linked lists */
123 /* Patch up the rest of the links */
130 if (next
) next
->prev
= head
; /**/
135 /* Check the typename */
136 SWIGRUNTIME(swig_type_info
*)
137 SWIG_TypeCheck(char *c
, swig_type_info
*ty
)
140 if (!ty
) return 0; /* Void pointer */
141 s
= ty
->next
; /* First element always just a name */
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
;
148 s
->next
->prev
= s
->prev
;
150 /* Insert s as second element in the list */
152 if (ty
->next
) ty
->next
->prev
= s
;
158 } while (s
&& (s
!= ty
->next
));
162 /* Cast a pointer up an inheritance hierarchy */
164 SWIG_TypeCast(swig_type_info
*ty
, void *ptr
)
166 if ((!ty
) || (!ty
->converter
)) return ptr
;
167 return (*ty
->converter
)(ptr
);
170 /* Dynamic pointer casting. Down an inheritance hierarchy */
171 SWIGRUNTIME(swig_type_info
*)
172 SWIG_TypeDynamicCast(swig_type_info
*ty
, void **ptr
)
174 swig_type_info
*lastty
= ty
;
175 if (!ty
|| !ty
->dcast
) return ty
;
176 while (ty
&& (ty
->dcast
)) {
177 ty
= (*ty
->dcast
)(ptr
);
183 /* Return the name associated with this type */
184 SWIGRUNTIME(const char *)
185 SWIG_TypeName(const swig_type_info
*ty
) {
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
;
194 if (ty
->str
&& (strcmp(name
,ty
->str
) == 0)) return ty
;
195 if (ty
->name
&& (strcmp(name
,ty
->name
) == 0)) return ty
;
201 /* Set the clientdata field for a type */
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
;
209 if (!equiv
->converter
) {
212 if ((strcmp(tc
->name
, equiv
->name
) == 0))
213 SWIG_TypeClientData(tc
,clientdata
);
226 /***********************************************************************
229 * This file contains the runtime support for Python modules
230 * and includes code for managing global variables and pointer
233 * Author : David Beazley (beazley@cs.uchicago.edu)
234 ************************************************************************/
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
247 /* Flags for pointer conversion */
249 #define SWIG_POINTER_EXCEPTION 0x1
250 #define SWIG_POINTER_DISOWN 0x2
252 /* Exception handling in wrappers */
253 #define SWIG_fail goto fail
255 /* Constant information structure */
256 typedef struct swig_const_info
{
262 swig_type_info
**ptype
;
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)
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)
289 #ifdef SWIG_NOINCLUDE
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);
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
[]);
304 /* -----------------------------------------------------------------------------
305 * global variable support code.
306 * ----------------------------------------------------------------------------- */
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
;
315 typedef struct swig_varlinkobject
{
317 swig_globalvar
*vars
;
318 } swig_varlinkobject
;
321 swig_varlink_repr(swig_varlinkobject
*v
) {
323 return PyString_FromString("<Global variables>");
327 swig_varlink_print(swig_varlinkobject
*v
, FILE *fp
, int flags
) {
330 fprintf(fp
,"Global variables { ");
331 for (var
= v
->vars
; var
; var
=var
->next
) {
332 fprintf(fp
,"%s", var
->name
);
333 if (var
->next
) fprintf(fp
,", ");
340 swig_varlink_getattr(swig_varlinkobject
*v
, char *n
) {
341 swig_globalvar
*var
= v
->vars
;
343 if (strcmp(var
->name
,n
) == 0) {
344 return (*var
->get_attr
)();
348 PyErr_SetString(PyExc_NameError
,"Unknown C global variable");
353 swig_varlink_setattr(swig_varlinkobject
*v
, char *n
, PyObject
*p
) {
354 swig_globalvar
*var
= v
->vars
;
356 if (strcmp(var
->name
,n
) == 0) {
357 return (*var
->set_attr
)(p
);
361 PyErr_SetString(PyExc_NameError
,"Unknown C global variable");
365 statichere PyTypeObject varlinktype
= {
366 PyObject_HEAD_INIT(0)
368 (char *)"swigvarlink", /* Type name */
369 sizeof(swig_varlinkobject
), /* Basic size */
372 (printfunc
) swig_varlink_print
, /* Print */
373 (getattrfunc
) swig_varlink_getattr
, /* get attr */
374 (setattrfunc
) swig_varlink_setattr
, /* Set attr */
376 (reprfunc
) swig_varlink_repr
, /* tp_repr */
377 0, /* tp_as_number */
378 0, /* tp_as_mapping*/
382 /* Create a variable linking object for use later */
383 SWIGRUNTIME(PyObject
*)
384 SWIG_Python_newvarlink(void) {
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
;
390 result
->ob_refcnt
= 0;
391 Py_XINCREF((PyObject
*) result
);
392 return ((PyObject
*) result
);
396 SWIG_Python_addvarlink(PyObject
*p
, char *name
,
397 PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
)) {
398 swig_varlinkobject
*v
;
400 v
= (swig_varlinkobject
*) p
;
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
;
410 /* Pack binary data into a string */
412 SWIG_Python_PackData(char *c
, void *ptr
, int sz
) {
413 static char hex
[17] = "0123456789abcdef";
415 unsigned char *u
= (unsigned char *) ptr
;
416 register unsigned char uu
;
417 for (i
= 0; i
< sz
; i
++,u
++) {
419 *(c
++) = hex
[(uu
& 0xf0) >> 4];
420 *(c
++) = hex
[uu
& 0xf];
425 /* Unpack binary data from a string */
427 SWIG_Python_UnpackData(char *c
, void *ptr
, int sz
) {
428 register unsigned char uu
= 0;
430 unsigned char *u
= (unsigned char *) ptr
;
432 for (i
= 0; i
< sz
; i
++, u
++) {
434 if ((d
>= '0') && (d
<= '9'))
435 uu
= ((d
- '0') << 4);
436 else if ((d
>= 'a') && (d
<= 'f'))
437 uu
= ((d
- ('a'-10)) << 4);
439 if ((d
>= '0') && (d
<= '9'))
441 else if ((d
>= 'a') && (d
<= 'f'))
442 uu
|= (d
- ('a'-10));
448 /* Convert a pointer value */
450 SWIG_Python_ConvertPtr(PyObject
*obj
, void **ptr
, swig_type_info
*ty
, int flags
) {
453 static PyObject
*SWIG_this
= 0;
458 if (obj
== Py_None
) {
462 #ifdef SWIG_COBJECT_TYPES
463 if (!(PyCObject_Check(obj
))) {
465 SWIG_this
= PyString_FromString("this");
467 obj
= PyObject_GetAttr(obj
,SWIG_this
);
469 if (!obj
) goto type_error
;
470 if (!PyCObject_Check(obj
)) {
475 *ptr
= PyCObject_AsVoidPtr(obj
);
476 c
= (char *) PyCObject_GetDesc(obj
);
477 if (newref
) Py_DECREF(obj
);
480 if (!(PyString_Check(obj
))) {
482 SWIG_this
= PyString_FromString("this");
484 obj
= PyObject_GetAttr(obj
,SWIG_this
);
486 if (!obj
) goto type_error
;
487 if (!PyString_Check(obj
)) {
492 c
= PyString_AsString(obj
);
493 /* Pointer values must start with leading underscore */
496 if (strcmp(c
,"NULL") == 0) {
497 if (newref
) { Py_DECREF(obj
); }
500 if (newref
) { Py_DECREF(obj
); }
505 c
= SWIG_UnpackData(c
,ptr
,sizeof(void *));
506 if (newref
) { Py_DECREF(obj
); }
509 #ifdef SWIG_COBJECT_TYPES
514 tc
= SWIG_TypeCheck(c
,ty
);
515 if (!tc
) goto type_error
;
516 *ptr
= SWIG_TypeCast(tc
,(void*) *ptr
);
519 if ((pyobj
) && (flags
& SWIG_POINTER_DISOWN
)) {
520 PyObject
*zero
= PyInt_FromLong(0);
521 PyObject_SetAttrString(pyobj
,(char*)"thisown",zero
);
527 if (flags
& SWIG_POINTER_EXCEPTION
) {
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
);
534 PyErr_SetString(PyExc_TypeError
,"Expected a pointer");
540 /* Convert a pointer value, signal an exception on a type mismatch */
542 SWIG_Python_MustGetPtr(PyObject
*obj
, swig_type_info
*ty
, int argnum
, int flags
)
545 SWIG_Python_ConvertPtr(obj
, &result
, ty
, flags
| SWIG_POINTER_EXCEPTION
);
549 /* Convert a packed value value */
551 SWIG_Python_ConvertPacked(PyObject
*obj
, void *ptr
, int sz
, swig_type_info
*ty
, int flags
) {
555 if ((!obj
) || (!PyString_Check(obj
))) goto type_error
;
556 c
= PyString_AsString(obj
);
557 /* Pointer values must start with leading underscore */
558 if (*c
!= '_') goto type_error
;
560 c
= SWIG_UnpackData(c
,ptr
,sz
);
562 tc
= SWIG_TypeCheck(c
,ty
);
563 if (!tc
) goto type_error
;
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
);
576 PyErr_SetString(PyExc_TypeError
,"Expected a pointer");
582 /* Create a new pointer object */
583 SWIGRUNTIME(PyObject
*)
584 SWIG_Python_NewPointerObj(void *ptr
, swig_type_info
*type
, int own
) {
590 #ifdef SWIG_COBJECT_TYPES
591 robj
= PyCObject_FromVoidPtrAndDesc((void *) ptr
, (char *) type
->name
, NULL
);
597 r
= SWIG_PackData(r
,&ptr
,sizeof(void *));
598 strcpy(r
,type
->name
);
599 robj
= PyString_FromString(result
);
602 if (!robj
|| (robj
== Py_None
)) return robj
;
603 if (type
->clientdata
) {
605 PyObject
*args
= Py_BuildValue((char*)"(O)", robj
);
607 inst
= PyObject_CallObject((PyObject
*) type
->clientdata
, args
);
611 PyObject
*n
= PyInt_FromLong(1);
612 PyObject_SetAttrString(inst
,(char*)"thisown",n
);
621 SWIGRUNTIME(PyObject
*)
622 SWIG_Python_NewPackedObj(void *ptr
, int sz
, swig_type_info
*type
) {
625 if ((2*sz
+ 1 + strlen(type
->name
)) > 1000) return 0;
627 r
= SWIG_PackData(r
,ptr
,sz
);
628 strcpy(r
,type
->name
);
629 return PyString_FromString(result
);
632 /* Install Constants */
634 SWIG_Python_InstallConstants(PyObject
*d
, swig_const_info constants
[]) {
637 for (i
= 0; constants
[i
].type
; i
++) {
638 switch(constants
[i
].type
) {
640 obj
= PyInt_FromLong(constants
[i
].lvalue
);
643 obj
= PyFloat_FromDouble(constants
[i
].dvalue
);
646 obj
= PyString_FromString((char *) constants
[i
].pvalue
);
648 case SWIG_PY_POINTER
:
649 obj
= SWIG_NewPointerObj(constants
[i
].pvalue
, *(constants
[i
]).ptype
,0);
652 obj
= SWIG_NewPackedObj(constants
[i
].pvalue
, constants
[i
].lvalue
, *(constants
[i
].ptype
));
659 PyDict_SetItemString(d
,constants
[i
].name
,obj
);
667 /* Contract support */
669 #define SWIG_preassert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, msg #expr ); goto fail; } else
670 #define SWIG_postassert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, msg #expr ); goto fail; } else
672 #define SWIG_inherit_preassert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, msg #expr ); goto fail; } else
673 #define SWIG_inherit_postassert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, msg #expr ); goto fail; } else
675 #define SWIG_invariant(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, msg #expr ); goto fail; } else
676 #define SWIG_invariant_begin(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, msg #expr ); goto fail; } else
677 #define SWIG_invariant_end(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, msg #expr ); goto fail; } else