/tags/rel-1-3-29/SWIG/Lib/python/pyrun.swg
Unknown | 1477 lines | 1356 code | 121 blank | 0 comment | 0 complexity | f516ad6f89f5a26a476b1f930b873268 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1/* ----------------------------------------------------------------------------- 2 * See the LICENSE file for information on copyright, usage and redistribution 3 * of SWIG, and the README file for authors - http://www.swig.org/release.html. 4 * 5 * pyrun.swg 6 * 7 * This file contains the runtime support for Python modules 8 * and includes code for managing global variables and pointer 9 * type checking. 10 * 11 * ----------------------------------------------------------------------------- */ 12 13/* Common SWIG API */ 14 15/* for raw pointers */ 16#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) 17#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) 18#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) 19#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) 20#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) 21#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) 22#define swig_owntype int 23 24/* for raw packed data */ 25#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) 26#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) 27 28/* for class or struct pointers */ 29#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) 30#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) 31 32/* for C or C++ function pointers */ 33#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) 34#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) 35 36/* for C++ member pointers, ie, member methods */ 37#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) 38#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) 39 40 41/* Runtime API */ 42 43#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() 44#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) 45#define SWIG_NewClientData(obj) PySwigClientData_New(obj) 46 47#define SWIG_SetErrorObj SWIG_Python_SetErrorObj 48#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg 49#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) 50#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 51#define SWIG_fail goto fail 52 53 54/* Runtime API implementation */ 55 56/* Error manipulation */ 57 58SWIGINTERN void 59SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { 60 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 61 PyErr_SetObject(errtype, obj); 62 Py_DECREF(obj); 63 SWIG_PYTHON_THREAD_END_BLOCK; 64} 65 66SWIGINTERN void 67SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { 68 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 69 PyErr_SetString(errtype, (char *) msg); 70 SWIG_PYTHON_THREAD_END_BLOCK; 71} 72 73#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) 74 75/* Set a constant value */ 76 77SWIGINTERN void 78SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { 79 PyDict_SetItemString(d, (char*) name, obj); 80 Py_DECREF(obj); 81} 82 83/* Append a value to the result obj */ 84 85SWIGINTERN PyObject* 86SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { 87#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) 88 if (!result) { 89 result = obj; 90 } else if (result == Py_None) { 91 Py_DECREF(result); 92 result = obj; 93 } else { 94 if (!PyList_Check(result)) { 95 PyObject *o2 = result; 96 result = PyList_New(1); 97 PyList_SetItem(result, 0, o2); 98 } 99 PyList_Append(result,obj); 100 Py_DECREF(obj); 101 } 102 return result; 103#else 104 PyObject* o2; 105 PyObject* o3; 106 if (!result) { 107 result = obj; 108 } else if (result == Py_None) { 109 Py_DECREF(result); 110 result = obj; 111 } else { 112 if (!PyTuple_Check(result)) { 113 o2 = result; 114 result = PyTuple_New(1); 115 PyTuple_SET_ITEM(result, 0, o2); 116 } 117 o3 = PyTuple_New(1); 118 PyTuple_SET_ITEM(o3, 0, obj); 119 o2 = result; 120 result = PySequence_Concat(o2, o3); 121 Py_DECREF(o2); 122 Py_DECREF(o3); 123 } 124 return result; 125#endif 126} 127 128/* Unpack the argument tuple */ 129 130SWIGINTERN int 131SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs) 132{ 133 if (!args) { 134 if (!min && !max) { 135 return 1; 136 } else { 137 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 138 name, (min == max ? "" : "at least "), min); 139 return 0; 140 } 141 } 142 if (!PyTuple_Check(args)) { 143 PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); 144 return 0; 145 } else { 146 register int l = PyTuple_GET_SIZE(args); 147 if (l < min) { 148 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 149 name, (min == max ? "" : "at least "), min, l); 150 return 0; 151 } else if (l > max) { 152 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 153 name, (min == max ? "" : "at most "), max, l); 154 return 0; 155 } else { 156 register int i; 157 for (i = 0; i < l; ++i) { 158 objs[i] = PyTuple_GET_ITEM(args, i); 159 } 160 for (; l < max; ++l) { 161 objs[l] = 0; 162 } 163 return i + 1; 164 } 165 } 166} 167 168/* A functor is a function object with one single object argument */ 169#if PY_VERSION_HEX >= 0x02020000 170#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); 171#else 172#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); 173#endif 174 175/* 176 Helper for static pointer initialization for both C and C++ code, for example 177 static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); 178*/ 179#ifdef __cplusplus 180#define SWIG_STATIC_POINTER(var) var 181#else 182#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var 183#endif 184 185/* ----------------------------------------------------------------------------- 186 * Pointer declarations 187 * ----------------------------------------------------------------------------- */ 188 189/* Flags for new pointer objects */ 190#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) 191#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) 192 193#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) 194 195#ifdef __cplusplus 196extern "C" { 197#if 0 198} /* cc-mode */ 199#endif 200#endif 201 202/* How to access Py_None */ 203#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 204# ifndef SWIG_PYTHON_NO_BUILD_NONE 205# ifndef SWIG_PYTHON_BUILD_NONE 206# define SWIG_PYTHON_BUILD_NONE 207# endif 208# endif 209#endif 210 211#ifdef SWIG_PYTHON_BUILD_NONE 212# ifdef Py_None 213# undef Py_None 214# define Py_None SWIG_Py_None() 215# endif 216SWIGRUNTIMEINLINE PyObject * 217_SWIG_Py_None(void) 218{ 219 PyObject *none = Py_BuildValue(""); 220 Py_DECREF(none); 221 return none; 222} 223SWIGRUNTIME PyObject * 224SWIG_Py_None(void) 225{ 226 static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); 227 return none; 228} 229#endif 230 231/* The python void return value */ 232 233SWIGRUNTIMEINLINE PyObject * 234SWIG_Py_Void(void) 235{ 236 PyObject *none = Py_None; 237 Py_INCREF(none); 238 return none; 239} 240 241/* PySwigClientData */ 242 243typedef struct { 244 PyObject *klass; 245 PyObject *newraw; 246 PyObject *newargs; 247 PyObject *destroy; 248 int delargs; 249 int implicitconv; 250} PySwigClientData; 251 252SWIGRUNTIMEINLINE int 253SWIG_Python_CheckImplicit(swig_type_info *ty) 254{ 255 PySwigClientData *data = (PySwigClientData *)ty->clientdata; 256 return data ? data->implicitconv : 0; 257} 258 259SWIGRUNTIMEINLINE PyObject * 260SWIG_Python_ExceptionType(swig_type_info *desc) { 261 PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; 262 PyObject *klass = data ? data->klass : 0; 263 return (klass ? klass : PyExc_RuntimeError); 264} 265 266 267SWIGRUNTIME PySwigClientData * 268PySwigClientData_New(PyObject* obj) 269{ 270 if (!obj) { 271 return 0; 272 } else { 273 PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); 274 /* the klass element */ 275 data->klass = obj; 276 Py_INCREF(data->klass); 277 /* the newraw method and newargs arguments used to create a new raw instance */ 278 if (PyClass_Check(obj)) { 279 data->newraw = 0; 280 data->newargs = obj; 281 Py_INCREF(obj); 282 } else { 283#if (PY_VERSION_HEX < 0x02020000) 284 data->newraw = 0; 285#else 286 data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); 287#endif 288 if (data->newraw) { 289 Py_INCREF(data->newraw); 290 data->newargs = PyTuple_New(1); 291 PyTuple_SetItem(data->newargs, 0, obj); 292 } else { 293 data->newargs = obj; 294 } 295 Py_INCREF(data->newargs); 296 } 297 /* the destroy method, aka as the C++ delete method */ 298 data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); 299 if (PyErr_Occurred()) { 300 PyErr_Clear(); 301 data->destroy = 0; 302 } 303 if (data->destroy) { 304 int flags; 305 Py_INCREF(data->destroy); 306 flags = PyCFunction_GET_FLAGS(data->destroy); 307#ifdef METH_O 308 data->delargs = !(flags & (METH_O)); 309#else 310 data->delargs = 0; 311#endif 312 } else { 313 data->delargs = 0; 314 } 315 data->implicitconv = 0; 316 return data; 317 } 318} 319 320SWIGRUNTIME void 321PySwigClientData_Del(PySwigClientData* data) 322{ 323 Py_XDECREF(data->newraw); 324 Py_XDECREF(data->newargs); 325 Py_XDECREF(data->destroy); 326} 327 328/* =============== PySwigObject =====================*/ 329 330typedef struct { 331 PyObject_HEAD 332 void *ptr; 333 swig_type_info *ty; 334 int own; 335 PyObject *next; 336} PySwigObject; 337 338SWIGRUNTIME PyObject * 339PySwigObject_long(PySwigObject *v) 340{ 341 return PyLong_FromVoidPtr(v->ptr); 342} 343 344SWIGRUNTIME PyObject * 345PySwigObject_format(const char* fmt, PySwigObject *v) 346{ 347 PyObject *res = NULL; 348 PyObject *args = PyTuple_New(1); 349 if (args) { 350 if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { 351 PyObject *ofmt = PyString_FromString(fmt); 352 if (ofmt) { 353 res = PyString_Format(ofmt,args); 354 Py_DECREF(ofmt); 355 } 356 Py_DECREF(args); 357 } 358 } 359 return res; 360} 361 362SWIGRUNTIME PyObject * 363PySwigObject_oct(PySwigObject *v) 364{ 365 return PySwigObject_format("%o",v); 366} 367 368SWIGRUNTIME PyObject * 369PySwigObject_hex(PySwigObject *v) 370{ 371 return PySwigObject_format("%x",v); 372} 373 374SWIGRUNTIME PyObject * 375#ifdef METH_NOARGS 376PySwigObject_repr(PySwigObject *v) 377#else 378PySwigObject_repr(PySwigObject *v, PyObject *args) 379#endif 380{ 381 const char *name = SWIG_TypePrettyName(v->ty); 382 PyObject *hex = PySwigObject_hex(v); 383 PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex)); 384 Py_DECREF(hex); 385 if (v->next) { 386#ifdef METH_NOARGS 387 PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); 388#else 389 PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); 390#endif 391 PyString_ConcatAndDel(&repr,nrep); 392 } 393 return repr; 394} 395 396SWIGRUNTIME int 397PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) 398{ 399#ifdef METH_NOARGS 400 PyObject *repr = PySwigObject_repr(v); 401#else 402 PyObject *repr = PySwigObject_repr(v, NULL); 403#endif 404 if (repr) { 405 fputs(PyString_AsString(repr), fp); 406 Py_DECREF(repr); 407 return 0; 408 } else { 409 return 1; 410 } 411} 412 413SWIGRUNTIME PyObject * 414PySwigObject_str(PySwigObject *v) 415{ 416 char result[SWIG_BUFFER_SIZE]; 417 return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? 418 PyString_FromString(result) : 0; 419} 420 421SWIGRUNTIME int 422PySwigObject_compare(PySwigObject *v, PySwigObject *w) 423{ 424 void *i = v->ptr; 425 void *j = w->ptr; 426 return (i < j) ? -1 : ((i > j) ? 1 : 0); 427} 428 429SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); 430 431SWIGRUNTIME PyTypeObject* 432PySwigObject_type(void) { 433 static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); 434 return type; 435} 436 437SWIGRUNTIMEINLINE int 438PySwigObject_Check(PyObject *op) { 439 return ((op)->ob_type == PySwigObject_type()) 440 || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); 441} 442 443SWIGRUNTIME PyObject * 444PySwigObject_New(void *ptr, swig_type_info *ty, int own); 445 446SWIGRUNTIME void 447PySwigObject_dealloc(PyObject *v) 448{ 449 PySwigObject *sobj = (PySwigObject *) v; 450 PyObject *next = sobj->next; 451 if (sobj->own) { 452 swig_type_info *ty = sobj->ty; 453 PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; 454 PyObject *destroy = data ? data->destroy : 0; 455 if (destroy) { 456 /* destroy is always a VARARGS method */ 457 PyObject *res; 458 if (data->delargs) { 459 /* we need to create a temporal object to carry the destroy operation */ 460 PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); 461 res = SWIG_Python_CallFunctor(destroy, tmp); 462 Py_DECREF(tmp); 463 } else { 464 PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); 465 PyObject *mself = PyCFunction_GET_SELF(destroy); 466 res = ((*meth)(mself, v)); 467 } 468 Py_XDECREF(res); 469 } else { 470 const char *name = SWIG_TypePrettyName(ty); 471#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) 472 printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); 473#endif 474 } 475 } 476 Py_XDECREF(next); 477 PyObject_DEL(v); 478} 479 480SWIGRUNTIME PyObject* 481PySwigObject_append(PyObject* v, PyObject* next) 482{ 483 PySwigObject *sobj = (PySwigObject *) v; 484#ifndef METH_O 485 PyObject *tmp = 0; 486 if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; 487 next = tmp; 488#endif 489 if (!PySwigObject_Check(next)) { 490 return NULL; 491 } 492 sobj->next = next; 493 Py_INCREF(next); 494 return SWIG_Py_Void(); 495} 496 497SWIGRUNTIME PyObject* 498#ifdef METH_NOARGS 499PySwigObject_next(PyObject* v) 500#else 501PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 502#endif 503{ 504 PySwigObject *sobj = (PySwigObject *) v; 505 if (sobj->next) { 506 Py_INCREF(sobj->next); 507 return sobj->next; 508 } else { 509 return SWIG_Py_Void(); 510 } 511} 512 513SWIGINTERN PyObject* 514#ifdef METH_NOARGS 515PySwigObject_disown(PyObject *v) 516#else 517PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 518#endif 519{ 520 PySwigObject *sobj = (PySwigObject *)v; 521 sobj->own = 0; 522 return SWIG_Py_Void(); 523} 524 525SWIGINTERN PyObject* 526#ifdef METH_NOARGS 527PySwigObject_acquire(PyObject *v) 528#else 529PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 530#endif 531{ 532 PySwigObject *sobj = (PySwigObject *)v; 533 sobj->own = SWIG_POINTER_OWN; 534 return SWIG_Py_Void(); 535} 536 537SWIGINTERN PyObject* 538PySwigObject_own(PyObject *v, PyObject *args) 539{ 540 PyObject *val = 0; 541#if (PY_VERSION_HEX < 0x02020000) 542 if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) 543#else 544 if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 545#endif 546 { 547 return NULL; 548 } 549 else 550 { 551 PySwigObject *sobj = (PySwigObject *)v; 552 PyObject *obj = PyBool_FromLong(sobj->own); 553 if (val) { 554#ifdef METH_NOARGS 555 if (PyObject_IsTrue(val)) { 556 PySwigObject_acquire(v); 557 } else { 558 PySwigObject_disown(v); 559 } 560#else 561 if (PyObject_IsTrue(val)) { 562 PySwigObject_acquire(v,args); 563 } else { 564 PySwigObject_disown(v,args); 565 } 566#endif 567 } 568 return obj; 569 } 570} 571 572#ifdef METH_O 573static PyMethodDef 574swigobject_methods[] = { 575 {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, 576 {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, 577 {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 578 {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, 579 {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, 580 {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, 581 {0, 0, 0, 0} 582}; 583#else 584static PyMethodDef 585swigobject_methods[] = { 586 {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, 587 {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, 588 {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 589 {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, 590 {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, 591 {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, 592 {0, 0, 0, 0} 593}; 594#endif 595 596#if PY_VERSION_HEX < 0x02020000 597SWIGINTERN PyObject * 598PySwigObject_getattr(PySwigObject *sobj,char *name) 599{ 600 return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); 601} 602#endif 603 604SWIGRUNTIME PyTypeObject* 605_PySwigObject_type(void) { 606 static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; 607 608 static PyNumberMethods PySwigObject_as_number = { 609 (binaryfunc)0, /*nb_add*/ 610 (binaryfunc)0, /*nb_subtract*/ 611 (binaryfunc)0, /*nb_multiply*/ 612 (binaryfunc)0, /*nb_divide*/ 613 (binaryfunc)0, /*nb_remainder*/ 614 (binaryfunc)0, /*nb_divmod*/ 615 (ternaryfunc)0,/*nb_power*/ 616 (unaryfunc)0, /*nb_negative*/ 617 (unaryfunc)0, /*nb_positive*/ 618 (unaryfunc)0, /*nb_absolute*/ 619 (inquiry)0, /*nb_nonzero*/ 620 0, /*nb_invert*/ 621 0, /*nb_lshift*/ 622 0, /*nb_rshift*/ 623 0, /*nb_and*/ 624 0, /*nb_xor*/ 625 0, /*nb_or*/ 626 (coercion)0, /*nb_coerce*/ 627 (unaryfunc)PySwigObject_long, /*nb_int*/ 628 (unaryfunc)PySwigObject_long, /*nb_long*/ 629 (unaryfunc)0, /*nb_float*/ 630 (unaryfunc)PySwigObject_oct, /*nb_oct*/ 631 (unaryfunc)PySwigObject_hex, /*nb_hex*/ 632#if PY_VERSION_HEX >= 0x02020000 633 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ 634#elif PY_VERSION_HEX >= 0x02000000 635 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ 636#endif 637 }; 638 639 static PyTypeObject pyswigobject_type; 640 static int type_init = 0; 641 if (!type_init) { 642 const PyTypeObject tmp 643 = { 644 PyObject_HEAD_INIT(NULL) 645 0, /* ob_size */ 646 (char *)"PySwigObject", /* tp_name */ 647 sizeof(PySwigObject), /* tp_basicsize */ 648 0, /* tp_itemsize */ 649 (destructor)PySwigObject_dealloc, /* tp_dealloc */ 650 (printfunc)PySwigObject_print, /* tp_print */ 651#if PY_VERSION_HEX < 0x02020000 652 (getattrfunc)PySwigObject_getattr, /* tp_getattr */ 653#else 654 (getattrfunc)0, /* tp_getattr */ 655#endif 656 (setattrfunc)0, /* tp_setattr */ 657 (cmpfunc)PySwigObject_compare, /* tp_compare */ 658 (reprfunc)PySwigObject_repr, /* tp_repr */ 659 &PySwigObject_as_number, /* tp_as_number */ 660 0, /* tp_as_sequence */ 661 0, /* tp_as_mapping */ 662 (hashfunc)0, /* tp_hash */ 663 (ternaryfunc)0, /* tp_call */ 664 (reprfunc)PySwigObject_str, /* tp_str */ 665 PyObject_GenericGetAttr, /* tp_getattro */ 666 0, /* tp_setattro */ 667 0, /* tp_as_buffer */ 668 Py_TPFLAGS_DEFAULT, /* tp_flags */ 669 swigobject_doc, /* tp_doc */ 670 0, /* tp_traverse */ 671 0, /* tp_clear */ 672 0, /* tp_richcompare */ 673 0, /* tp_weaklistoffset */ 674#if PY_VERSION_HEX >= 0x02020000 675 0, /* tp_iter */ 676 0, /* tp_iternext */ 677 swigobject_methods, /* tp_methods */ 678 0, /* tp_members */ 679 0, /* tp_getset */ 680 0, /* tp_base */ 681 0, /* tp_dict */ 682 0, /* tp_descr_get */ 683 0, /* tp_descr_set */ 684 0, /* tp_dictoffset */ 685 0, /* tp_init */ 686 0, /* tp_alloc */ 687 0, /* tp_new */ 688 0, /* tp_free */ 689 0, /* tp_is_gc */ 690 0, /* tp_bases */ 691 0, /* tp_mro */ 692 0, /* tp_cache */ 693 0, /* tp_subclasses */ 694 0, /* tp_weaklist */ 695#endif 696#if PY_VERSION_HEX >= 0x02030000 697 0, /* tp_del */ 698#endif 699#ifdef COUNT_ALLOCS 700 0,0,0,0 /* tp_alloc -> tp_next */ 701#endif 702 }; 703 pyswigobject_type = tmp; 704 pyswigobject_type.ob_type = &PyType_Type; 705 type_init = 1; 706 } 707 return &pyswigobject_type; 708} 709 710SWIGRUNTIME PyObject * 711PySwigObject_New(void *ptr, swig_type_info *ty, int own) 712{ 713 PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); 714 if (sobj) { 715 sobj->ptr = ptr; 716 sobj->ty = ty; 717 sobj->own = own; 718 sobj->next = 0; 719 } 720 return (PyObject *)sobj; 721} 722 723/* ----------------------------------------------------------------------------- 724 * Implements a simple Swig Packed type, and use it instead of string 725 * ----------------------------------------------------------------------------- */ 726 727typedef struct { 728 PyObject_HEAD 729 void *pack; 730 swig_type_info *ty; 731 size_t size; 732} PySwigPacked; 733 734SWIGRUNTIME int 735PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) 736{ 737 char result[SWIG_BUFFER_SIZE]; 738 fputs("<Swig Packed ", fp); 739 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { 740 fputs("at ", fp); 741 fputs(result, fp); 742 } 743 fputs(v->ty->name,fp); 744 fputs(">", fp); 745 return 0; 746} 747 748SWIGRUNTIME PyObject * 749PySwigPacked_repr(PySwigPacked *v) 750{ 751 char result[SWIG_BUFFER_SIZE]; 752 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { 753 return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); 754 } else { 755 return PyString_FromFormat("<Swig Packed %s>", v->ty->name); 756 } 757} 758 759SWIGRUNTIME PyObject * 760PySwigPacked_str(PySwigPacked *v) 761{ 762 char result[SWIG_BUFFER_SIZE]; 763 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ 764 return PyString_FromFormat("%s%s", result, v->ty->name); 765 } else { 766 return PyString_FromString(v->ty->name); 767 } 768} 769 770SWIGRUNTIME int 771PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) 772{ 773 size_t i = v->size; 774 size_t j = w->size; 775 int s = (i < j) ? -1 : ((i > j) ? 1 : 0); 776 return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); 777} 778 779SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); 780 781SWIGRUNTIME PyTypeObject* 782PySwigPacked_type(void) { 783 static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); 784 return type; 785} 786 787SWIGRUNTIMEINLINE int 788PySwigPacked_Check(PyObject *op) { 789 return ((op)->ob_type == _PySwigPacked_type()) 790 || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); 791} 792 793SWIGRUNTIME void 794PySwigPacked_dealloc(PyObject *v) 795{ 796 if (PySwigPacked_Check(v)) { 797 PySwigPacked *sobj = (PySwigPacked *) v; 798 free(sobj->pack); 799 } 800 PyObject_DEL(v); 801} 802 803SWIGRUNTIME PyTypeObject* 804_PySwigPacked_type(void) { 805 static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; 806 static PyTypeObject pyswigpacked_type; 807 static int type_init = 0; 808 if (!type_init) { 809 const PyTypeObject tmp 810 = { 811 PyObject_HEAD_INIT(NULL) 812 0, /* ob_size */ 813 (char *)"PySwigPacked", /* tp_name */ 814 sizeof(PySwigPacked), /* tp_basicsize */ 815 0, /* tp_itemsize */ 816 (destructor)PySwigPacked_dealloc, /* tp_dealloc */ 817 (printfunc)PySwigPacked_print, /* tp_print */ 818 (getattrfunc)0, /* tp_getattr */ 819 (setattrfunc)0, /* tp_setattr */ 820 (cmpfunc)PySwigPacked_compare, /* tp_compare */ 821 (reprfunc)PySwigPacked_repr, /* tp_repr */ 822 0, /* tp_as_number */ 823 0, /* tp_as_sequence */ 824 0, /* tp_as_mapping */ 825 (hashfunc)0, /* tp_hash */ 826 (ternaryfunc)0, /* tp_call */ 827 (reprfunc)PySwigPacked_str, /* tp_str */ 828 PyObject_GenericGetAttr, /* tp_getattro */ 829 0, /* tp_setattro */ 830 0, /* tp_as_buffer */ 831 Py_TPFLAGS_DEFAULT, /* tp_flags */ 832 swigpacked_doc, /* tp_doc */ 833 0, /* tp_traverse */ 834 0, /* tp_clear */ 835 0, /* tp_richcompare */ 836 0, /* tp_weaklistoffset */ 837#if PY_VERSION_HEX >= 0x02020000 838 0, /* tp_iter */ 839 0, /* tp_iternext */ 840 0, /* tp_methods */ 841 0, /* tp_members */ 842 0, /* tp_getset */ 843 0, /* tp_base */ 844 0, /* tp_dict */ 845 0, /* tp_descr_get */ 846 0, /* tp_descr_set */ 847 0, /* tp_dictoffset */ 848 0, /* tp_init */ 849 0, /* tp_alloc */ 850 0, /* tp_new */ 851 0, /* tp_free */ 852 0, /* tp_is_gc */ 853 0, /* tp_bases */ 854 0, /* tp_mro */ 855 0, /* tp_cache */ 856 0, /* tp_subclasses */ 857 0, /* tp_weaklist */ 858#endif 859#if PY_VERSION_HEX >= 0x02030000 860 0, /* tp_del */ 861#endif 862#ifdef COUNT_ALLOCS 863 0,0,0,0 /* tp_alloc -> tp_next */ 864#endif 865 }; 866 pyswigpacked_type = tmp; 867 pyswigpacked_type.ob_type = &PyType_Type; 868 type_init = 1; 869 } 870 return &pyswigpacked_type; 871} 872 873SWIGRUNTIME PyObject * 874PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) 875{ 876 PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); 877 if (sobj) { 878 void *pack = malloc(size); 879 if (pack) { 880 memcpy(pack, ptr, size); 881 sobj->pack = pack; 882 sobj->ty = ty; 883 sobj->size = size; 884 } else { 885 PyObject_DEL((PyObject *) sobj); 886 sobj = 0; 887 } 888 } 889 return (PyObject *) sobj; 890} 891 892SWIGRUNTIME swig_type_info * 893PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) 894{ 895 if (PySwigPacked_Check(obj)) { 896 PySwigPacked *sobj = (PySwigPacked *)obj; 897 if (sobj->size != size) return 0; 898 memcpy(ptr, sobj->pack, size); 899 return sobj->ty; 900 } else { 901 return 0; 902 } 903} 904 905/* ----------------------------------------------------------------------------- 906 * pointers/data manipulation 907 * ----------------------------------------------------------------------------- */ 908 909SWIGRUNTIMEINLINE PyObject * 910_SWIG_This(void) 911{ 912 return PyString_FromString("this"); 913} 914 915SWIGRUNTIME PyObject * 916SWIG_This(void) 917{ 918 static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); 919 return swig_this; 920} 921 922/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ 923 924SWIGRUNTIME PySwigObject * 925SWIG_Python_GetSwigThis(PyObject *pyobj) 926{ 927 if (PySwigObject_Check(pyobj)) { 928 return (PySwigObject *) pyobj; 929 } else { 930 PyObject *obj = 0; 931#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) 932 if (PyInstance_Check(pyobj)) { 933 obj = _PyInstance_Lookup(pyobj, SWIG_This()); 934 } else { 935 PyObject **dictptr = _PyObject_GetDictPtr(pyobj); 936 if (dictptr != NULL) { 937 PyObject *dict = *dictptr; 938 obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; 939 } else { 940#ifdef PyWeakref_CheckProxy 941 if (PyWeakref_CheckProxy(pyobj)) { 942 PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); 943 return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; 944 } 945#endif 946 obj = PyObject_GetAttr(pyobj,SWIG_This()); 947 if (obj) { 948 Py_DECREF(obj); 949 } else { 950 if (PyErr_Occurred()) PyErr_Clear(); 951 return 0; 952 } 953 } 954 } 955#else 956 obj = PyObject_GetAttr(pyobj,SWIG_This()); 957 if (obj) { 958 Py_DECREF(obj); 959 } else { 960 if (PyErr_Occurred()) PyErr_Clear(); 961 return 0; 962 } 963#endif 964 if (obj && !PySwigObject_Check(obj)) { 965 /* a PyObject is called 'this', try to get the 'real this' 966 PySwigObject from it */ 967 return SWIG_Python_GetSwigThis(obj); 968 } 969 return (PySwigObject *)obj; 970 } 971} 972 973/* Acquire a pointer value */ 974 975SWIGRUNTIME int 976SWIG_Python_AcquirePtr(PyObject *obj, int own) { 977 if (own) { 978 PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); 979 if (sobj) { 980 int oldown = sobj->own; 981 sobj->own = own; 982 return oldown; 983 } 984 } 985 return 0; 986} 987 988/* Convert a pointer value */ 989 990SWIGRUNTIME int 991SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { 992 if (!obj) return SWIG_ERROR; 993 if (obj == Py_None) { 994 if (ptr) *ptr = 0; 995 return SWIG_OK; 996 } else { 997 PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); 998 while (sobj) { 999 void *vptr = sobj->ptr; 1000 if (ty) { 1001 swig_type_info *to = sobj->ty; 1002 if (to == ty) { 1003 /* no type cast needed */ 1004 if (ptr) *ptr = vptr; 1005 break; 1006 } else { 1007 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 1008 if (!tc) { 1009 sobj = (PySwigObject *)sobj->next; 1010 } else { 1011 if (ptr) *ptr = SWIG_TypeCast(tc,vptr); 1012 break; 1013 } 1014 } 1015 } else { 1016 if (ptr) *ptr = vptr; 1017 break; 1018 } 1019 } 1020 if (sobj) { 1021 if (own) *own = sobj->own; 1022 if (flags & SWIG_POINTER_DISOWN) { 1023 sobj->own = 0; 1024 } 1025 return SWIG_OK; 1026 } else { 1027 int res = SWIG_ERROR; 1028 if (flags & SWIG_POINTER_IMPLICIT_CONV) { 1029 PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; 1030 if (data && !data->implicitconv) { 1031 PyObject *klass = data->klass; 1032 if (klass) { 1033 PyObject *impconv; 1034 data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ 1035 impconv = SWIG_Python_CallFunctor(klass, obj); 1036 data->implicitconv = 0; 1037 if (PyErr_Occurred()) { 1038 PyErr_Clear(); 1039 impconv = 0; 1040 } 1041 if (impconv) { 1042 PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); 1043 if (iobj) { 1044 void *vptr; 1045 res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); 1046 if (SWIG_IsOK(res)) { 1047 if (ptr) { 1048 *ptr = vptr; 1049 /* transfer the ownership to 'ptr' */ 1050 iobj->own = 0; 1051 res = SWIG_AddCast(res); 1052 res = SWIG_AddNewMask(res); 1053 } else { 1054 res = SWIG_AddCast(res); 1055 } 1056 } 1057 } 1058 Py_DECREF(impconv); 1059 } 1060 } 1061 } 1062 } 1063 return res; 1064 } 1065 } 1066} 1067 1068/* Convert a function ptr value */ 1069 1070SWIGRUNTIME int 1071SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { 1072 if (!PyCFunction_Check(obj)) { 1073 return SWIG_ConvertPtr(obj, ptr, ty, 0); 1074 } else { 1075 void *vptr = 0; 1076 1077 /* here we get the method pointer for callbacks */ 1078 char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); 1079 const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; 1080 if (desc) { 1081 desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; 1082 if (!desc) return SWIG_ERROR; 1083 } 1084 if (ty) { 1085 swig_cast_info *tc = SWIG_TypeCheck(desc,ty); 1086 if (!tc) return SWIG_ERROR; 1087 *ptr = SWIG_TypeCast(tc,vptr); 1088 } else { 1089 *ptr = vptr; 1090 } 1091 return SWIG_OK; 1092 } 1093} 1094 1095/* Convert a packed value value */ 1096 1097SWIGRUNTIME int 1098SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { 1099 swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); 1100 if (!to) return SWIG_ERROR; 1101 if (ty) { 1102 if (to != ty) { 1103 /* check type cast? */ 1104 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 1105 if (!tc) return SWIG_ERROR; 1106 } 1107 } 1108 return SWIG_OK; 1109} 1110 1111/* ----------------------------------------------------------------------------- 1112 * Create a new pointer object 1113 * ----------------------------------------------------------------------------- */ 1114 1115/* 1116 Create a new instance object, whitout calling __init__, and set the 1117 'this' attribute. 1118*/ 1119 1120SWIGRUNTIME PyObject* 1121SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) 1122{ 1123#if (PY_VERSION_HEX >= 0x02020000) 1124 PyObject *inst = 0; 1125 PyObject *newraw = data->newraw; 1126 if (newraw) { 1127 inst = PyObject_Call(newraw, data->newargs, NULL); 1128 if (inst) { 1129#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) 1130 PyObject **dictptr = _PyObject_GetDictPtr(inst); 1131 if (dictptr != NULL) { 1132 PyObject *dict = *dictptr; 1133 if (dict == NULL) { 1134 dict = PyDict_New(); 1135 *dictptr = dict; 1136 PyDict_SetItem(dict, SWIG_This(), swig_this); 1137 } 1138 } 1139#else 1140 PyObject *key = SWIG_This(); 1141 PyObject_SetAttr(inst, key, swig_this); 1142#endif 1143 } 1144 } else { 1145 PyObject *dict = PyDict_New(); 1146 PyDict_SetItem(dict, SWIG_This(), swig_this); 1147 inst = PyInstance_NewRaw(data->newargs, dict); 1148 Py_DECREF(dict); 1149 } 1150 return inst; 1151#else 1152#if (PY_VERSION_HEX >= 0x02010000) 1153 PyObject *inst; 1154 PyObject *dict = PyDict_New(); 1155 PyDict_SetItem(dict, SWIG_This(), swig_this); 1156 inst = PyInstance_NewRaw(data->newargs, dict); 1157 Py_DECREF(dict); 1158 return (PyObject *) inst; 1159#else 1160 PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); 1161 if (inst == NULL) { 1162 return NULL; 1163 } 1164 inst->in_class = (PyClassObject *)data->newargs; 1165 Py_INCREF(inst->in_class); 1166 inst->in_dict = PyDict_New(); 1167 if (inst->in_dict == NULL) { 1168 Py_DECREF(inst); 1169 return NULL; 1170 } 1171#ifdef Py_TPFLAGS_HAVE_WEAKREFS 1172 inst->in_weakreflist = NULL; 1173#endif 1174#ifdef Py_TPFLAGS_GC 1175 PyObject_GC_Init(inst); 1176#endif 1177 PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); 1178 return (PyObject *) inst; 1179#endif 1180#endif 1181} 1182 1183SWIGRUNTIME void 1184SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) 1185{ 1186 PyObject *dict; 1187#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) 1188 PyObject **dictptr = _PyObject_GetDictPtr(inst); 1189 if (dictptr != NULL) { 1190 dict = *dictptr; 1191 if (dict == NULL) { 1192 dict = PyDict_New(); 1193 *dictptr = dict; 1194 } 1195 PyDict_SetItem(dict, SWIG_This(), swig_this); 1196 return; 1197 } 1198#endif 1199 dict = PyObject_GetAttrString(inst, "__dict__"); 1200 PyDict_SetItem(dict, SWIG_This(), swig_this); 1201 Py_DECREF(dict); 1202} 1203 1204 1205SWIGINTERN PyObject * 1206SWIG_Python_InitShadowInstance(PyObject *args) { 1207 PyObject *obj[2]; 1208 if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { 1209 return NULL; 1210 } else { 1211 PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); 1212 if (sthis) { 1213 PySwigObject_append((PyObject*) sthis, obj[1]); 1214 } else { 1215 SWIG_Python_SetSwigThis(obj[0], obj[1]); 1216 } 1217 return SWIG_Py_Void(); 1218 } 1219} 1220 1221/* Create a new pointer object */ 1222 1223SWIGRUNTIME PyObject * 1224SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { 1225 if (!ptr) { 1226 return SWIG_Py_Void(); 1227 } else { 1228 int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; 1229 PyObject *robj = PySwigObject_New(ptr, type, own); 1230 PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; 1231 if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { 1232 PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); 1233 if (inst) { 1234 Py_DECREF(robj); 1235 robj = inst; 1236 } 1237 } 1238 return robj; 1239 } 1240} 1241 1242/* Create a new packed object */ 1243 1244SWIGRUNTIMEINLINE PyObject * 1245SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { 1246 return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); 1247} 1248 1249/* -----------------------------------------------------------------------------* 1250 * Get type list 1251 * -----------------------------------------------------------------------------*/ 1252 1253#ifdef SWIG_LINK_RUNTIME 1254void *SWIG_ReturnGlobalTypeList(void *); 1255#endif 1256 1257SWIGRUNTIME swig_module_info * 1258SWIG_Python_GetModule(void) { 1259 static void *type_pointer = (void *)0; 1260 /* first check if module already created */ 1261 if (!type_pointer) { 1262#ifdef SWIG_LINK_RUNTIME 1263 type_pointer = SWIG_ReturnGlobalTypeList((void *)0); 1264#else 1265 type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, 1266 (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); 1267 if (PyErr_Occurred()) { 1268 PyErr_Clear(); 1269 type_pointer = (void *)0; 1270 } 1271#endif 1272 } 1273 return (swig_module_info *) type_pointer; 1274} 1275 1276#if PY_MAJOR_VERSION < 2 1277/* PyModule_AddObject function was introduced in Python 2.0. The following function 1278 is copied out of Python/modsupport.c in python version 2.3.4 */ 1279SWIGINTERN int 1280PyModule_AddObject(PyObject *m, char *name, PyObject *o) 1281{ 1282 PyObject *dict; 1283 if (!PyModule_Check(m)) { 1284 PyErr_SetString(PyExc_TypeError, 1285 "PyModule_AddObject() needs module as first arg"); 1286 return SWIG_ERROR; 1287 } 1288 if (!o) { 1289 PyErr_SetString(PyExc_TypeError, 1290 "PyModule_AddObject() needs non-NULL value"); 1291 return SWIG_ERROR; 1292 } 1293 1294 dict = PyModule_GetDict(m); 1295 if (dict == NULL) { 1296 /* Internal error -- modules must have a dict! */ 1297 PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", 1298 PyModule_GetName(m)); 1299 return SWIG_ERROR; 1300 } 1301 if (PyDict_SetItemString(dict, name, o)) 1302 return SWIG_ERROR; 1303 Py_DECREF(o); 1304 return SWIG_OK; 1305} 1306#endif 1307 1308SWIGRUNTIME void 1309SWIG_Python_DestroyModule(void *vptr) 1310{ 1311 swig_module_info *swig_module = (swig_module_info *) vptr; 1312 swig_type_info **types = swig_module->types; 1313 size_t i; 1314 for (i =0; i < swig_module->size; ++i) { 1315 swig_type_info *ty = types[i]; 1316 if (ty->owndata) { 1317 PySwigClientData *data = (PySwigClientData *) ty->clientdata; 1318 if (data) PySwigClientData_Del(data); 1319 } 1320 } 1321 Py_DECREF(SWIG_This()); 1322} 1323 1324SWIGRUNTIME void 1325SWIG_Python_SetModule(swig_module_info *swig_module) { 1326 static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ 1327 1328 PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, 1329 swig_empty_runtime_method_table); 1330 PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); 1331 if (pointer && module) { 1332 PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); 1333 } else { 1334 Py_XDECREF(pointer); 1335 } 1336} 1337 1338/* The python cached type query */ 1339SWIGRUNTIME PyObject * 1340SWIG_Python_TypeCache() { 1341 static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); 1342 return cache; 1343} 1344 1345SWIGRUNTIME swig_type_info * 1346SWIG_Python_TypeQuery(const char *type) 1347{ 1348 PyObject *cache = SWIG_Python_TypeCache(); 1349 PyObject *key = PyString_FromString(type); 1350 PyObject *obj = PyDict_GetItem(cache, key); 1351 swig_type_info *descriptor; 1352 if (obj) { 1353 descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); 1354 } else { 1355 swig_module_info *swig_module = SWIG_Python_GetModule(); 1356 descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); 1357 if (descriptor) { 1358 obj = PyCObject_FromVoidPtr(descriptor, NULL); 1359 PyDict_SetItem(cache, key, obj); 1360 Py_DECREF(obj); 1361 } 1362 } 1363 Py_DECREF(key); 1364 return descriptor; 1365} 1366 1367/* 1368 For backward compatibility only 1369*/ 1370#define SWIG_POINTER_EXCEPTION 0 1371#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) 1372#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) 1373 1374SWIGRUNTIME int 1375SWIG_Python_AddErrMesg(const char* mesg, int infront) 1376{ 1377 if (PyErr_Occurred()) { 1378 PyObject *type = 0; 1379 PyObject *value = 0; 1380 PyObject *traceback = 0; 1381 PyErr_Fetch(&type, &value, &traceback); 1382 if (value) { 1383 PyObject *old_str = PyObject_Str(value); 1384 Py_XINCREF(type); 1385 PyErr_Clear(); 1386 if (infront) { 1387 PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); 1388 } else { 1389 PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); 1390 } 1391 Py_DECREF(old_str); 1392 } 1393 return 1; 1394 } else { 1395 return 0; 1396 } 1397} 1398 1399SWIGRUNTIME int 1400SWIG_Python_ArgFail(int argnum) 1401{ 1402 if (PyErr_Occurred()) { 1403 /* add information about failing argument */ 1404 char mesg[256]; 1405 PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); 1406 return SWIG_Python_AddErrMesg(mesg, 1); 1407 } else { 1408 return 0; 1409 } 1410} 1411 1412SWIGRUNTIMEINLINE const char * 1413PySwigObject_GetDesc(PyObject *self) 1414{ 1415 PySwigObject *v = (PySwigObject *)self; 1416 swig_type_info *ty = v ? v->ty : 0; 1417 return ty ? ty->str : (char*)""; 1418} 1419 1420SWIGRUNTIME void 1421SWIG_Python_TypeError(const char *type, PyObject *obj) 1422{ 1423 if (type) { 1424#if defined(SWIG_COBJECT_TYPES) 1425 if (obj && PySwigObject_Check(obj)) { 1426 const char *otype = (const char *) PySwigObject_GetDesc(obj); 1427 if (otype) { 1428 PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", 1429 type, otype); 1430 return; 1431 } 1432 } else 1433#endif 1434 { 1435 const char *otype = (obj ? obj->ob_type->tp_name : 0); 1436 if (otype) { 1437 PyObject *str = PyObject_Str(obj); 1438 const char *cstr = str ? PyString_AsString(str) : 0; 1439 if (cstr) { 1440 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", 1441 type, otype, cstr); 1442 } else { 1443 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", 1444 type, otype); 1445 } 1446 Py_XDECREF(str); 1447 return; 1448 } 1449 } 1450 PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); 1451 } else { 1452 PyErr_Format(PyExc_TypeError, "unexpected type is received"); 1453 } 1454} 1455 1456 1457/* Convert a pointer value, signal an exception on a type mismatch */ 1458SWIGRUNTIME void * 1459SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { 1460 void *result; 1461 if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { 1462 PyErr_Clear(); 1463 if (flags & SWIG_POINTER_EXCEPTION) { 1464 SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); 1465 SWIG_Python_ArgFail(argnum); 1466 } 1467 } 1468 return result; 1469} 1470 1471 1472#ifdef __cplusplus 1473#if 0 1474{ /* cc-mode */ 1475#endif 1476} 1477#endif