1 /* ----------------------------------------------------------------------------
2 * This file was automatically generated by SWIG (http://www.swig.org).
5 * This file is not intended to be easily readable and contains a number of
6 * coding conventions designed to improve portability and efficiency. Do not make
7 * changes to this file unless you know what you are doing--modify the SWIG
8 * interface file instead.
9 * ----------------------------------------------------------------------------- */
18 /*************************************************************** -*- c -*-
19 * python/precommon.swg
21 * Rename all exported symbols from common.swg, to avoid symbol
22 * clashes if multiple interpreters are included
24 ************************************************************************/
26 #define SWIG_TypeRegister SWIG_Python_TypeRegister
27 #define SWIG_TypeCheck SWIG_Python_TypeCheck
28 #define SWIG_TypeCast SWIG_Python_TypeCast
29 #define SWIG_TypeDynamicCast SWIG_Python_TypeDynamicCast
30 #define SWIG_TypeName SWIG_Python_TypeName
31 #define SWIG_TypeQuery SWIG_Python_TypeQuery
32 #define SWIG_TypeClientData SWIG_Python_TypeClientData
33 #define SWIG_PackData SWIG_Python_PackData
34 #define SWIG_UnpackData SWIG_Python_UnpackData
37 /***********************************************************************
40 * This file contains generic SWIG runtime support for pointer
41 * type checking as well as a few commonly used macros to control
44 * Author : David Beazley (beazley@cs.uchicago.edu)
46 * Copyright (c) 1999-2000, The University of Chicago
48 * This file may be freely redistributed without license or fee provided
49 * this copyright message remains intact.
50 ************************************************************************/
54 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
55 # if defined(_MSC_VER) || defined(__GNUC__)
56 # if defined(STATIC_LINKED)
57 # define SWIGEXPORT(a) a
58 # define SWIGIMPORT(a) extern a
60 # define SWIGEXPORT(a) __declspec(dllexport) a
61 # define SWIGIMPORT(a) extern a
64 # if defined(__BORLANDC__)
65 # define SWIGEXPORT(a) a _export
66 # define SWIGIMPORT(a) a _export
68 # define SWIGEXPORT(a) a
69 # define SWIGIMPORT(a) a
73 # define SWIGEXPORT(a) a
74 # define SWIGIMPORT(a) a
78 # define SWIGRUNTIME(a) SWIGEXPORT(a)
80 # define SWIGRUNTIME(a) static a
87 typedef void *(*swig_converter_func
)(void *);
88 typedef struct swig_type_info
*(*swig_dycast_func
)(void **);
90 typedef struct swig_type_info
{
92 swig_converter_func converter
;
95 swig_dycast_func dcast
;
96 struct swig_type_info
*next
;
97 struct swig_type_info
*prev
;
100 #ifdef SWIG_NOINCLUDE
102 SWIGIMPORT(swig_type_info
*) SWIG_TypeRegister(swig_type_info
*);
103 SWIGIMPORT(swig_type_info
*) SWIG_TypeCheck(char *c
, swig_type_info
*);
104 SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info
*, void *);
105 SWIGIMPORT(swig_type_info
*) SWIG_TypeDynamicCast(swig_type_info
*, void **);
106 SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info
*);
107 SWIGIMPORT(swig_type_info
*) SWIG_TypeQuery(const char *);
108 SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info
*, void *);
109 SWIGIMPORT(char *) SWIG_PackData(char *, void *, int);
110 SWIGIMPORT(char *) SWIG_UnpackData(char *, void *, int);
114 static swig_type_info
*swig_type_list
= 0;
116 /* Register a type mapping with the type-checking */
117 SWIGRUNTIME(swig_type_info
*)
118 SWIG_TypeRegister(swig_type_info
*ti
) {
119 swig_type_info
*tc
, *head
, *ret
, *next
;
120 /* Check to see if this type has already been registered */
123 if (strcmp(tc
->name
, ti
->name
) == 0) {
124 /* Already exists in the table. Just add additional types to the list */
125 if (tc
->clientdata
) ti
->clientdata
= tc
->clientdata
;
136 ti
->prev
= swig_type_list
;
139 /* Build linked lists */
143 /* Patch up the rest of the links */
150 if (next
) next
->prev
= head
;
155 /* Check the typename */
156 SWIGRUNTIME(swig_type_info
*)
157 SWIG_TypeCheck(char *c
, swig_type_info
*ty
) {
159 if (!ty
) return 0; /* Void pointer */
160 s
= ty
->next
; /* First element always just a name */
162 if (strcmp(s
->name
,c
) == 0) {
163 if (s
== ty
->next
) return s
;
164 /* Move s to the top of the linked list */
165 s
->prev
->next
= s
->next
;
167 s
->next
->prev
= s
->prev
;
169 /* Insert s as second element in the list */
171 if (ty
->next
) ty
->next
->prev
= s
;
177 } while (s
&& (s
!= ty
->next
));
181 /* Cast a pointer up an inheritance hierarchy */
183 SWIG_TypeCast(swig_type_info
*ty
, void *ptr
) {
184 if ((!ty
) || (!ty
->converter
)) return ptr
;
185 return (*ty
->converter
)(ptr
);
188 /* Dynamic pointer casting. Down an inheritance hierarchy */
189 SWIGRUNTIME(swig_type_info
*)
190 SWIG_TypeDynamicCast(swig_type_info
*ty
, void **ptr
) {
191 swig_type_info
*lastty
= ty
;
192 if (!ty
|| !ty
->dcast
) return ty
;
193 while (ty
&& (ty
->dcast
)) {
194 ty
= (*ty
->dcast
)(ptr
);
200 /* Return the name associated with this type */
201 SWIGRUNTIME(const char *)
202 SWIG_TypeName(const swig_type_info
*ty
) {
206 /* Search for a swig_type_info structure */
207 SWIGRUNTIME(swig_type_info
*)
208 SWIG_TypeQuery(const char *name
) {
209 swig_type_info
*ty
= swig_type_list
;
211 if (ty
->str
&& (strcmp(name
,ty
->str
) == 0)) return ty
;
212 if (ty
->name
&& (strcmp(name
,ty
->name
) == 0)) return ty
;
218 /* Set the clientdata field for a type */
220 SWIG_TypeClientData(swig_type_info
*ti
, void *clientdata
) {
221 swig_type_info
*tc
, *equiv
;
222 if (ti
->clientdata
== clientdata
) return;
223 ti
->clientdata
= clientdata
;
226 if (!equiv
->converter
) {
229 if ((strcmp(tc
->name
, equiv
->name
) == 0))
230 SWIG_TypeClientData(tc
,clientdata
);
238 /* Pack binary data into a string */
240 SWIG_PackData(char *c
, void *ptr
, int sz
) {
241 static char hex
[17] = "0123456789abcdef";
243 unsigned char *u
= (unsigned char *) ptr
;
244 register unsigned char uu
;
245 for (i
= 0; i
< sz
; i
++,u
++) {
247 *(c
++) = hex
[(uu
& 0xf0) >> 4];
248 *(c
++) = hex
[uu
& 0xf];
253 /* Unpack binary data from a string */
255 SWIG_UnpackData(char *c
, void *ptr
, int sz
) {
256 register unsigned char uu
= 0;
258 unsigned char *u
= (unsigned char *) ptr
;
260 for (i
= 0; i
< sz
; i
++, u
++) {
262 if ((d
>= '0') && (d
<= '9'))
263 uu
= ((d
- '0') << 4);
264 else if ((d
>= 'a') && (d
<= 'f'))
265 uu
= ((d
- ('a'-10)) << 4);
267 if ((d
>= '0') && (d
<= '9'))
269 else if ((d
>= 'a') && (d
<= 'f'))
270 uu
|= (d
- ('a'-10));
282 /***********************************************************************
285 * This file contains the runtime support for Python modules
286 * and includes code for managing global variables and pointer
289 * Author : David Beazley (beazley@cs.uchicago.edu)
290 ************************************************************************/
298 #define SWIG_PY_INT 1
299 #define SWIG_PY_FLOAT 2
300 #define SWIG_PY_STRING 3
301 #define SWIG_PY_POINTER 4
302 #define SWIG_PY_BINARY 5
304 /* Flags for pointer conversion */
306 #define SWIG_POINTER_EXCEPTION 0x1
307 #define SWIG_POINTER_DISOWN 0x2
309 /* Exception handling in wrappers */
310 #define SWIG_fail goto fail
312 /* Constant information structure */
313 typedef struct swig_const_info
{
319 swig_type_info
**ptype
;
322 /* Common SWIG API */
323 #define SWIG_ConvertPtr(obj, pp, type, flags) \
324 SWIG_Python_ConvertPtr(obj, pp, type, flags)
325 #define SWIG_NewPointerObj(p, type, flags) \
326 SWIG_Python_NewPointerObj(p, type, flags)
327 #define SWIG_MustGetPtr(p, type, argnum, flags) \
328 SWIG_Python_MustGetPtr(p, type, argnum, flags)
330 /* Python-specific SWIG API */
331 #define SWIG_newvarlink() \
332 SWIG_Python_newvarlink()
333 #define SWIG_addvarlink(p, name, get_attr, set_attr) \
334 SWIG_Python_addvarlink(p, name, get_attr, set_attr)
335 #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
336 SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
337 #define SWIG_NewPackedObj(ptr, sz, type) \
338 SWIG_Python_NewPackedObj(ptr, sz, type)
339 #define SWIG_InstallConstants(d, constants) \
340 SWIG_Python_InstallConstants(d, constants)
342 #ifdef SWIG_NOINCLUDE
344 SWIGIMPORT(int) SWIG_Python_ConvertPtr(PyObject
*, void **, swig_type_info
*, int);
345 SWIGIMPORT(PyObject
*) SWIG_Python_NewPointerObj(void *, swig_type_info
*,int own
);
346 SWIGIMPORT(void *) SWIG_Python_MustGetPtr(PyObject
*, swig_type_info
*, int, int);
347 SWIGIMPORT(PyObject
*) SWIG_Python_newvarlink(void);
348 SWIGIMPORT(void) SWIG_Python_addvarlink(PyObject
*, char *, PyObject
*(*)(void), int (*)(PyObject
*));
349 SWIGIMPORT(int) SWIG_Python_ConvertPacked(PyObject
*, void *, int sz
, swig_type_info
*, int);
350 SWIGIMPORT(PyObject
*) SWIG_Python_NewPackedObj(void *, int sz
, swig_type_info
*);
351 SWIGIMPORT(void) SWIG_Python_InstallConstants(PyObject
*d
, swig_const_info constants
[]);
355 /* -----------------------------------------------------------------------------
356 * global variable support code.
357 * ----------------------------------------------------------------------------- */
359 typedef struct swig_globalvar
{
360 char *name
; /* Name of global variable */
361 PyObject
*(*get_attr
)(void); /* Return the current value */
362 int (*set_attr
)(PyObject
*); /* Set the value */
363 struct swig_globalvar
*next
;
366 typedef struct swig_varlinkobject
{
368 swig_globalvar
*vars
;
369 } swig_varlinkobject
;
372 swig_varlink_repr(swig_varlinkobject
*v
) {
374 return PyString_FromString("<Global variables>");
378 swig_varlink_print(swig_varlinkobject
*v
, FILE *fp
, int flags
) {
381 fprintf(fp
,"Global variables { ");
382 for (var
= v
->vars
; var
; var
=var
->next
) {
383 fprintf(fp
,"%s", var
->name
);
384 if (var
->next
) fprintf(fp
,", ");
391 swig_varlink_getattr(swig_varlinkobject
*v
, char *n
) {
392 swig_globalvar
*var
= v
->vars
;
394 if (strcmp(var
->name
,n
) == 0) {
395 return (*var
->get_attr
)();
399 PyErr_SetString(PyExc_NameError
,"Unknown C global variable");
404 swig_varlink_setattr(swig_varlinkobject
*v
, char *n
, PyObject
*p
) {
405 swig_globalvar
*var
= v
->vars
;
407 if (strcmp(var
->name
,n
) == 0) {
408 return (*var
->set_attr
)(p
);
412 PyErr_SetString(PyExc_NameError
,"Unknown C global variable");
416 statichere PyTypeObject varlinktype
= {
417 PyObject_HEAD_INIT(0)
419 (char *)"swigvarlink", /* Type name */
420 sizeof(swig_varlinkobject
), /* Basic size */
423 (printfunc
) swig_varlink_print
, /* Print */
424 (getattrfunc
) swig_varlink_getattr
, /* get attr */
425 (setattrfunc
) swig_varlink_setattr
, /* Set attr */
427 (reprfunc
) swig_varlink_repr
, /* tp_repr */
428 0, /* tp_as_number */
429 0, /* tp_as_mapping*/
433 /* Create a variable linking object for use later */
434 SWIGRUNTIME(PyObject
*)
435 SWIG_Python_newvarlink(void) {
436 swig_varlinkobject
*result
= 0;
437 result
= PyMem_NEW(swig_varlinkobject
,1);
438 varlinktype
.ob_type
= &PyType_Type
; /* Patch varlinktype into a PyType */
439 result
->ob_type
= &varlinktype
;
441 result
->ob_refcnt
= 0;
442 Py_XINCREF((PyObject
*) result
);
443 return ((PyObject
*) result
);
447 SWIG_Python_addvarlink(PyObject
*p
, char *name
, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
)) {
448 swig_varlinkobject
*v
;
450 v
= (swig_varlinkobject
*) p
;
451 gv
= (swig_globalvar
*) malloc(sizeof(swig_globalvar
));
452 gv
->name
= (char *) malloc(strlen(name
)+1);
453 strcpy(gv
->name
,name
);
454 gv
->get_attr
= get_attr
;
455 gv
->set_attr
= set_attr
;
460 /* Convert a pointer value */
462 SWIG_Python_ConvertPtr(PyObject
*obj
, void **ptr
, swig_type_info
*ty
, int flags
) {
465 static PyObject
*SWIG_this
= 0;
470 if (obj
== Py_None
) {
474 #ifdef SWIG_COBJECT_TYPES
475 if (!(PyCObject_Check(obj
))) {
477 SWIG_this
= PyString_FromString("this");
479 obj
= PyObject_GetAttr(obj
,SWIG_this
);
481 if (!obj
) goto type_error
;
482 if (!PyCObject_Check(obj
)) {
487 *ptr
= PyCObject_AsVoidPtr(obj
);
488 c
= (char *) PyCObject_GetDesc(obj
);
489 if (newref
) Py_DECREF(obj
);
492 if (!(PyString_Check(obj
))) {
494 SWIG_this
= PyString_FromString("this");
496 obj
= PyObject_GetAttr(obj
,SWIG_this
);
498 if (!obj
) goto type_error
;
499 if (!PyString_Check(obj
)) {
504 c
= PyString_AsString(obj
);
505 /* Pointer values must start with leading underscore */
508 if (strcmp(c
,"NULL") == 0) {
509 if (newref
) { Py_DECREF(obj
); }
512 if (newref
) { Py_DECREF(obj
); }
517 c
= SWIG_UnpackData(c
,ptr
,sizeof(void *));
518 if (newref
) { Py_DECREF(obj
); }
521 #ifdef SWIG_COBJECT_TYPES
526 tc
= SWIG_TypeCheck(c
,ty
);
527 if (!tc
) goto type_error
;
528 *ptr
= SWIG_TypeCast(tc
,(void*) *ptr
);
531 if ((pyobj
) && (flags
& SWIG_POINTER_DISOWN
)) {
532 PyObject
*zero
= PyInt_FromLong(0);
533 PyObject_SetAttrString(pyobj
,(char*)"thisown",zero
);
539 if (flags
& SWIG_POINTER_EXCEPTION
) {
541 char *temp
= (char *) malloc(64+strlen(ty
->name
)+strlen(c
));
542 sprintf(temp
,"Type error. Got %s, expected %s", c
, ty
->name
);
543 PyErr_SetString(PyExc_TypeError
, temp
);
546 PyErr_SetString(PyExc_TypeError
,"Expected a pointer");
552 /* Convert a pointer value, signal an exception on a type mismatch */
554 SWIG_Python_MustGetPtr(PyObject
*obj
, swig_type_info
*ty
, int argnum
, int flags
) {
556 SWIG_Python_ConvertPtr(obj
, &result
, ty
, flags
| SWIG_POINTER_EXCEPTION
);
560 /* Convert a packed value value */
562 SWIG_Python_ConvertPacked(PyObject
*obj
, void *ptr
, int sz
, swig_type_info
*ty
, int flags
) {
566 if ((!obj
) || (!PyString_Check(obj
))) goto type_error
;
567 c
= PyString_AsString(obj
);
568 /* Pointer values must start with leading underscore */
569 if (*c
!= '_') goto type_error
;
571 c
= SWIG_UnpackData(c
,ptr
,sz
);
573 tc
= SWIG_TypeCheck(c
,ty
);
574 if (!tc
) goto type_error
;
582 char *temp
= (char *) malloc(64+strlen(ty
->name
)+strlen(c
));
583 sprintf(temp
,"Type error. Got %s, expected %s", c
, ty
->name
);
584 PyErr_SetString(PyExc_TypeError
, temp
);
587 PyErr_SetString(PyExc_TypeError
,"Expected a pointer");
593 /* Create a new pointer object */
594 SWIGRUNTIME(PyObject
*)
595 SWIG_Python_NewPointerObj(void *ptr
, swig_type_info
*type
, int own
) {
601 #ifdef SWIG_COBJECT_TYPES
602 robj
= PyCObject_FromVoidPtrAndDesc((void *) ptr
, (char *) type
->name
, NULL
);
608 r
= SWIG_PackData(r
,&ptr
,sizeof(void *));
609 strcpy(r
,type
->name
);
610 robj
= PyString_FromString(result
);
613 if (!robj
|| (robj
== Py_None
)) return robj
;
614 if (type
->clientdata
) {
616 PyObject
*args
= Py_BuildValue((char*)"(O)", robj
);
618 inst
= PyObject_CallObject((PyObject
*) type
->clientdata
, args
);
622 PyObject
*n
= PyInt_FromLong(1);
623 PyObject_SetAttrString(inst
,(char*)"thisown",n
);
632 SWIGRUNTIME(PyObject
*)
633 SWIG_Python_NewPackedObj(void *ptr
, int sz
, swig_type_info
*type
) {
636 if ((2*sz
+ 1 + strlen(type
->name
)) > 1000) return 0;
638 r
= SWIG_PackData(r
,ptr
,sz
);
639 strcpy(r
,type
->name
);
640 return PyString_FromString(result
);
643 /* Install Constants */
645 SWIG_Python_InstallConstants(PyObject
*d
, swig_const_info constants
[]) {
648 for (i
= 0; constants
[i
].type
; i
++) {
649 switch(constants
[i
].type
) {
651 obj
= PyInt_FromLong(constants
[i
].lvalue
);
654 obj
= PyFloat_FromDouble(constants
[i
].dvalue
);
657 obj
= PyString_FromString((char *) constants
[i
].pvalue
);
659 case SWIG_PY_POINTER
:
660 obj
= SWIG_NewPointerObj(constants
[i
].pvalue
, *(constants
[i
]).ptype
,0);
663 obj
= SWIG_NewPackedObj(constants
[i
].pvalue
, constants
[i
].lvalue
, *(constants
[i
].ptype
));
670 PyDict_SetItemString(d
,constants
[i
].name
,obj
);
678 /* Contract support */
680 #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else
687 /* -------- TYPES TABLE (BEGIN) -------- */
689 static swig_type_info
*swig_types
[1];
691 /* -------- TYPES TABLE (END) -------- */
694 /*-----------------------------------------------
695 @(target):= _swigrun.so
696 ------------------------------------------------*/
697 #define SWIG_init init_swigrun
699 #define SWIG_name "_swigrun"
703 static PyMethodDef SwigMethods
[] = {
708 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
711 static swig_type_info
*swig_types_initial
[] = {
716 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
718 static swig_const_info swig_const_table
[] = {
728 SWIGEXPORT(void) SWIG_init(void) {
729 static PyObject
*SWIG_globals
= 0;
730 static int typeinit
= 0;
733 if (!SWIG_globals
) SWIG_globals
= SWIG_newvarlink();
734 m
= Py_InitModule((char *) SWIG_name
, SwigMethods
);
735 d
= PyModule_GetDict(m
);
738 for (i
= 0; swig_types_initial
[i
]; i
++) {
739 swig_types
[i
] = SWIG_TypeRegister(swig_types_initial
[i
]);
743 SWIG_InstallConstants(d
,swig_const_table
);