Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v8plus / share / swig / 1.3.26 / python / pyrun.swg
CommitLineData
920dae64
AT
1/***********************************************************************
2 * pyrun.swg
3 *
4 * This file contains the runtime support for Python modules
5 * and includes code for managing global variables and pointer
6 * type checking.
7 *
8 * Author : David Beazley (beazley@cs.uchicago.edu)
9 ************************************************************************/
10
11/* Common SWIG API */
12#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags)
13#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags)
14#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
15
16
17/* Python-specific SWIG API */
18#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
19#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
20
21/* Runtime API */
22#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
23#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
24
25/* -----------------------------------------------------------------------------
26 * Pointer declarations
27 * ----------------------------------------------------------------------------- */
28/*
29 Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent
30 C/C++ pointers in the python side. Very useful for debugging, but
31 not always safe.
32*/
33#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES)
34# define SWIG_COBJECT_TYPES
35#endif
36
37/* Flags for pointer conversion */
38#define SWIG_POINTER_EXCEPTION 0x1
39#define SWIG_POINTER_DISOWN 0x2
40
41
42/* Add PyOS_snprintf for old Pythons */
43#if PY_VERSION_HEX < 0x02020000
44#define PyOS_snprintf snprintf
45#endif
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/* -----------------------------------------------------------------------------
52 * Create a new pointer string
53 * ----------------------------------------------------------------------------- */
54#ifndef SWIG_BUFFER_SIZE
55#define SWIG_BUFFER_SIZE 1024
56#endif
57
58/* A crude PyString_FromFormat implementation for old Pythons */
59#if PY_VERSION_HEX < 0x02020000
60static PyObject *
61PyString_FromFormat(const char *fmt, ...) {
62 va_list ap;
63 char buf[SWIG_BUFFER_SIZE * 2];
64 int res;
65 va_start(ap, fmt);
66 res = vsnprintf(buf, sizeof(buf), fmt, ap);
67 va_end(ap);
68 return (res < 0 || res >= sizeof(buf)) ? 0 : PyString_FromString(buf);
69}
70#endif
71
72#if PY_VERSION_HEX < 0x01060000
73#define PyObject_Del(op) PyMem_DEL((op))
74#endif
75
76#if defined(SWIG_COBJECT_TYPES)
77#if !defined(SWIG_COBJECT_PYTHON)
78/* -----------------------------------------------------------------------------
79 * Implements a simple Swig Object type, and use it instead of PyCObject
80 * ----------------------------------------------------------------------------- */
81
82typedef struct {
83 PyObject_HEAD
84 void *ptr;
85 const char *desc;
86} PySwigObject;
87
88/* Declarations for objects of type PySwigObject */
89
90SWIGRUNTIME int
91PySwigObject_print(PySwigObject *v, FILE *fp, int flags)
92{
93 char result[SWIG_BUFFER_SIZE];
94 flags = flags;
95 if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) {
96 fputs("<Swig Object at ", fp); fputs(result, fp); fputs(">", fp);
97 return 0;
98 } else {
99 return 1;
100 }
101}
102
103SWIGRUNTIME PyObject *
104PySwigObject_repr(PySwigObject *v)
105{
106 char result[SWIG_BUFFER_SIZE];
107 return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ?
108 PyString_FromFormat("<Swig Object at %s>", result) : 0;
109}
110
111SWIGRUNTIME PyObject *
112PySwigObject_str(PySwigObject *v)
113{
114 char result[SWIG_BUFFER_SIZE];
115 return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ?
116 PyString_FromString(result) : 0;
117}
118
119SWIGRUNTIME PyObject *
120PySwigObject_long(PySwigObject *v)
121{
122 return PyLong_FromVoidPtr(v->ptr);
123}
124
125SWIGRUNTIME PyObject *
126PySwigObject_format(const char* fmt, PySwigObject *v)
127{
128 PyObject *res = NULL;
129 PyObject *args = PyTuple_New(1);
130 if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) {
131 PyObject *ofmt = PyString_FromString(fmt);
132 if (ofmt) {
133 res = PyString_Format(ofmt,args);
134 Py_DECREF(ofmt);
135 }
136 Py_DECREF(args);
137 }
138 return res;
139}
140
141SWIGRUNTIME PyObject *
142PySwigObject_oct(PySwigObject *v)
143{
144 return PySwigObject_format("%o",v);
145}
146
147SWIGRUNTIME PyObject *
148PySwigObject_hex(PySwigObject *v)
149{
150 return PySwigObject_format("%x",v);
151}
152
153SWIGRUNTIME int
154PySwigObject_compare(PySwigObject *v, PySwigObject *w)
155{
156 int c = strcmp(v->desc, w->desc);
157 if (c) {
158 return (c > 0) ? 1 : -1;
159 } else {
160 void *i = v->ptr;
161 void *j = w->ptr;
162 return (i < j) ? -1 : ((i > j) ? 1 : 0);
163 }
164}
165
166SWIGRUNTIME void
167PySwigObject_dealloc(PySwigObject *self)
168{
169 PyObject_Del(self);
170}
171
172SWIGRUNTIME PyTypeObject*
173PySwigObject_type(void) {
174 static char pyswigobject_type__doc__[] =
175 "Swig object carries a C/C++ instance pointer";
176
177 static PyNumberMethods PySwigObject_as_number = {
178 (binaryfunc)0, /*nb_add*/
179 (binaryfunc)0, /*nb_subtract*/
180 (binaryfunc)0, /*nb_multiply*/
181 (binaryfunc)0, /*nb_divide*/
182 (binaryfunc)0, /*nb_remainder*/
183 (binaryfunc)0, /*nb_divmod*/
184 (ternaryfunc)0,/*nb_power*/
185 (unaryfunc)0, /*nb_negative*/
186 (unaryfunc)0, /*nb_positive*/
187 (unaryfunc)0, /*nb_absolute*/
188 (inquiry)0, /*nb_nonzero*/
189 0, /*nb_invert*/
190 0, /*nb_lshift*/
191 0, /*nb_rshift*/
192 0, /*nb_and*/
193 0, /*nb_xor*/
194 0, /*nb_or*/
195 (coercion)0, /*nb_coerce*/
196 (unaryfunc)PySwigObject_long, /*nb_int*/
197 (unaryfunc)PySwigObject_long, /*nb_long*/
198 (unaryfunc)0, /*nb_float*/
199 (unaryfunc)PySwigObject_oct, /*nb_oct*/
200 (unaryfunc)PySwigObject_hex, /*nb_hex*/
201#if PY_VERSION_HEX >= 0x02020000
202 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
203#elif PY_VERSION_HEX >= 0x02000000
204 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
205#endif
206 };
207
208 static PyTypeObject pyswigobject_type
209#if !defined(__cplusplus)
210 ;
211 static int type_init = 0;
212 if (!type_init) {
213 PyTypeObject tmp
214#endif
215 = {
216 PyObject_HEAD_INIT(&PyType_Type)
217 0, /*ob_size*/
218 (char *)"PySwigObject", /*tp_name*/
219 sizeof(PySwigObject), /*tp_basicsize*/
220 0, /*tp_itemsize*/
221 /* methods */
222 (destructor)PySwigObject_dealloc, /*tp_dealloc*/
223 (printfunc)PySwigObject_print, /*tp_print*/
224 (getattrfunc)0, /*tp_getattr*/
225 (setattrfunc)0, /*tp_setattr*/
226 (cmpfunc)PySwigObject_compare, /*tp_compare*/
227 (reprfunc)PySwigObject_repr, /*tp_repr*/
228 &PySwigObject_as_number, /*tp_as_number*/
229 0, /*tp_as_sequence*/
230 0, /*tp_as_mapping*/
231 (hashfunc)0, /*tp_hash*/
232 (ternaryfunc)0, /*tp_call*/
233 (reprfunc)PySwigObject_str, /*tp_str*/
234 /* Space for future expansion */
235 0,0,0,0,
236 pyswigobject_type__doc__, /* Documentation string */
237#if PY_VERSION_HEX >= 0x02000000
238 0, /* tp_traverse */
239 0, /* tp_clear */
240#endif
241#if PY_VERSION_HEX >= 0x02010000
242 0, /* tp_richcompare */
243 0, /* tp_weaklistoffset */
244#endif
245#if PY_VERSION_HEX >= 0x02020000
246 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
247#endif
248#if PY_VERSION_HEX >= 0x02030000
249 0, /* tp_del */
250#endif
251#ifdef COUNT_ALLOCS
252 0,0,0,0 /* tp_alloc -> tp_next */
253#endif
254 };
255#if !defined(__cplusplus)
256 pyswigobject_type = tmp;
257 type_init = 1;
258 }
259#endif
260 return &pyswigobject_type;
261}
262
263SWIGRUNTIME PyObject *
264PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc)
265{
266 PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type());
267 if (self) {
268 self->ptr = ptr;
269 self->desc = desc;
270 }
271 return (PyObject *)self;
272}
273
274SWIGRUNTIMEINLINE void *
275PySwigObject_AsVoidPtr(PyObject *self)
276{
277 return ((PySwigObject *)self)->ptr;
278}
279
280SWIGRUNTIMEINLINE const char *
281PySwigObject_GetDesc(PyObject *self)
282{
283 return ((PySwigObject *)self)->desc;
284}
285
286SWIGRUNTIMEINLINE int
287PySwigObject_Check(PyObject *op) {
288 return ((op)->ob_type == PySwigObject_type())
289 || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
290}
291
292/* -----------------------------------------------------------------------------
293 * Implements a simple Swig Packed type, and use it instead of string
294 * ----------------------------------------------------------------------------- */
295
296typedef struct {
297 PyObject_HEAD
298 void *pack;
299 const char *desc;
300 size_t size;
301} PySwigPacked;
302
303SWIGRUNTIME int
304PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags)
305{
306 char result[SWIG_BUFFER_SIZE];
307 flags = flags;
308 fputs("<Swig Packed ", fp);
309 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
310 fputs("at ", fp);
311 fputs(result, fp);
312 }
313 fputs(v->desc,fp);
314 fputs(">", fp);
315 return 0;
316}
317
318SWIGRUNTIME PyObject *
319PySwigPacked_repr(PySwigPacked *v)
320{
321 char result[SWIG_BUFFER_SIZE];
322 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
323 return PyString_FromFormat("<Swig Packed at %s%s>", result, v->desc);
324 } else {
325 return PyString_FromFormat("<Swig Packed %s>", v->desc);
326 }
327}
328
329SWIGRUNTIME PyObject *
330PySwigPacked_str(PySwigPacked *v)
331{
332 char result[SWIG_BUFFER_SIZE];
333 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
334 return PyString_FromFormat("%s%s", result, v->desc);
335 } else {
336 return PyString_FromString(v->desc);
337 }
338}
339
340SWIGRUNTIME int
341PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
342{
343 int c = strcmp(v->desc, w->desc);
344 if (c) {
345 return (c > 0) ? 1 : -1;
346 } else {
347 size_t i = v->size;
348 size_t j = w->size;
349 int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
350 return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
351 }
352}
353
354SWIGRUNTIME void
355PySwigPacked_dealloc(PySwigPacked *self)
356{
357 free(self->pack);
358 PyObject_Del(self);
359}
360
361SWIGRUNTIME PyTypeObject*
362PySwigPacked_type(void) {
363 static char pyswigpacked_type__doc__[] =
364 "Swig object carries a C/C++ instance pointer";
365 static PyTypeObject pyswigpacked_type
366#if !defined(__cplusplus)
367 ;
368 static int type_init = 0;
369 if (!type_init) {
370 PyTypeObject tmp
371#endif
372 = {
373 PyObject_HEAD_INIT(&PyType_Type)
374 0, /*ob_size*/
375 (char *)"PySwigPacked", /*tp_name*/
376 sizeof(PySwigPacked), /*tp_basicsize*/
377 0, /*tp_itemsize*/
378 /* methods */
379 (destructor)PySwigPacked_dealloc, /*tp_dealloc*/
380 (printfunc)PySwigPacked_print, /*tp_print*/
381 (getattrfunc)0, /*tp_getattr*/
382 (setattrfunc)0, /*tp_setattr*/
383 (cmpfunc)PySwigPacked_compare, /*tp_compare*/
384 (reprfunc)PySwigPacked_repr, /*tp_repr*/
385 0, /*tp_as_number*/
386 0, /*tp_as_sequence*/
387 0, /*tp_as_mapping*/
388 (hashfunc)0, /*tp_hash*/
389 (ternaryfunc)0, /*tp_call*/
390 (reprfunc)PySwigPacked_str, /*tp_str*/
391 /* Space for future expansion */
392 0,0,0,0,
393 pyswigpacked_type__doc__, /* Documentation string */
394#if PY_VERSION_HEX >= 0x02000000
395 0, /* tp_traverse */
396 0, /* tp_clear */
397#endif
398#if PY_VERSION_HEX >= 0x02010000
399 0, /* tp_richcompare */
400 0, /* tp_weaklistoffset */
401#endif
402#if PY_VERSION_HEX >= 0x02020000
403 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */
404#endif
405#if PY_VERSION_HEX >= 0x02030000
406 0, /* tp_del */
407#endif
408#ifdef COUNT_ALLOCS
409 0,0,0,0 /* tp_alloc -> tp_next */
410#endif
411 };
412#if !defined(__cplusplus)
413 pyswigpacked_type = tmp;
414 type_init = 1;
415 }
416#endif
417 return &pyswigpacked_type;
418}
419
420SWIGRUNTIME PyObject *
421PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc)
422{
423 PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type());
424 if (self == NULL) {
425 return NULL;
426 } else {
427 void *pack = malloc(size);
428 if (pack) {
429 memcpy(pack, ptr, size);
430 self->pack = pack;
431 self->desc = desc;
432 self->size = size;
433 return (PyObject *) self;
434 }
435 return NULL;
436 }
437}
438
439SWIGRUNTIMEINLINE const char *
440PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
441{
442 PySwigPacked *self = (PySwigPacked *)obj;
443 if (self->size != size) return 0;
444 memcpy(ptr, self->pack, size);
445 return self->desc;
446}
447
448SWIGRUNTIMEINLINE const char *
449PySwigPacked_GetDesc(PyObject *self)
450{
451 return ((PySwigPacked *)self)->desc;
452}
453
454SWIGRUNTIMEINLINE int
455PySwigPacked_Check(PyObject *op) {
456 return ((op)->ob_type == PySwigPacked_type())
457 || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
458}
459
460#else
461/* -----------------------------------------------------------------------------
462 * Use the old Python PyCObject instead of PySwigObject
463 * ----------------------------------------------------------------------------- */
464
465#define PySwigObject_GetDesc(obj) PyCObject_GetDesc(obj)
466#define PySwigObject_Check(obj) PyCObject_Check(obj)
467#define PySwigObject_AsVoidPtr(obj) PyCObject_AsVoidPtr(obj)
468#define PySwigObject_FromVoidPtrAndDesc(p, d) PyCObject_FromVoidPtrAndDesc(p, d, NULL)
469
470#endif
471
472#endif
473
474/* -----------------------------------------------------------------------------
475 * errors manipulation
476 * ----------------------------------------------------------------------------- */
477
478SWIGRUNTIME void
479SWIG_Python_TypeError(const char *type, PyObject *obj)
480{
481 if (type) {
482#if defined(SWIG_COBJECT_TYPES)
483 if (obj && PySwigObject_Check(obj)) {
484 const char *otype = (const char *) PySwigObject_GetDesc(obj);
485 if (otype) {
486 PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
487 type, otype);
488 return;
489 }
490 } else
491#endif
492 {
493 const char *otype = (obj ? obj->ob_type->tp_name : 0);
494 if (otype) {
495 PyObject *str = PyObject_Str(obj);
496 const char *cstr = str ? PyString_AsString(str) : 0;
497 if (cstr) {
498 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
499 type, otype, cstr);
500 } else {
501 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
502 type, otype);
503 }
504 Py_XDECREF(str);
505 return;
506 }
507 }
508 PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
509 } else {
510 PyErr_Format(PyExc_TypeError, "unexpected type is received");
511 }
512}
513
514SWIGRUNTIMEINLINE void
515SWIG_Python_NullRef(const char *type)
516{
517 if (type) {
518 PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type);
519 } else {
520 PyErr_Format(PyExc_TypeError, "null reference was received");
521 }
522}
523
524SWIGRUNTIME int
525SWIG_Python_AddErrMesg(const char* mesg, int infront)
526{
527 if (PyErr_Occurred()) {
528 PyObject *type = 0;
529 PyObject *value = 0;
530 PyObject *traceback = 0;
531 PyErr_Fetch(&type, &value, &traceback);
532 if (value) {
533 PyObject *old_str = PyObject_Str(value);
534 Py_XINCREF(type);
535 PyErr_Clear();
536 if (infront) {
537 PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
538 } else {
539 PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
540 }
541 Py_DECREF(old_str);
542 }
543 return 1;
544 } else {
545 return 0;
546 }
547}
548
549SWIGRUNTIME int
550SWIG_Python_ArgFail(int argnum)
551{
552 if (PyErr_Occurred()) {
553 /* add information about failing argument */
554 char mesg[256];
555 PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
556 return SWIG_Python_AddErrMesg(mesg, 1);
557 } else {
558 return 0;
559 }
560}
561
562
563/* -----------------------------------------------------------------------------
564 * pointers/data manipulation
565 * ----------------------------------------------------------------------------- */
566
567/* Convert a pointer value */
568SWIGRUNTIME int
569SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
570 swig_cast_info *tc;
571 const char *c = 0;
572 static PyObject *SWIG_this = 0;
573 int newref = 0;
574 PyObject *pyobj = 0;
575 void *vptr;
576
577 if (!obj) return 0;
578 if (obj == Py_None) {
579 *ptr = 0;
580 return 0;
581 }
582
583#ifdef SWIG_COBJECT_TYPES
584 if (!(PySwigObject_Check(obj))) {
585 if (!SWIG_this)
586 SWIG_this = PyString_FromString("this");
587 pyobj = obj;
588 obj = PyObject_GetAttr(obj,SWIG_this);
589 newref = 1;
590 if (!obj) goto type_error;
591 if (!PySwigObject_Check(obj)) {
592 Py_DECREF(obj);
593 goto type_error;
594 }
595 }
596 vptr = PySwigObject_AsVoidPtr(obj);
597 c = (const char *) PySwigObject_GetDesc(obj);
598 if (newref) { Py_DECREF(obj); }
599 goto type_check;
600#else
601 if (!(PyString_Check(obj))) {
602 if (!SWIG_this)
603 SWIG_this = PyString_FromString("this");
604 pyobj = obj;
605 obj = PyObject_GetAttr(obj,SWIG_this);
606 newref = 1;
607 if (!obj) goto type_error;
608 if (!PyString_Check(obj)) {
609 Py_DECREF(obj);
610 goto type_error;
611 }
612 }
613 c = PyString_AsString(obj);
614 /* Pointer values must start with leading underscore */
615 c = SWIG_UnpackVoidPtr(c, &vptr, ty->name);
616 if (newref) { Py_DECREF(obj); }
617 if (!c) goto type_error;
618#endif
619
620type_check:
621 if (ty) {
622 tc = SWIG_TypeCheck(c,ty);
623 if (!tc) goto type_error;
624 *ptr = SWIG_TypeCast(tc,vptr);
625 } else {
626 *ptr = vptr;
627 }
628 if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) {
629 PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False);
630 }
631 return 0;
632
633type_error:
634 PyErr_Clear();
635 if (pyobj && !obj) {
636 obj = pyobj;
637 if (PyCFunction_Check(obj)) {
638 /* here we get the method pointer for callbacks */
639 char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
640 c = doc ? strstr(doc, "swig_ptr: ") : 0;
641 if (c) {
642 c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0;
643 if (!c) goto type_error;
644 goto type_check;
645 }
646 }
647 }
648 if (flags & SWIG_POINTER_EXCEPTION) {
649 if (ty) {
650 SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
651 } else {
652 SWIG_Python_TypeError("C/C++ pointer", obj);
653 }
654 }
655 return -1;
656}
657
658/* Convert a pointer value, signal an exception on a type mismatch */
659SWIGRUNTIME void *
660SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
661 void *result;
662 if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
663 PyErr_Clear();
664 if (flags & SWIG_POINTER_EXCEPTION) {
665 SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
666 SWIG_Python_ArgFail(argnum);
667 }
668 }
669 return result;
670}
671
672/* Convert a packed value value */
673SWIGRUNTIME int
674SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
675 swig_cast_info *tc;
676 const char *c = 0;
677
678#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON)
679 c = PySwigPacked_UnpackData(obj, ptr, sz);
680#else
681 if ((!obj) || (!PyString_Check(obj))) goto type_error;
682 c = PyString_AsString(obj);
683 /* Pointer values must start with leading underscore */
684 c = SWIG_UnpackDataName(c, ptr, sz, ty->name);
685#endif
686 if (!c) goto type_error;
687 if (ty) {
688 tc = SWIG_TypeCheck(c,ty);
689 if (!tc) goto type_error;
690 }
691 return 0;
692
693type_error:
694 PyErr_Clear();
695 if (flags & SWIG_POINTER_EXCEPTION) {
696 if (ty) {
697 SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
698 } else {
699 SWIG_Python_TypeError("C/C++ packed data", obj);
700 }
701 }
702 return -1;
703}
704
705/* Create a new array object */
706SWIGRUNTIME PyObject *
707SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) {
708 PyObject *robj = 0;
709 if (!type) {
710 if (!PyErr_Occurred()) {
711 PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj");
712 }
713 return robj;
714 }
715 if (!ptr) {
716 Py_INCREF(Py_None);
717 return Py_None;
718 }
719#ifdef SWIG_COBJECT_TYPES
720 robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name);
721#else
722 {
723 char result[SWIG_BUFFER_SIZE];
724 robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ?
725 PyString_FromString(result) : 0;
726 }
727#endif
728 if (!robj || (robj == Py_None)) return robj;
729 if (type->clientdata) {
730 PyObject *inst;
731 PyObject *args = Py_BuildValue((char*)"(O)", robj);
732 Py_DECREF(robj);
733 inst = PyObject_CallObject((PyObject *) type->clientdata, args);
734 Py_DECREF(args);
735 if (inst) {
736 if (own) {
737 PyObject_SetAttrString(inst,(char*)"thisown",Py_True);
738 }
739 robj = inst;
740 }
741 }
742 return robj;
743}
744
745SWIGRUNTIME PyObject *
746SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
747 PyObject *robj = 0;
748 if (!ptr) {
749 Py_INCREF(Py_None);
750 return Py_None;
751 }
752#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON)
753 robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name);
754#else
755 {
756 char result[SWIG_BUFFER_SIZE];
757 robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ?
758 PyString_FromString(result) : 0;
759 }
760#endif
761 return robj;
762}
763
764/* -----------------------------------------------------------------------------*
765 * Get type list
766 * -----------------------------------------------------------------------------*/
767
768#ifdef SWIG_LINK_RUNTIME
769void *SWIG_ReturnGlobalTypeList(void *);
770#endif
771
772SWIGRUNTIME swig_module_info *
773SWIG_Python_GetModule(void) {
774 static void *type_pointer = (void *)0;
775 /* first check if module already created */
776 if (!type_pointer) {
777#ifdef SWIG_LINK_RUNTIME
778 type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
779#else
780 type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
781 (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
782 if (PyErr_Occurred()) {
783 PyErr_Clear();
784 type_pointer = (void *)0;
785 }
786#endif
787 }
788 return (swig_module_info *) type_pointer;
789}
790
791#if PY_MAJOR_VERSION < 2
792/* PyModule_AddObject function was introduced in Python 2.0. The following function
793is copied out of Python/modsupport.c in python version 2.3.4 */
794SWIGINTERN int
795PyModule_AddObject(PyObject *m, char *name, PyObject *o)
796{
797 PyObject *dict;
798 if (!PyModule_Check(m)) {
799 PyErr_SetString(PyExc_TypeError,
800 "PyModule_AddObject() needs module as first arg");
801 return -1;
802 }
803 if (!o) {
804 PyErr_SetString(PyExc_TypeError,
805 "PyModule_AddObject() needs non-NULL value");
806 return -1;
807 }
808
809 dict = PyModule_GetDict(m);
810 if (dict == NULL) {
811 /* Internal error -- modules must have a dict! */
812 PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
813 PyModule_GetName(m));
814 return -1;
815 }
816 if (PyDict_SetItemString(dict, name, o))
817 return -1;
818 Py_DECREF(o);
819 return 0;
820}
821#endif
822
823SWIGRUNTIME void
824SWIG_Python_SetModule(swig_module_info *swig_module) {
825 static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
826
827 PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
828 swig_empty_runtime_method_table);
829 PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL);
830 if (pointer && module) {
831 PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
832 }
833}
834
835#ifdef __cplusplus
836}
837#endif