pyrun.swg 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829
  1. /* -----------------------------------------------------------------------------
  2. * pyrun.swg
  3. *
  4. * This file contains the runtime support for Python modules
  5. * and includes code for managing global variables and pointer
  6. * type checking.
  7. *
  8. * ----------------------------------------------------------------------------- */
  9. /* Common SWIG API */
  10. /* for raw pointers */
  11. #define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
  12. #define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags)
  13. #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
  14. #ifdef SWIGPYTHON_BUILTIN
  15. #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(self, ptr, type, flags)
  16. #else
  17. #define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
  18. #endif
  19. #define SWIG_InternalNewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
  20. #define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty)
  21. #define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src)
  22. #define swig_owntype int
  23. /* for raw packed data */
  24. #define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
  25. #define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
  26. /* for class or struct pointers */
  27. #define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags)
  28. #define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags)
  29. /* for C or C++ function pointers */
  30. #define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
  31. #define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(NULL, ptr, type, 0)
  32. /* for C++ member pointers, ie, member methods */
  33. #define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
  34. #define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
  35. /* Runtime API */
  36. #define SWIG_GetModule(clientdata) SWIG_Python_GetModule(clientdata)
  37. #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
  38. #define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
  39. #define SWIG_SetErrorObj SWIG_Python_SetErrorObj
  40. #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
  41. #define SWIG_ErrorType(code) SWIG_Python_ErrorType(code)
  42. #define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg)
  43. #define SWIG_fail goto fail
  44. /* Runtime API implementation */
  45. /* Error manipulation */
  46. SWIGINTERN void
  47. SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
  48. SWIG_PYTHON_THREAD_BEGIN_BLOCK;
  49. PyErr_SetObject(errtype, obj);
  50. Py_DECREF(obj);
  51. SWIG_PYTHON_THREAD_END_BLOCK;
  52. }
  53. SWIGINTERN void
  54. SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
  55. SWIG_PYTHON_THREAD_BEGIN_BLOCK;
  56. PyErr_SetString(errtype, msg);
  57. SWIG_PYTHON_THREAD_END_BLOCK;
  58. }
  59. #define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj)
  60. /* Set a constant value */
  61. #if defined(SWIGPYTHON_BUILTIN)
  62. SWIGINTERN void
  63. SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
  64. PyObject *s = PyString_InternFromString(key);
  65. PyList_Append(seq, s);
  66. Py_DECREF(s);
  67. }
  68. SWIGINTERN void
  69. SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {
  70. #if PY_VERSION_HEX < 0x02030000
  71. PyDict_SetItemString(d, (char *)name, obj);
  72. #else
  73. PyDict_SetItemString(d, name, obj);
  74. #endif
  75. Py_DECREF(obj);
  76. if (public_interface)
  77. SwigPyBuiltin_AddPublicSymbol(public_interface, name);
  78. }
  79. #else
  80. SWIGINTERN void
  81. SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {
  82. #if PY_VERSION_HEX < 0x02030000
  83. PyDict_SetItemString(d, (char *)name, obj);
  84. #else
  85. PyDict_SetItemString(d, name, obj);
  86. #endif
  87. Py_DECREF(obj);
  88. }
  89. #endif
  90. /* Append a value to the result obj */
  91. SWIGINTERN PyObject*
  92. SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
  93. #if !defined(SWIG_PYTHON_OUTPUT_TUPLE)
  94. if (!result) {
  95. result = obj;
  96. } else if (result == Py_None) {
  97. Py_DECREF(result);
  98. result = obj;
  99. } else {
  100. if (!PyList_Check(result)) {
  101. PyObject *o2 = result;
  102. result = PyList_New(1);
  103. PyList_SetItem(result, 0, o2);
  104. }
  105. PyList_Append(result,obj);
  106. Py_DECREF(obj);
  107. }
  108. return result;
  109. #else
  110. PyObject* o2;
  111. PyObject* o3;
  112. if (!result) {
  113. result = obj;
  114. } else if (result == Py_None) {
  115. Py_DECREF(result);
  116. result = obj;
  117. } else {
  118. if (!PyTuple_Check(result)) {
  119. o2 = result;
  120. result = PyTuple_New(1);
  121. PyTuple_SET_ITEM(result, 0, o2);
  122. }
  123. o3 = PyTuple_New(1);
  124. PyTuple_SET_ITEM(o3, 0, obj);
  125. o2 = result;
  126. result = PySequence_Concat(o2, o3);
  127. Py_DECREF(o2);
  128. Py_DECREF(o3);
  129. }
  130. return result;
  131. #endif
  132. }
  133. /* Unpack the argument tuple */
  134. SWIGINTERN Py_ssize_t
  135. SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
  136. {
  137. if (!args) {
  138. if (!min && !max) {
  139. return 1;
  140. } else {
  141. PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none",
  142. name, (min == max ? "" : "at least "), (int)min);
  143. return 0;
  144. }
  145. }
  146. if (!PyTuple_Check(args)) {
  147. if (min <= 1 && max >= 1) {
  148. Py_ssize_t i;
  149. objs[0] = args;
  150. for (i = 1; i < max; ++i) {
  151. objs[i] = 0;
  152. }
  153. return 2;
  154. }
  155. PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
  156. return 0;
  157. } else {
  158. Py_ssize_t l = PyTuple_GET_SIZE(args);
  159. if (l < min) {
  160. PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
  161. name, (min == max ? "" : "at least "), (int)min, (int)l);
  162. return 0;
  163. } else if (l > max) {
  164. PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d",
  165. name, (min == max ? "" : "at most "), (int)max, (int)l);
  166. return 0;
  167. } else {
  168. Py_ssize_t i;
  169. for (i = 0; i < l; ++i) {
  170. objs[i] = PyTuple_GET_ITEM(args, i);
  171. }
  172. for (; l < max; ++l) {
  173. objs[l] = 0;
  174. }
  175. return i + 1;
  176. }
  177. }
  178. }
  179. /* A functor is a function object with one single object argument */
  180. #if PY_VERSION_HEX >= 0x02020000
  181. #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL);
  182. #else
  183. #define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj);
  184. #endif
  185. /*
  186. Helper for static pointer initialization for both C and C++ code, for example
  187. static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...);
  188. */
  189. #ifdef __cplusplus
  190. #define SWIG_STATIC_POINTER(var) var
  191. #else
  192. #define SWIG_STATIC_POINTER(var) var = 0; if (!var) var
  193. #endif
  194. /* -----------------------------------------------------------------------------
  195. * Pointer declarations
  196. * ----------------------------------------------------------------------------- */
  197. /* Flags for new pointer objects */
  198. #define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1)
  199. #define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN)
  200. #define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1)
  201. #define SWIG_BUILTIN_TP_INIT (SWIG_POINTER_OWN << 2)
  202. #define SWIG_BUILTIN_INIT (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
  203. #ifdef __cplusplus
  204. extern "C" {
  205. #endif
  206. /* How to access Py_None */
  207. #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
  208. # ifndef SWIG_PYTHON_NO_BUILD_NONE
  209. # ifndef SWIG_PYTHON_BUILD_NONE
  210. # define SWIG_PYTHON_BUILD_NONE
  211. # endif
  212. # endif
  213. #endif
  214. #ifdef SWIG_PYTHON_BUILD_NONE
  215. # ifdef Py_None
  216. # undef Py_None
  217. # define Py_None SWIG_Py_None()
  218. # endif
  219. SWIGRUNTIMEINLINE PyObject *
  220. _SWIG_Py_None(void)
  221. {
  222. PyObject *none = Py_BuildValue((char*)"");
  223. Py_DECREF(none);
  224. return none;
  225. }
  226. SWIGRUNTIME PyObject *
  227. SWIG_Py_None(void)
  228. {
  229. static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None();
  230. return none;
  231. }
  232. #endif
  233. /* The python void return value */
  234. SWIGRUNTIMEINLINE PyObject *
  235. SWIG_Py_Void(void)
  236. {
  237. PyObject *none = Py_None;
  238. Py_INCREF(none);
  239. return none;
  240. }
  241. /* SwigPyClientData */
  242. typedef struct {
  243. PyObject *klass;
  244. PyObject *newraw;
  245. PyObject *newargs;
  246. PyObject *destroy;
  247. int delargs;
  248. int implicitconv;
  249. PyTypeObject *pytype;
  250. } SwigPyClientData;
  251. SWIGRUNTIMEINLINE int
  252. SWIG_Python_CheckImplicit(swig_type_info *ty)
  253. {
  254. SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
  255. return data ? data->implicitconv : 0;
  256. }
  257. SWIGRUNTIMEINLINE PyObject *
  258. SWIG_Python_ExceptionType(swig_type_info *desc) {
  259. SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
  260. PyObject *klass = data ? data->klass : 0;
  261. return (klass ? klass : PyExc_RuntimeError);
  262. }
  263. SWIGRUNTIME SwigPyClientData *
  264. SwigPyClientData_New(PyObject* obj)
  265. {
  266. if (!obj) {
  267. return 0;
  268. } else {
  269. SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
  270. /* the klass element */
  271. data->klass = obj;
  272. Py_INCREF(data->klass);
  273. /* the newraw method and newargs arguments used to create a new raw instance */
  274. if (PyClass_Check(obj)) {
  275. data->newraw = 0;
  276. data->newargs = obj;
  277. Py_INCREF(obj);
  278. } else {
  279. #if (PY_VERSION_HEX < 0x02020000)
  280. data->newraw = 0;
  281. #else
  282. data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__");
  283. #endif
  284. if (data->newraw) {
  285. Py_INCREF(data->newraw);
  286. data->newargs = PyTuple_New(1);
  287. PyTuple_SetItem(data->newargs, 0, obj);
  288. } else {
  289. data->newargs = obj;
  290. }
  291. Py_INCREF(data->newargs);
  292. }
  293. /* the destroy method, aka as the C++ delete method */
  294. data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__");
  295. if (PyErr_Occurred()) {
  296. PyErr_Clear();
  297. data->destroy = 0;
  298. }
  299. if (data->destroy) {
  300. int flags;
  301. Py_INCREF(data->destroy);
  302. flags = PyCFunction_GET_FLAGS(data->destroy);
  303. #ifdef METH_O
  304. data->delargs = !(flags & (METH_O));
  305. #else
  306. data->delargs = 0;
  307. #endif
  308. } else {
  309. data->delargs = 0;
  310. }
  311. data->implicitconv = 0;
  312. data->pytype = 0;
  313. return data;
  314. }
  315. }
  316. SWIGRUNTIME void
  317. SwigPyClientData_Del(SwigPyClientData *data) {
  318. Py_XDECREF(data->newraw);
  319. Py_XDECREF(data->newargs);
  320. Py_XDECREF(data->destroy);
  321. }
  322. /* =============== SwigPyObject =====================*/
  323. typedef struct {
  324. PyObject_HEAD
  325. void *ptr;
  326. swig_type_info *ty;
  327. int own;
  328. PyObject *next;
  329. #ifdef SWIGPYTHON_BUILTIN
  330. PyObject *dict;
  331. #endif
  332. } SwigPyObject;
  333. #ifdef SWIGPYTHON_BUILTIN
  334. SWIGRUNTIME PyObject *
  335. SwigPyObject_get___dict__(PyObject *v, PyObject *SWIGUNUSEDPARM(args))
  336. {
  337. SwigPyObject *sobj = (SwigPyObject *)v;
  338. if (!sobj->dict)
  339. sobj->dict = PyDict_New();
  340. Py_INCREF(sobj->dict);
  341. return sobj->dict;
  342. }
  343. #endif
  344. SWIGRUNTIME PyObject *
  345. SwigPyObject_long(SwigPyObject *v)
  346. {
  347. return PyLong_FromVoidPtr(v->ptr);
  348. }
  349. SWIGRUNTIME PyObject *
  350. SwigPyObject_format(const char* fmt, SwigPyObject *v)
  351. {
  352. PyObject *res = NULL;
  353. PyObject *args = PyTuple_New(1);
  354. if (args) {
  355. if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
  356. PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
  357. if (ofmt) {
  358. #if PY_VERSION_HEX >= 0x03000000
  359. res = PyUnicode_Format(ofmt,args);
  360. #else
  361. res = PyString_Format(ofmt,args);
  362. #endif
  363. Py_DECREF(ofmt);
  364. }
  365. Py_DECREF(args);
  366. }
  367. }
  368. return res;
  369. }
  370. SWIGRUNTIME PyObject *
  371. SwigPyObject_oct(SwigPyObject *v)
  372. {
  373. return SwigPyObject_format("%o",v);
  374. }
  375. SWIGRUNTIME PyObject *
  376. SwigPyObject_hex(SwigPyObject *v)
  377. {
  378. return SwigPyObject_format("%x",v);
  379. }
  380. SWIGRUNTIME PyObject *
  381. #ifdef METH_NOARGS
  382. SwigPyObject_repr(SwigPyObject *v)
  383. #else
  384. SwigPyObject_repr(SwigPyObject *v, PyObject *args)
  385. #endif
  386. {
  387. const char *name = SWIG_TypePrettyName(v->ty);
  388. PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
  389. if (v->next) {
  390. # ifdef METH_NOARGS
  391. PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
  392. # else
  393. PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
  394. # endif
  395. # if PY_VERSION_HEX >= 0x03000000
  396. PyObject *joined = PyUnicode_Concat(repr, nrep);
  397. Py_DecRef(repr);
  398. Py_DecRef(nrep);
  399. repr = joined;
  400. # else
  401. PyString_ConcatAndDel(&repr,nrep);
  402. # endif
  403. }
  404. return repr;
  405. }
  406. SWIGRUNTIME int
  407. SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
  408. {
  409. void *i = v->ptr;
  410. void *j = w->ptr;
  411. return (i < j) ? -1 : ((i > j) ? 1 : 0);
  412. }
  413. /* Added for Python 3.x, would it also be useful for Python 2.x? */
  414. SWIGRUNTIME PyObject*
  415. SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
  416. {
  417. PyObject* res;
  418. if( op != Py_EQ && op != Py_NE ) {
  419. Py_INCREF(Py_NotImplemented);
  420. return Py_NotImplemented;
  421. }
  422. res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);
  423. return res;
  424. }
  425. SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
  426. #ifdef SWIGPYTHON_BUILTIN
  427. static swig_type_info *SwigPyObject_stype = 0;
  428. SWIGRUNTIME PyTypeObject*
  429. SwigPyObject_type(void) {
  430. SwigPyClientData *cd;
  431. assert(SwigPyObject_stype);
  432. cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
  433. assert(cd);
  434. assert(cd->pytype);
  435. return cd->pytype;
  436. }
  437. #else
  438. SWIGRUNTIME PyTypeObject*
  439. SwigPyObject_type(void) {
  440. static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
  441. return type;
  442. }
  443. #endif
  444. SWIGRUNTIMEINLINE int
  445. SwigPyObject_Check(PyObject *op) {
  446. #ifdef SWIGPYTHON_BUILTIN
  447. PyTypeObject *target_tp = SwigPyObject_type();
  448. if (PyType_IsSubtype(op->ob_type, target_tp))
  449. return 1;
  450. return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0);
  451. #else
  452. return (Py_TYPE(op) == SwigPyObject_type())
  453. || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
  454. #endif
  455. }
  456. SWIGRUNTIME PyObject *
  457. SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
  458. SWIGRUNTIME void
  459. SwigPyObject_dealloc(PyObject *v)
  460. {
  461. SwigPyObject *sobj = (SwigPyObject *) v;
  462. PyObject *next = sobj->next;
  463. if (sobj->own == SWIG_POINTER_OWN) {
  464. swig_type_info *ty = sobj->ty;
  465. SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
  466. PyObject *destroy = data ? data->destroy : 0;
  467. if (destroy) {
  468. /* destroy is always a VARARGS method */
  469. PyObject *res;
  470. /* PyObject_CallFunction() has the potential to silently drop
  471. the active active exception. In cases of unnamed temporary
  472. variable or where we just finished iterating over a generator
  473. StopIteration will be active right now, and this needs to
  474. remain true upon return from SwigPyObject_dealloc. So save
  475. and restore. */
  476. PyObject *val = NULL, *type = NULL, *tb = NULL;
  477. PyErr_Fetch(&val, &type, &tb);
  478. if (data->delargs) {
  479. /* we need to create a temporary object to carry the destroy operation */
  480. PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
  481. res = SWIG_Python_CallFunctor(destroy, tmp);
  482. Py_DECREF(tmp);
  483. } else {
  484. PyCFunction meth = PyCFunction_GET_FUNCTION(destroy);
  485. PyObject *mself = PyCFunction_GET_SELF(destroy);
  486. res = ((*meth)(mself, v));
  487. }
  488. if (!res)
  489. PyErr_WriteUnraisable(destroy);
  490. PyErr_Restore(val, type, tb);
  491. Py_XDECREF(res);
  492. }
  493. #if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
  494. else {
  495. const char *name = SWIG_TypePrettyName(ty);
  496. printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
  497. }
  498. #endif
  499. }
  500. Py_XDECREF(next);
  501. PyObject_DEL(v);
  502. }
  503. SWIGRUNTIME PyObject*
  504. SwigPyObject_append(PyObject* v, PyObject* next)
  505. {
  506. SwigPyObject *sobj = (SwigPyObject *) v;
  507. #ifndef METH_O
  508. PyObject *tmp = 0;
  509. if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
  510. next = tmp;
  511. #endif
  512. if (!SwigPyObject_Check(next)) {
  513. PyErr_SetString(PyExc_TypeError, "Attempt to append a non SwigPyObject");
  514. return NULL;
  515. }
  516. sobj->next = next;
  517. Py_INCREF(next);
  518. return SWIG_Py_Void();
  519. }
  520. SWIGRUNTIME PyObject*
  521. #ifdef METH_NOARGS
  522. SwigPyObject_next(PyObject* v)
  523. #else
  524. SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
  525. #endif
  526. {
  527. SwigPyObject *sobj = (SwigPyObject *) v;
  528. if (sobj->next) {
  529. Py_INCREF(sobj->next);
  530. return sobj->next;
  531. } else {
  532. return SWIG_Py_Void();
  533. }
  534. }
  535. SWIGINTERN PyObject*
  536. #ifdef METH_NOARGS
  537. SwigPyObject_disown(PyObject *v)
  538. #else
  539. SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
  540. #endif
  541. {
  542. SwigPyObject *sobj = (SwigPyObject *)v;
  543. sobj->own = 0;
  544. return SWIG_Py_Void();
  545. }
  546. SWIGINTERN PyObject*
  547. #ifdef METH_NOARGS
  548. SwigPyObject_acquire(PyObject *v)
  549. #else
  550. SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
  551. #endif
  552. {
  553. SwigPyObject *sobj = (SwigPyObject *)v;
  554. sobj->own = SWIG_POINTER_OWN;
  555. return SWIG_Py_Void();
  556. }
  557. SWIGINTERN PyObject*
  558. SwigPyObject_own(PyObject *v, PyObject *args)
  559. {
  560. PyObject *val = 0;
  561. #if (PY_VERSION_HEX < 0x02020000)
  562. if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
  563. #elif (PY_VERSION_HEX < 0x02050000)
  564. if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val))
  565. #else
  566. if (!PyArg_UnpackTuple(args, "own", 0, 1, &val))
  567. #endif
  568. {
  569. return NULL;
  570. }
  571. else
  572. {
  573. SwigPyObject *sobj = (SwigPyObject *)v;
  574. PyObject *obj = PyBool_FromLong(sobj->own);
  575. if (val) {
  576. #ifdef METH_NOARGS
  577. if (PyObject_IsTrue(val)) {
  578. SwigPyObject_acquire(v);
  579. } else {
  580. SwigPyObject_disown(v);
  581. }
  582. #else
  583. if (PyObject_IsTrue(val)) {
  584. SwigPyObject_acquire(v,args);
  585. } else {
  586. SwigPyObject_disown(v,args);
  587. }
  588. #endif
  589. }
  590. return obj;
  591. }
  592. }
  593. #ifdef METH_O
  594. static PyMethodDef
  595. swigobject_methods[] = {
  596. {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
  597. {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"acquires ownership of the pointer"},
  598. {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
  599. {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
  600. {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
  601. {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"},
  602. {0, 0, 0, 0}
  603. };
  604. #else
  605. static PyMethodDef
  606. swigobject_methods[] = {
  607. {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
  608. {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"acquires ownership of the pointer"},
  609. {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
  610. {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
  611. {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
  612. {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"},
  613. {0, 0, 0, 0}
  614. };
  615. #endif
  616. #if PY_VERSION_HEX < 0x02020000
  617. SWIGINTERN PyObject *
  618. SwigPyObject_getattr(SwigPyObject *sobj,char *name)
  619. {
  620. return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
  621. }
  622. #endif
  623. SWIGRUNTIME PyTypeObject*
  624. SwigPyObject_TypeOnce(void) {
  625. static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
  626. static PyNumberMethods SwigPyObject_as_number = {
  627. (binaryfunc)0, /*nb_add*/
  628. (binaryfunc)0, /*nb_subtract*/
  629. (binaryfunc)0, /*nb_multiply*/
  630. /* nb_divide removed in Python 3 */
  631. #if PY_VERSION_HEX < 0x03000000
  632. (binaryfunc)0, /*nb_divide*/
  633. #endif
  634. (binaryfunc)0, /*nb_remainder*/
  635. (binaryfunc)0, /*nb_divmod*/
  636. (ternaryfunc)0,/*nb_power*/
  637. (unaryfunc)0, /*nb_negative*/
  638. (unaryfunc)0, /*nb_positive*/
  639. (unaryfunc)0, /*nb_absolute*/
  640. (inquiry)0, /*nb_nonzero*/
  641. 0, /*nb_invert*/
  642. 0, /*nb_lshift*/
  643. 0, /*nb_rshift*/
  644. 0, /*nb_and*/
  645. 0, /*nb_xor*/
  646. 0, /*nb_or*/
  647. #if PY_VERSION_HEX < 0x03000000
  648. 0, /*nb_coerce*/
  649. #endif
  650. (unaryfunc)SwigPyObject_long, /*nb_int*/
  651. #if PY_VERSION_HEX < 0x03000000
  652. (unaryfunc)SwigPyObject_long, /*nb_long*/
  653. #else
  654. 0, /*nb_reserved*/
  655. #endif
  656. (unaryfunc)0, /*nb_float*/
  657. #if PY_VERSION_HEX < 0x03000000
  658. (unaryfunc)SwigPyObject_oct, /*nb_oct*/
  659. (unaryfunc)SwigPyObject_hex, /*nb_hex*/
  660. #endif
  661. #if PY_VERSION_HEX >= 0x03050000 /* 3.5 */
  662. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_matrix_multiply */
  663. #elif PY_VERSION_HEX >= 0x03000000 /* 3.0 */
  664. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
  665. #elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
  666. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
  667. #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
  668. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
  669. #elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
  670. 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
  671. #endif
  672. };
  673. static PyTypeObject swigpyobject_type;
  674. static int type_init = 0;
  675. if (!type_init) {
  676. const PyTypeObject tmp = {
  677. /* PyObject header changed in Python 3 */
  678. #if PY_VERSION_HEX >= 0x03000000
  679. PyVarObject_HEAD_INIT(NULL, 0)
  680. #else
  681. PyObject_HEAD_INIT(NULL)
  682. 0, /* ob_size */
  683. #endif
  684. (char *)"SwigPyObject", /* tp_name */
  685. sizeof(SwigPyObject), /* tp_basicsize */
  686. 0, /* tp_itemsize */
  687. (destructor)SwigPyObject_dealloc, /* tp_dealloc */
  688. 0, /* tp_print */
  689. #if PY_VERSION_HEX < 0x02020000
  690. (getattrfunc)SwigPyObject_getattr, /* tp_getattr */
  691. #else
  692. (getattrfunc)0, /* tp_getattr */
  693. #endif
  694. (setattrfunc)0, /* tp_setattr */
  695. #if PY_VERSION_HEX >= 0x03000000
  696. 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
  697. #else
  698. (cmpfunc)SwigPyObject_compare, /* tp_compare */
  699. #endif
  700. (reprfunc)SwigPyObject_repr, /* tp_repr */
  701. &SwigPyObject_as_number, /* tp_as_number */
  702. 0, /* tp_as_sequence */
  703. 0, /* tp_as_mapping */
  704. (hashfunc)0, /* tp_hash */
  705. (ternaryfunc)0, /* tp_call */
  706. 0, /* tp_str */
  707. PyObject_GenericGetAttr, /* tp_getattro */
  708. 0, /* tp_setattro */
  709. 0, /* tp_as_buffer */
  710. Py_TPFLAGS_DEFAULT, /* tp_flags */
  711. swigobject_doc, /* tp_doc */
  712. 0, /* tp_traverse */
  713. 0, /* tp_clear */
  714. (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
  715. 0, /* tp_weaklistoffset */
  716. #if PY_VERSION_HEX >= 0x02020000
  717. 0, /* tp_iter */
  718. 0, /* tp_iternext */
  719. swigobject_methods, /* tp_methods */
  720. 0, /* tp_members */
  721. 0, /* tp_getset */
  722. 0, /* tp_base */
  723. 0, /* tp_dict */
  724. 0, /* tp_descr_get */
  725. 0, /* tp_descr_set */
  726. 0, /* tp_dictoffset */
  727. 0, /* tp_init */
  728. 0, /* tp_alloc */
  729. 0, /* tp_new */
  730. 0, /* tp_free */
  731. 0, /* tp_is_gc */
  732. 0, /* tp_bases */
  733. 0, /* tp_mro */
  734. 0, /* tp_cache */
  735. 0, /* tp_subclasses */
  736. 0, /* tp_weaklist */
  737. #endif
  738. #if PY_VERSION_HEX >= 0x02030000
  739. 0, /* tp_del */
  740. #endif
  741. #if PY_VERSION_HEX >= 0x02060000
  742. 0, /* tp_version_tag */
  743. #endif
  744. #if PY_VERSION_HEX >= 0x03040000
  745. 0, /* tp_finalize */
  746. #endif
  747. #ifdef COUNT_ALLOCS
  748. 0, /* tp_allocs */
  749. 0, /* tp_frees */
  750. 0, /* tp_maxalloc */
  751. #if PY_VERSION_HEX >= 0x02050000
  752. 0, /* tp_prev */
  753. #endif
  754. 0 /* tp_next */
  755. #endif
  756. };
  757. swigpyobject_type = tmp;
  758. type_init = 1;
  759. #if PY_VERSION_HEX < 0x02020000
  760. swigpyobject_type.ob_type = &PyType_Type;
  761. #else
  762. if (PyType_Ready(&swigpyobject_type) < 0)
  763. return NULL;
  764. #endif
  765. }
  766. return &swigpyobject_type;
  767. }
  768. SWIGRUNTIME PyObject *
  769. SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
  770. {
  771. SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
  772. if (sobj) {
  773. sobj->ptr = ptr;
  774. sobj->ty = ty;
  775. sobj->own = own;
  776. sobj->next = 0;
  777. }
  778. return (PyObject *)sobj;
  779. }
  780. /* -----------------------------------------------------------------------------
  781. * Implements a simple Swig Packed type, and use it instead of string
  782. * ----------------------------------------------------------------------------- */
  783. typedef struct {
  784. PyObject_HEAD
  785. void *pack;
  786. swig_type_info *ty;
  787. size_t size;
  788. } SwigPyPacked;
  789. SWIGRUNTIME int
  790. SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
  791. {
  792. char result[SWIG_BUFFER_SIZE];
  793. fputs("<Swig Packed ", fp);
  794. if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
  795. fputs("at ", fp);
  796. fputs(result, fp);
  797. }
  798. fputs(v->ty->name,fp);
  799. fputs(">", fp);
  800. return 0;
  801. }
  802. SWIGRUNTIME PyObject *
  803. SwigPyPacked_repr(SwigPyPacked *v)
  804. {
  805. char result[SWIG_BUFFER_SIZE];
  806. if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
  807. return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
  808. } else {
  809. return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
  810. }
  811. }
  812. SWIGRUNTIME PyObject *
  813. SwigPyPacked_str(SwigPyPacked *v)
  814. {
  815. char result[SWIG_BUFFER_SIZE];
  816. if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
  817. return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
  818. } else {
  819. return SWIG_Python_str_FromChar(v->ty->name);
  820. }
  821. }
  822. SWIGRUNTIME int
  823. SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
  824. {
  825. size_t i = v->size;
  826. size_t j = w->size;
  827. int s = (i < j) ? -1 : ((i > j) ? 1 : 0);
  828. return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
  829. }
  830. SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
  831. SWIGRUNTIME PyTypeObject*
  832. SwigPyPacked_type(void) {
  833. static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
  834. return type;
  835. }
  836. SWIGRUNTIMEINLINE int
  837. SwigPyPacked_Check(PyObject *op) {
  838. return ((op)->ob_type == SwigPyPacked_TypeOnce())
  839. || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
  840. }
  841. SWIGRUNTIME void
  842. SwigPyPacked_dealloc(PyObject *v)
  843. {
  844. if (SwigPyPacked_Check(v)) {
  845. SwigPyPacked *sobj = (SwigPyPacked *) v;
  846. free(sobj->pack);
  847. }
  848. PyObject_DEL(v);
  849. }
  850. SWIGRUNTIME PyTypeObject*
  851. SwigPyPacked_TypeOnce(void) {
  852. static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
  853. static PyTypeObject swigpypacked_type;
  854. static int type_init = 0;
  855. if (!type_init) {
  856. const PyTypeObject tmp = {
  857. /* PyObject header changed in Python 3 */
  858. #if PY_VERSION_HEX>=0x03000000
  859. PyVarObject_HEAD_INIT(NULL, 0)
  860. #else
  861. PyObject_HEAD_INIT(NULL)
  862. 0, /* ob_size */
  863. #endif
  864. (char *)"SwigPyPacked", /* tp_name */
  865. sizeof(SwigPyPacked), /* tp_basicsize */
  866. 0, /* tp_itemsize */
  867. (destructor)SwigPyPacked_dealloc, /* tp_dealloc */
  868. (printfunc)SwigPyPacked_print, /* tp_print */
  869. (getattrfunc)0, /* tp_getattr */
  870. (setattrfunc)0, /* tp_setattr */
  871. #if PY_VERSION_HEX>=0x03000000
  872. 0, /* tp_reserved in 3.0.1 */
  873. #else
  874. (cmpfunc)SwigPyPacked_compare, /* tp_compare */
  875. #endif
  876. (reprfunc)SwigPyPacked_repr, /* tp_repr */
  877. 0, /* tp_as_number */
  878. 0, /* tp_as_sequence */
  879. 0, /* tp_as_mapping */
  880. (hashfunc)0, /* tp_hash */
  881. (ternaryfunc)0, /* tp_call */
  882. (reprfunc)SwigPyPacked_str, /* tp_str */
  883. PyObject_GenericGetAttr, /* tp_getattro */
  884. 0, /* tp_setattro */
  885. 0, /* tp_as_buffer */
  886. Py_TPFLAGS_DEFAULT, /* tp_flags */
  887. swigpacked_doc, /* tp_doc */
  888. 0, /* tp_traverse */
  889. 0, /* tp_clear */
  890. 0, /* tp_richcompare */
  891. 0, /* tp_weaklistoffset */
  892. #if PY_VERSION_HEX >= 0x02020000
  893. 0, /* tp_iter */
  894. 0, /* tp_iternext */
  895. 0, /* tp_methods */
  896. 0, /* tp_members */
  897. 0, /* tp_getset */
  898. 0, /* tp_base */
  899. 0, /* tp_dict */
  900. 0, /* tp_descr_get */
  901. 0, /* tp_descr_set */
  902. 0, /* tp_dictoffset */
  903. 0, /* tp_init */
  904. 0, /* tp_alloc */
  905. 0, /* tp_new */
  906. 0, /* tp_free */
  907. 0, /* tp_is_gc */
  908. 0, /* tp_bases */
  909. 0, /* tp_mro */
  910. 0, /* tp_cache */
  911. 0, /* tp_subclasses */
  912. 0, /* tp_weaklist */
  913. #endif
  914. #if PY_VERSION_HEX >= 0x02030000
  915. 0, /* tp_del */
  916. #endif
  917. #if PY_VERSION_HEX >= 0x02060000
  918. 0, /* tp_version_tag */
  919. #endif
  920. #if PY_VERSION_HEX >= 0x03040000
  921. 0, /* tp_finalize */
  922. #endif
  923. #ifdef COUNT_ALLOCS
  924. 0, /* tp_allocs */
  925. 0, /* tp_frees */
  926. 0, /* tp_maxalloc */
  927. #if PY_VERSION_HEX >= 0x02050000
  928. 0, /* tp_prev */
  929. #endif
  930. 0 /* tp_next */
  931. #endif
  932. };
  933. swigpypacked_type = tmp;
  934. type_init = 1;
  935. #if PY_VERSION_HEX < 0x02020000
  936. swigpypacked_type.ob_type = &PyType_Type;
  937. #else
  938. if (PyType_Ready(&swigpypacked_type) < 0)
  939. return NULL;
  940. #endif
  941. }
  942. return &swigpypacked_type;
  943. }
  944. SWIGRUNTIME PyObject *
  945. SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
  946. {
  947. SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
  948. if (sobj) {
  949. void *pack = malloc(size);
  950. if (pack) {
  951. memcpy(pack, ptr, size);
  952. sobj->pack = pack;
  953. sobj->ty = ty;
  954. sobj->size = size;
  955. } else {
  956. PyObject_DEL((PyObject *) sobj);
  957. sobj = 0;
  958. }
  959. }
  960. return (PyObject *) sobj;
  961. }
  962. SWIGRUNTIME swig_type_info *
  963. SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
  964. {
  965. if (SwigPyPacked_Check(obj)) {
  966. SwigPyPacked *sobj = (SwigPyPacked *)obj;
  967. if (sobj->size != size) return 0;
  968. memcpy(ptr, sobj->pack, size);
  969. return sobj->ty;
  970. } else {
  971. return 0;
  972. }
  973. }
  974. /* -----------------------------------------------------------------------------
  975. * pointers/data manipulation
  976. * ----------------------------------------------------------------------------- */
  977. SWIGRUNTIMEINLINE PyObject *
  978. _SWIG_This(void)
  979. {
  980. return SWIG_Python_str_FromChar("this");
  981. }
  982. static PyObject *swig_this = NULL;
  983. SWIGRUNTIME PyObject *
  984. SWIG_This(void)
  985. {
  986. if (swig_this == NULL)
  987. swig_this = _SWIG_This();
  988. return swig_this;
  989. }
  990. /* #define SWIG_PYTHON_SLOW_GETSET_THIS */
  991. /* TODO: I don't know how to implement the fast getset in Python 3 right now */
  992. #if PY_VERSION_HEX>=0x03000000
  993. #define SWIG_PYTHON_SLOW_GETSET_THIS
  994. #endif
  995. SWIGRUNTIME SwigPyObject *
  996. SWIG_Python_GetSwigThis(PyObject *pyobj)
  997. {
  998. PyObject *obj;
  999. if (SwigPyObject_Check(pyobj))
  1000. return (SwigPyObject *) pyobj;
  1001. #ifdef SWIGPYTHON_BUILTIN
  1002. (void)obj;
  1003. # ifdef PyWeakref_CheckProxy
  1004. if (PyWeakref_CheckProxy(pyobj)) {
  1005. pyobj = PyWeakref_GET_OBJECT(pyobj);
  1006. if (pyobj && SwigPyObject_Check(pyobj))
  1007. return (SwigPyObject*) pyobj;
  1008. }
  1009. # endif
  1010. return NULL;
  1011. #else
  1012. obj = 0;
  1013. #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
  1014. if (PyInstance_Check(pyobj)) {
  1015. obj = _PyInstance_Lookup(pyobj, SWIG_This());
  1016. } else {
  1017. PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
  1018. if (dictptr != NULL) {
  1019. PyObject *dict = *dictptr;
  1020. obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
  1021. } else {
  1022. #ifdef PyWeakref_CheckProxy
  1023. if (PyWeakref_CheckProxy(pyobj)) {
  1024. PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
  1025. return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
  1026. }
  1027. #endif
  1028. obj = PyObject_GetAttr(pyobj,SWIG_This());
  1029. if (obj) {
  1030. Py_DECREF(obj);
  1031. } else {
  1032. if (PyErr_Occurred()) PyErr_Clear();
  1033. return 0;
  1034. }
  1035. }
  1036. }
  1037. #else
  1038. obj = PyObject_GetAttr(pyobj,SWIG_This());
  1039. if (obj) {
  1040. Py_DECREF(obj);
  1041. } else {
  1042. if (PyErr_Occurred()) PyErr_Clear();
  1043. return 0;
  1044. }
  1045. #endif
  1046. if (obj && !SwigPyObject_Check(obj)) {
  1047. /* a PyObject is called 'this', try to get the 'real this'
  1048. SwigPyObject from it */
  1049. return SWIG_Python_GetSwigThis(obj);
  1050. }
  1051. return (SwigPyObject *)obj;
  1052. #endif
  1053. }
  1054. /* Acquire a pointer value */
  1055. SWIGRUNTIME int
  1056. SWIG_Python_AcquirePtr(PyObject *obj, int own) {
  1057. if (own == SWIG_POINTER_OWN) {
  1058. SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
  1059. if (sobj) {
  1060. int oldown = sobj->own;
  1061. sobj->own = own;
  1062. return oldown;
  1063. }
  1064. }
  1065. return 0;
  1066. }
  1067. /* Convert a pointer value */
  1068. SWIGRUNTIME int
  1069. SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
  1070. int res;
  1071. SwigPyObject *sobj;
  1072. int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
  1073. if (!obj)
  1074. return SWIG_ERROR;
  1075. if (obj == Py_None && !implicit_conv) {
  1076. if (ptr)
  1077. *ptr = 0;
  1078. return SWIG_OK;
  1079. }
  1080. res = SWIG_ERROR;
  1081. sobj = SWIG_Python_GetSwigThis(obj);
  1082. if (own)
  1083. *own = 0;
  1084. while (sobj) {
  1085. void *vptr = sobj->ptr;
  1086. if (ty) {
  1087. swig_type_info *to = sobj->ty;
  1088. if (to == ty) {
  1089. /* no type cast needed */
  1090. if (ptr) *ptr = vptr;
  1091. break;
  1092. } else {
  1093. swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
  1094. if (!tc) {
  1095. sobj = (SwigPyObject *)sobj->next;
  1096. } else {
  1097. if (ptr) {
  1098. int newmemory = 0;
  1099. *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
  1100. if (newmemory == SWIG_CAST_NEW_MEMORY) {
  1101. assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
  1102. if (own)
  1103. *own = *own | SWIG_CAST_NEW_MEMORY;
  1104. }
  1105. }
  1106. break;
  1107. }
  1108. }
  1109. } else {
  1110. if (ptr) *ptr = vptr;
  1111. break;
  1112. }
  1113. }
  1114. if (sobj) {
  1115. if (own)
  1116. *own = *own | sobj->own;
  1117. if (flags & SWIG_POINTER_DISOWN) {
  1118. sobj->own = 0;
  1119. }
  1120. res = SWIG_OK;
  1121. } else {
  1122. if (implicit_conv) {
  1123. SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
  1124. if (data && !data->implicitconv) {
  1125. PyObject *klass = data->klass;
  1126. if (klass) {
  1127. PyObject *impconv;
  1128. data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
  1129. impconv = SWIG_Python_CallFunctor(klass, obj);
  1130. data->implicitconv = 0;
  1131. if (PyErr_Occurred()) {
  1132. PyErr_Clear();
  1133. impconv = 0;
  1134. }
  1135. if (impconv) {
  1136. SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
  1137. if (iobj) {
  1138. void *vptr;
  1139. res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
  1140. if (SWIG_IsOK(res)) {
  1141. if (ptr) {
  1142. *ptr = vptr;
  1143. /* transfer the ownership to 'ptr' */
  1144. iobj->own = 0;
  1145. res = SWIG_AddCast(res);
  1146. res = SWIG_AddNewMask(res);
  1147. } else {
  1148. res = SWIG_AddCast(res);
  1149. }
  1150. }
  1151. }
  1152. Py_DECREF(impconv);
  1153. }
  1154. }
  1155. }
  1156. }
  1157. if (!SWIG_IsOK(res) && obj == Py_None) {
  1158. if (ptr)
  1159. *ptr = 0;
  1160. if (PyErr_Occurred())
  1161. PyErr_Clear();
  1162. res = SWIG_OK;
  1163. }
  1164. }
  1165. return res;
  1166. }
  1167. /* Convert a function ptr value */
  1168. SWIGRUNTIME int
  1169. SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
  1170. if (!PyCFunction_Check(obj)) {
  1171. return SWIG_ConvertPtr(obj, ptr, ty, 0);
  1172. } else {
  1173. void *vptr = 0;
  1174. /* here we get the method pointer for callbacks */
  1175. const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
  1176. const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
  1177. if (desc)
  1178. desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
  1179. if (!desc)
  1180. return SWIG_ERROR;
  1181. if (ty) {
  1182. swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
  1183. if (tc) {
  1184. int newmemory = 0;
  1185. *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
  1186. assert(!newmemory); /* newmemory handling not yet implemented */
  1187. } else {
  1188. return SWIG_ERROR;
  1189. }
  1190. } else {
  1191. *ptr = vptr;
  1192. }
  1193. return SWIG_OK;
  1194. }
  1195. }
  1196. /* Convert a packed value value */
  1197. SWIGRUNTIME int
  1198. SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
  1199. swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
  1200. if (!to) return SWIG_ERROR;
  1201. if (ty) {
  1202. if (to != ty) {
  1203. /* check type cast? */
  1204. swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
  1205. if (!tc) return SWIG_ERROR;
  1206. }
  1207. }
  1208. return SWIG_OK;
  1209. }
  1210. /* -----------------------------------------------------------------------------
  1211. * Create a new pointer object
  1212. * ----------------------------------------------------------------------------- */
  1213. /*
  1214. Create a new instance object, without calling __init__, and set the
  1215. 'this' attribute.
  1216. */
  1217. SWIGRUNTIME PyObject*
  1218. SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
  1219. {
  1220. #if (PY_VERSION_HEX >= 0x02020000)
  1221. PyObject *inst = 0;
  1222. PyObject *newraw = data->newraw;
  1223. if (newraw) {
  1224. inst = PyObject_Call(newraw, data->newargs, NULL);
  1225. if (inst) {
  1226. #if !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
  1227. PyObject **dictptr = _PyObject_GetDictPtr(inst);
  1228. if (dictptr != NULL) {
  1229. PyObject *dict = *dictptr;
  1230. if (dict == NULL) {
  1231. dict = PyDict_New();
  1232. *dictptr = dict;
  1233. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1234. }
  1235. }
  1236. #else
  1237. PyObject *key = SWIG_This();
  1238. PyObject_SetAttr(inst, key, swig_this);
  1239. #endif
  1240. }
  1241. } else {
  1242. #if PY_VERSION_HEX >= 0x03000000
  1243. inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
  1244. if (inst) {
  1245. PyObject_SetAttr(inst, SWIG_This(), swig_this);
  1246. Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
  1247. }
  1248. #else
  1249. PyObject *dict = PyDict_New();
  1250. if (dict) {
  1251. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1252. inst = PyInstance_NewRaw(data->newargs, dict);
  1253. Py_DECREF(dict);
  1254. }
  1255. #endif
  1256. }
  1257. return inst;
  1258. #else
  1259. #if (PY_VERSION_HEX >= 0x02010000)
  1260. PyObject *inst = 0;
  1261. PyObject *dict = PyDict_New();
  1262. if (dict) {
  1263. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1264. inst = PyInstance_NewRaw(data->newargs, dict);
  1265. Py_DECREF(dict);
  1266. }
  1267. return (PyObject *) inst;
  1268. #else
  1269. PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
  1270. if (inst == NULL) {
  1271. return NULL;
  1272. }
  1273. inst->in_class = (PyClassObject *)data->newargs;
  1274. Py_INCREF(inst->in_class);
  1275. inst->in_dict = PyDict_New();
  1276. if (inst->in_dict == NULL) {
  1277. Py_DECREF(inst);
  1278. return NULL;
  1279. }
  1280. #ifdef Py_TPFLAGS_HAVE_WEAKREFS
  1281. inst->in_weakreflist = NULL;
  1282. #endif
  1283. #ifdef Py_TPFLAGS_GC
  1284. PyObject_GC_Init(inst);
  1285. #endif
  1286. PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this);
  1287. return (PyObject *) inst;
  1288. #endif
  1289. #endif
  1290. }
  1291. SWIGRUNTIME void
  1292. SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
  1293. {
  1294. PyObject *dict;
  1295. #if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS)
  1296. PyObject **dictptr = _PyObject_GetDictPtr(inst);
  1297. if (dictptr != NULL) {
  1298. dict = *dictptr;
  1299. if (dict == NULL) {
  1300. dict = PyDict_New();
  1301. *dictptr = dict;
  1302. }
  1303. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1304. return;
  1305. }
  1306. #endif
  1307. dict = PyObject_GetAttrString(inst, (char*)"__dict__");
  1308. PyDict_SetItem(dict, SWIG_This(), swig_this);
  1309. Py_DECREF(dict);
  1310. }
  1311. SWIGINTERN PyObject *
  1312. SWIG_Python_InitShadowInstance(PyObject *args) {
  1313. PyObject *obj[2];
  1314. if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) {
  1315. return NULL;
  1316. } else {
  1317. SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
  1318. if (sthis) {
  1319. SwigPyObject_append((PyObject*) sthis, obj[1]);
  1320. } else {
  1321. SWIG_Python_SetSwigThis(obj[0], obj[1]);
  1322. }
  1323. return SWIG_Py_Void();
  1324. }
  1325. }
  1326. /* Create a new pointer object */
  1327. SWIGRUNTIME PyObject *
  1328. SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
  1329. SwigPyClientData *clientdata;
  1330. PyObject * robj;
  1331. int own;
  1332. if (!ptr)
  1333. return SWIG_Py_Void();
  1334. clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
  1335. own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
  1336. if (clientdata && clientdata->pytype) {
  1337. SwigPyObject *newobj;
  1338. if (flags & SWIG_BUILTIN_TP_INIT) {
  1339. newobj = (SwigPyObject*) self;
  1340. if (newobj->ptr) {
  1341. PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
  1342. while (newobj->next)
  1343. newobj = (SwigPyObject *) newobj->next;
  1344. newobj->next = next_self;
  1345. newobj = (SwigPyObject *)next_self;
  1346. #ifdef SWIGPYTHON_BUILTIN
  1347. newobj->dict = 0;
  1348. #endif
  1349. }
  1350. } else {
  1351. newobj = PyObject_New(SwigPyObject, clientdata->pytype);
  1352. #ifdef SWIGPYTHON_BUILTIN
  1353. newobj->dict = 0;
  1354. #endif
  1355. }
  1356. if (newobj) {
  1357. newobj->ptr = ptr;
  1358. newobj->ty = type;
  1359. newobj->own = own;
  1360. newobj->next = 0;
  1361. return (PyObject*) newobj;
  1362. }
  1363. return SWIG_Py_Void();
  1364. }
  1365. assert(!(flags & SWIG_BUILTIN_TP_INIT));
  1366. robj = SwigPyObject_New(ptr, type, own);
  1367. if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
  1368. PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
  1369. Py_DECREF(robj);
  1370. robj = inst;
  1371. }
  1372. return robj;
  1373. }
  1374. /* Create a new packed object */
  1375. SWIGRUNTIMEINLINE PyObject *
  1376. SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
  1377. return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
  1378. }
  1379. /* -----------------------------------------------------------------------------*
  1380. * Get type list
  1381. * -----------------------------------------------------------------------------*/
  1382. #ifdef SWIG_LINK_RUNTIME
  1383. void *SWIG_ReturnGlobalTypeList(void *);
  1384. #endif
  1385. SWIGRUNTIME swig_module_info *
  1386. SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
  1387. static void *type_pointer = (void *)0;
  1388. /* first check if module already created */
  1389. if (!type_pointer) {
  1390. #ifdef SWIG_LINK_RUNTIME
  1391. type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
  1392. #else
  1393. # ifdef SWIGPY_USE_CAPSULE
  1394. type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
  1395. # else
  1396. type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
  1397. (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
  1398. # endif
  1399. if (PyErr_Occurred()) {
  1400. PyErr_Clear();
  1401. type_pointer = (void *)0;
  1402. }
  1403. #endif
  1404. }
  1405. return (swig_module_info *) type_pointer;
  1406. }
  1407. #if PY_MAJOR_VERSION < 2
  1408. /* PyModule_AddObject function was introduced in Python 2.0. The following function
  1409. is copied out of Python/modsupport.c in python version 2.3.4 */
  1410. SWIGINTERN int
  1411. PyModule_AddObject(PyObject *m, char *name, PyObject *o)
  1412. {
  1413. PyObject *dict;
  1414. if (!PyModule_Check(m)) {
  1415. PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs module as first arg");
  1416. return SWIG_ERROR;
  1417. }
  1418. if (!o) {
  1419. PyErr_SetString(PyExc_TypeError, "PyModule_AddObject() needs non-NULL value");
  1420. return SWIG_ERROR;
  1421. }
  1422. dict = PyModule_GetDict(m);
  1423. if (dict == NULL) {
  1424. /* Internal error -- modules must have a dict! */
  1425. PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__",
  1426. PyModule_GetName(m));
  1427. return SWIG_ERROR;
  1428. }
  1429. if (PyDict_SetItemString(dict, name, o))
  1430. return SWIG_ERROR;
  1431. Py_DECREF(o);
  1432. return SWIG_OK;
  1433. }
  1434. #endif
  1435. SWIGRUNTIME void
  1436. #ifdef SWIGPY_USE_CAPSULE
  1437. SWIG_Python_DestroyModule(PyObject *obj)
  1438. #else
  1439. SWIG_Python_DestroyModule(void *vptr)
  1440. #endif
  1441. {
  1442. #ifdef SWIGPY_USE_CAPSULE
  1443. swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
  1444. #else
  1445. swig_module_info *swig_module = (swig_module_info *) vptr;
  1446. #endif
  1447. swig_type_info **types = swig_module->types;
  1448. size_t i;
  1449. for (i =0; i < swig_module->size; ++i) {
  1450. swig_type_info *ty = types[i];
  1451. if (ty->owndata) {
  1452. SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
  1453. if (data) SwigPyClientData_Del(data);
  1454. }
  1455. }
  1456. Py_DECREF(SWIG_This());
  1457. swig_this = NULL;
  1458. }
  1459. SWIGRUNTIME void
  1460. SWIG_Python_SetModule(swig_module_info *swig_module) {
  1461. #if PY_VERSION_HEX >= 0x03000000
  1462. /* Add a dummy module object into sys.modules */
  1463. PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
  1464. #else
  1465. static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
  1466. PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
  1467. #endif
  1468. #ifdef SWIGPY_USE_CAPSULE
  1469. PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
  1470. if (pointer && module) {
  1471. PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
  1472. } else {
  1473. Py_XDECREF(pointer);
  1474. }
  1475. #else
  1476. PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
  1477. if (pointer && module) {
  1478. PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
  1479. } else {
  1480. Py_XDECREF(pointer);
  1481. }
  1482. #endif
  1483. }
  1484. /* The python cached type query */
  1485. SWIGRUNTIME PyObject *
  1486. SWIG_Python_TypeCache(void) {
  1487. static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New();
  1488. return cache;
  1489. }
  1490. SWIGRUNTIME swig_type_info *
  1491. SWIG_Python_TypeQuery(const char *type)
  1492. {
  1493. PyObject *cache = SWIG_Python_TypeCache();
  1494. PyObject *key = SWIG_Python_str_FromChar(type);
  1495. PyObject *obj = PyDict_GetItem(cache, key);
  1496. swig_type_info *descriptor;
  1497. if (obj) {
  1498. #ifdef SWIGPY_USE_CAPSULE
  1499. descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
  1500. #else
  1501. descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
  1502. #endif
  1503. } else {
  1504. swig_module_info *swig_module = SWIG_GetModule(0);
  1505. descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
  1506. if (descriptor) {
  1507. #ifdef SWIGPY_USE_CAPSULE
  1508. obj = PyCapsule_New((void*) descriptor, NULL, NULL);
  1509. #else
  1510. obj = PyCObject_FromVoidPtr(descriptor, NULL);
  1511. #endif
  1512. PyDict_SetItem(cache, key, obj);
  1513. Py_DECREF(obj);
  1514. }
  1515. }
  1516. Py_DECREF(key);
  1517. return descriptor;
  1518. }
  1519. /*
  1520. For backward compatibility only
  1521. */
  1522. #define SWIG_POINTER_EXCEPTION 0
  1523. #define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg)
  1524. #define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags)
  1525. SWIGRUNTIME int
  1526. SWIG_Python_AddErrMesg(const char* mesg, int infront)
  1527. {
  1528. if (PyErr_Occurred()) {
  1529. PyObject *type = 0;
  1530. PyObject *value = 0;
  1531. PyObject *traceback = 0;
  1532. PyErr_Fetch(&type, &value, &traceback);
  1533. if (value) {
  1534. char *tmp;
  1535. PyObject *old_str = PyObject_Str(value);
  1536. Py_XINCREF(type);
  1537. PyErr_Clear();
  1538. if (infront) {
  1539. PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
  1540. } else {
  1541. PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
  1542. }
  1543. SWIG_Python_str_DelForPy3(tmp);
  1544. Py_DECREF(old_str);
  1545. }
  1546. return 1;
  1547. } else {
  1548. return 0;
  1549. }
  1550. }
  1551. SWIGRUNTIME int
  1552. SWIG_Python_ArgFail(int argnum)
  1553. {
  1554. if (PyErr_Occurred()) {
  1555. /* add information about failing argument */
  1556. char mesg[256];
  1557. PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum);
  1558. return SWIG_Python_AddErrMesg(mesg, 1);
  1559. } else {
  1560. return 0;
  1561. }
  1562. }
  1563. SWIGRUNTIMEINLINE const char *
  1564. SwigPyObject_GetDesc(PyObject *self)
  1565. {
  1566. SwigPyObject *v = (SwigPyObject *)self;
  1567. swig_type_info *ty = v ? v->ty : 0;
  1568. return ty ? ty->str : "";
  1569. }
  1570. SWIGRUNTIME void
  1571. SWIG_Python_TypeError(const char *type, PyObject *obj)
  1572. {
  1573. if (type) {
  1574. #if defined(SWIG_COBJECT_TYPES)
  1575. if (obj && SwigPyObject_Check(obj)) {
  1576. const char *otype = (const char *) SwigPyObject_GetDesc(obj);
  1577. if (otype) {
  1578. PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
  1579. type, otype);
  1580. return;
  1581. }
  1582. } else
  1583. #endif
  1584. {
  1585. const char *otype = (obj ? obj->ob_type->tp_name : 0);
  1586. if (otype) {
  1587. PyObject *str = PyObject_Str(obj);
  1588. const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
  1589. if (cstr) {
  1590. PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
  1591. type, otype, cstr);
  1592. SWIG_Python_str_DelForPy3(cstr);
  1593. } else {
  1594. PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
  1595. type, otype);
  1596. }
  1597. Py_XDECREF(str);
  1598. return;
  1599. }
  1600. }
  1601. PyErr_Format(PyExc_TypeError, "a '%s' is expected", type);
  1602. } else {
  1603. PyErr_Format(PyExc_TypeError, "unexpected type is received");
  1604. }
  1605. }
  1606. /* Convert a pointer value, signal an exception on a type mismatch */
  1607. SWIGRUNTIME void *
  1608. SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) {
  1609. void *result;
  1610. if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
  1611. PyErr_Clear();
  1612. #if SWIG_POINTER_EXCEPTION
  1613. if (flags) {
  1614. SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
  1615. SWIG_Python_ArgFail(argnum);
  1616. }
  1617. #endif
  1618. }
  1619. return result;
  1620. }
  1621. #ifdef SWIGPYTHON_BUILTIN
  1622. SWIGRUNTIME int
  1623. SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
  1624. PyTypeObject *tp = obj->ob_type;
  1625. PyObject *descr;
  1626. PyObject *encoded_name;
  1627. descrsetfunc f;
  1628. int res = -1;
  1629. # ifdef Py_USING_UNICODE
  1630. if (PyString_Check(name)) {
  1631. name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
  1632. if (!name)
  1633. return -1;
  1634. } else if (!PyUnicode_Check(name))
  1635. # else
  1636. if (!PyString_Check(name))
  1637. # endif
  1638. {
  1639. PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
  1640. return -1;
  1641. } else {
  1642. Py_INCREF(name);
  1643. }
  1644. if (!tp->tp_dict) {
  1645. if (PyType_Ready(tp) < 0)
  1646. goto done;
  1647. }
  1648. descr = _PyType_Lookup(tp, name);
  1649. f = NULL;
  1650. if (descr != NULL)
  1651. f = descr->ob_type->tp_descr_set;
  1652. if (!f) {
  1653. if (PyString_Check(name)) {
  1654. encoded_name = name;
  1655. Py_INCREF(name);
  1656. } else {
  1657. encoded_name = PyUnicode_AsUTF8String(name);
  1658. }
  1659. PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
  1660. Py_DECREF(encoded_name);
  1661. } else {
  1662. res = f(descr, obj, value);
  1663. }
  1664. done:
  1665. Py_DECREF(name);
  1666. return res;
  1667. }
  1668. #endif
  1669. #ifdef __cplusplus
  1670. }
  1671. #endif