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
36 /***********************************************************************
39 * This file contains generic SWIG runtime support for pointer
40 * type checking as well as a few commonly used macros to control
43 * Author : David Beazley (beazley@cs.uchicago.edu)
45 * Copyright (c) 1999-2000, The University of Chicago
47 * This file may be freely redistributed without license or fee provided
48 * this copyright message remains intact.
49 ************************************************************************/
53 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
54 # if defined(_MSC_VER) || defined(__GNUC__)
55 # if defined(STATIC_LINKED)
56 # define SWIGEXPORT(a) a
57 # define SWIGIMPORT(a) extern a
59 # define SWIGEXPORT(a) __declspec(dllexport) a
60 # define SWIGIMPORT(a) extern a
63 # if defined(__BORLANDC__)
64 # define SWIGEXPORT(a) a _export
65 # define SWIGIMPORT(a) a _export
67 # define SWIGEXPORT(a) a
68 # define SWIGIMPORT(a) a
72 # define SWIGEXPORT(a) a
73 # define SWIGIMPORT(a) a
77 # define SWIGRUNTIME(a) SWIGEXPORT(a)
79 # define SWIGRUNTIME(a) static a
86 typedef void *(*swig_converter_func
)(void *);
87 typedef struct swig_type_info
*(*swig_dycast_func
)(void **);
89 typedef struct swig_type_info
{
91 swig_converter_func converter
;
94 swig_dycast_func dcast
;
95 struct swig_type_info
*next
;
96 struct swig_type_info
*prev
;
101 SWIGIMPORT(swig_type_info
*) SWIG_TypeRegister(swig_type_info
*);
102 SWIGIMPORT(swig_type_info
*) SWIG_TypeCheck(char *c
, swig_type_info
*);
103 SWIGIMPORT(void *) SWIG_TypeCast(swig_type_info
*, void *);
104 SWIGIMPORT(swig_type_info
*) SWIG_TypeDynamicCast(swig_type_info
*, void **);
105 SWIGIMPORT(const char *) SWIG_TypeName(const swig_type_info
*);
106 SWIGIMPORT(swig_type_info
*) SWIG_TypeQuery(const char *);
107 SWIGIMPORT(void) SWIG_TypeClientData(swig_type_info
*, void *);
108 SWIGIMPORT(char *) SWIG_PackData(char *, void *, int);
109 SWIGIMPORT(char *) SWIG_UnpackData(char *, void *, int);
113 static swig_type_info
*swig_type_list
= 0;
115 /* Register a type mapping with the type-checking */
116 SWIGRUNTIME(swig_type_info
*)
117 SWIG_TypeRegister(swig_type_info
*ti
) {
118 swig_type_info
*tc
, *head
, *ret
, *next
;
119 /* Check to see if this type has already been registered */
122 if (strcmp(tc
->name
, ti
->name
) == 0) {
123 /* Already exists in the table. Just add additional types to the list */
124 if (tc
->clientdata
) ti
->clientdata
= tc
->clientdata
;
135 ti
->prev
= swig_type_list
;
138 /* Build linked lists */
142 /* Patch up the rest of the links */
149 if (next
) next
->prev
= head
;
154 /* Check the typename */
155 SWIGRUNTIME(swig_type_info
*)
156 SWIG_TypeCheck(char *c
, swig_type_info
*ty
) {
158 if (!ty
) return 0; /* Void pointer */
159 s
= ty
->next
; /* First element always just a name */
161 if (strcmp(s
->name
,c
) == 0) {
162 if (s
== ty
->next
) return s
;
163 /* Move s to the top of the linked list */
164 s
->prev
->next
= s
->next
;
166 s
->next
->prev
= s
->prev
;
168 /* Insert s as second element in the list */
170 if (ty
->next
) ty
->next
->prev
= s
;
176 } while (s
&& (s
!= ty
->next
));
180 /* Cast a pointer up an inheritance hierarchy */
182 SWIG_TypeCast(swig_type_info
*ty
, void *ptr
) {
183 if ((!ty
) || (!ty
->converter
)) return ptr
;
184 return (*ty
->converter
)(ptr
);
187 /* Dynamic pointer casting. Down an inheritance hierarchy */
188 SWIGRUNTIME(swig_type_info
*)
189 SWIG_TypeDynamicCast(swig_type_info
*ty
, void **ptr
) {
190 swig_type_info
*lastty
= ty
;
191 if (!ty
|| !ty
->dcast
) return ty
;
192 while (ty
&& (ty
->dcast
)) {
193 ty
= (*ty
->dcast
)(ptr
);
199 /* Return the name associated with this type */
200 SWIGRUNTIME(const char *)
201 SWIG_TypeName(const swig_type_info
*ty
) {
205 /* Search for a swig_type_info structure */
206 SWIGRUNTIME(swig_type_info
*)
207 SWIG_TypeQuery(const char *name
) {
208 swig_type_info
*ty
= swig_type_list
;
210 if (ty
->str
&& (strcmp(name
,ty
->str
) == 0)) return ty
;
211 if (ty
->name
&& (strcmp(name
,ty
->name
) == 0)) return ty
;
217 /* Set the clientdata field for a type */
219 SWIG_TypeClientData(swig_type_info
*ti
, void *clientdata
) {
220 swig_type_info
*tc
, *equiv
;
221 if (ti
->clientdata
== clientdata
) return;
222 ti
->clientdata
= clientdata
;
225 if (!equiv
->converter
) {
228 if ((strcmp(tc
->name
, equiv
->name
) == 0))
229 SWIG_TypeClientData(tc
,clientdata
);
237 /* Pack binary data into a string */
239 SWIG_PackData(char *c
, void *ptr
, int sz
) {
240 static char hex
[17] = "0123456789abcdef";
242 unsigned char *u
= (unsigned char *) ptr
;
243 register unsigned char uu
;
244 for (i
= 0; i
< sz
; i
++,u
++) {
246 *(c
++) = hex
[(uu
& 0xf0) >> 4];
247 *(c
++) = hex
[uu
& 0xf];
252 /* Unpack binary data from a string */
254 SWIG_UnpackData(char *c
, void *ptr
, int sz
) {
255 register unsigned char uu
= 0;
257 unsigned char *u
= (unsigned char *) ptr
;
259 for (i
= 0; i
< sz
; i
++, u
++) {
261 if ((d
>= '0') && (d
<= '9'))
262 uu
= ((d
- '0') << 4);
263 else if ((d
>= 'a') && (d
<= 'f'))
264 uu
= ((d
- ('a'-10)) << 4);
266 if ((d
>= '0') && (d
<= '9'))
268 else if ((d
>= 'a') && (d
<= 'f'))
269 uu
|= (d
- ('a'-10));
281 /***********************************************************************
284 * This file contains the runtime support for Python modules
285 * and includes code for managing global variables and pointer
288 * Author : David Beazley (beazley@cs.uchicago.edu)
289 ************************************************************************/
297 #define SWIG_PY_INT 1
298 #define SWIG_PY_FLOAT 2
299 #define SWIG_PY_STRING 3
300 #define SWIG_PY_POINTER 4
301 #define SWIG_PY_BINARY 5
303 /* Flags for pointer conversion */
305 #define SWIG_POINTER_EXCEPTION 0x1
306 #define SWIG_POINTER_DISOWN 0x2
308 /* Exception handling in wrappers */
309 #define SWIG_fail goto fail
311 /* Constant information structure */
312 typedef struct swig_const_info
{
318 swig_type_info
**ptype
;
321 /* Common SWIG API */
322 #define SWIG_ConvertPtr(obj, pp, type, flags) \
323 SWIG_Python_ConvertPtr(obj, pp, type, flags)
324 #define SWIG_NewPointerObj(p, type, flags) \
325 SWIG_Python_NewPointerObj(p, type, flags)
326 #define SWIG_MustGetPtr(p, type, argnum, flags) \
327 SWIG_Python_MustGetPtr(p, type, argnum, flags)
329 /* Python-specific SWIG API */
330 #define SWIG_newvarlink() \
331 SWIG_Python_newvarlink()
332 #define SWIG_addvarlink(p, name, get_attr, set_attr) \
333 SWIG_Python_addvarlink(p, name, get_attr, set_attr)
334 #define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) \
335 SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
336 #define SWIG_NewPackedObj(ptr, sz, type) \
337 SWIG_Python_NewPackedObj(ptr, sz, type)
338 #define SWIG_InstallConstants(d, constants) \
339 SWIG_Python_InstallConstants(d, constants)
341 #ifdef SWIG_NOINCLUDE
343 SWIGIMPORT(int) SWIG_Python_ConvertPtr(PyObject
*, void **, swig_type_info
*, int);
344 SWIGIMPORT(PyObject
*) SWIG_Python_NewPointerObj(void *, swig_type_info
*,int own
);
345 SWIGIMPORT(void *) SWIG_Python_MustGetPtr(PyObject
*, swig_type_info
*, int, int);
346 SWIGIMPORT(PyObject
*) SWIG_Python_newvarlink(void);
347 SWIGIMPORT(void) SWIG_Python_addvarlink(PyObject
*, char *, PyObject
*(*)(void), int (*)(PyObject
*));
348 SWIGIMPORT(int) SWIG_Python_ConvertPacked(PyObject
*, void *, int sz
, swig_type_info
*, int);
349 SWIGIMPORT(PyObject
*) SWIG_Python_NewPackedObj(void *, int sz
, swig_type_info
*);
350 SWIGIMPORT(void) SWIG_Python_InstallConstants(PyObject
*d
, swig_const_info constants
[]);
354 /* -----------------------------------------------------------------------------
355 * global variable support code.
356 * ----------------------------------------------------------------------------- */
358 typedef struct swig_globalvar
{
359 char *name
; /* Name of global variable */
360 PyObject
*(*get_attr
)(void); /* Return the current value */
361 int (*set_attr
)(PyObject
*); /* Set the value */
362 struct swig_globalvar
*next
;
365 typedef struct swig_varlinkobject
{
367 swig_globalvar
*vars
;
368 } swig_varlinkobject
;
371 swig_varlink_repr(swig_varlinkobject
*v
) {
373 return PyString_FromString("<Global variables>");
377 swig_varlink_print(swig_varlinkobject
*v
, FILE *fp
, int flags
) {
380 fprintf(fp
,"Global variables { ");
381 for (var
= v
->vars
; var
; var
=var
->next
) {
382 fprintf(fp
,"%s", var
->name
);
383 if (var
->next
) fprintf(fp
,", ");
390 swig_varlink_getattr(swig_varlinkobject
*v
, char *n
) {
391 swig_globalvar
*var
= v
->vars
;
393 if (strcmp(var
->name
,n
) == 0) {
394 return (*var
->get_attr
)();
398 PyErr_SetString(PyExc_NameError
,"Unknown C global variable");
403 swig_varlink_setattr(swig_varlinkobject
*v
, char *n
, PyObject
*p
) {
404 swig_globalvar
*var
= v
->vars
;
406 if (strcmp(var
->name
,n
) == 0) {
407 return (*var
->set_attr
)(p
);
411 PyErr_SetString(PyExc_NameError
,"Unknown C global variable");
415 statichere PyTypeObject varlinktype
= {
416 PyObject_HEAD_INIT(0)
418 (char *)"swigvarlink", /* Type name */
419 sizeof(swig_varlinkobject
), /* Basic size */
422 (printfunc
) swig_varlink_print
, /* Print */
423 (getattrfunc
) swig_varlink_getattr
, /* get attr */
424 (setattrfunc
) swig_varlink_setattr
, /* Set attr */
426 (reprfunc
) swig_varlink_repr
, /* tp_repr */
427 0, /* tp_as_number */
428 0, /* tp_as_mapping*/
432 /* Create a variable linking object for use later */
433 SWIGRUNTIME(PyObject
*)
434 SWIG_Python_newvarlink(void) {
435 swig_varlinkobject
*result
= 0;
436 result
= PyMem_NEW(swig_varlinkobject
,1);
437 varlinktype
.ob_type
= &PyType_Type
; /* Patch varlinktype into a PyType */
438 result
->ob_type
= &varlinktype
;
440 result
->ob_refcnt
= 0;
441 Py_XINCREF((PyObject
*) result
);
442 return ((PyObject
*) result
);
446 SWIG_Python_addvarlink(PyObject
*p
, char *name
, PyObject
*(*get_attr
)(void), int (*set_attr
)(PyObject
*p
)) {
447 swig_varlinkobject
*v
;
449 v
= (swig_varlinkobject
*) p
;
450 gv
= (swig_globalvar
*) malloc(sizeof(swig_globalvar
));
451 gv
->name
= (char *) malloc(strlen(name
)+1);
452 strcpy(gv
->name
,name
);
453 gv
->get_attr
= get_attr
;
454 gv
->set_attr
= set_attr
;
459 /* Convert a pointer value */
461 SWIG_Python_ConvertPtr(PyObject
*obj
, void **ptr
, swig_type_info
*ty
, int flags
) {
464 static PyObject
*SWIG_this
= 0;
469 if (obj
== Py_None
) {
473 #ifdef SWIG_COBJECT_TYPES
474 if (!(PyCObject_Check(obj
))) {
476 SWIG_this
= PyString_FromString("this");
478 obj
= PyObject_GetAttr(obj
,SWIG_this
);
480 if (!obj
) goto type_error
;
481 if (!PyCObject_Check(obj
)) {
486 *ptr
= PyCObject_AsVoidPtr(obj
);
487 c
= (char *) PyCObject_GetDesc(obj
);
488 if (newref
) Py_DECREF(obj
);
491 if (!(PyString_Check(obj
))) {
493 SWIG_this
= PyString_FromString("this");
495 obj
= PyObject_GetAttr(obj
,SWIG_this
);
497 if (!obj
) goto type_error
;
498 if (!PyString_Check(obj
)) {
503 c
= PyString_AsString(obj
);
504 /* Pointer values must start with leading underscore */
507 if (strcmp(c
,"NULL") == 0) {
508 if (newref
) { Py_DECREF(obj
); }
511 if (newref
) { Py_DECREF(obj
); }
516 c
= SWIG_UnpackData(c
,ptr
,sizeof(void *));
517 if (newref
) { Py_DECREF(obj
); }
520 #ifdef SWIG_COBJECT_TYPES
525 tc
= SWIG_TypeCheck(c
,ty
);
526 if (!tc
) goto type_error
;
527 *ptr
= SWIG_TypeCast(tc
,(void*) *ptr
);
530 if ((pyobj
) && (flags
& SWIG_POINTER_DISOWN
)) {
531 PyObject
*zero
= PyInt_FromLong(0);
532 PyObject_SetAttrString(pyobj
,(char*)"thisown",zero
);
538 if (flags
& SWIG_POINTER_EXCEPTION
) {
540 char *temp
= (char *) malloc(64+strlen(ty
->name
)+strlen(c
));
541 sprintf(temp
,"Type error. Got %s, expected %s", c
, ty
->name
);
542 PyErr_SetString(PyExc_TypeError
, temp
);
545 PyErr_SetString(PyExc_TypeError
,"Expected a pointer");
551 /* Convert a pointer value, signal an exception on a type mismatch */
553 SWIG_Python_MustGetPtr(PyObject
*obj
, swig_type_info
*ty
, int argnum
, int flags
) {
555 SWIG_Python_ConvertPtr(obj
, &result
, ty
, flags
| SWIG_POINTER_EXCEPTION
);
559 /* Convert a packed value value */
561 SWIG_Python_ConvertPacked(PyObject
*obj
, void *ptr
, int sz
, swig_type_info
*ty
, int flags
) {
565 if ((!obj
) || (!PyString_Check(obj
))) goto type_error
;
566 c
= PyString_AsString(obj
);
567 /* Pointer values must start with leading underscore */
568 if (*c
!= '_') goto type_error
;
570 c
= SWIG_UnpackData(c
,ptr
,sz
);
572 tc
= SWIG_TypeCheck(c
,ty
);
573 if (!tc
) goto type_error
;
581 char *temp
= (char *) malloc(64+strlen(ty
->name
)+strlen(c
));
582 sprintf(temp
,"Type error. Got %s, expected %s", c
, ty
->name
);
583 PyErr_SetString(PyExc_TypeError
, temp
);
586 PyErr_SetString(PyExc_TypeError
,"Expected a pointer");
592 /* Create a new pointer object */
593 SWIGRUNTIME(PyObject
*)
594 SWIG_Python_NewPointerObj(void *ptr
, swig_type_info
*type
, int own
) {
600 #ifdef SWIG_COBJECT_TYPES
601 robj
= PyCObject_FromVoidPtrAndDesc((void *) ptr
, (char *) type
->name
, NULL
);
607 r
= SWIG_PackData(r
,&ptr
,sizeof(void *));
608 strcpy(r
,type
->name
);
609 robj
= PyString_FromString(result
);
612 if (!robj
|| (robj
== Py_None
)) return robj
;
613 if (type
->clientdata
) {
615 PyObject
*args
= Py_BuildValue((char*)"(O)", robj
);
617 inst
= PyObject_CallObject((PyObject
*) type
->clientdata
, args
);
621 PyObject
*n
= PyInt_FromLong(1);
622 PyObject_SetAttrString(inst
,(char*)"thisown",n
);
631 SWIGRUNTIME(PyObject
*)
632 SWIG_Python_NewPackedObj(void *ptr
, int sz
, swig_type_info
*type
) {
635 if ((2*sz
+ 1 + strlen(type
->name
)) > 1000) return 0;
637 r
= SWIG_PackData(r
,ptr
,sz
);
638 strcpy(r
,type
->name
);
639 return PyString_FromString(result
);
642 /* Install Constants */
644 SWIG_Python_InstallConstants(PyObject
*d
, swig_const_info constants
[]) {
647 for (i
= 0; constants
[i
].type
; i
++) {
648 switch(constants
[i
].type
) {
650 obj
= PyInt_FromLong(constants
[i
].lvalue
);
653 obj
= PyFloat_FromDouble(constants
[i
].dvalue
);
656 obj
= PyString_FromString((char *) constants
[i
].pvalue
);
658 case SWIG_PY_POINTER
:
659 obj
= SWIG_NewPointerObj(constants
[i
].pvalue
, *(constants
[i
]).ptype
,0);
662 obj
= SWIG_NewPackedObj(constants
[i
].pvalue
, constants
[i
].lvalue
, *(constants
[i
].ptype
));
669 PyDict_SetItemString(d
,constants
[i
].name
,obj
);
677 /* Contract support */
679 #define SWIG_contract_assert(expr, msg) if (!(expr)) { PyErr_SetString(PyExc_RuntimeError, (char *) msg ); goto fail; } else
686 /* -------- TYPES TABLE (BEGIN) -------- */
688 static swig_type_info
*swig_types
[1];
690 /* -------- TYPES TABLE (END) -------- */
693 /*-----------------------------------------------
694 @(target):= _swigrun.so
695 ------------------------------------------------*/
696 #define SWIG_init init_swigrun
698 #define SWIG_name "_swigrun"
702 static PyMethodDef SwigMethods
[] = {
707 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
710 static swig_type_info
*swig_types_initial
[] = {
715 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
717 static swig_const_info swig_const_table
[] = {
727 SWIGEXPORT(void) SWIG_init(void) {
728 static PyObject
*SWIG_globals
= 0;
729 static int typeinit
= 0;
732 if (!SWIG_globals
) SWIG_globals
= SWIG_newvarlink();
733 m
= Py_InitModule((char *) SWIG_name
, SwigMethods
);
734 d
= PyModule_GetDict(m
);
737 for (i
= 0; swig_types_initial
[i
]; i
++) {
738 swig_types
[i
] = SWIG_TypeRegister(swig_types_initial
[i
]);
742 SWIG_InstallConstants(d
,swig_const_table
);