PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Lib/python/builtin.swg

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