PageRenderTime 42ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Lib/python/pyrun.swg

#
Unknown | 1477 lines | 1356 code | 121 blank | 0 comment | 0 complexity | f516ad6f89f5a26a476b1f930b873268 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * See the LICENSE file for information on copyright, usage and redistribution
  3. * of SWIG, and the README file for authors - http://www.swig.org/release.html.
  4. *
  5. * pyrun.swg
  6. *
  7. * This file contains the runtime support for Python modules
  8. * and includes code for managing global variables and pointer
  9. * type checking.
  10. *
  11. * ----------------------------------------------------------------------------- */
  12. /* Common SWIG API */
  13. /* for raw pointers */
  14. #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
  15. #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
  16. #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
  17. #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags)
  18. #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
  19. #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
  20. #define swig_owntype int
  21. /* for raw packed data */
  22. #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
  23. #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
  24. /* for class or struct pointers */
  25. #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
  26. #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
  27. /* for C or C++ function pointers */
  28. #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
  29. #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0)
  30. /* for C++ member pointers, ie, member methods */
  31. #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
  32. #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
  33. /* Runtime API */
  34. #define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
  35. #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
  36. #define SWIG_NewClientData(obj) PySwigClientData_New(obj)
  37. #define SWIG_SetErrorObj SWIG_Python_SetErrorObj
  38. #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
  39. #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
  40. #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
  41. #define SWIG_fail goto fail
  42. /* Runtime API implementation */
  43. /* Error manipulation */
  44. SWIGINTERN void
  45. SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
  46. SWIG_PYTHON_THREAD_BEGIN_BLOCK;
  47. PyErr_SetObject(errtype, obj);
  48. Py_DECREF(obj);
  49. SWIG_PYTHON_THREAD_END_BLOCK;
  50. }
  51. SWIGINTERN void
  52. SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
  53. SWIG_PYTHON_THREAD_BEGIN_BLOCK;
  54. PyErr_SetString(errtype, (char *) msg);
  55. SWIG_PYTHON_THREAD_END_BLOCK;
  56. }
  57. #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
  58. /* Set a constant value */
  59. SWIGINTERN void
  60. SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
  61. PyDict_SetItemString(d, (char*) name, obj);
  62. Py_DECREF(obj);
  63. }
  64. /* Append a value to the result obj */
  65. SWIGINTERN PyObject*
  66. SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
  67. #if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
  68. if (!result) {
  69. result = obj;
  70. } else if (result == Py_None) {
  71. Py_DECREF(result);
  72. result = obj;
  73. } else {
  74. if (!PyList_Check(result)) {
  75. PyObject *o2 = result;
  76. result = PyList_New(1);
  77. PyList_SetItem(result, 0, o2);
  78. }
  79. PyList_Append(result,obj);
  80. Py_DECREF(obj);
  81. }
  82. return result;
  83. #else
  84. PyObject* o2;
  85. PyObject* o3;
  86. if (!result) {
  87. result = obj;
  88. } else if (result == Py_None) {
  89. Py_DECREF(result);
  90. result = obj;
  91. } else {
  92. if (!PyTuple_Check(result)) {
  93. o2 = result;
  94. result = PyTuple_New(1);
  95. PyTuple_SET_ITEM(result, 0, o2);
  96. }
  97. o3 = PyTuple_New(1);
  98. PyTuple_SET_ITEM(o3, 0, obj);
  99. o2 = result;
  100. result = PySequence_Concat(o2, o3);
  101. Py_DECREF(o2);
  102. Py_DECREF(o3);
  103. }
  104. return result;
  105. #endif
  106. }
  107. /* Unpack the argument tuple */
  108. SWIGINTERN int
  109. SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs)
  110. {
  111. if (!args) {
  112. if (!min && !max) {
  113. return 1;
  114. } else {
  115. PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
  116. name, (min == max ? "" : "at least "), min);
  117. return 0;
  118. }
  119. }
  120. if (!PyTuple_Check(args)) {
  121. PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
  122. return 0;
  123. } else {
  124. register int l = PyTuple_GET_SIZE(args);
  125. if (l < min) {
  126. PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
  127. name, (min == max ? "" : "at least "), min, l);
  128. return 0;
  129. } else if (l > max) {
  130. PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
  131. name, (min == max ? "" : "at most "), max, l);
  132. return 0;
  133. } else {
  134. register int i;
  135. for (i = 0; i < l; ++i) {
  136. objs[i] = PyTuple_GET_ITEM(args, i);
  137. }
  138. for (; l < max; ++l) {
  139. objs[l] = 0;
  140. }
  141. return i + 1;
  142. }
  143. }
  144. }
  145. /* A functor is a function object with one single object argument */
  146. #if PY_VERSION_HEX >= 0x02020000
  147. #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
  148. #else
  149. #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
  150. #endif
  151. /*
  152. Helper for static pointer initialization for both C and C++ code, for example
  153. static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
  154. */
  155. #ifdef __cplusplus
  156. #define SWIG_STATIC_POINTER(var) var
  157. #else
  158. #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
  159. #endif
  160. /* -----------------------------------------------------------------------------
  161. * Pointer declarations
  162. * ----------------------------------------------------------------------------- */
  163. /* Flags for new pointer objects */
  164. #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
  165. #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
  166. #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
  167. #ifdef __cplusplus
  168. extern "C" {
  169. #if 0
  170. } /* cc-mode */
  171. #endif
  172. #endif
  173. /* How to access Py_None */
  174. #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
  175. # ifndef SWIG_PYTHON_NO_BUILD_NONE
  176. # ifndef SWIG_PYTHON_BUILD_NONE
  177. # define SWIG_PYTHON_BUILD_NONE
  178. # endif
  179. # endif
  180. #endif
  181. #ifdef SWIG_PYTHON_BUILD_NONE
  182. # ifdef Py_None
  183. # undef Py_None
  184. # define Py_None SWIG_Py_None()
  185. # endif
  186. SWIGRUNTIMEINLINE PyObject *
  187. _SWIG_Py_None(void)
  188. {
  189. PyObject *none = Py_BuildValue("");
  190. Py_DECREF(none);
  191. return none;
  192. }
  193. SWIGRUNTIME PyObject *
  194. SWIG_Py_None(void)
  195. {
  196. static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
  197. return none;
  198. }
  199. #endif
  200. /* The python void return value */
  201. SWIGRUNTIMEINLINE PyObject *
  202. SWIG_Py_Void(void)
  203. {
  204. PyObject *none = Py_None;
  205. Py_INCREF(none);
  206. return none;
  207. }
  208. /* PySwigClientData */
  209. typedef struct {
  210. PyObject *klass;
  211. PyObject *newraw;
  212. PyObject *newargs;
  213. PyObject *destroy;
  214. int delargs;
  215. int implicitconv;
  216. } PySwigClientData;
  217. SWIGRUNTIMEINLINE int
  218. SWIG_Python_CheckImplicit(swig_type_info *ty)
  219. {
  220. PySwigClientData *data = (PySwigClientData *)ty->clientdata;
  221. return data ? data->implicitconv : 0;
  222. }
  223. SWIGRUNTIMEINLINE PyObject *
  224. SWIG_Python_ExceptionType(swig_type_info *desc) {
  225. PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
  226. PyObject *klass = data ? data->klass : 0;
  227. return (klass ? klass : PyExc_RuntimeError);
  228. }
  229. SWIGRUNTIME PySwigClientData *
  230. PySwigClientData_New(PyObject* obj)
  231. {
  232. if (!obj) {
  233. return 0;
  234. } else {
  235. PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
  236. /* the klass element */
  237. data->klass = obj;
  238. Py_INCREF(data->klass);
  239. /* the newraw method and newargs arguments used to create a new raw instance */
  240. if (PyClass_Check(obj)) {
  241. data->newraw = 0;
  242. data->newargs = obj;
  243. Py_INCREF(obj);
  244. } else {
  245. #if (PY_VERSION_HEX < 0x02020000)
  246. data->newraw = 0;
  247. #else
  248. data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
  249. #endif
  250. if (data->newraw) {
  251. Py_INCREF(data->newraw);
  252. data->newargs = PyTuple_New(1);
  253. PyTuple_SetItem(data->newargs, 0, obj);
  254. } else {
  255. data->newargs = obj;
  256. }
  257. Py_INCREF(data->newargs);
  258. }
  259. /* the destroy method, aka as the C++ delete method */
  260. data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
  261. if (PyErr_Occurred()) {
  262. PyErr_Clear();
  263. data->destroy = 0;
  264. }
  265. if (data->destroy) {
  266. int flags;
  267. Py_INCREF(data->destroy);
  268. flags = PyCFunction_GET_FLAGS(data->destroy);
  269. #ifdef METH_O
  270. data->delargs = !(flags & (METH_O));
  271. #else
  272. data->delargs = 0;
  273. #endif
  274. } else {
  275. data->delargs = 0;
  276. }
  277. data->implicitconv = 0;
  278. return data;
  279. }
  280. }
  281. SWIGRUNTIME void
  282. PySwigClientData_Del(PySwigClientData* data)
  283. {
  284. Py_XDECREF(data->newraw);
  285. Py_XDECREF(data->newargs);
  286. Py_XDECREF(data->destroy);
  287. }
  288. /* =============== PySwigObject =====================*/
  289. typedef struct {
  290. PyObject_HEAD
  291. void *ptr;
  292. swig_type_info *ty;
  293. int own;
  294. PyObject *next;
  295. } PySwigObject;
  296. SWIGRUNTIME PyObject *
  297. PySwigObject_long(PySwigObject *v)
  298. {
  299. return PyLong_FromVoidPtr(v->ptr);
  300. }
  301. SWIGRUNTIME PyObject *
  302. PySwigObject_format(const char* fmt, PySwigObject *v)
  303. {
  304. PyObject *res = NULL;
  305. PyObject *args = PyTuple_New(1);
  306. if (args) {
  307. if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
  308. PyObject *ofmt = PyString_FromString(fmt);
  309. if (ofmt) {
  310. res = PyString_Format(ofmt,args);
  311. Py_DECREF(ofmt);
  312. }
  313. Py_DECREF(args);
  314. }
  315. }
  316. return res;
  317. }
  318. SWIGRUNTIME PyObject *
  319. PySwigObject_oct(PySwigObject *v)
  320. {
  321. return PySwigObject_format("%o",v);
  322. }
  323. SWIGRUNTIME PyObject *
  324. PySwigObject_hex(PySwigObject *v)
  325. {
  326. return PySwigObject_format("%x",v);
  327. }
  328. SWIGRUNTIME PyObject *
  329. #ifdef METH_NOARGS
  330. PySwigObject_repr(PySwigObject *v)
  331. #else
  332. PySwigObject_repr(PySwigObject *v, PyObject *args)
  333. #endif
  334. {
  335. const char *name = SWIG_TypePrettyName(v->ty);
  336. PyObject *hex = PySwigObject_hex(v);
  337. PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
  338. Py_DECREF(hex);
  339. if (v->next) {
  340. #ifdef METH_NOARGS
  341. PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
  342. #else
  343. PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
  344. #endif
  345. PyString_ConcatAndDel(&repr,nrep);
  346. }
  347. return repr;
  348. }
  349. SWIGRUNTIME int
  350. PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
  351. {
  352. #ifdef METH_NOARGS
  353. PyObject *repr = PySwigObject_repr(v);
  354. #else
  355. PyObject *repr = PySwigObject_repr(v, NULL);
  356. #endif
  357. if (repr) {
  358. fputs(PyString_AsString(repr), fp);
  359. Py_DECREF(repr);
  360. return 0;
  361. } else {
  362. return 1;
  363. }
  364. }
  365. SWIGRUNTIME PyObject *
  366. PySwigObject_str(PySwigObject *v)
  367. {
  368. char result[SWIG_BUFFER_SIZE];
  369. return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
  370. PyString_FromString(result) : 0;
  371. }
  372. SWIGRUNTIME int
  373. PySwigObject_compare(PySwigObject *v, PySwigObject *w)
  374. {
  375. void *i = v->ptr;
  376. void *j = w->ptr;
  377. return (i < j) ? -1 : ((i > j) ? 1 : 0);
  378. }
  379. SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
  380. SWIGRUNTIME PyTypeObject*
  381. PySwigObject_type(void) {
  382. static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
  383. return type;
  384. }
  385. SWIGRUNTIMEINLINE int
  386. PySwigObject_Check(PyObject *op) {
  387. return ((op)->ob_type == PySwigObject_type())
  388. || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
  389. }
  390. SWIGRUNTIME PyObject *
  391. PySwigObject_New(void *ptr, swig_type_info *ty, int own);
  392. SWIGRUNTIME void
  393. PySwigObject_dealloc(PyObject *v)
  394. {
  395. PySwigObject *sobj = (PySwigObject *) v;
  396. PyObject *next = sobj->next;
  397. if (sobj->own) {
  398. swig_type_info *ty = sobj->ty;
  399. PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
  400. PyObject *destroy = data ? data->destroy : 0;
  401. if (destroy) {
  402. /* destroy is always a VARARGS method */
  403. PyObject *res;
  404. if (data->delargs) {
  405. /* we need to create a temporal object to carry the destroy operation */
  406. PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
  407. res = SWIG_Python_CallFunctor(destroy, tmp);
  408. Py_DECREF(tmp);
  409. } else {
  410. PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
  411. PyObject *mself = PyCFunction_GET_SELF(destroy);
  412. res = ((*meth)(mself, v));
  413. }
  414. Py_XDECREF(res);
  415. } else {
  416. const char *name = SWIG_TypePrettyName(ty);
  417. #if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
  418. printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
  419. #endif
  420. }
  421. }
  422. Py_XDECREF(next);
  423. PyObject_DEL(v);
  424. }
  425. SWIGRUNTIME PyObject*
  426. PySwigObject_append(PyObject* v, PyObject* next)
  427. {
  428. PySwigObject *sobj = (PySwigObject *) v;
  429. #ifndef METH_O
  430. PyObject *tmp = 0;
  431. if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
  432. next = tmp;
  433. #endif
  434. if (!PySwigObject_Check(next)) {
  435. return NULL;
  436. }
  437. sobj->next = next;
  438. Py_INCREF(next);
  439. return SWIG_Py_Void();
  440. }
  441. SWIGRUNTIME PyObject*
  442. #ifdef METH_NOARGS
  443. PySwigObject_next(PyObject* v)
  444. #else
  445. PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
  446. #endif
  447. {
  448. PySwigObject *sobj = (PySwigObject *) v;
  449. if (sobj->next) {
  450. Py_INCREF(sobj->next);
  451. return sobj->next;
  452. } else {
  453. return SWIG_Py_Void();
  454. }
  455. }
  456. SWIGINTERN PyObject*
  457. #ifdef METH_NOARGS
  458. PySwigObject_disown(PyObject *v)
  459. #else
  460. PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
  461. #endif
  462. {
  463. PySwigObject *sobj = (PySwigObject *)v;
  464. sobj->own = 0;
  465. return SWIG_Py_Void();
  466. }
  467. SWIGINTERN PyObject*
  468. #ifdef METH_NOARGS
  469. PySwigObject_acquire(PyObject *v)
  470. #else
  471. PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
  472. #endif
  473. {
  474. PySwigObject *sobj = (PySwigObject *)v;
  475. sobj->own = SWIG_POINTER_OWN;
  476. return SWIG_Py_Void();
  477. }
  478. SWIGINTERN PyObject*
  479. PySwigObject_own(PyObject *v, PyObject *args)
  480. {
  481. PyObject *val = 0;
  482. #if (PY_VERSION_HEX < 0x02020000)
  483. if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
  484. #else
  485. if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
  486. #endif
  487. {
  488. return NULL;
  489. }
  490. else
  491. {
  492. PySwigObject *sobj = (PySwigObject *)v;
  493. PyObject *obj = PyBool_FromLong(sobj->own);
  494. if (val) {
  495. #ifdef METH_NOARGS
  496. if (PyObject_IsTrue(val)) {
  497. PySwigObject_acquire(v);
  498. } else {
  499. PySwigObject_disown(v);
  500. }
  501. #else
  502. if (PyObject_IsTrue(val)) {
  503. PySwigObject_acquire(v,args);
  504. } else {
  505. PySwigObject_disown(v,args);
  506. }
  507. #endif
  508. }
  509. return obj;
  510. }
  511. }
  512. #ifdef METH_O
  513. static PyMethodDef
  514. swigobject_methods[] = {
  515. {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
  516. {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
  517. {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
  518. {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
  519. {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
  520. {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
  521. {0, 0, 0, 0}
  522. };
  523. #else
  524. static PyMethodDef
  525. swigobject_methods[] = {
  526. {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
  527. {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
  528. {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
  529. {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
  530. {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
  531. {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
  532. {0, 0, 0, 0}
  533. };
  534. #endif
  535. #if PY_VERSION_HEX < 0x02020000
  536. SWIGINTERN PyObject *
  537. PySwigObject_getattr(PySwigObject *sobj,char *name)
  538. {
  539. return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
  540. }
  541. #endif
  542. SWIGRUNTIME PyTypeObject*
  543. _PySwigObject_type(void) {
  544. static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
  545. static PyNumberMethods PySwigObject_as_number = {
  546. (binaryfunc)0, /*nb_add*/
  547. (binaryfunc)0, /*nb_subtract*/
  548. (binaryfunc)0, /*nb_multiply*/
  549. (binaryfunc)0, /*nb_divide*/
  550. (binaryfunc)0, /*nb_remainder*/
  551. (binaryfunc)0, /*nb_divmod*/
  552. (ternaryfunc)0,/*nb_power*/
  553. (unaryfunc)0, /*nb_negative*/
  554. (unaryfunc)0, /*nb_positive*/
  555. (unaryfunc)0, /*nb_absolute*/
  556. (inquiry)0, /*nb_nonzero*/
  557. 0, /*nb_invert*/
  558. 0, /*nb_lshift*/
  559. 0, /*nb_rshift*/
  560. 0, /*nb_and*/
  561. 0, /*nb_xor*/
  562. 0, /*nb_or*/
  563. (coercion)0, /*nb_coerce*/
  564. (unaryfunc)PySwigObject_long, /*nb_int*/
  565. (unaryfunc)PySwigObject_long, /*nb_long*/
  566. (unaryfunc)0, /*nb_float*/
  567. (unaryfunc)PySwigObject_oct, /*nb_oct*/
  568. (unaryfunc)PySwigObject_hex, /*nb_hex*/
  569. #if PY_VERSION_HEX >= 0x02020000
  570. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
  571. #elif PY_VERSION_HEX >= 0x02000000
  572. 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
  573. #endif
  574. };
  575. static PyTypeObject pyswigobject_type;
  576. static int type_init = 0;
  577. if (!type_init) {
  578. const PyTypeObject tmp
  579. = {
  580. PyObject_HEAD_INIT(NULL)
  581. 0, /* ob_size */
  582. (char *)"PySwigObject", /* tp_name */
  583. sizeof(PySwigObject), /* tp_basicsize */
  584. 0, /* tp_itemsize */
  585. (destructor)PySwigObject_dealloc, /* tp_dealloc */
  586. (printfunc)PySwigObject_print, /* tp_print */
  587. #if PY_VERSION_HEX < 0x02020000
  588. (getattrfunc)PySwigObject_getattr, /* tp_getattr */
  589. #else
  590. (getattrfunc)0, /* tp_getattr */
  591. #endif
  592. (setattrfunc)0, /* tp_setattr */
  593. (cmpfunc)PySwigObject_compare, /* tp_compare */
  594. (reprfunc)PySwigObject_repr, /* tp_repr */
  595. &PySwigObject_as_number, /* tp_as_number */
  596. 0, /* tp_as_sequence */
  597. 0, /* tp_as_mapping */
  598. (hashfunc)0, /* tp_hash */
  599. (ternaryfunc)0, /* tp_call */
  600. (reprfunc)PySwigObject_str, /* tp_str */
  601. PyObject_GenericGetAttr, /* tp_getattro */
  602. 0, /* tp_setattro */
  603. 0, /* tp_as_buffer */
  604. Py_TPFLAGS_DEFAULT, /* tp_flags */
  605. swigobject_doc, /* tp_doc */
  606. 0, /* tp_traverse */
  607. 0, /* tp_clear */
  608. 0, /* tp_richcompare */
  609. 0, /* tp_weaklistoffset */
  610. #if PY_VERSION_HEX >= 0x02020000
  611. 0, /* tp_iter */
  612. 0, /* tp_iternext */
  613. swigobject_methods, /* tp_methods */
  614. 0, /* tp_members */
  615. 0, /* tp_getset */
  616. 0, /* tp_base */
  617. 0, /* tp_dict */
  618. 0, /* tp_descr_get */
  619. 0, /* tp_descr_set */
  620. 0, /* tp_dictoffset */
  621. 0, /* tp_init */
  622. 0, /* tp_alloc */
  623. 0, /* tp_new */
  624. 0, /* tp_free */
  625. 0, /* tp_is_gc */
  626. 0, /* tp_bases */
  627. 0, /* tp_mro */
  628. 0, /* tp_cache */
  629. 0, /* tp_subclasses */
  630. 0, /* tp_weaklist */
  631. #endif
  632. #if PY_VERSION_HEX >= 0x02030000
  633. 0, /* tp_del */
  634. #endif
  635. #ifdef COUNT_ALLOCS
  636. 0,0,0,0 /* tp_alloc -> tp_next */
  637. #endif
  638. };
  639. pyswigobject_type = tmp;
  640. pyswigobject_type.ob_type = &PyType_Type;
  641. type_init = 1;
  642. }
  643. return &pyswigobject_type;
  644. }
  645. SWIGRUNTIME PyObject *
  646. PySwigObject_New(void *ptr, swig_type_info *ty, int own)
  647. {
  648. PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
  649. if (sobj) {
  650. sobj->ptr = ptr;
  651. sobj->ty = ty;
  652. sobj->own = own;
  653. sobj->next = 0;
  654. }
  655. return (PyObject *)sobj;
  656. }
  657. /* -----------------------------------------------------------------------------
  658. * Implements a simple Swig Packed type, and use it instead of string
  659. * ----------------------------------------------------------------------------- */
  660. typedef struct {
  661. PyObject_HEAD
  662. void *pack;
  663. swig_type_info *ty;
  664. size_t size;
  665. } PySwigPacked;
  666. SWIGRUNTIME int
  667. PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
  668. {
  669. char result[SWIG_BUFFER_SIZE];
  670. fputs("<Swig Packed ", fp);
  671. if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
  672. fputs("at ", fp);
  673. fputs(result, fp);
  674. }
  675. fputs(v->ty->name,fp);
  676. fputs(">", fp);
  677. return 0;
  678. }
  679. SWIGRUNTIME PyObject *
  680. PySwigPacked_repr(PySwigPacked *v)
  681. {
  682. char result[SWIG_BUFFER_SIZE];
  683. if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
  684. return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
  685. } else {
  686. return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
  687. }
  688. }
  689. SWIGRUNTIME PyObject *
  690. PySwigPacked_str(PySwigPacked *v)
  691. {
  692. char result[SWIG_BUFFER_SIZE];
  693. if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
  694. return PyString_FromFormat("%s%s", result, v->ty->name);
  695. } else {
  696. return PyString_FromString(v->ty->name);
  697. }
  698. }
  699. SWIGRUNTIME int
  700. PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
  701. {
  702. size_t i = v->size;
  703. size_t j = w->size;
  704. int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
  705. return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
  706. }
  707. SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
  708. SWIGRUNTIME PyTypeObject*
  709. PySwigPacked_type(void) {
  710. static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
  711. return type;
  712. }
  713. SWIGRUNTIMEINLINE int
  714. PySwigPacked_Check(PyObject *op) {
  715. return ((op)->ob_type == _PySwigPacked_type())
  716. || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
  717. }
  718. SWIGRUNTIME void
  719. PySwigPacked_dealloc(PyObject *v)
  720. {
  721. if (PySwigPacked_Check(v)) {
  722. PySwigPacked *sobj = (PySwigPacked *) v;
  723. free(sobj->pack);
  724. }
  725. PyObject_DEL(v);
  726. }
  727. SWIGRUNTIME PyTypeObject*
  728. _PySwigPacked_type(void) {
  729. static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
  730. static PyTypeObject pyswigpacked_type;
  731. static int type_init = 0;
  732. if (!type_init) {
  733. const PyTypeObject tmp
  734. = {
  735. PyObject_HEAD_INIT(NULL)
  736. 0, /* ob_size */
  737. (char *)"PySwigPacked", /* tp_name */
  738. sizeof(PySwigPacked), /* tp_basicsize */
  739. 0, /* tp_itemsize */
  740. (destructor)PySwigPacked_dealloc, /* tp_dealloc */
  741. (printfunc)PySwigPacked_print, /* tp_print */
  742. (getattrfunc)0, /* tp_getattr */
  743. (setattrfunc)0, /* tp_setattr */
  744. (cmpfunc)PySwigPacked_compare, /* tp_compare */
  745. (reprfunc)PySwigPacked_repr, /* tp_repr */
  746. 0, /* tp_as_number */
  747. 0, /* tp_as_sequence */
  748. 0, /* tp_as_mapping */
  749. (hashfunc)0, /* tp_hash */
  750. (ternaryfunc)0, /* tp_call */
  751. (reprfunc)PySwigPacked_str, /* tp_str */
  752. PyObject_GenericGetAttr, /* tp_getattro */
  753. 0, /* tp_setattro */
  754. 0, /* tp_as_buffer */
  755. Py_TPFLAGS_DEFAULT, /* tp_flags */
  756. swigpacked_doc, /* tp_doc */
  757. 0, /* tp_traverse */
  758. 0, /* tp_clear */
  759. 0, /* tp_richcompare */
  760. 0, /* tp_weaklistoffset */
  761. #if PY_VERSION_HEX >= 0x02020000
  762. 0, /* tp_iter */
  763. 0, /* tp_iternext */
  764. 0, /* tp_methods */
  765. 0, /* tp_members */
  766. 0, /* tp_getset */
  767. 0, /* tp_base */
  768. 0, /* tp_dict */
  769. 0, /* tp_descr_get */
  770. 0, /* tp_descr_set */
  771. 0, /* tp_dictoffset */
  772. 0, /* tp_init */
  773. 0, /* tp_alloc */
  774. 0, /* tp_new */
  775. 0, /* tp_free */
  776. 0, /* tp_is_gc */
  777. 0, /* tp_bases */
  778. 0, /* tp_mro */
  779. 0, /* tp_cache */
  780. 0, /* tp_subclasses */
  781. 0, /* tp_weaklist */
  782. #endif
  783. #if PY_VERSION_HEX >= 0x02030000
  784. 0, /* tp_del */
  785. #endif
  786. #ifdef COUNT_ALLOCS
  787. 0,0,0,0 /* tp_alloc -> tp_next */
  788. #endif
  789. };
  790. pyswigpacked_type = tmp;
  791. pyswigpacked_type.ob_type = &PyType_Type;
  792. type_init = 1;
  793. }
  794. return &pyswigpacked_type;
  795. }
  796. SWIGRUNTIME PyObject *
  797. PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
  798. {
  799. PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
  800. if (sobj) {
  801. void *pack = malloc(size);
  802. if (pack) {
  803. memcpy(pack, ptr, size);
  804. sobj->pack = pack;
  805. sobj->ty = ty;
  806. sobj->size = size;
  807. } else {
  808. PyObject_DEL((PyObject *) sobj);
  809. sobj = 0;
  810. }
  811. }
  812. return (PyObject *) sobj;
  813. }
  814. SWIGRUNTIME swig_type_info *
  815. PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
  816. {
  817. if (PySwigPacked_Check(obj)) {
  818. PySwigPacked *sobj = (PySwigPacked *)obj;
  819. if (sobj->size != size) return 0;
  820. memcpy(ptr, sobj->pack, size);
  821. return sobj->ty;
  822. } else {
  823. return 0;
  824. }
  825. }
  826. /* -----------------------------------------------------------------------------
  827. * pointers/data manipulation
  828. * ----------------------------------------------------------------------------- */
  829. SWIGRUNTIMEINLINE PyObject *
  830. _SWIG_This(void)
  831. {
  832. return PyString_FromString("this");
  833. }
  834. SWIGRUNTIME PyObject *
  835. SWIG_This(void)
  836. {
  837. static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
  838. return swig_this;
  839. }
  840. /* #define SWIG_PYTHON_SLOW_GETSET_THIS */
  841. SWIGRUNTIME PySwigObject *
  842. SWIG_Python_GetSwigThis(PyObject *pyobj)
  843. {
  844. if (PySwigObject_Check(pyobj)) {
  845. return (PySwigObject *) pyobj;
  846. } else {
  847. PyObject *obj = 0;
  848. #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
  849. if (PyInstance_Check(pyobj)) {
  850. obj = _PyInstance_Lookup(pyobj, SWIG_This());
  851. } else {
  852. PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
  853. if (dictptr != NULL) {
  854. PyObject *dict = *dictptr;
  855. obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
  856. } else {
  857. #ifdef PyWeakref_CheckProxy
  858. if (PyWeakref_CheckProxy(pyobj)) {
  859. PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
  860. return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
  861. }
  862. #endif
  863. obj = PyObject_GetAttr(pyobj,SWIG_This());
  864. if (obj) {
  865. Py_DECREF(obj);
  866. } else {
  867. if (PyErr_Occurred()) PyErr_Clear();
  868. return 0;
  869. }
  870. }
  871. }
  872. #else
  873. obj = PyObject_GetAttr(pyobj,SWIG_This());
  874. if (obj) {
  875. Py_DECREF(obj);
  876. } else {
  877. if (PyErr_Occurred()) PyErr_Clear();
  878. return 0;
  879. }
  880. #endif
  881. if (obj && !PySwigObject_Check(obj)) {
  882. /* a PyObject is called 'this', try to get the 'real this'
  883. PySwigObject from it */
  884. return SWIG_Python_GetSwigThis(obj);
  885. }
  886. return (PySwigObject *)obj;
  887. }
  888. }
  889. /* Acquire a pointer value */
  890. SWIGRUNTIME int
  891. SWIG_Python_AcquirePtr(PyObject *obj, int own) {
  892. if (own) {
  893. PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
  894. if (sobj) {
  895. int oldown = sobj->own;
  896. sobj->own = own;
  897. return oldown;
  898. }
  899. }
  900. return 0;
  901. }
  902. /* Convert a pointer value */
  903. SWIGRUNTIME int
  904. SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
  905. if (!obj) return SWIG_ERROR;
  906. if (obj == Py_None) {
  907. if (ptr) *ptr = 0;
  908. return SWIG_OK;
  909. } else {
  910. PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
  911. while (sobj) {
  912. void *vptr = sobj->ptr;
  913. if (ty) {
  914. swig_type_info *to = sobj->ty;
  915. if (to == ty) {
  916. /* no type cast needed */
  917. if (ptr) *ptr = vptr;
  918. break;
  919. } else {
  920. swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
  921. if (!tc) {
  922. sobj = (PySwigObject *)sobj->next;
  923. } else {
  924. if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
  925. break;
  926. }
  927. }
  928. } else {
  929. if (ptr) *ptr = vptr;
  930. break;
  931. }
  932. }
  933. if (sobj) {
  934. if (own) *own = sobj->own;
  935. if (flags & SWIG_POINTER_DISOWN) {
  936. sobj->own = 0;
  937. }
  938. return SWIG_OK;
  939. } else {
  940. int res = SWIG_ERROR;
  941. if (flags & SWIG_POINTER_IMPLICIT_CONV) {
  942. PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
  943. if (data && !data->implicitconv) {
  944. PyObject *klass = data->klass;
  945. if (klass) {
  946. PyObject *impconv;
  947. data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
  948. impconv = SWIG_Python_CallFunctor(klass, obj);
  949. data->implicitconv = 0;
  950. if (PyErr_Occurred()) {
  951. PyErr_Clear();
  952. impconv = 0;
  953. }
  954. if (impconv) {
  955. PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
  956. if (iobj) {
  957. void *vptr;
  958. res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
  959. if (SWIG_IsOK(res)) {
  960. if (ptr) {
  961. *ptr = vptr;
  962. /* transfer the ownership to 'ptr' */
  963. iobj->own = 0;
  964. res = SWIG_AddCast(res);
  965. res = SWIG_AddNewMask(res);
  966. } else {
  967. res = SWIG_AddCast(res);
  968. }
  969. }
  970. }
  971. Py_DECREF(impconv);
  972. }
  973. }
  974. }
  975. }
  976. return res;
  977. }
  978. }
  979. }
  980. /* Convert a function ptr value */
  981. SWIGRUNTIME int
  982. SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
  983. if (!PyCFunction_Check(obj)) {
  984. return SWIG_ConvertPtr(obj, ptr, ty, 0);
  985. } else {
  986. void *vptr = 0;
  987. /* here we get the method pointer for callbacks */
  988. char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
  989. const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
  990. if (desc) {
  991. desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
  992. if (!desc) return SWIG_ERROR;
  993. }
  994. if (ty) {
  995. swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
  996. if (!tc) return SWIG_ERROR;
  997. *ptr = SWIG_TypeCast(tc,vptr);
  998. } else {
  999. *ptr = vptr;
  1000. }
  1001. return SWIG_OK;
  1002. }
  1003. }
  1004. /* Convert a packed value value */
  1005. SWIGRUNTIME int
  1006. SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
  1007. swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
  1008. if (!to) return SWIG_ERROR;
  1009. if (ty) {
  1010. if (to != ty) {
  1011. /* check type cast? */
  1012. swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
  1013. if (!tc) return SWIG_ERROR;
  1014. }
  1015. }
  1016. return SWIG_OK;
  1017. }
  1018. /* -----------------------------------------------------------------------------
  1019. * Create a new pointer object
  1020. * ----------------------------------------------------------------------------- */
  1021. /*
  1022. Create a new instance object, whitout calling __init__, and set the
  1023. 'this' attribute.
  1024. */
  1025. SWIGRUNTIME PyObject*
  1026. SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
  1027. {
  1028. #if (PY_VERSION_HEX >= 0x02020000)
  1029. PyObject *inst = 0;
  1030. PyObject *newraw = data->newraw;
  1031. if (newraw) {
  1032. inst = PyObject_Call(newraw, data->newargs, NULL);
  1033. if (inst) {
  1034. #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
  1035. PyObject **dictptr = _PyObject_GetDictPtr(inst);
  1036. if (dictptr != NULL) {
  1037. PyObject *dict = *dictptr;
  1038. if (dict == NULL) {
  1039. dict = PyDict_New();
  1040. *dictptr = dict;
  1041. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1042. }
  1043. }
  1044. #else
  1045. PyObject *key = SWIG_This();
  1046. PyObject_SetAttr(inst, key, swig_this);
  1047. #endif
  1048. }
  1049. } else {
  1050. PyObject *dict = PyDict_New();
  1051. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1052. inst = PyInstance_NewRaw(data->newargs, dict);
  1053. Py_DECREF(dict);
  1054. }
  1055. return inst;
  1056. #else
  1057. #if (PY_VERSION_HEX >= 0x02010000)
  1058. PyObject *inst;
  1059. PyObject *dict = PyDict_New();
  1060. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1061. inst = PyInstance_NewRaw(data->newargs, dict);
  1062. Py_DECREF(dict);
  1063. return (PyObject *) inst;
  1064. #else
  1065. PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
  1066. if (inst == NULL) {
  1067. return NULL;
  1068. }
  1069. inst->in_class = (PyClassObject *)data->newargs;
  1070. Py_INCREF(inst->in_class);
  1071. inst->in_dict = PyDict_New();
  1072. if (inst->in_dict == NULL) {
  1073. Py_DECREF(inst);
  1074. return NULL;
  1075. }
  1076. #ifdef Py_TPFLAGS_HAVE_WEAKREFS
  1077. inst->in_weakreflist = NULL;
  1078. #endif
  1079. #ifdef Py_TPFLAGS_GC
  1080. PyObject_GC_Init(inst);
  1081. #endif
  1082. PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
  1083. return (PyObject *) inst;
  1084. #endif
  1085. #endif
  1086. }
  1087. SWIGRUNTIME void
  1088. SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
  1089. {
  1090. PyObject *dict;
  1091. #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
  1092. PyObject **dictptr = _PyObject_GetDictPtr(inst);
  1093. if (dictptr != NULL) {
  1094. dict = *dictptr;
  1095. if (dict == NULL) {
  1096. dict = PyDict_New();
  1097. *dictptr = dict;
  1098. }
  1099. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1100. return;
  1101. }
  1102. #endif
  1103. dict = PyObject_GetAttrString(inst, "__dict__");
  1104. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1105. Py_DECREF(dict);
  1106. }
  1107. SWIGINTERN PyObject *
  1108. SWIG_Python_InitShadowInstance(PyObject *args) {
  1109. PyObject *obj[2];
  1110. if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
  1111. return NULL;
  1112. } else {
  1113. PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
  1114. if (sthis) {
  1115. PySwigObject_append((PyObject*) sthis, obj[1]);
  1116. } else {
  1117. SWIG_Python_SetSwigThis(obj[0], obj[1]);
  1118. }
  1119. return SWIG_Py_Void();
  1120. }
  1121. }
  1122. /* Create a new pointer object */
  1123. SWIGRUNTIME PyObject *
  1124. SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
  1125. if (!ptr) {
  1126. return SWIG_Py_Void();
  1127. } else {
  1128. int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
  1129. PyObject *robj = PySwigObject_New(ptr, type, own);
  1130. PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
  1131. if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
  1132. PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
  1133. if (inst) {
  1134. Py_DECREF(robj);
  1135. robj = inst;
  1136. }
  1137. }
  1138. return robj;
  1139. }
  1140. }
  1141. /* Create a new packed object */
  1142. SWIGRUNTIMEINLINE PyObject *
  1143. SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
  1144. return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
  1145. }
  1146. /* -----------------------------------------------------------------------------*
  1147. * Get type list
  1148. * -----------------------------------------------------------------------------*/
  1149. #ifdef SWIG_LINK_RUNTIME
  1150. void *SWIG_ReturnGlobalTypeList(void *);
  1151. #endif
  1152. SWIGRUNTIME swig_module_info *
  1153. SWIG_Python_GetModule(void) {
  1154. static void *type_pointer = (void *)0;
  1155. /* first check if module already created */
  1156. if (!type_pointer) {
  1157. #ifdef SWIG_LINK_RUNTIME
  1158. type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
  1159. #else
  1160. type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
  1161. (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
  1162. if (PyErr_Occurred()) {
  1163. PyErr_Clear();
  1164. type_pointer = (void *)0;
  1165. }
  1166. #endif
  1167. }
  1168. return (swig_module_info *) type_pointer;
  1169. }
  1170. #if PY_MAJOR_VERSION < 2
  1171. /* PyModule_AddObject function was introduced in Python 2.0. The following function
  1172. is copied out of Python/modsupport.c in python version 2.3.4 */
  1173. SWIGINTERN int
  1174. PyModule_AddObject(PyObject *m, char *name, PyObject *o)
  1175. {
  1176. PyObject *dict;
  1177. if (!PyModule_Check(m)) {
  1178. PyErr_SetString(PyExc_TypeError,
  1179. "PyModule_AddObject() needs module as first arg");
  1180. return SWIG_ERROR;
  1181. }
  1182. if (!o) {
  1183. PyErr_SetString(PyExc_TypeError,
  1184. "PyModule_AddObject() needs non-NULL value");
  1185. return SWIG_ERROR;
  1186. }
  1187. dict = PyModule_GetDict(m);
  1188. if (dict == NULL) {
  1189. /* Internal error -- modules must have a dict! */
  1190. PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
  1191. PyModule_GetName(m));
  1192. return SWIG_ERROR;
  1193. }
  1194. if (PyDict_SetItemString(dict, name, o))
  1195. return SWIG_ERROR;
  1196. Py_DECREF(o);
  1197. return SWIG_OK;
  1198. }
  1199. #endif
  1200. SWIGRUNTIME void
  1201. SWIG_Python_DestroyModule(void *vptr)
  1202. {
  1203. swig_module_info *swig_module = (swig_module_info *) vptr;
  1204. swig_type_info **types = swig_module->types;
  1205. size_t i;
  1206. for (i =0; i < swig_module->size; ++i) {
  1207. swig_type_info *ty = types[i];
  1208. if (ty->owndata) {
  1209. PySwigClientData *data = (PySwigClientData *) ty->clientdata;
  1210. if (data) PySwigClientData_Del(data);
  1211. }
  1212. }
  1213. Py_DECREF(SWIG_This());
  1214. }
  1215. SWIGRUNTIME void
  1216. SWIG_Python_SetModule(swig_module_info *swig_module) {
  1217. static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
  1218. PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
  1219. swig_empty_runtime_method_table);
  1220. PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
  1221. if (pointer && module) {
  1222. PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
  1223. } else {
  1224. Py_XDECREF(pointer);
  1225. }
  1226. }
  1227. /* The python cached type query */
  1228. SWIGRUNTIME PyObject *
  1229. SWIG_Python_TypeCache() {
  1230. static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
  1231. return cache;
  1232. }
  1233. SWIGRUNTIME swig_type_info *
  1234. SWIG_Python_TypeQuery(const char *type)
  1235. {
  1236. PyObject *cache = SWIG_Python_TypeCache();
  1237. PyObject *key = PyString_FromString(type);
  1238. PyObject *obj = PyDict_GetItem(cache, key);
  1239. swig_type_info *descriptor;
  1240. if (obj) {
  1241. descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
  1242. } else {
  1243. swig_module_info *swig_module = SWIG_Python_GetModule();
  1244. descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
  1245. if (descriptor) {
  1246. obj = PyCObject_FromVoidPtr(descriptor, NULL);
  1247. PyDict_SetItem(cache, key, obj);
  1248. Py_DECREF(obj);
  1249. }
  1250. }
  1251. Py_DECREF(key);
  1252. return descriptor;
  1253. }
  1254. /*
  1255. For backward compatibility only
  1256. */
  1257. #define SWIG_POINTER_EXCEPTION 0
  1258. #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
  1259. #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
  1260. SWIGRUNTIME int
  1261. SWIG_Python_AddErrMesg(const char* mesg, int infront)
  1262. {
  1263. if (PyErr_Occurred()) {
  1264. PyObject *type = 0;
  1265. PyObject *value = 0;
  1266. PyObject *traceback = 0;
  1267. PyErr_Fetch(&type, &value, &traceback);
  1268. if (value) {
  1269. PyObject *old_str = PyObject_Str(value);
  1270. Py_XINCREF(type);
  1271. PyErr_Clear();
  1272. if (infront) {
  1273. PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
  1274. } else {
  1275. PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
  1276. }
  1277. Py_DECREF(old_str);
  1278. }
  1279. return 1;
  1280. } else {
  1281. return 0;
  1282. }
  1283. }
  1284. SWIGRUNTIME int
  1285. SWIG_Python_ArgFail(int argnum)
  1286. {
  1287. if (PyErr_Occurred()) {
  1288. /* add information about failing argument */
  1289. char mesg[256];
  1290. PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
  1291. return SWIG_Python_AddErrMesg(mesg, 1);
  1292. } else {
  1293. return 0;
  1294. }
  1295. }
  1296. SWIGRUNTIMEINLINE const char *
  1297. PySwigObject_GetDesc(PyObject *self)
  1298. {
  1299. PySwigObject *v = (PySwigObject *)self;
  1300. swig_type_info *ty = v ? v->ty : 0;
  1301. return ty ? ty->str : (char*)"";
  1302. }
  1303. SWIGRUNTIME void
  1304. SWIG_Python_TypeError(const char *type, PyObject *obj)
  1305. {
  1306. if (type) {
  1307. #if defined(SWIG_COBJECT_TYPES)
  1308. if (obj && PySwigObject_Check(obj)) {
  1309. const char *otype = (const char *) PySwigObject_GetDesc(obj);
  1310. if (otype) {
  1311. PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
  1312. type, otype);
  1313. return;
  1314. }
  1315. } else
  1316. #endif
  1317. {
  1318. const char *otype = (obj ? obj->ob_type->tp_name : 0);
  1319. if (otype) {
  1320. PyObject *str = PyObject_Str(obj);
  1321. const char *cstr = str ? PyString_AsString(str) : 0;
  1322. if (cstr) {
  1323. PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
  1324. type, otype, cstr);
  1325. } else {
  1326. PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
  1327. type, otype);
  1328. }
  1329. Py_XDECREF(str);
  1330. return;
  1331. }
  1332. }
  1333. PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
  1334. } else {
  1335. PyErr_Format(PyExc_TypeError, "unexpected type is received");
  1336. }
  1337. }
  1338. /* Convert a pointer value, signal an exception on a type mismatch */
  1339. SWIGRUNTIME void *
  1340. SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
  1341. void *result;
  1342. if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
  1343. PyErr_Clear();
  1344. if (flags & SWIG_POINTER_EXCEPTION) {
  1345. SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
  1346. SWIG_Python_ArgFail(argnum);
  1347. }
  1348. }
  1349. return result;
  1350. }
  1351. #ifdef __cplusplus
  1352. #if 0
  1353. { /* cc-mode */
  1354. #endif
  1355. }
  1356. #endif