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 * ----------------------------------------------------------------------------- */ 9 10/* Common SWIG API */ 11 12/* for raw pointers */ 13#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) 14#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) 15#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) 16 17#ifdef SWIGPYTHON_BUILTIN 18#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags) 19#else 20#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) 21#endif 22 23#define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags) 24 25#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) 26#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) 27#define swig_owntype int 28 29/* for raw packed data */ 30#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) 31#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) 32 33/* for class or struct pointers */ 34#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) 35#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) 36 37/* for C or C++ function pointers */ 38#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) 39#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0) 40 41/* for C++ member pointers, ie, member methods */ 42#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) 43#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) 44 45 46/* Runtime API */ 47 48#define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata) 49#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) 50#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) 51 52#define SWIG_SetErrorObj SWIG_Python_SetErrorObj 53#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg 54#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) 55#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) 56#define SWIG_fail goto fail 57 58 59/* Runtime API implementation */ 60 61/* Error manipulation */ 62 63SWIGINTERN void 64SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { 65 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 66 PyErr_SetObject(errtype, obj); 67 Py_DECREF(obj); 68 SWIG_PYTHON_THREAD_END_BLOCK; 69} 70 71SWIGINTERN void 72SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { 73 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 74 PyErr_SetString(errtype, msg); 75 SWIG_PYTHON_THREAD_END_BLOCK; 76} 77 78#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) 79 80/* Set a constant value */ 81 82#if defined(SWIGPYTHON_BUILTIN) 83 84SWIGINTERN void 85SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) { 86 PyObject *s = PyString_InternFromString(key); 87 PyList_Append(seq, s); 88 Py_DECREF(s); 89} 90 91SWIGINTERN void 92SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) { 93#if PY_VERSION_HEX < 0x02030000 94 PyDict_SetItemString(d, (char *)name, obj); 95#else 96 PyDict_SetItemString(d, name, obj); 97#endif 98 Py_DECREF(obj); 99 if (public_interface) 100 SwigPyBuiltin_AddPublicSymbol(public_interface, name); 101} 102 103#else 104 105SWIGINTERN void 106SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { 107#if PY_VERSION_HEX < 0x02030000 108 PyDict_SetItemString(d, (char *)name, obj); 109#else 110 PyDict_SetItemString(d, name, obj); 111#endif 112 Py_DECREF(obj); 113} 114 115#endif 116 117/* Append a value to the result obj */ 118 119SWIGINTERN PyObject* 120SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { 121#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) 122 if (!result) { 123 result = obj; 124 } else if (result == Py_None) { 125 Py_DECREF(result); 126 result = obj; 127 } else { 128 if (!PyList_Check(result)) { 129 PyObject *o2 = result; 130 result = PyList_New(1); 131 PyList_SetItem(result, 0, o2); 132 } 133 PyList_Append(result,obj); 134 Py_DECREF(obj); 135 } 136 return result; 137#else 138 PyObject* o2; 139 PyObject* o3; 140 if (!result) { 141 result = obj; 142 } else if (result == Py_None) { 143 Py_DECREF(result); 144 result = obj; 145 } else { 146 if (!PyTuple_Check(result)) { 147 o2 = result; 148 result = PyTuple_New(1); 149 PyTuple_SET_ITEM(result, 0, o2); 150 } 151 o3 = PyTuple_New(1); 152 PyTuple_SET_ITEM(o3, 0, obj); 153 o2 = result; 154 result = PySequence_Concat(o2, o3); 155 Py_DECREF(o2); 156 Py_DECREF(o3); 157 } 158 return result; 159#endif 160} 161 162/* Unpack the argument tuple */ 163 164SWIGINTERN Py_ssize_t 165SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) 166{ 167 if (!args) { 168 if (!min && !max) { 169 return 1; 170 } else { 171 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 172 name, (min == max ? "" : "at least "), (int)min); 173 return 0; 174 } 175 } 176 if (!PyTuple_Check(args)) { 177 if (min <= 1 && max >= 1) { 178 Py_ssize_t i; 179 objs[0] = args; 180 for (i = 1; i < max; ++i) { 181 objs[i] = 0; 182 } 183 return 2; 184 } 185 PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); 186 return 0; 187 } else { 188 Py_ssize_t l = PyTuple_GET_SIZE(args); 189 if (l < min) { 190 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 191 name, (min == max ? "" : "at least "), (int)min, (int)l); 192 return 0; 193 } else if (l > max) { 194 PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 195 name, (min == max ? "" : "at most "), (int)max, (int)l); 196 return 0; 197 } else { 198 Py_ssize_t i; 199 for (i = 0; i < l; ++i) { 200 objs[i] = PyTuple_GET_ITEM(args, i); 201 } 202 for (; l < max; ++l) { 203 objs[l] = 0; 204 } 205 return i + 1; 206 } 207 } 208} 209 210/* A functor is a function object with one single object argument */ 211#if PY_VERSION_HEX >= 0x02020000 212#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); 213#else 214#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); 215#endif 216 217/* 218 Helper for static pointer initialization for both C and C++ code, for example 219 static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); 220*/ 221#ifdef __cplusplus 222#define SWIG_STATIC_POINTER(var) var 223#else 224#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var 225#endif 226 227/* ----------------------------------------------------------------------------- 228 * Pointer declarations 229 * ----------------------------------------------------------------------------- */ 230 231/* Flags for new pointer objects */ 232#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) 233#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) 234 235#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) 236 237#define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2) 238#define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN) 239 240#ifdef __cplusplus 241extern "C" { 242#endif 243 244/* How to access Py_None */ 245#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) 246# ifndef SWIG_PYTHON_NO_BUILD_NONE 247# ifndef SWIG_PYTHON_BUILD_NONE 248# define SWIG_PYTHON_BUILD_NONE 249# endif 250# endif 251#endif 252 253#ifdef SWIG_PYTHON_BUILD_NONE 254# ifdef Py_None 255# undef Py_None 256# define Py_None SWIG_Py_None() 257# endif 258SWIGRUNTIMEINLINE PyObject * 259_SWIG_Py_None(void) 260{ 261 PyObject *none = Py_BuildValue((char*)""); 262 Py_DECREF(none); 263 return none; 264} 265SWIGRUNTIME PyObject * 266SWIG_Py_None(void) 267{ 268 static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); 269 return none; 270} 271#endif 272 273/* The python void return value */ 274 275SWIGRUNTIMEINLINE PyObject * 276SWIG_Py_Void(void) 277{ 278 PyObject *none = Py_None; 279 Py_INCREF(none); 280 return none; 281} 282 283/* SwigPyClientData */ 284 285typedef struct { 286 PyObject *klass; 287 PyObject *newraw; 288 PyObject *newargs; 289 PyObject *destroy; 290 int delargs; 291 int implicitconv; 292 PyTypeObject *pytype; 293} SwigPyClientData; 294 295SWIGRUNTIMEINLINE int 296SWIG_Python_CheckImplicit(swig_type_info *ty) 297{ 298 SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; 299 return data ? data->implicitconv : 0; 300} 301 302SWIGRUNTIMEINLINE PyObject * 303SWIG_Python_ExceptionType(swig_type_info *desc) { 304 SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; 305 PyObject *klass = data ? data->klass : 0; 306 return (klass ? klass : PyExc_RuntimeError); 307} 308 309 310SWIGRUNTIME SwigPyClientData * 311SwigPyClientData_New(PyObject* obj) 312{ 313 if (!obj) { 314 return 0; 315 } else { 316 SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); 317 /* the klass element */ 318 data->klass = obj; 319 Py_INCREF(data->klass); 320 /* the newraw method and newargs arguments used to create a new raw instance */ 321 if (PyClass_Check(obj)) { 322 data->newraw = 0; 323 data->newargs = obj; 324 Py_INCREF(obj); 325 } else { 326#if (PY_VERSION_HEX < 0x02020000) 327 data->newraw = 0; 328#else 329 data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); 330#endif 331 if (data->newraw) { 332 Py_INCREF(data->newraw); 333 data->newargs = PyTuple_New(1); 334 PyTuple_SetItem(data->newargs, 0, obj); 335 } else { 336 data->newargs = obj; 337 } 338 Py_INCREF(data->newargs); 339 } 340 /* the destroy method, aka as the C++ delete method */ 341 data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); 342 if (PyErr_Occurred()) { 343 PyErr_Clear(); 344 data->destroy = 0; 345 } 346 if (data->destroy) { 347 int flags; 348 Py_INCREF(data->destroy); 349 flags = PyCFunction_GET_FLAGS(data->destroy); 350#ifdef METH_O 351 data->delargs = !(flags & (METH_O)); 352#else 353 data->delargs = 0; 354#endif 355 } else { 356 data->delargs = 0; 357 } 358 data->implicitconv = 0; 359 data->pytype = 0; 360 return data; 361 } 362} 363 364SWIGRUNTIME void 365SwigPyClientData_Del(SwigPyClientData *data) { 366 Py_XDECREF(data->newraw); 367 Py_XDECREF(data->newargs); 368 Py_XDECREF(data->destroy); 369} 370 371/* =============== SwigPyObject =====================*/ 372 373typedef struct { 374 PyObject_HEAD 375 void *ptr; 376 swig_type_info *ty; 377 int own; 378 PyObject *next; 379#ifdef SWIGPYTHON_BUILTIN 380 PyObject *dict; 381#endif 382} SwigPyObject; 383 384 385#ifdef SWIGPYTHON_BUILTIN 386 387SWIGRUNTIME PyObject * 388SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args)) 389{ 390 SwigPyObject *sobj = (SwigPyObject *)v; 391 392 if (!sobj->dict) 393 sobj->dict = PyDict_New(); 394 395 Py_INCREF(sobj->dict); 396 return sobj->dict; 397} 398 399#endif 400 401SWIGRUNTIME PyObject * 402SwigPyObject_long(SwigPyObject *v) 403{ 404 return PyLong_FromVoidPtr(v->ptr); 405} 406 407SWIGRUNTIME PyObject * 408SwigPyObject_format(const char* fmt, SwigPyObject *v) 409{ 410 PyObject *res = NULL; 411 PyObject *args = PyTuple_New(1); 412 if (args) { 413 if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { 414 PyObject *ofmt = SWIG_Python_str_FromChar(fmt); 415 if (ofmt) { 416#if PY_VERSION_HEX >= 0x03000000 417 res = PyUnicode_Format(ofmt,args); 418#else 419 res = PyString_Format(ofmt,args); 420#endif 421 Py_DECREF(ofmt); 422 } 423 Py_DECREF(args); 424 } 425 } 426 return res; 427} 428 429SWIGRUNTIME PyObject * 430SwigPyObject_oct(SwigPyObject *v) 431{ 432 return SwigPyObject_format("%o",v); 433} 434 435SWIGRUNTIME PyObject * 436SwigPyObject_hex(SwigPyObject *v) 437{ 438 return SwigPyObject_format("%x",v); 439} 440 441SWIGRUNTIME PyObject * 442#ifdef METH_NOARGS 443SwigPyObject_repr(SwigPyObject *v) 444#else 445SwigPyObject_repr(SwigPyObject *v, PyObject *args) 446#endif 447{ 448 const char *name = SWIG_TypePrettyName(v->ty); 449 PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v); 450 if (v->next) { 451# ifdef METH_NOARGS 452 PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); 453# else 454 PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); 455# endif 456# if PY_VERSION_HEX >= 0x03000000 457 PyObject *joined = PyUnicode_Concat(repr, nrep); 458 Py_DecRef(repr); 459 Py_DecRef(nrep); 460 repr = joined; 461# else 462 PyString_ConcatAndDel(&repr,nrep); 463# endif 464 } 465 return repr; 466} 467 468SWIGRUNTIME int 469SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) 470{ 471 void *i = v->ptr; 472 void *j = w->ptr; 473 return (i < j) ? -1 : ((i > j) ? 1 : 0); 474} 475 476/* Added for Python 3.x, would it also be useful for Python 2.x? */ 477SWIGRUNTIME PyObject* 478SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) 479{ 480 PyObject* res; 481 if( op != Py_EQ && op != Py_NE ) { 482 Py_INCREF(Py_NotImplemented); 483 return Py_NotImplemented; 484 } 485 res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0); 486 return res; 487} 488 489 490SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void); 491 492#ifdef SWIGPYTHON_BUILTIN 493static swig_type_info *SwigPyObject_stype = 0; 494SWIGRUNTIME PyTypeObject* 495SwigPyObject_type(void) { 496 SwigPyClientData *cd; 497 assert(SwigPyObject_stype); 498 cd = (SwigPyClientData*) SwigPyObject_stype->clientdata; 499 assert(cd); 500 assert(cd->pytype); 501 return cd->pytype; 502} 503#else 504SWIGRUNTIME PyTypeObject* 505SwigPyObject_type(void) { 506 static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce(); 507 return type; 508} 509#endif 510 511SWIGRUNTIMEINLINE int 512SwigPyObject_Check(PyObject *op) { 513#ifdef SWIGPYTHON_BUILTIN 514 PyTypeObject *target_tp = SwigPyObject_type(); 515 if (PyType_IsSubtype(op->ob_type, target_tp)) 516 return 1; 517 return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0); 518#else 519 return (Py_TYPE(op) == SwigPyObject_type()) 520 || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); 521#endif 522} 523 524SWIGRUNTIME PyObject * 525SwigPyObject_New(void *ptr, swig_type_info *ty, int own); 526 527SWIGRUNTIME void 528SwigPyObject_dealloc(PyObject *v) 529{ 530 SwigPyObject *sobj = (SwigPyObject *) v; 531 PyObject *next = sobj->next; 532 if (sobj->own == SWIG_POINTER_OWN) { 533 swig_type_info *ty = sobj->ty; 534 SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; 535 PyObject *destroy = data ? data->destroy : 0; 536 if (destroy) { 537 /* destroy is always a VARARGS method */ 538 PyObject *res; 539 540 /* PyObject_CallFunction() has the potential to silently drop 541 the active active exception. In cases of unnamed temporary 542 variable or where we just finished iterating over a generator 543 StopIteration will be active right now, and this needs to 544 remain true upon return from SwigPyObject_dealloc. So save 545 and restore. */ 546 547 PyObject *val = NULL, *type = NULL, *tb = NULL; 548 PyErr_Fetch(&val, &type, &tb); 549 550 if (data->delargs) { 551 /* we need to create a temporary object to carry the destroy operation */ 552 PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); 553 res = SWIG_Python_CallFunctor(destroy, tmp); 554 Py_DECREF(tmp); 555 } else { 556 PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); 557 PyObject *mself = PyCFunction_GET_SELF(destroy); 558 res = ((*meth)(mself, v)); 559 } 560 if (!res) 561 PyErr_WriteUnraisable(destroy); 562 563 PyErr_Restore(val, type, tb); 564 565 Py_XDECREF(res); 566 } 567#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) 568 else { 569 const char *name = SWIG_TypePrettyName(ty); 570 printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); 571 } 572#endif 573 } 574 Py_XDECREF(next); 575 PyObject_DEL(v); 576} 577 578SWIGRUNTIME PyObject* 579SwigPyObject_append(PyObject* v, PyObject* next) 580{ 581 SwigPyObject *sobj = (SwigPyObject *) v; 582#ifndef METH_O 583 PyObject *tmp = 0; 584 if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; 585 next = tmp; 586#endif 587 if (!SwigPyObject_Check(next)) { 588 PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject"); 589 return NULL; 590 } 591 sobj->next = next; 592 Py_INCREF(next); 593 return SWIG_Py_Void(); 594} 595 596SWIGRUNTIME PyObject* 597#ifdef METH_NOARGS 598SwigPyObject_next(PyObject* v) 599#else 600SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 601#endif 602{ 603 SwigPyObject *sobj = (SwigPyObject *) v; 604 if (sobj->next) { 605 Py_INCREF(sobj->next); 606 return sobj->next; 607 } else { 608 return SWIG_Py_Void(); 609 } 610} 611 612SWIGINTERN PyObject* 613#ifdef METH_NOARGS 614SwigPyObject_disown(PyObject *v) 615#else 616SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 617#endif 618{ 619 SwigPyObject *sobj = (SwigPyObject *)v; 620 sobj->own = 0; 621 return SWIG_Py_Void(); 622} 623 624SWIGINTERN PyObject* 625#ifdef METH_NOARGS 626SwigPyObject_acquire(PyObject *v) 627#else 628SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) 629#endif 630{ 631 SwigPyObject *sobj = (SwigPyObject *)v; 632 sobj->own = SWIG_POINTER_OWN; 633 return SWIG_Py_Void(); 634} 635 636SWIGINTERN PyObject* 637SwigPyObject_own(PyObject *v, PyObject *args) 638{ 639 PyObject *val = 0; 640#if (PY_VERSION_HEX < 0x02020000) 641 if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) 642#elif (PY_VERSION_HEX < 0x02050000) 643 if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 644#else 645 if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) 646#endif 647 { 648 return NULL; 649 } 650 else 651 { 652 SwigPyObject *sobj = (SwigPyObject *)v; 653 PyObject *obj = PyBool_FromLong(sobj->own); 654 if (val) { 655#ifdef METH_NOARGS 656 if (PyObject_IsTrue(val)) { 657 SwigPyObject_acquire(v); 658 } else { 659 SwigPyObject_disown(v); 660 } 661#else 662 if (PyObject_IsTrue(val)) { 663 SwigPyObject_acquire(v,args); 664 } else { 665 SwigPyObject_disown(v,args); 666 } 667#endif 668 } 669 return obj; 670 } 671} 672 673#ifdef METH_O 674static PyMethodDef 675swigobject_methods[] = { 676 {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, 677 {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"}, 678 {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 679 {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, 680 {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, 681 {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, 682 {0, 0, 0, 0} 683}; 684#else 685static PyMethodDef 686swigobject_methods[] = { 687 {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, 688 {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"}, 689 {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, 690 {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, 691 {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, 692 {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, 693 {0, 0, 0, 0} 694}; 695#endif 696 697#if PY_VERSION_HEX < 0x02020000 698SWIGINTERN PyObject * 699SwigPyObject_getattr(SwigPyObject *sobj,char *name) 700{ 701 return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); 702} 703#endif 704 705SWIGRUNTIME PyTypeObject* 706SwigPyObject_TypeOnce(void) { 707 static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; 708 709 static PyNumberMethods SwigPyObject_as_number = { 710 (binaryfunc)0, /*nb_add*/ 711 (binaryfunc)0, /*nb_subtract*/ 712 (binaryfunc)0, /*nb_multiply*/ 713 /* nb_divide removed in Python 3 */ 714#if PY_VERSION_HEX < 0x03000000 715 (binaryfunc)0, /*nb_divide*/ 716#endif 717 (binaryfunc)0, /*nb_remainder*/ 718 (binaryfunc)0, /*nb_divmod*/ 719 (ternaryfunc)0,/*nb_power*/ 720 (unaryfunc)0, /*nb_negative*/ 721 (unaryfunc)0, /*nb_positive*/ 722 (unaryfunc)0, /*nb_absolute*/ 723 (inquiry)0, /*nb_nonzero*/ 724 0, /*nb_invert*/ 725 0, /*nb_lshift*/ 726 0, /*nb_rshift*/ 727 0, /*nb_and*/ 728 0, /*nb_xor*/ 729 0, /*nb_or*/ 730#if PY_VERSION_HEX < 0x03000000 731 0, /*nb_coerce*/ 732#endif 733 (unaryfunc)SwigPyObject_long, /*nb_int*/ 734#if PY_VERSION_HEX < 0x03000000 735 (unaryfunc)SwigPyObject_long, /*nb_long*/ 736#else 737 0, /*nb_reserved*/ 738#endif 739 (unaryfunc)0, /*nb_float*/ 740#if PY_VERSION_HEX < 0x03000000 741 (unaryfunc)SwigPyObject_oct, /*nb_oct*/ 742 (unaryfunc)SwigPyObject_hex, /*nb_hex*/ 743#endif 744#if PY_VERSION_HEX >= 0x03050000 /* 3.5 */ 745 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */ 746#elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */ 747 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ 748#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 749 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ 750#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 751 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ 752#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ 753 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ 754#endif 755 }; 756 757 static PyTypeObject swigpyobject_type; 758 static int type_init = 0; 759 if (!type_init) { 760 const PyTypeObject tmp = { 761#if PY_VERSION_HEX >= 0x03000000 762 PyVarObject_HEAD_INIT(NULL, 0) 763#else 764 PyObject_HEAD_INIT(NULL) 765 0, /* ob_size */ 766#endif 767 (char *)"SwigPyObject", /* tp_name */ 768 sizeof(SwigPyObject), /* tp_basicsize */ 769 0, /* tp_itemsize */ 770 (destructor)SwigPyObject_dealloc, /* tp_dealloc */ 771 0, /* tp_print */ 772#if PY_VERSION_HEX < 0x02020000 773 (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ 774#else 775 (getattrfunc)0, /* tp_getattr */ 776#endif 777 (setattrfunc)0, /* tp_setattr */ 778#if PY_VERSION_HEX >= 0x03000000 779 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ 780#else 781 (cmpfunc)SwigPyObject_compare, /* tp_compare */ 782#endif 783 (reprfunc)SwigPyObject_repr, /* tp_repr */ 784 &SwigPyObject_as_number, /* tp_as_number */ 785 0, /* tp_as_sequence */ 786 0, /* tp_as_mapping */ 787 (hashfunc)0, /* tp_hash */ 788 (ternaryfunc)0, /* tp_call */ 789 0, /* tp_str */ 790 PyObject_GenericGetAttr, /* tp_getattro */ 791 0, /* tp_setattro */ 792 0, /* tp_as_buffer */ 793 Py_TPFLAGS_DEFAULT, /* tp_flags */ 794 swigobject_doc, /* tp_doc */ 795 0, /* tp_traverse */ 796 0, /* tp_clear */ 797 (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */ 798 0, /* tp_weaklistoffset */ 799#if PY_VERSION_HEX >= 0x02020000 800 0, /* tp_iter */ 801 0, /* tp_iternext */ 802 swigobject_methods, /* tp_methods */ 803 0, /* tp_members */ 804 0, /* tp_getset */ 805 0, /* tp_base */ 806 0, /* tp_dict */ 807 0, /* tp_descr_get */ 808 0, /* tp_descr_set */ 809 0, /* tp_dictoffset */ 810 0, /* tp_init */ 811 0, /* tp_alloc */ 812 0, /* tp_new */ 813 0, /* tp_free */ 814 0, /* tp_is_gc */ 815 0, /* tp_bases */ 816 0, /* tp_mro */ 817 0, /* tp_cache */ 818 0, /* tp_subclasses */ 819 0, /* tp_weaklist */ 820#endif 821#if PY_VERSION_HEX >= 0x02030000 822 0, /* tp_del */ 823#endif 824#if PY_VERSION_HEX >= 0x02060000 825 0, /* tp_version_tag */ 826#endif 827#if PY_VERSION_HEX >= 0x03040000 828 0, /* tp_finalize */ 829#endif 830#ifdef COUNT_ALLOCS 831 0, /* tp_allocs */ 832 0, /* tp_frees */ 833 0, /* tp_maxalloc */ 834#if PY_VERSION_HEX >= 0x02050000 835 0, /* tp_prev */ 836#endif 837 0 /* tp_next */ 838#endif 839 }; 840 swigpyobject_type = tmp; 841 type_init = 1; 842#if PY_VERSION_HEX < 0x02020000 843 swigpyobject_type.ob_type = &PyType_Type; 844#else 845 if (PyType_Ready(&swigpyobject_type) < 0) 846 return NULL; 847#endif 848 } 849 return &swigpyobject_type; 850} 851 852SWIGRUNTIME PyObject * 853SwigPyObject_New(void *ptr, swig_type_info *ty, int own) 854{ 855 SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); 856 if (sobj) { 857 sobj->ptr = ptr; 858 sobj->ty = ty; 859 sobj->own = own; 860 sobj->next = 0; 861 } 862 return (PyObject *)sobj; 863} 864 865/* ----------------------------------------------------------------------------- 866 * Implements a simple Swig Packed type, and use it instead of string 867 * ----------------------------------------------------------------------------- */ 868 869typedef struct { 870 PyObject_HEAD 871 void *pack; 872 swig_type_info *ty; 873 size_t size; 874} SwigPyPacked; 875 876SWIGRUNTIME int 877SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) 878{ 879 char result[SWIG_BUFFER_SIZE]; 880 fputs("<Swig Packed ", fp); 881 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { 882 fputs("at ", fp); 883 fputs(result, fp); 884 } 885 fputs(v->ty->name,fp); 886 fputs(">", fp); 887 return 0; 888} 889 890SWIGRUNTIME PyObject * 891SwigPyPacked_repr(SwigPyPacked *v) 892{ 893 char result[SWIG_BUFFER_SIZE]; 894 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { 895 return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); 896 } else { 897 return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name); 898 } 899} 900 901SWIGRUNTIME PyObject * 902SwigPyPacked_str(SwigPyPacked *v) 903{ 904 char result[SWIG_BUFFER_SIZE]; 905 if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ 906 return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); 907 } else { 908 return SWIG_Python_str_FromChar(v->ty->name); 909 } 910} 911 912SWIGRUNTIME int 913SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) 914{ 915 size_t i = v->size; 916 size_t j = w->size; 917 int s = (i < j) ? -1 : ((i > j) ? 1 : 0); 918 return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); 919} 920 921SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void); 922 923SWIGRUNTIME PyTypeObject* 924SwigPyPacked_type(void) { 925 static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce(); 926 return type; 927} 928 929SWIGRUNTIMEINLINE int 930SwigPyPacked_Check(PyObject *op) { 931 return ((op)->ob_type == SwigPyPacked_TypeOnce()) 932 || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); 933} 934 935SWIGRUNTIME void 936SwigPyPacked_dealloc(PyObject *v) 937{ 938 if (SwigPyPacked_Check(v)) { 939 SwigPyPacked *sobj = (SwigPyPacked *) v; 940 free(sobj->pack); 941 } 942 PyObject_DEL(v); 943} 944 945SWIGRUNTIME PyTypeObject* 946SwigPyPacked_TypeOnce(void) { 947 static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; 948 static PyTypeObject swigpypacked_type; 949 static int type_init = 0; 950 if (!type_init) { 951 const PyTypeObject tmp = { 952#if PY_VERSION_HEX>=0x03000000 953 PyVarObject_HEAD_INIT(NULL, 0) 954#else 955 PyObject_HEAD_INIT(NULL) 956 0, /* ob_size */ 957#endif 958 (char *)"SwigPyPacked", /* tp_name */ 959 sizeof(SwigPyPacked), /* tp_basicsize */ 960 0, /* tp_itemsize */ 961 (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ 962 (printfunc)SwigPyPacked_print, /* tp_print */ 963 (getattrfunc)0, /* tp_getattr */ 964 (setattrfunc)0, /* tp_setattr */ 965#if PY_VERSION_HEX>=0x03000000 966 0, /* tp_reserved in 3.0.1 */ 967#else 968 (cmpfunc)SwigPyPacked_compare, /* tp_compare */ 969#endif 970 (reprfunc)SwigPyPacked_repr, /* tp_repr */ 971 0, /* tp_as_number */ 972 0, /* tp_as_sequence */ 973 0, /* tp_as_mapping */ 974 (hashfunc)0, /* tp_hash */ 975 (ternaryfunc)0, /* tp_call */ 976 (reprfunc)SwigPyPacked_str, /* tp_str */ 977 PyObject_GenericGetAttr, /* tp_getattro */ 978 0, /* tp_setattro */ 979 0, /* tp_as_buffer */ 980 Py_TPFLAGS_DEFAULT, /* tp_flags */ 981 swigpacked_doc, /* tp_doc */ 982 0, /* tp_traverse */ 983 0, /* tp_clear */ 984 0, /* tp_richcompare */ 985 0, /* tp_weaklistoffset */ 986#if PY_VERSION_HEX >= 0x02020000 987 0, /* tp_iter */ 988 0, /* tp_iternext */ 989 0, /* tp_methods */ 990 0, /* tp_members */ 991 0, /* tp_getset */ 992 0, /* tp_base */ 993 0, /* tp_dict */ 994 0, /* tp_descr_get */ 995 0, /* tp_descr_set */ 996 0, /* tp_dictoffset */ 997 0, /* tp_init */ 998 0, /* tp_alloc */ 999 0, /* tp_new */ 1000 0, /* tp_free */ 1001 0, /* tp_is_gc */ 1002 0, /* tp_bases */ 1003 0, /* tp_mro */ 1004 0, /* tp_cache */ 1005 0, /* tp_subclasses */ 1006 0, /* tp_weaklist */ 1007#endif 1008#if PY_VERSION_HEX >= 0x02030000 1009 0, /* tp_del */ 1010#endif 1011#if PY_VERSION_HEX >= 0x02060000 1012 0, /* tp_version_tag */ 1013#endif 1014#if PY_VERSION_HEX >= 0x03040000 1015 0, /* tp_finalize */ 1016#endif 1017#ifdef COUNT_ALLOCS 1018 0, /* tp_allocs */ 1019 0, /* tp_frees */ 1020 0, /* tp_maxalloc */ 1021#if PY_VERSION_HEX >= 0x02050000 1022 0, /* tp_prev */ 1023#endif 1024 0 /* tp_next */ 1025#endif 1026 }; 1027 swigpypacked_type = tmp; 1028 type_init = 1; 1029#if PY_VERSION_HEX < 0x02020000 1030 swigpypacked_type.ob_type = &PyType_Type; 1031#else 1032 if (PyType_Ready(&swigpypacked_type) < 0) 1033 return NULL; 1034#endif 1035 } 1036 return &swigpypacked_type; 1037} 1038 1039SWIGRUNTIME PyObject * 1040SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) 1041{ 1042 SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); 1043 if (sobj) { 1044 void *pack = malloc(size); 1045 if (pack) { 1046 memcpy(pack, ptr, size); 1047 sobj->pack = pack; 1048 sobj->ty = ty; 1049 sobj->size = size; 1050 } else { 1051 PyObject_DEL((PyObject *) sobj); 1052 sobj = 0; 1053 } 1054 } 1055 return (PyObject *) sobj; 1056} 1057 1058SWIGRUNTIME swig_type_info * 1059SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) 1060{ 1061 if (SwigPyPacked_Check(obj)) { 1062 SwigPyPacked *sobj = (SwigPyPacked *)obj; 1063 if (sobj->size != size) return 0; 1064 memcpy(ptr, sobj->pack, size); 1065 return sobj->ty; 1066 } else { 1067 return 0; 1068 } 1069} 1070 1071/* ----------------------------------------------------------------------------- 1072 * pointers/data manipulation 1073 * ----------------------------------------------------------------------------- */ 1074 1075SWIGRUNTIMEINLINE PyObject * 1076_SWIG_This(void) 1077{ 1078 return SWIG_Python_str_FromChar("this"); 1079} 1080 1081static PyObject *swig_this = NULL; 1082 1083SWIGRUNTIME PyObject * 1084SWIG_This(void) 1085{ 1086 if (swig_this == NULL) 1087 swig_this = _SWIG_This(); 1088 return swig_this; 1089} 1090 1091/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ 1092 1093/* TODO: I don't know how to implement the fast getset in Python 3 right now */ 1094#if PY_VERSION_HEX>=0x03000000 1095#define SWIG_PYTHON_SLOW_GETSET_THIS 1096#endif 1097 1098SWIGRUNTIME SwigPyObject * 1099SWIG_Python_GetSwigThis(PyObject *pyobj) 1100{ 1101 PyObject *obj; 1102 1103 if (SwigPyObject_Check(pyobj)) 1104 return (SwigPyObject *) pyobj; 1105 1106#ifdef SWIGPYTHON_BUILTIN 1107 (void)obj; 1108# ifdef PyWeakref_CheckProxy 1109 if (PyWeakref_CheckProxy(pyobj)) { 1110 pyobj = PyWeakref_GET_OBJECT(pyobj); 1111 if (pyobj && SwigPyObject_Check(pyobj)) 1112 return (SwigPyObject*) pyobj; 1113 } 1114# endif 1115 return NULL; 1116#else 1117 1118 obj = 0; 1119 1120#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) 1121 if (PyInstance_Check(pyobj)) { 1122 obj = _PyInstance_Lookup(pyobj, SWIG_This()); 1123 } else { 1124 PyObject **dictptr = _PyObject_GetDictPtr(pyobj); 1125 if (dictptr != NULL) { 1126 PyObject *dict = *dictptr; 1127 obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; 1128 } else { 1129#ifdef PyWeakref_CheckProxy 1130 if (PyWeakref_CheckProxy(pyobj)) { 1131 PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); 1132 return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; 1133 } 1134#endif 1135 obj = PyObject_GetAttr(pyobj,SWIG_This()); 1136 if (obj) { 1137 Py_DECREF(obj); 1138 } else { 1139 if (PyErr_Occurred()) PyErr_Clear(); 1140 return 0; 1141 } 1142 } 1143 } 1144#else 1145 obj = PyObject_GetAttr(pyobj,SWIG_This()); 1146 if (obj) { 1147 Py_DECREF(obj); 1148 } else { 1149 if (PyErr_Occurred()) PyErr_Clear(); 1150 return 0; 1151 } 1152#endif 1153 if (obj && !SwigPyObject_Check(obj)) { 1154 /* a PyObject is called 'this', try to get the 'real this' 1155 SwigPyObject from it */ 1156 return SWIG_Python_GetSwigThis(obj); 1157 } 1158 return (SwigPyObject *)obj; 1159#endif 1160} 1161 1162/* Acquire a pointer value */ 1163 1164SWIGRUNTIME int 1165SWIG_Python_AcquirePtr(PyObject *obj, int own) { 1166 if (own == SWIG_POINTER_OWN) { 1167 SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); 1168 if (sobj) { 1169 int oldown = sobj->own; 1170 sobj->own = own; 1171 return oldown; 1172 } 1173 } 1174 return 0; 1175} 1176 1177/* Convert a pointer value */ 1178 1179SWIGRUNTIME int 1180SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { 1181 int res; 1182 SwigPyObject *sobj; 1183 int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0; 1184 1185 if (!obj) 1186 return SWIG_ERROR; 1187 if (obj == Py_None && !implicit_conv) { 1188 if (ptr) 1189 *ptr = 0; 1190 return SWIG_OK; 1191 } 1192 1193 res = SWIG_ERROR; 1194 1195 sobj = SWIG_Python_GetSwigThis(obj); 1196 if (own) 1197 *own = 0; 1198 while (sobj) { 1199 void *vptr = sobj->ptr; 1200 if (ty) { 1201 swig_type_info *to = sobj->ty; 1202 if (to == ty) { 1203 /* no type cast needed */ 1204 if (ptr) *ptr = vptr; 1205 break; 1206 } else { 1207 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 1208 if (!tc) { 1209 sobj = (SwigPyObject *)sobj->next; 1210 } else { 1211 if (ptr) { 1212 int newmemory = 0; 1213 *ptr = SWIG_TypeCast(tc,vptr,&newmemory); 1214 if (newmemory == SWIG_CAST_NEW_MEMORY) { 1215 assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ 1216 if (own) 1217 *own = *own | SWIG_CAST_NEW_MEMORY; 1218 } 1219 } 1220 break; 1221 } 1222 } 1223 } else { 1224 if (ptr) *ptr = vptr; 1225 break; 1226 } 1227 } 1228 if (sobj) { 1229 if (own) 1230 *own = *own | sobj->own; 1231 if (flags & SWIG_POINTER_DISOWN) { 1232 sobj->own = 0; 1233 } 1234 res = SWIG_OK; 1235 } else { 1236 if (implicit_conv) { 1237 SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; 1238 if (data && !data->implicitconv) { 1239 PyObject *klass = data->klass; 1240 if (klass) { 1241 PyObject *impconv; 1242 data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ 1243 impconv = SWIG_Python_CallFunctor(klass, obj); 1244 data->implicitconv = 0; 1245 if (PyErr_Occurred()) { 1246 PyErr_Clear(); 1247 impconv = 0; 1248 } 1249 if (impconv) { 1250 SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); 1251 if (iobj) { 1252 void *vptr; 1253 res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); 1254 if (SWIG_IsOK(res)) { 1255 if (ptr) { 1256 *ptr = vptr; 1257 /* transfer the ownership to 'ptr' */ 1258 iobj->own = 0; 1259 res = SWIG_AddCast(res); 1260 res = SWIG_AddNewMask(res); 1261 } else { 1262 res = SWIG_AddCast(res); 1263 } 1264 } 1265 } 1266 Py_DECREF(impconv); 1267 } 1268 } 1269 } 1270 } 1271 if (!SWIG_IsOK(res) && obj == Py_None) { 1272 if (ptr) 1273 *ptr = 0; 1274 if (PyErr_Occurred()) 1275 PyErr_Clear(); 1276 res = SWIG_OK; 1277 } 1278 } 1279 return res; 1280} 1281 1282/* Convert a function ptr value */ 1283 1284SWIGRUNTIME int 1285SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { 1286 if (!PyCFunction_Check(obj)) { 1287 return SWIG_ConvertPtr(obj, ptr, ty, 0); 1288 } else { 1289 void *vptr = 0; 1290 1291 /* here we get the method pointer for callbacks */ 1292 const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); 1293 const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; 1294 if (desc) 1295 desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; 1296 if (!desc) 1297 return SWIG_ERROR; 1298 if (ty) { 1299 swig_cast_info *tc = SWIG_TypeCheck(desc,ty); 1300 if (tc) { 1301 int newmemory = 0; 1302 *ptr = SWIG_TypeCast(tc,vptr,&newmemory); 1303 assert(!newmemory); /* newmemory handling not yet implemented */ 1304 } else { 1305 return SWIG_ERROR; 1306 } 1307 } else { 1308 *ptr = vptr; 1309 } 1310 return SWIG_OK; 1311 } 1312} 1313 1314/* Convert a packed value value */ 1315 1316SWIGRUNTIME int 1317SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { 1318 swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); 1319 if (!to) return SWIG_ERROR; 1320 if (ty) { 1321 if (to != ty) { 1322 /* check type cast? */ 1323 swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); 1324 if (!tc) return SWIG_ERROR; 1325 } 1326 } 1327 return SWIG_OK; 1328} 1329 1330/* ----------------------------------------------------------------------------- 1331 * Create a new pointer object 1332 * ----------------------------------------------------------------------------- */ 1333 1334/* 1335 Create a new instance object, without calling __init__, and set the 1336 'this' attribute. 1337*/ 1338 1339SWIGRUNTIME PyObject* 1340SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) 1341{ 1342#if (PY_VERSION_HEX >= 0x02020000) 1343 PyObject *inst = 0; 1344 PyObject *newraw = data->newraw; 1345 if (newraw) { 1346 inst = PyObject_Call(newraw, data->newargs, NULL); 1347 if (inst) { 1348#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) 1349 PyObject **dictptr = _PyObject_GetDictPtr(inst); 1350 if (dictptr != NULL) { 1351 PyObject *dict = *dictptr; 1352 if (dict == NULL) { 1353 dict = PyDict_New(); 1354 *dictptr = dict; 1355 PyDict_SetItem(dict, SWIG_This(), swig_this); 1356 } 1357 } 1358#else 1359 PyObject *key = SWIG_This(); 1360 PyObject_SetAttr(inst, key, swig_this); 1361#endif 1362 } 1363 } else { 1364#if PY_VERSION_HEX >= 0x03000000 1365 inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); 1366 if (inst) { 1367 PyObject_SetAttr(inst, SWIG_This(), swig_this); 1368 Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; 1369 } 1370#else 1371 PyObject *dict = PyDict_New(); 1372 if (dict) { 1373 PyDict_SetItem(dict, SWIG_This(), swig_this); 1374 inst = PyInstance_NewRaw(data->newargs, dict); 1375 Py_DECREF(dict); 1376 } 1377#endif 1378 } 1379 return inst; 1380#else 1381#if (PY_VERSION_HEX >= 0x02010000) 1382 PyObject *inst = 0; 1383 PyObject *dict = PyDict_New(); 1384 if (dict) { 1385 PyDict_SetItem(dict, SWIG_This(), swig_this); 1386 inst = PyInstance_NewRaw(data->newargs, dict); 1387 Py_DECREF(dict); 1388 } 1389 return (PyObject *) inst; 1390#else 1391 PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); 1392 if (inst == NULL) { 1393 return NULL; 1394 } 1395 inst->in_class = (PyClassObject *)data->newargs; 1396 Py_INCREF(inst->in_class); 1397 inst->in_dict = PyDict_New(); 1398 if (inst->in_dict == NULL) { 1399 Py_DECREF(inst); 1400 return NULL; 1401 } 1402#ifdef Py_TPFLAGS_HAVE_WEAKREFS 1403 inst->in_weakreflist = NULL; 1404#endif 1405#ifdef Py_TPFLAGS_GC 1406 PyObject_GC_Init(inst); 1407#endif 1408 PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); 1409 return (PyObject *) inst; 1410#endif 1411#endif 1412} 1413 1414SWIGRUNTIME void 1415SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) 1416{ 1417 PyObject *dict; 1418#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) 1419 PyObject **dictptr = _PyObject_GetDictPtr(inst); 1420 if (dictptr != NULL) { 1421 dict = *dictptr; 1422 if (dict == NULL) { 1423 dict = PyDict_New(); 1424 *dictptr = dict; 1425 } 1426 PyDict_SetItem(dict, SWIG_This(), swig_this); 1427 return; 1428 } 1429#endif 1430 dict = PyObject_GetAttrString(inst, (char*)"__dict__"); 1431 PyDict_SetItem(dict, SWIG_This(), swig_this); 1432 Py_DECREF(dict); 1433} 1434 1435 1436SWIGINTERN PyObject * 1437SWIG_Python_InitShadowInstance(PyObject *args) { 1438 PyObject *obj[2]; 1439 if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) { 1440 return NULL; 1441 } else { 1442 SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); 1443 if (sthis) { 1444 SwigPyObject_append((PyObject*) sthis, obj[1]); 1445 } else { 1446 SWIG_Python_SetSwigThis(obj[0], obj[1]); 1447 } 1448 return SWIG_Py_Void(); 1449 } 1450} 1451 1452/* Create a new pointer object */ 1453 1454SWIGRUNTIME PyObject * 1455SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) { 1456 SwigPyClientData *clientdata; 1457 PyObject * robj; 1458 int own; 1459 1460 if (!ptr) 1461 return SWIG_Py_Void(); 1462 1463 clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; 1464 own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; 1465 if (clientdata && clientdata->pytype) { 1466 SwigPyObject *newobj; 1467 if (flags & SWIG_BUILTIN_TP_INIT) { 1468 newobj = (SwigPyObject*) self; 1469 if (newobj->ptr) { 1470 PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0); 1471 while (newobj->next) 1472 newobj = (SwigPyObject *) newobj->next; 1473 newobj->next = next_self; 1474 newobj = (SwigPyObject *)next_self; 1475#ifdef SWIGPYTHON_BUILTIN 1476 newobj->dict = 0; 1477#endif 1478 } 1479 } else { 1480 newobj = PyObject_New(SwigPyObject, clientdata->pytype); 1481#ifdef SWIGPYTHON_BUILTIN 1482 newobj->dict = 0; 1483#endif 1484 } 1485 if (newobj) { 1486 newobj->ptr = ptr; 1487 newobj->ty = type; 1488 newobj->own = own; 1489 newobj->next = 0; 1490 return (PyObject*) newobj; 1491 } 1492 return SWIG_Py_Void(); 1493 } 1494 1495 assert(!(flags & SWIG_BUILTIN_TP_INIT)); 1496 1497 robj = SwigPyObject_New(ptr, type, own); 1498 if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { 1499 PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); 1500 Py_DECREF(robj); 1501 robj = inst; 1502 } 1503 return robj; 1504} 1505 1506/* Create a new packed object */ 1507 1508SWIGRUNTIMEINLINE PyObject * 1509SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { 1510 return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); 1511} 1512 1513/* -----------------------------------------------------------------------------* 1514 * Get type list 1515 * -----------------------------------------------------------------------------*/ 1516 1517#ifdef SWIG_LINK_RUNTIME 1518void *SWIG_ReturnGlobalTypeList(void *); 1519#endif 1520 1521SWIGRUNTIME swig_module_info * 1522SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) { 1523 static void *type_pointer = (void *)0; 1524 /* first check if module already created */ 1525 if (!type_pointer) { 1526#ifdef SWIG_LINK_RUNTIME 1527 type_pointer = SWIG_ReturnGlobalTypeList((void *)0); 1528#else 1529# ifdef SWIGPY_USE_CAPSULE 1530 type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0); 1531# else 1532 type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, 1533 (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); 1534# endif 1535 if (PyErr_Occurred()) { 1536 PyErr_Clear(); 1537 type_pointer = (void *)0; 1538 } 1539#endif 1540 } 1541 return (swig_module_info *) type_pointer; 1542} 1543 1544#if PY_MAJOR_VERSION < 2 1545/* PyModule_AddObject function was introduced in Python 2.0. The following function 1546 is copied out of Python/modsupport.c in python version 2.3.4 */ 1547SWIGINTERN int 1548PyModule_AddObject(PyObject *m, char *name, PyObject *o) 1549{ 1550 PyObject *dict; 1551 if (!PyModule_Check(m)) { 1552 PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg"); 1553 return SWIG_ERROR; 1554 } 1555 if (!o) { 1556 PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value"); 1557 return SWIG_ERROR; 1558 } 1559 1560 dict = PyModule_GetDict(m); 1561 if (dict == NULL) { 1562 /* Internal error -- modules must have a dict! */ 1563 PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", 1564 PyModule_GetName(m)); 1565 return SWIG_ERROR; 1566 } 1567 if (PyDict_SetItemString(dict, name, o)) 1568 return SWIG_ERROR; 1569 Py_DECREF(o); 1570 return SWIG_OK; 1571} 1572#endif 1573 1574SWIGRUNTIME void 1575#ifdef SWIGPY_USE_CAPSULE 1576SWIG_Python_DestroyModule(PyObject *obj) 1577#else 1578SWIG_Python_DestroyModule(void *vptr) 1579#endif 1580{ 1581#ifdef SWIGPY_USE_CAPSULE 1582 swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME); 1583#else 1584 swig_module_info *swig_module = (swig_module_info *) vptr; 1585#endif 1586 swig_type_info **types = swig_module->types; 1587 size_t i; 1588 for (i =0; i < swig_module->size; ++i) { 1589 swig_type_info *ty = types[i]; 1590 if (ty->owndata) { 1591 SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; 1592 if (data) SwigPyClientData_Del(data); 1593 } 1594 } 1595 Py_DECREF(SWIG_This()); 1596 swig_this = NULL; 1597} 1598 1599SWIGRUNTIME void 1600SWIG_Python_SetModule(swig_module_info *swig_module) { 1601#if PY_VERSION_HEX >= 0x03000000 1602 /* Add a dummy module object into sys.modules */ 1603 PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); 1604#else 1605 static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */ 1606 PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); 1607#endif 1608#ifdef SWIGPY_USE_CAPSULE 1609 PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule); 1610 if (pointer && module) { 1611 PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer); 1612 } else { 1613 Py_XDECREF(pointer); 1614 } 1615#else 1616 PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); 1617 if (pointer && module) { 1618 PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); 1619 } else { 1620 Py_XDECREF(pointer); 1621 } 1622#endif 1623} 1624 1625/* The python cached type query */ 1626SWIGRUNTIME PyObject * 1627SWIG_Python_TypeCache(void) { 1628 static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); 1629 return cache; 1630} 1631 1632SWIGRUNTIME swig_type_info * 1633SWIG_Python_TypeQuery(const char *type) 1634{ 1635 PyObject *cache = SWIG_Python_TypeCache(); 1636 PyObject *key = SWIG_Python_str_FromChar(type); 1637 PyObject *obj = PyDict_GetItem(cache, key); 1638 swig_type_info *descriptor; 1639 if (obj) { 1640#ifdef SWIGPY_USE_CAPSULE 1641 descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL); 1642#else 1643 descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); 1644#endif 1645 } else { 1646 swig_module_info *swig_module = SWIG_GetModule(0); 1647 descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); 1648 if (descriptor) { 1649#ifdef SWIGPY_USE_CAPSULE 1650 obj = PyCapsule_New((void*) descriptor, NULL, NULL); 1651#else 1652 obj = PyCObject_FromVoidPtr(descriptor, NULL); 1653#endif 1654 PyDict_SetItem(cache, key, obj); 1655 Py_DECREF(obj); 1656 } 1657 } 1658 Py_DECREF(key); 1659 return descriptor; 1660} 1661 1662/* 1663 For backward compatibility only 1664*/ 1665#define SWIG_POINTER_EXCEPTION 0 1666#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) 1667#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) 1668 1669SWIGRUNTIME int 1670SWIG_Python_AddErrMesg(const char* mesg, int infront) 1671{ 1672 if (PyErr_Occurred()) { 1673 PyObject *type = 0; 1674 PyObject *value = 0; 1675 PyObject *traceback = 0; 1676 PyErr_Fetch(&type, &value, &traceback); 1677 if (value) { 1678 char *tmp; 1679 PyObject *old_str = PyObject_Str(value); 1680 Py_XINCREF(type); 1681 PyErr_Clear(); 1682 if (infront) { 1683 PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); 1684 } else { 1685 PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); 1686 } 1687 SWIG_Python_str_DelForPy3(tmp); 1688 Py_DECREF(old_str); 1689 } 1690 return 1; 1691 } else { 1692 return 0; 1693 } 1694} 1695 1696SWIGRUNTIME int 1697SWIG_Python_ArgFail(int argnum) 1698{ 1699 if (PyErr_Occurred()) { 1700 /* add information about failing argument */ 1701 char mesg[256]; 1702 PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); 1703 return SWIG_Python_AddErrMesg(mesg, 1); 1704 } else { 1705 return 0; 1706 } 1707} 1708 1709SWIGRUNTIMEINLINE const char * 1710SwigPyObject_GetDesc(PyObject *self) 1711{ 1712 SwigPyObject *v = (SwigPyObject *)self; 1713 swig_type_info *ty = v ? v->ty : 0; 1714 return ty ? ty->str : ""; 1715} 1716 1717SWIGRUNTIME void 1718SWIG_Python_TypeError(const char *type, PyObject *obj) 1719{ 1720 if (type) { 1721#if defined(SWIG_COBJECT_TYPES) 1722 if (obj && SwigPyObject_Check(obj)) { 1723 const char *otype = (const char *) SwigPyObject_GetDesc(obj); 1724 if (otype) { 1725 PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", 1726 type, otype); 1727 return; 1728 } 1729 } else 1730#endif 1731 { 1732 const char *otype = (obj ? obj->ob_type->tp_name : 0); 1733 if (otype) { 1734 PyObject *str = PyObject_Str(obj); 1735 const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; 1736 if (cstr) { 1737 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", 1738 type, otype, cstr); 1739 SWIG_Python_str_DelForPy3(cstr); 1740 } else { 1741 PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", 1742 type, otype); 1743 } 1744 Py_XDECREF(str); 1745 return; 1746 } 1747 } 1748 PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); 1749 } else { 1750 PyErr_Format(PyExc_TypeError, "unexpected type is received"); 1751 } 1752} 1753 1754 1755/* Convert a pointer value, signal an exception on a type mismatch */ 1756SWIGRUNTIME void * 1757SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) { 1758 void *result; 1759 if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { 1760 PyErr_Clear(); 1761#if SWIG_POINTER_EXCEPTION 1762 if (flags) { 1763 SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); 1764 SWIG_Python_ArgFail(argnum); 1765 } 1766#endif 1767 } 1768 return result; 1769} 1770 1771#ifdef SWIGPYTHON_BUILTIN 1772SWIGRUNTIME int 1773SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) { 1774 PyTypeObject *tp = obj->ob_type; 1775 PyObject *descr; 1776 PyObject *encoded_name; 1777 descrsetfunc f; 1778 int res = -1; 1779 1780# ifdef Py_USING_UNICODE 1781 if (PyString_Check(name)) { 1782 name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL); 1783 if (!name) 1784 return -1; 1785 } else if (!PyUnicode_Check(name)) 1786# else 1787 if (!PyString_Check(name)) 1788# endif 1789 { 1790 PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name); 1791 return -1; 1792 } else { 1793 Py_INCREF(name); 1794 } 1795 1796 if (!tp->tp_dict) { 1797 if (PyType_Ready(tp) < 0) 1798 goto done; 1799 } 1800 1801 descr = _PyType_Lookup(tp, name); 1802 f = NULL; 1803 if (descr != NULL) 1804 f = descr->ob_type->tp_descr_set; 1805 if (!f) { 1806 if (PyString_Check(name)) { 1807 encoded_name = name; 1808 Py_INCREF(name); 1809 } else { 1810 encoded_name = PyUnicode_AsUTF8String(name); 1811 } 1812 PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name)); 1813 Py_DECREF(encoded_name); 1814 } else { 1815 res = f(descr, obj, value); 1816 } 1817 1818 done: 1819 Py_DECREF(name); 1820 return res; 1821} 1822#endif 1823 1824 1825#ifdef __cplusplus 1826} 1827#endif 1828