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