Home | History | Annotate | Download | only in python
      1 #define SWIGPY_UNARYFUNC_CLOSURE(wrapper)	\
      2 SWIGINTERN PyObject *				\
      3 wrapper##_closure(PyObject *a) {		\
      4   return wrapper(a, NULL);			\
      5 }
      6 
      7 #define SWIGPY_DESTRUCTOR_CLOSURE(wrapper)	\
      8 SWIGINTERN void					\
      9 wrapper##_closure(PyObject *a) {		\
     10     SwigPyObject *sobj;				\
     11     sobj = (SwigPyObject *)a;			\
     12     if (sobj->own) {				\
     13 	PyObject *o = wrapper(a, NULL);		\
     14 	Py_XDECREF(o);				\
     15     }						\
     16     if (PyType_IS_GC(a->ob_type)) {		\
     17 	PyObject_GC_Del(a);			\
     18     } else {					\
     19 	PyObject_Del(a);			\
     20     }						\
     21 }
     22 
     23 #define SWIGPY_INQUIRY_CLOSURE(wrapper)				\
     24 SWIGINTERN int							\
     25 wrapper##_closure(PyObject *a) {				\
     26     PyObject *pyresult;						\
     27     int result;							\
     28     pyresult = wrapper(a, NULL);				\
     29     result = pyresult && PyObject_IsTrue(pyresult) ? 1 : 0;	\
     30     Py_XDECREF(pyresult);					\
     31     return result;						\
     32 }
     33 
     34 #define SWIGPY_BINARYFUNC_CLOSURE(wrapper)	\
     35 SWIGINTERN PyObject *				\
     36 wrapper##_closure(PyObject *a, PyObject *b) {	\
     37     PyObject *tuple, *result;			\
     38     tuple = PyTuple_New(1);			\
     39     assert(tuple);				\
     40     PyTuple_SET_ITEM(tuple, 0, b);		\
     41     Py_XINCREF(b);				\
     42     result = wrapper(a, tuple);			\
     43     Py_DECREF(tuple);				\
     44     return result;				\
     45 }
     46 
     47 typedef ternaryfunc ternarycallfunc;
     48 
     49 #define SWIGPY_TERNARYFUNC_CLOSURE(wrapper)			\
     50 SWIGINTERN PyObject *						\
     51 wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) {	\
     52     PyObject *tuple, *result;					\
     53     tuple = PyTuple_New(2);					\
     54     assert(tuple);						\
     55     PyTuple_SET_ITEM(tuple, 0, b);				\
     56     PyTuple_SET_ITEM(tuple, 1, c);				\
     57     Py_XINCREF(b);						\
     58     Py_XINCREF(c);						\
     59     result = wrapper(a, tuple);					\
     60     Py_DECREF(tuple);						\
     61     return result;						\
     62 }
     63 
     64 #define SWIGPY_TERNARYCALLFUNC_CLOSURE(wrapper)			\
     65 SWIGINTERN PyObject *						\
     66 wrapper##_closure(PyObject *callable_object, PyObject *args, PyObject *) {	\
     67     return wrapper(callable_object, args);			\
     68 }
     69 
     70 #define SWIGPY_LENFUNC_CLOSURE(wrapper)			\
     71 SWIGINTERN Py_ssize_t					\
     72 wrapper##_closure(PyObject *a) {			\
     73     PyObject *resultobj;				\
     74     Py_ssize_t result;					\
     75     resultobj = wrapper(a, NULL);			\
     76     result = PyNumber_AsSsize_t(resultobj, NULL);	\
     77     Py_DECREF(resultobj);				\
     78     return result;					\
     79 }
     80 
     81 #define SWIGPY_SSIZESSIZEARGFUNC_CLOSURE(wrapper)		\
     82 SWIGINTERN PyObject *						\
     83 wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c) {	\
     84     PyObject *tuple, *result;					\
     85     tuple = PyTuple_New(2);					\
     86     assert(tuple);						\
     87     PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));		\
     88     PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));		\
     89     result = wrapper(a, tuple);					\
     90     Py_DECREF(tuple);						\
     91     return result;						\
     92 }
     93 
     94 #define SWIGPY_SSIZESSIZEOBJARGPROC_CLOSURE(wrapper)			\
     95 SWIGINTERN int								\
     96 wrapper##_closure(PyObject *a, Py_ssize_t b, Py_ssize_t c, PyObject *d) { \
     97     PyObject *tuple, *resultobj;					\
     98     int result;								\
     99     tuple = PyTuple_New(d ? 3 : 2);					\
    100     assert(tuple);							\
    101     PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));			\
    102     PyTuple_SET_ITEM(tuple, 1, _PyLong_FromSsize_t(c));			\
    103     if (d) {								\
    104         PyTuple_SET_ITEM(tuple, 2, d);					\
    105         Py_INCREF(d);							\
    106     }									\
    107     resultobj = wrapper(a, tuple);					\
    108     result = resultobj ? 0 : -1;					\
    109     Py_DECREF(tuple);							\
    110     Py_XDECREF(resultobj);						\
    111     return result;							\
    112 }
    113 
    114 #define SWIGPY_SSIZEARGFUNC_CLOSURE(wrapper)		\
    115 SWIGINTERN PyObject *					\
    116 wrapper##_closure(PyObject *a, Py_ssize_t b) {		\
    117     PyObject *tuple, *result;				\
    118     tuple = PyTuple_New(1);				\
    119     assert(tuple);					\
    120     PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));	\
    121     result = wrapper(a, tuple);				\
    122     Py_DECREF(tuple);					\
    123     return result;					\
    124 }
    125 
    126 #define SWIGPY_FUNPACK_SSIZEARGFUNC_CLOSURE(wrapper)		\
    127 SWIGINTERN PyObject *					\
    128 wrapper##_closure(PyObject *a, Py_ssize_t b) {		\
    129     PyObject *arg, *result;				\
    130     arg = _PyLong_FromSsize_t(b);			\
    131     result = wrapper(a, arg);				\
    132     Py_DECREF(arg);					\
    133     return result;					\
    134 }
    135 
    136 #define SWIGPY_SSIZEOBJARGPROC_CLOSURE(wrapper)			\
    137 SWIGINTERN int							\
    138 wrapper##_closure(PyObject *a, Py_ssize_t b, PyObject *c) {	\
    139     PyObject *tuple, *resultobj;				\
    140     int result;							\
    141     tuple = PyTuple_New(2);					\
    142     assert(tuple);						\
    143     PyTuple_SET_ITEM(tuple, 0, _PyLong_FromSsize_t(b));		\
    144     PyTuple_SET_ITEM(tuple, 1, c);				\
    145     Py_XINCREF(c);						\
    146     resultobj = wrapper(a, tuple);				\
    147     result = resultobj ? 0 : -1;				\
    148     Py_XDECREF(resultobj);					\
    149     Py_DECREF(tuple);						\
    150     return result;						\
    151 }
    152 
    153 #define SWIGPY_OBJOBJARGPROC_CLOSURE(wrapper)			\
    154 SWIGINTERN int							\
    155 wrapper##_closure(PyObject *a, PyObject *b, PyObject *c) {	\
    156     PyObject *tuple, *resultobj;				\
    157     int result;							\
    158     tuple = PyTuple_New(c ? 2 : 1);				\
    159     assert(tuple);						\
    160     PyTuple_SET_ITEM(tuple, 0, b);				\
    161     Py_XINCREF(b);						\
    162     if (c) {							\
    163         PyTuple_SET_ITEM(tuple, 1, c);				\
    164         Py_XINCREF(c);						\
    165     }								\
    166     resultobj = wrapper(a, tuple);				\
    167     result = resultobj ? 0 : -1;				\
    168     Py_XDECREF(resultobj);					\
    169     Py_DECREF(tuple);						\
    170     return result;						\
    171 }
    172 
    173 #define SWIGPY_REPRFUNC_CLOSURE(wrapper)	\
    174 SWIGINTERN PyObject *				\
    175 wrapper##_closure(PyObject *a) {		\
    176     return wrapper(a, NULL);			\
    177 }
    178 
    179 #define SWIGPY_HASHFUNC_CLOSURE(wrapper)	\
    180 SWIGINTERN long					\
    181 wrapper##_closure(PyObject *a) {		\
    182     PyObject *pyresult;				\
    183     long result;				\
    184     pyresult = wrapper(a, NULL);		\
    185     if (!pyresult || !PyLong_Check(pyresult))	\
    186 	return -1;				\
    187     result = PyLong_AsLong(pyresult);		\
    188     Py_DECREF(pyresult);			\
    189     return result;				\
    190 }
    191 
    192 #define SWIGPY_ITERNEXT_CLOSURE(wrapper)	\
    193 SWIGINTERN PyObject *				\
    194 wrapper##_closure(PyObject *a) {		\
    195     PyObject *result;				\
    196     result = wrapper(a, NULL);			\
    197     if (result && result == Py_None) {		\
    198 	Py_DECREF(result);			\
    199 	result = NULL;				\
    200     }						\
    201     return result;				\
    202 }
    203 
    204 #ifdef __cplusplus
    205 extern "C" {
    206 #endif
    207 
    208 SWIGINTERN int
    209 SwigPyBuiltin_BadInit(PyObject *self, PyObject *SWIGUNUSEDPARM(args), PyObject *SWIGUNUSEDPARM(kwds)) {
    210   PyErr_Format(PyExc_TypeError, "Cannot create new instances of type '%.300s'", self->ob_type->tp_name);
    211   return -1;
    212 }
    213 
    214 SWIGINTERN void
    215 SwigPyBuiltin_BadDealloc(PyObject *pyobj) {
    216   SwigPyObject *sobj;
    217   sobj = (SwigPyObject *)pyobj;
    218   if (sobj->own) {
    219     PyErr_Format(PyExc_TypeError, "Swig detected a memory leak in type '%.300s': no callable destructor found.", pyobj->ob_type->tp_name);
    220   }
    221 }
    222 
    223 typedef struct {
    224   PyCFunction get;
    225   PyCFunction set;
    226 } SwigPyGetSet;
    227 
    228 SWIGINTERN PyObject *
    229 SwigPyBuiltin_GetterClosure (PyObject *obj, void *closure) {
    230   SwigPyGetSet *getset;
    231   PyObject *tuple, *result;
    232   if (!closure)
    233     return SWIG_Py_Void();
    234   getset = (SwigPyGetSet *)closure;
    235   if (!getset->get)
    236     return SWIG_Py_Void();
    237   tuple = PyTuple_New(0);
    238   assert(tuple);
    239   result = (*getset->get)(obj, tuple);
    240   Py_DECREF(tuple);
    241   return result;
    242 }
    243 
    244 SWIGINTERN PyObject *
    245 SwigPyBuiltin_FunpackGetterClosure (PyObject *obj, void *closure) {
    246   SwigPyGetSet *getset;
    247   PyObject *result;
    248   if (!closure)
    249     return SWIG_Py_Void();
    250   getset = (SwigPyGetSet *)closure;
    251   if (!getset->get)
    252     return SWIG_Py_Void();
    253   result = (*getset->get)(obj, NULL);
    254   return result;
    255 }
    256 
    257 SWIGINTERN int
    258 SwigPyBuiltin_SetterClosure (PyObject *obj, PyObject *val, void *closure) {
    259   SwigPyGetSet *getset;
    260   PyObject *tuple, *result;
    261   if (!closure) {
    262     PyErr_Format(PyExc_TypeError, "Missing getset closure");
    263     return -1;
    264   }
    265   getset = (SwigPyGetSet *)closure;
    266   if (!getset->set) {
    267     PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name);
    268     return -1;
    269   }
    270   tuple = PyTuple_New(1);
    271   assert(tuple);
    272   PyTuple_SET_ITEM(tuple, 0, val);
    273   Py_XINCREF(val);
    274   result = (*getset->set)(obj, tuple);
    275   Py_DECREF(tuple);
    276   Py_XDECREF(result);
    277   return result ? 0 : -1;
    278 }
    279 
    280 SWIGINTERN int
    281 SwigPyBuiltin_FunpackSetterClosure (PyObject *obj, PyObject *val, void *closure) {
    282   SwigPyGetSet *getset;
    283   PyObject *result;
    284   if (!closure) {
    285     PyErr_Format(PyExc_TypeError, "Missing getset closure");
    286     return -1;
    287   }
    288   getset = (SwigPyGetSet *)closure;
    289   if (!getset->set) {
    290     PyErr_Format(PyExc_TypeError, "Illegal member variable assignment in type '%.300s'", obj->ob_type->tp_name);
    291     return -1;
    292   }
    293   result = (*getset->set)(obj, val);
    294   Py_XDECREF(result);
    295   return result ? 0 : -1;
    296 }
    297 
    298 SWIGINTERN void
    299 SwigPyStaticVar_dealloc(PyDescrObject *descr) {
    300   _PyObject_GC_UNTRACK(descr);
    301   Py_XDECREF(PyDescr_TYPE(descr));
    302   Py_XDECREF(PyDescr_NAME(descr));
    303   PyObject_GC_Del(descr);
    304 }
    305 
    306 SWIGINTERN PyObject *
    307 SwigPyStaticVar_repr(PyGetSetDescrObject *descr) {
    308 #if PY_VERSION_HEX >= 0x03000000
    309 
    310   return PyUnicode_FromFormat("<class attribute '%S' of type '%s'>", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
    311 #else
    312   return PyString_FromFormat("<class attribute '%s' of type '%s'>", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
    313 #endif
    314 }
    315 
    316 SWIGINTERN int
    317 SwigPyStaticVar_traverse(PyObject *self, visitproc visit, void *arg) {
    318   PyDescrObject *descr;
    319   descr = (PyDescrObject *)self;
    320   Py_VISIT((PyObject*) PyDescr_TYPE(descr));
    321   return 0;
    322 }
    323 
    324 SWIGINTERN PyObject *
    325 SwigPyStaticVar_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *SWIGUNUSEDPARM(type)) {
    326   if (descr->d_getset->get != NULL)
    327     return descr->d_getset->get(obj, descr->d_getset->closure);
    328 #if PY_VERSION_HEX >= 0x03000000
    329   PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not readable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
    330 #else
    331   PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not readable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
    332 #endif
    333   return NULL;
    334 }
    335 
    336 SWIGINTERN int
    337 SwigPyStaticVar_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) {
    338   if (descr->d_getset->set != NULL)
    339     return descr->d_getset->set(obj, value, descr->d_getset->closure);
    340 #if PY_VERSION_HEX >= 0x03000000
    341   PyErr_Format(PyExc_AttributeError, "attribute '%.300S' of '%.100s' objects is not writable", PyDescr_NAME(descr), PyDescr_TYPE(descr)->tp_name);
    342 #else
    343   PyErr_Format(PyExc_AttributeError, "attribute '%.300s' of '%.100s' objects is not writable", PyString_AsString(PyDescr_NAME(descr)), PyDescr_TYPE(descr)->tp_name);
    344 #endif
    345   return -1;
    346 }
    347 
    348 SWIGINTERN int
    349 SwigPyObjectType_setattro(PyTypeObject *type, PyObject *name, PyObject *value) {
    350   PyObject *attribute;
    351   descrsetfunc local_set;
    352   attribute = _PyType_Lookup(type, name);
    353   if (attribute != NULL) {
    354     /* Implement descriptor functionality, if any */
    355     local_set = attribute->ob_type->tp_descr_set;
    356     if (local_set != NULL)
    357       return local_set(attribute, (PyObject *)type, value);
    358 #if PY_VERSION_HEX >= 0x03000000
    359     PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400S'", type->tp_name, name);
    360 #else 
    361     PyErr_Format(PyExc_AttributeError, "cannot modify read-only attribute '%.50s.%.400s'", type->tp_name, PyString_AS_STRING(name));
    362 #endif
    363   } else {
    364 #if PY_VERSION_HEX >= 0x03000000
    365     PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400S'", type->tp_name, name);
    366 #else
    367     PyErr_Format(PyExc_AttributeError, "type '%.50s' has no attribute '%.400s'", type->tp_name, PyString_AS_STRING(name));
    368 #endif
    369   }
    370 
    371   return -1;
    372 }
    373 
    374 SWIGINTERN PyTypeObject*
    375 SwigPyStaticVar_Type(void) {
    376   static PyTypeObject staticvar_type;
    377   static int type_init = 0;
    378   if (!type_init) {
    379     const PyTypeObject tmp = {
    380       /* PyObject header changed in Python 3 */
    381 #if PY_VERSION_HEX >= 0x03000000
    382       PyVarObject_HEAD_INIT(&PyType_Type, 0)
    383 #else
    384       PyObject_HEAD_INIT(&PyType_Type)
    385       0,
    386 #endif
    387       "swig_static_var_getset_descriptor",
    388       sizeof(PyGetSetDescrObject),
    389       0,
    390       (destructor)SwigPyStaticVar_dealloc,      /* tp_dealloc */
    391       0,                                        /* tp_print */
    392       0,                                        /* tp_getattr */
    393       0,                                        /* tp_setattr */
    394       0,                                        /* tp_compare */
    395       (reprfunc)SwigPyStaticVar_repr,           /* tp_repr */
    396       0,                                        /* tp_as_number */
    397       0,                                        /* tp_as_sequence */
    398       0,                                        /* tp_as_mapping */
    399       0,                                        /* tp_hash */
    400       0,                                        /* tp_call */
    401       0,                                        /* tp_str */
    402       PyObject_GenericGetAttr,                  /* tp_getattro */
    403       0,                                        /* tp_setattro */
    404       0,                                        /* tp_as_buffer */
    405       Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_HAVE_CLASS, /* tp_flags */
    406       0,                                        /* tp_doc */
    407       SwigPyStaticVar_traverse,                 /* tp_traverse */
    408       0,                                        /* tp_clear */
    409       0,                                        /* tp_richcompare */
    410       0,                                        /* tp_weaklistoffset */
    411       0,                                        /* tp_iter */
    412       0,                                        /* tp_iternext */
    413       0,                                        /* tp_methods */
    414       0,                                        /* tp_members */
    415       0,                                        /* tp_getset */
    416       0,                                        /* tp_base */
    417       0,                                        /* tp_dict */
    418       (descrgetfunc)SwigPyStaticVar_get,        /* tp_descr_get */
    419       (descrsetfunc)SwigPyStaticVar_set,        /* tp_descr_set */
    420       0,                                        /* tp_dictoffset */
    421       0,                                        /* tp_init */
    422       0,                                        /* tp_alloc */
    423       0,                                        /* tp_new */
    424       0,                                        /* tp_free */
    425       0,                                        /* tp_is_gc */
    426       0,                                        /* tp_bases */
    427       0,                                        /* tp_mro */
    428       0,                                        /* tp_cache */
    429       0,                                        /* tp_subclasses */
    430       0,                                        /* tp_weaklist */
    431 #if PY_VERSION_HEX >= 0x02030000
    432       0,                                        /* tp_del */
    433 #endif
    434 #if PY_VERSION_HEX >= 0x02060000
    435       0,                                        /* tp_version */
    436 #endif
    437 #ifdef COUNT_ALLOCS
    438       0,0,0,0                                   /* tp_alloc -> tp_next */
    439 #endif
    440     };
    441     staticvar_type = tmp;
    442     type_init = 1;
    443 #if PY_VERSION_HEX < 0x02020000
    444     staticvar_type.ob_type = &PyType_Type;
    445 #else
    446     if (PyType_Ready(&staticvar_type) < 0)
    447       return NULL;
    448 #endif
    449   }
    450   return &staticvar_type;
    451 }
    452 
    453 SWIGINTERN PyGetSetDescrObject *
    454 SwigPyStaticVar_new_getset(PyTypeObject *type, PyGetSetDef *getset) {
    455 
    456   PyGetSetDescrObject *descr;
    457   descr = (PyGetSetDescrObject *)PyType_GenericAlloc(SwigPyStaticVar_Type(), 0);
    458   assert(descr);
    459   Py_XINCREF(type);
    460   PyDescr_TYPE(descr) = type;
    461   PyDescr_NAME(descr) = PyString_InternFromString(getset->name);
    462   descr->d_getset = getset;
    463   if (PyDescr_NAME(descr) == NULL) {
    464     Py_DECREF(descr);
    465     descr = NULL;
    466   }
    467   return descr;
    468 }
    469 
    470 SWIGINTERN void
    471 SwigPyBuiltin_InitBases (PyTypeObject *type, PyTypeObject **bases) {
    472   int base_count = 0;
    473   PyTypeObject **b;
    474   PyObject *tuple;
    475   int i;
    476 
    477   if (!bases[0]) {
    478     bases[0] = SwigPyObject_type();
    479     bases[1] = NULL;
    480   }
    481   type->tp_base = bases[0];
    482   Py_INCREF((PyObject *)bases[0]);
    483   for (b = bases; *b != NULL; ++b)
    484     ++base_count;
    485   tuple = PyTuple_New(base_count);
    486   for (i = 0; i < base_count; ++i) {
    487     PyTuple_SET_ITEM(tuple, i, (PyObject *)bases[i]);
    488     Py_INCREF((PyObject *)bases[i]);
    489   }
    490   type->tp_bases = tuple;
    491 }
    492 
    493 SWIGINTERN PyObject *
    494 SwigPyBuiltin_ThisClosure (PyObject *self, void *SWIGUNUSEDPARM(closure)) {
    495   PyObject *result;
    496   result = (PyObject *)SWIG_Python_GetSwigThis(self);
    497   Py_XINCREF(result);
    498   return result;
    499 }
    500 
    501 SWIGINTERN void
    502 SwigPyBuiltin_SetMetaType (PyTypeObject *type, PyTypeObject *metatype)
    503 {
    504 #if PY_VERSION_HEX >= 0x03000000
    505     type->ob_base.ob_base.ob_type = metatype;
    506 #else
    507     type->ob_type = metatype;
    508 #endif
    509 }
    510 
    511 #ifdef __cplusplus
    512 }
    513 #endif
    514 
    515