builtin.swg 17 KB

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