cytpl.c 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468
  1. /* Generated by Cython 0.28.4 */
  2. #define PY_SSIZE_T_CLEAN
  3. #include "Python.h"
  4. #ifndef Py_PYTHON_H
  5. #error Python headers needed to compile C extensions, please install development version of Python.
  6. #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
  7. #error Cython requires Python 2.6+ or Python 3.3+.
  8. #else
  9. #define CYTHON_ABI "0_28_4"
  10. #define CYTHON_FUTURE_DIVISION 0
  11. #include <stddef.h>
  12. #ifndef offsetof
  13. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  14. #endif
  15. #if !defined(WIN32) && !defined(MS_WINDOWS)
  16. #ifndef __stdcall
  17. #define __stdcall
  18. #endif
  19. #ifndef __cdecl
  20. #define __cdecl
  21. #endif
  22. #ifndef __fastcall
  23. #define __fastcall
  24. #endif
  25. #endif
  26. #ifndef DL_IMPORT
  27. #define DL_IMPORT(t) t
  28. #endif
  29. #ifndef DL_EXPORT
  30. #define DL_EXPORT(t) t
  31. #endif
  32. #define __PYX_COMMA ,
  33. #ifndef HAVE_LONG_LONG
  34. #if PY_VERSION_HEX >= 0x02070000
  35. #define HAVE_LONG_LONG
  36. #endif
  37. #endif
  38. #ifndef PY_LONG_LONG
  39. #define PY_LONG_LONG LONG_LONG
  40. #endif
  41. #ifndef Py_HUGE_VAL
  42. #define Py_HUGE_VAL HUGE_VAL
  43. #endif
  44. #ifdef PYPY_VERSION
  45. #define CYTHON_COMPILING_IN_PYPY 1
  46. #define CYTHON_COMPILING_IN_PYSTON 0
  47. #define CYTHON_COMPILING_IN_CPYTHON 0
  48. #undef CYTHON_USE_TYPE_SLOTS
  49. #define CYTHON_USE_TYPE_SLOTS 0
  50. #undef CYTHON_USE_PYTYPE_LOOKUP
  51. #define CYTHON_USE_PYTYPE_LOOKUP 0
  52. #if PY_VERSION_HEX < 0x03050000
  53. #undef CYTHON_USE_ASYNC_SLOTS
  54. #define CYTHON_USE_ASYNC_SLOTS 0
  55. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  56. #define CYTHON_USE_ASYNC_SLOTS 1
  57. #endif
  58. #undef CYTHON_USE_PYLIST_INTERNALS
  59. #define CYTHON_USE_PYLIST_INTERNALS 0
  60. #undef CYTHON_USE_UNICODE_INTERNALS
  61. #define CYTHON_USE_UNICODE_INTERNALS 0
  62. #undef CYTHON_USE_UNICODE_WRITER
  63. #define CYTHON_USE_UNICODE_WRITER 0
  64. #undef CYTHON_USE_PYLONG_INTERNALS
  65. #define CYTHON_USE_PYLONG_INTERNALS 0
  66. #undef CYTHON_AVOID_BORROWED_REFS
  67. #define CYTHON_AVOID_BORROWED_REFS 1
  68. #undef CYTHON_ASSUME_SAFE_MACROS
  69. #define CYTHON_ASSUME_SAFE_MACROS 0
  70. #undef CYTHON_UNPACK_METHODS
  71. #define CYTHON_UNPACK_METHODS 0
  72. #undef CYTHON_FAST_THREAD_STATE
  73. #define CYTHON_FAST_THREAD_STATE 0
  74. #undef CYTHON_FAST_PYCALL
  75. #define CYTHON_FAST_PYCALL 0
  76. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  77. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  78. #undef CYTHON_USE_TP_FINALIZE
  79. #define CYTHON_USE_TP_FINALIZE 0
  80. #elif defined(PYSTON_VERSION)
  81. #define CYTHON_COMPILING_IN_PYPY 0
  82. #define CYTHON_COMPILING_IN_PYSTON 1
  83. #define CYTHON_COMPILING_IN_CPYTHON 0
  84. #ifndef CYTHON_USE_TYPE_SLOTS
  85. #define CYTHON_USE_TYPE_SLOTS 1
  86. #endif
  87. #undef CYTHON_USE_PYTYPE_LOOKUP
  88. #define CYTHON_USE_PYTYPE_LOOKUP 0
  89. #undef CYTHON_USE_ASYNC_SLOTS
  90. #define CYTHON_USE_ASYNC_SLOTS 0
  91. #undef CYTHON_USE_PYLIST_INTERNALS
  92. #define CYTHON_USE_PYLIST_INTERNALS 0
  93. #ifndef CYTHON_USE_UNICODE_INTERNALS
  94. #define CYTHON_USE_UNICODE_INTERNALS 1
  95. #endif
  96. #undef CYTHON_USE_UNICODE_WRITER
  97. #define CYTHON_USE_UNICODE_WRITER 0
  98. #undef CYTHON_USE_PYLONG_INTERNALS
  99. #define CYTHON_USE_PYLONG_INTERNALS 0
  100. #ifndef CYTHON_AVOID_BORROWED_REFS
  101. #define CYTHON_AVOID_BORROWED_REFS 0
  102. #endif
  103. #ifndef CYTHON_ASSUME_SAFE_MACROS
  104. #define CYTHON_ASSUME_SAFE_MACROS 1
  105. #endif
  106. #ifndef CYTHON_UNPACK_METHODS
  107. #define CYTHON_UNPACK_METHODS 1
  108. #endif
  109. #undef CYTHON_FAST_THREAD_STATE
  110. #define CYTHON_FAST_THREAD_STATE 0
  111. #undef CYTHON_FAST_PYCALL
  112. #define CYTHON_FAST_PYCALL 0
  113. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  114. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  115. #undef CYTHON_USE_TP_FINALIZE
  116. #define CYTHON_USE_TP_FINALIZE 0
  117. #else
  118. #define CYTHON_COMPILING_IN_PYPY 0
  119. #define CYTHON_COMPILING_IN_PYSTON 0
  120. #define CYTHON_COMPILING_IN_CPYTHON 1
  121. #ifndef CYTHON_USE_TYPE_SLOTS
  122. #define CYTHON_USE_TYPE_SLOTS 1
  123. #endif
  124. #if PY_VERSION_HEX < 0x02070000
  125. #undef CYTHON_USE_PYTYPE_LOOKUP
  126. #define CYTHON_USE_PYTYPE_LOOKUP 0
  127. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  128. #define CYTHON_USE_PYTYPE_LOOKUP 1
  129. #endif
  130. #if PY_MAJOR_VERSION < 3
  131. #undef CYTHON_USE_ASYNC_SLOTS
  132. #define CYTHON_USE_ASYNC_SLOTS 0
  133. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  134. #define CYTHON_USE_ASYNC_SLOTS 1
  135. #endif
  136. #if PY_VERSION_HEX < 0x02070000
  137. #undef CYTHON_USE_PYLONG_INTERNALS
  138. #define CYTHON_USE_PYLONG_INTERNALS 0
  139. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  140. #define CYTHON_USE_PYLONG_INTERNALS 1
  141. #endif
  142. #ifndef CYTHON_USE_PYLIST_INTERNALS
  143. #define CYTHON_USE_PYLIST_INTERNALS 1
  144. #endif
  145. #ifndef CYTHON_USE_UNICODE_INTERNALS
  146. #define CYTHON_USE_UNICODE_INTERNALS 1
  147. #endif
  148. #if PY_VERSION_HEX < 0x030300F0
  149. #undef CYTHON_USE_UNICODE_WRITER
  150. #define CYTHON_USE_UNICODE_WRITER 0
  151. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  152. #define CYTHON_USE_UNICODE_WRITER 1
  153. #endif
  154. #ifndef CYTHON_AVOID_BORROWED_REFS
  155. #define CYTHON_AVOID_BORROWED_REFS 0
  156. #endif
  157. #ifndef CYTHON_ASSUME_SAFE_MACROS
  158. #define CYTHON_ASSUME_SAFE_MACROS 1
  159. #endif
  160. #ifndef CYTHON_UNPACK_METHODS
  161. #define CYTHON_UNPACK_METHODS 1
  162. #endif
  163. #ifndef CYTHON_FAST_THREAD_STATE
  164. #define CYTHON_FAST_THREAD_STATE 1
  165. #endif
  166. #ifndef CYTHON_FAST_PYCALL
  167. #define CYTHON_FAST_PYCALL 1
  168. #endif
  169. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  170. #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000)
  171. #endif
  172. #ifndef CYTHON_USE_TP_FINALIZE
  173. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  174. #endif
  175. #endif
  176. #if !defined(CYTHON_FAST_PYCCALL)
  177. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  178. #endif
  179. #if CYTHON_USE_PYLONG_INTERNALS
  180. #include "longintrepr.h"
  181. #undef SHIFT
  182. #undef BASE
  183. #undef MASK
  184. #endif
  185. #ifndef __has_attribute
  186. #define __has_attribute(x) 0
  187. #endif
  188. #ifndef __has_cpp_attribute
  189. #define __has_cpp_attribute(x) 0
  190. #endif
  191. #ifndef CYTHON_RESTRICT
  192. #if defined(__GNUC__)
  193. #define CYTHON_RESTRICT __restrict__
  194. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  195. #define CYTHON_RESTRICT __restrict
  196. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  197. #define CYTHON_RESTRICT restrict
  198. #else
  199. #define CYTHON_RESTRICT
  200. #endif
  201. #endif
  202. #ifndef CYTHON_UNUSED
  203. # if defined(__GNUC__)
  204. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  205. # define CYTHON_UNUSED __attribute__ ((__unused__))
  206. # else
  207. # define CYTHON_UNUSED
  208. # endif
  209. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  210. # define CYTHON_UNUSED __attribute__ ((__unused__))
  211. # else
  212. # define CYTHON_UNUSED
  213. # endif
  214. #endif
  215. #ifndef CYTHON_MAYBE_UNUSED_VAR
  216. # if defined(__cplusplus)
  217. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  218. # else
  219. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  220. # endif
  221. #endif
  222. #ifndef CYTHON_NCP_UNUSED
  223. # if CYTHON_COMPILING_IN_CPYTHON
  224. # define CYTHON_NCP_UNUSED
  225. # else
  226. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  227. # endif
  228. #endif
  229. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  230. #ifdef _MSC_VER
  231. #ifndef _MSC_STDINT_H_
  232. #if _MSC_VER < 1300
  233. typedef unsigned char uint8_t;
  234. typedef unsigned int uint32_t;
  235. #else
  236. typedef unsigned __int8 uint8_t;
  237. typedef unsigned __int32 uint32_t;
  238. #endif
  239. #endif
  240. #else
  241. #include <stdint.h>
  242. #endif
  243. #ifndef CYTHON_FALLTHROUGH
  244. #if defined(__cplusplus) && __cplusplus >= 201103L
  245. #if __has_cpp_attribute(fallthrough)
  246. #define CYTHON_FALLTHROUGH [[fallthrough]]
  247. #elif __has_cpp_attribute(clang::fallthrough)
  248. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  249. #elif __has_cpp_attribute(gnu::fallthrough)
  250. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  251. #endif
  252. #endif
  253. #ifndef CYTHON_FALLTHROUGH
  254. #if __has_attribute(fallthrough)
  255. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  256. #else
  257. #define CYTHON_FALLTHROUGH
  258. #endif
  259. #endif
  260. #if defined(__clang__ ) && defined(__apple_build_version__)
  261. #if __apple_build_version__ < 7000000
  262. #undef CYTHON_FALLTHROUGH
  263. #define CYTHON_FALLTHROUGH
  264. #endif
  265. #endif
  266. #endif
  267. #ifndef CYTHON_INLINE
  268. #if defined(__clang__)
  269. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  270. #elif defined(__GNUC__)
  271. #define CYTHON_INLINE __inline__
  272. #elif defined(_MSC_VER)
  273. #define CYTHON_INLINE __inline
  274. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  275. #define CYTHON_INLINE inline
  276. #else
  277. #define CYTHON_INLINE
  278. #endif
  279. #endif
  280. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  281. #define Py_OptimizeFlag 0
  282. #endif
  283. #define __PYX_BUILD_PY_SSIZE_T "n"
  284. #define CYTHON_FORMAT_SSIZE_T "z"
  285. #if PY_MAJOR_VERSION < 3
  286. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  287. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  288. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  289. #define __Pyx_DefaultClassType PyClass_Type
  290. #else
  291. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  292. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  293. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  294. #define __Pyx_DefaultClassType PyType_Type
  295. #endif
  296. #ifndef Py_TPFLAGS_CHECKTYPES
  297. #define Py_TPFLAGS_CHECKTYPES 0
  298. #endif
  299. #ifndef Py_TPFLAGS_HAVE_INDEX
  300. #define Py_TPFLAGS_HAVE_INDEX 0
  301. #endif
  302. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  303. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  304. #endif
  305. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  306. #define Py_TPFLAGS_HAVE_FINALIZE 0
  307. #endif
  308. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  309. #ifndef METH_FASTCALL
  310. #define METH_FASTCALL 0x80
  311. #endif
  312. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  313. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  314. Py_ssize_t nargs, PyObject *kwnames);
  315. #else
  316. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  317. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  318. #endif
  319. #if CYTHON_FAST_PYCCALL
  320. #define __Pyx_PyFastCFunction_Check(func)\
  321. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS)))))
  322. #else
  323. #define __Pyx_PyFastCFunction_Check(func) 0
  324. #endif
  325. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  326. #define PyObject_Malloc(s) PyMem_Malloc(s)
  327. #define PyObject_Free(p) PyMem_Free(p)
  328. #define PyObject_Realloc(p) PyMem_Realloc(p)
  329. #endif
  330. #if CYTHON_COMPILING_IN_PYSTON
  331. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  332. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  333. #else
  334. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  335. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  336. #endif
  337. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  338. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  339. #elif PY_VERSION_HEX >= 0x03060000
  340. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  341. #elif PY_VERSION_HEX >= 0x03000000
  342. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  343. #else
  344. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  345. #endif
  346. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  347. #include "pythread.h"
  348. #define Py_tss_NEEDS_INIT 0
  349. typedef int Py_tss_t;
  350. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  351. *key = PyThread_create_key();
  352. return 0; // PyThread_create_key reports success always
  353. }
  354. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  355. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  356. *key = Py_tss_NEEDS_INIT;
  357. return key;
  358. }
  359. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  360. PyObject_Free(key);
  361. }
  362. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  363. return *key != Py_tss_NEEDS_INIT;
  364. }
  365. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  366. PyThread_delete_key(*key);
  367. *key = Py_tss_NEEDS_INIT;
  368. }
  369. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  370. return PyThread_set_key_value(*key, value);
  371. }
  372. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  373. return PyThread_get_key_value(*key);
  374. }
  375. #endif // TSS (Thread Specific Storage) API
  376. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  377. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  378. #else
  379. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  380. #endif
  381. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  382. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  383. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  384. #else
  385. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  386. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  387. #endif
  388. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  389. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  390. #else
  391. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  392. #endif
  393. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  394. #define CYTHON_PEP393_ENABLED 1
  395. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  396. 0 : _PyUnicode_Ready((PyObject *)(op)))
  397. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  398. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  399. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  400. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  401. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  402. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  403. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  404. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  405. #else
  406. #define CYTHON_PEP393_ENABLED 0
  407. #define PyUnicode_1BYTE_KIND 1
  408. #define PyUnicode_2BYTE_KIND 2
  409. #define PyUnicode_4BYTE_KIND 4
  410. #define __Pyx_PyUnicode_READY(op) (0)
  411. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  412. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  413. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  414. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  415. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  416. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  417. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  418. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  419. #endif
  420. #if CYTHON_COMPILING_IN_PYPY
  421. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  422. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  423. #else
  424. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  425. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  426. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  427. #endif
  428. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  429. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  430. #endif
  431. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  432. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  433. #endif
  434. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  435. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  436. #endif
  437. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  438. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  439. #if PY_MAJOR_VERSION >= 3
  440. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  441. #else
  442. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  443. #endif
  444. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  445. #define PyObject_ASCII(o) PyObject_Repr(o)
  446. #endif
  447. #if PY_MAJOR_VERSION >= 3
  448. #define PyBaseString_Type PyUnicode_Type
  449. #define PyStringObject PyUnicodeObject
  450. #define PyString_Type PyUnicode_Type
  451. #define PyString_Check PyUnicode_Check
  452. #define PyString_CheckExact PyUnicode_CheckExact
  453. #define PyObject_Unicode PyObject_Str
  454. #endif
  455. #if PY_MAJOR_VERSION >= 3
  456. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  457. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  458. #else
  459. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  460. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  461. #endif
  462. #ifndef PySet_CheckExact
  463. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  464. #endif
  465. #if CYTHON_ASSUME_SAFE_MACROS
  466. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  467. #else
  468. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  469. #endif
  470. #if PY_MAJOR_VERSION >= 3
  471. #define PyIntObject PyLongObject
  472. #define PyInt_Type PyLong_Type
  473. #define PyInt_Check(op) PyLong_Check(op)
  474. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  475. #define PyInt_FromString PyLong_FromString
  476. #define PyInt_FromUnicode PyLong_FromUnicode
  477. #define PyInt_FromLong PyLong_FromLong
  478. #define PyInt_FromSize_t PyLong_FromSize_t
  479. #define PyInt_FromSsize_t PyLong_FromSsize_t
  480. #define PyInt_AsLong PyLong_AsLong
  481. #define PyInt_AS_LONG PyLong_AS_LONG
  482. #define PyInt_AsSsize_t PyLong_AsSsize_t
  483. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  484. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  485. #define PyNumber_Int PyNumber_Long
  486. #endif
  487. #if PY_MAJOR_VERSION >= 3
  488. #define PyBoolObject PyLongObject
  489. #endif
  490. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  491. #ifndef PyUnicode_InternFromString
  492. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  493. #endif
  494. #endif
  495. #if PY_VERSION_HEX < 0x030200A4
  496. typedef long Py_hash_t;
  497. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  498. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  499. #else
  500. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  501. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  502. #endif
  503. #if PY_MAJOR_VERSION >= 3
  504. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
  505. #else
  506. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  507. #endif
  508. #if CYTHON_USE_ASYNC_SLOTS
  509. #if PY_VERSION_HEX >= 0x030500B1
  510. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  511. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  512. #else
  513. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  514. #endif
  515. #else
  516. #define __Pyx_PyType_AsAsync(obj) NULL
  517. #endif
  518. #ifndef __Pyx_PyAsyncMethodsStruct
  519. typedef struct {
  520. unaryfunc am_await;
  521. unaryfunc am_aiter;
  522. unaryfunc am_anext;
  523. } __Pyx_PyAsyncMethodsStruct;
  524. #endif
  525. #if defined(WIN32) || defined(MS_WINDOWS)
  526. #define _USE_MATH_DEFINES
  527. #endif
  528. #include <math.h>
  529. #ifdef NAN
  530. #define __PYX_NAN() ((float) NAN)
  531. #else
  532. static CYTHON_INLINE float __PYX_NAN() {
  533. float value;
  534. memset(&value, 0xFF, sizeof(value));
  535. return value;
  536. }
  537. #endif
  538. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  539. #define __Pyx_truncl trunc
  540. #else
  541. #define __Pyx_truncl truncl
  542. #endif
  543. #define __PYX_ERR(f_index, lineno, Ln_error) \
  544. { \
  545. __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
  546. }
  547. #ifndef __PYX_EXTERN_C
  548. #ifdef __cplusplus
  549. #define __PYX_EXTERN_C extern "C"
  550. #else
  551. #define __PYX_EXTERN_C extern
  552. #endif
  553. #endif
  554. #define __PYX_HAVE__lakesuperior__cy_include__cytpl
  555. #define __PYX_HAVE_API__lakesuperior__cy_include__cytpl
  556. /* Early includes */
  557. #include <string.h>
  558. #include <stdio.h>
  559. #include <stdint.h>
  560. #include <tbb/tbbmalloc_proxy.h>
  561. #include "tpl.h"
  562. #ifdef _OPENMP
  563. #include <omp.h>
  564. #endif /* _OPENMP */
  565. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  566. #define CYTHON_WITHOUT_ASSERTIONS
  567. #endif
  568. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  569. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  570. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  571. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  572. #define __PYX_DEFAULT_STRING_ENCODING ""
  573. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  574. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  575. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  576. #define __Pyx_long_cast(x) ((long)x)
  577. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  578. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  579. (sizeof(type) > sizeof(Py_ssize_t) &&\
  580. likely(v < (type)PY_SSIZE_T_MAX ||\
  581. v == (type)PY_SSIZE_T_MAX) &&\
  582. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  583. v == (type)PY_SSIZE_T_MIN))) ||\
  584. (sizeof(type) == sizeof(Py_ssize_t) &&\
  585. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  586. v == (type)PY_SSIZE_T_MAX))) )
  587. #if defined (__cplusplus) && __cplusplus >= 201103L
  588. #include <cstdlib>
  589. #define __Pyx_sst_abs(value) std::abs(value)
  590. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  591. #define __Pyx_sst_abs(value) abs(value)
  592. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  593. #define __Pyx_sst_abs(value) labs(value)
  594. #elif defined (_MSC_VER)
  595. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  596. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  597. #define __Pyx_sst_abs(value) llabs(value)
  598. #elif defined (__GNUC__)
  599. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  600. #else
  601. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  602. #endif
  603. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  604. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  605. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  606. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  607. #define __Pyx_PyBytes_FromString PyBytes_FromString
  608. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  609. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  610. #if PY_MAJOR_VERSION < 3
  611. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  612. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  613. #else
  614. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  615. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  616. #endif
  617. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  618. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  619. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  620. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  621. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  622. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  623. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  624. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  625. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  626. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  627. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  628. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  629. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  630. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  631. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  632. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  633. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  634. const Py_UNICODE *u_end = u;
  635. while (*u_end++) ;
  636. return (size_t)(u_end - u - 1);
  637. }
  638. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  639. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  640. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  641. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  642. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  643. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  644. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  645. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  646. #define __Pyx_PySequence_Tuple(obj)\
  647. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  648. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  649. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  650. #if CYTHON_ASSUME_SAFE_MACROS
  651. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  652. #else
  653. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  654. #endif
  655. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  656. #if PY_MAJOR_VERSION >= 3
  657. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  658. #else
  659. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  660. #endif
  661. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  662. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  663. static int __Pyx_sys_getdefaultencoding_not_ascii;
  664. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  665. PyObject* sys;
  666. PyObject* default_encoding = NULL;
  667. PyObject* ascii_chars_u = NULL;
  668. PyObject* ascii_chars_b = NULL;
  669. const char* default_encoding_c;
  670. sys = PyImport_ImportModule("sys");
  671. if (!sys) goto bad;
  672. default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
  673. Py_DECREF(sys);
  674. if (!default_encoding) goto bad;
  675. default_encoding_c = PyBytes_AsString(default_encoding);
  676. if (!default_encoding_c) goto bad;
  677. if (strcmp(default_encoding_c, "ascii") == 0) {
  678. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  679. } else {
  680. char ascii_chars[128];
  681. int c;
  682. for (c = 0; c < 128; c++) {
  683. ascii_chars[c] = c;
  684. }
  685. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  686. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  687. if (!ascii_chars_u) goto bad;
  688. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  689. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  690. PyErr_Format(
  691. PyExc_ValueError,
  692. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  693. default_encoding_c);
  694. goto bad;
  695. }
  696. Py_DECREF(ascii_chars_u);
  697. Py_DECREF(ascii_chars_b);
  698. }
  699. Py_DECREF(default_encoding);
  700. return 0;
  701. bad:
  702. Py_XDECREF(default_encoding);
  703. Py_XDECREF(ascii_chars_u);
  704. Py_XDECREF(ascii_chars_b);
  705. return -1;
  706. }
  707. #endif
  708. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  709. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  710. #else
  711. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  712. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  713. static char* __PYX_DEFAULT_STRING_ENCODING;
  714. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  715. PyObject* sys;
  716. PyObject* default_encoding = NULL;
  717. char* default_encoding_c;
  718. sys = PyImport_ImportModule("sys");
  719. if (!sys) goto bad;
  720. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  721. Py_DECREF(sys);
  722. if (!default_encoding) goto bad;
  723. default_encoding_c = PyBytes_AsString(default_encoding);
  724. if (!default_encoding_c) goto bad;
  725. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  726. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  727. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  728. Py_DECREF(default_encoding);
  729. return 0;
  730. bad:
  731. Py_XDECREF(default_encoding);
  732. return -1;
  733. }
  734. #endif
  735. #endif
  736. /* Test for GCC > 2.95 */
  737. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  738. #define likely(x) __builtin_expect(!!(x), 1)
  739. #define unlikely(x) __builtin_expect(!!(x), 0)
  740. #else /* !__GNUC__ or GCC < 2.95 */
  741. #define likely(x) (x)
  742. #define unlikely(x) (x)
  743. #endif /* __GNUC__ */
  744. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  745. static PyObject *__pyx_m = NULL;
  746. static PyObject *__pyx_d;
  747. static PyObject *__pyx_b;
  748. static PyObject *__pyx_cython_runtime = NULL;
  749. static PyObject *__pyx_empty_tuple;
  750. static PyObject *__pyx_empty_bytes;
  751. static PyObject *__pyx_empty_unicode;
  752. static int __pyx_lineno;
  753. static int __pyx_clineno = 0;
  754. static const char * __pyx_cfilenm= __FILE__;
  755. static const char *__pyx_filename;
  756. static const char *__pyx_f[] = {
  757. "lakesuperior/cy_include/cytpl.pxd",
  758. "type.pxd",
  759. };
  760. /*--- Type declarations ---*/
  761. /* --- Runtime support code (head) --- */
  762. /* Refnanny.proto */
  763. #ifndef CYTHON_REFNANNY
  764. #define CYTHON_REFNANNY 0
  765. #endif
  766. #if CYTHON_REFNANNY
  767. typedef struct {
  768. void (*INCREF)(void*, PyObject*, int);
  769. void (*DECREF)(void*, PyObject*, int);
  770. void (*GOTREF)(void*, PyObject*, int);
  771. void (*GIVEREF)(void*, PyObject*, int);
  772. void* (*SetupContext)(const char*, int, const char*);
  773. void (*FinishContext)(void**);
  774. } __Pyx_RefNannyAPIStruct;
  775. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  776. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  777. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  778. #ifdef WITH_THREAD
  779. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  780. if (acquire_gil) {\
  781. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  782. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  783. PyGILState_Release(__pyx_gilstate_save);\
  784. } else {\
  785. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  786. }
  787. #else
  788. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  789. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  790. #endif
  791. #define __Pyx_RefNannyFinishContext()\
  792. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  793. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  794. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  795. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  796. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  797. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  798. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  799. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  800. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  801. #else
  802. #define __Pyx_RefNannyDeclarations
  803. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  804. #define __Pyx_RefNannyFinishContext()
  805. #define __Pyx_INCREF(r) Py_INCREF(r)
  806. #define __Pyx_DECREF(r) Py_DECREF(r)
  807. #define __Pyx_GOTREF(r)
  808. #define __Pyx_GIVEREF(r)
  809. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  810. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  811. #define __Pyx_XGOTREF(r)
  812. #define __Pyx_XGIVEREF(r)
  813. #endif
  814. #define __Pyx_XDECREF_SET(r, v) do {\
  815. PyObject *tmp = (PyObject *) r;\
  816. r = v; __Pyx_XDECREF(tmp);\
  817. } while (0)
  818. #define __Pyx_DECREF_SET(r, v) do {\
  819. PyObject *tmp = (PyObject *) r;\
  820. r = v; __Pyx_DECREF(tmp);\
  821. } while (0)
  822. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  823. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  824. /* PyObjectGetAttrStr.proto */
  825. #if CYTHON_USE_TYPE_SLOTS
  826. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  827. #else
  828. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  829. #endif
  830. /* PyThreadStateGet.proto */
  831. #if CYTHON_FAST_THREAD_STATE
  832. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  833. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  834. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  835. #else
  836. #define __Pyx_PyThreadState_declare
  837. #define __Pyx_PyThreadState_assign
  838. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  839. #endif
  840. /* PyErrFetchRestore.proto */
  841. #if CYTHON_FAST_THREAD_STATE
  842. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  843. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  844. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  845. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  846. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  847. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  848. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  849. #if CYTHON_COMPILING_IN_CPYTHON
  850. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  851. #else
  852. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  853. #endif
  854. #else
  855. #define __Pyx_PyErr_Clear() PyErr_Clear()
  856. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  857. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  858. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  859. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  860. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  861. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  862. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  863. #endif
  864. /* CLineInTraceback.proto */
  865. #ifdef CYTHON_CLINE_IN_TRACEBACK
  866. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  867. #else
  868. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  869. #endif
  870. /* CodeObjectCache.proto */
  871. typedef struct {
  872. PyCodeObject* code_object;
  873. int code_line;
  874. } __Pyx_CodeObjectCacheEntry;
  875. struct __Pyx_CodeObjectCache {
  876. int count;
  877. int max_count;
  878. __Pyx_CodeObjectCacheEntry* entries;
  879. };
  880. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  881. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  882. static PyCodeObject *__pyx_find_code_object(int code_line);
  883. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  884. /* AddTraceback.proto */
  885. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  886. int py_line, const char *filename);
  887. /* CIntToPy.proto */
  888. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  889. /* CIntFromPy.proto */
  890. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  891. /* CIntFromPy.proto */
  892. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  893. /* FastTypeChecks.proto */
  894. #if CYTHON_COMPILING_IN_CPYTHON
  895. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  896. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  897. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  898. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  899. #else
  900. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  901. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  902. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  903. #endif
  904. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  905. /* CheckBinaryVersion.proto */
  906. static int __Pyx_check_binary_version(void);
  907. /* PyIdentifierFromString.proto */
  908. #if !defined(__Pyx_PyIdentifier_FromString)
  909. #if PY_MAJOR_VERSION < 3
  910. #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
  911. #else
  912. #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
  913. #endif
  914. #endif
  915. /* ModuleImport.proto */
  916. static PyObject *__Pyx_ImportModule(const char *name);
  917. /* TypeImport.proto */
  918. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
  919. /* InitStrings.proto */
  920. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  921. /* Module declarations from 'libc.string' */
  922. /* Module declarations from 'libc.stdio' */
  923. /* Module declarations from '__builtin__' */
  924. /* Module declarations from 'cpython.type' */
  925. static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
  926. /* Module declarations from 'cpython' */
  927. /* Module declarations from 'cpython.object' */
  928. /* Module declarations from 'cpython.string' */
  929. /* Module declarations from 'libc.stdint' */
  930. /* Module declarations from 'lakesuperior.cy_include.cytpl' */
  931. #define __Pyx_MODULE_NAME "lakesuperior.cy_include.cytpl"
  932. extern int __pyx_module_is_main_lakesuperior__cy_include__cytpl;
  933. int __pyx_module_is_main_lakesuperior__cy_include__cytpl = 0;
  934. /* Implementation of 'lakesuperior.cy_include.cytpl' */
  935. static const char __pyx_k_main[] = "__main__";
  936. static const char __pyx_k_test[] = "__test__";
  937. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  938. static PyObject *__pyx_n_s_cline_in_traceback;
  939. static PyObject *__pyx_n_s_main;
  940. static PyObject *__pyx_n_s_test;
  941. /* Late includes */
  942. static PyMethodDef __pyx_methods[] = {
  943. {0, 0, 0, 0}
  944. };
  945. #if PY_MAJOR_VERSION >= 3
  946. #if CYTHON_PEP489_MULTI_PHASE_INIT
  947. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  948. static int __pyx_pymod_exec_cytpl(PyObject* module); /*proto*/
  949. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  950. {Py_mod_create, (void*)__pyx_pymod_create},
  951. {Py_mod_exec, (void*)__pyx_pymod_exec_cytpl},
  952. {0, NULL}
  953. };
  954. #endif
  955. static struct PyModuleDef __pyx_moduledef = {
  956. PyModuleDef_HEAD_INIT,
  957. "cytpl",
  958. 0, /* m_doc */
  959. #if CYTHON_PEP489_MULTI_PHASE_INIT
  960. 0, /* m_size */
  961. #else
  962. -1, /* m_size */
  963. #endif
  964. __pyx_methods /* m_methods */,
  965. #if CYTHON_PEP489_MULTI_PHASE_INIT
  966. __pyx_moduledef_slots, /* m_slots */
  967. #else
  968. NULL, /* m_reload */
  969. #endif
  970. NULL, /* m_traverse */
  971. NULL, /* m_clear */
  972. NULL /* m_free */
  973. };
  974. #endif
  975. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  976. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  977. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  978. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  979. {0, 0, 0, 0, 0, 0, 0}
  980. };
  981. static int __Pyx_InitCachedBuiltins(void) {
  982. return 0;
  983. }
  984. static int __Pyx_InitCachedConstants(void) {
  985. __Pyx_RefNannyDeclarations
  986. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  987. __Pyx_RefNannyFinishContext();
  988. return 0;
  989. }
  990. static int __Pyx_InitGlobals(void) {
  991. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  992. return 0;
  993. __pyx_L1_error:;
  994. return -1;
  995. }
  996. static int __Pyx_modinit_global_init_code(void); /*proto*/
  997. static int __Pyx_modinit_variable_export_code(void); /*proto*/
  998. static int __Pyx_modinit_function_export_code(void); /*proto*/
  999. static int __Pyx_modinit_type_init_code(void); /*proto*/
  1000. static int __Pyx_modinit_type_import_code(void); /*proto*/
  1001. static int __Pyx_modinit_variable_import_code(void); /*proto*/
  1002. static int __Pyx_modinit_function_import_code(void); /*proto*/
  1003. static int __Pyx_modinit_global_init_code(void) {
  1004. __Pyx_RefNannyDeclarations
  1005. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  1006. /*--- Global init code ---*/
  1007. __Pyx_RefNannyFinishContext();
  1008. return 0;
  1009. }
  1010. static int __Pyx_modinit_variable_export_code(void) {
  1011. __Pyx_RefNannyDeclarations
  1012. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  1013. /*--- Variable export code ---*/
  1014. __Pyx_RefNannyFinishContext();
  1015. return 0;
  1016. }
  1017. static int __Pyx_modinit_function_export_code(void) {
  1018. __Pyx_RefNannyDeclarations
  1019. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  1020. /*--- Function export code ---*/
  1021. __Pyx_RefNannyFinishContext();
  1022. return 0;
  1023. }
  1024. static int __Pyx_modinit_type_init_code(void) {
  1025. __Pyx_RefNannyDeclarations
  1026. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  1027. /*--- Type init code ---*/
  1028. __Pyx_RefNannyFinishContext();
  1029. return 0;
  1030. }
  1031. static int __Pyx_modinit_type_import_code(void) {
  1032. __Pyx_RefNannyDeclarations
  1033. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  1034. /*--- Type import code ---*/
  1035. __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
  1036. #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  1037. sizeof(PyTypeObject),
  1038. #else
  1039. sizeof(PyHeapTypeObject),
  1040. #endif
  1041. 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) __PYX_ERR(1, 9, __pyx_L1_error)
  1042. __Pyx_RefNannyFinishContext();
  1043. return 0;
  1044. __pyx_L1_error:;
  1045. __Pyx_RefNannyFinishContext();
  1046. return -1;
  1047. }
  1048. static int __Pyx_modinit_variable_import_code(void) {
  1049. __Pyx_RefNannyDeclarations
  1050. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  1051. /*--- Variable import code ---*/
  1052. __Pyx_RefNannyFinishContext();
  1053. return 0;
  1054. }
  1055. static int __Pyx_modinit_function_import_code(void) {
  1056. __Pyx_RefNannyDeclarations
  1057. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  1058. /*--- Function import code ---*/
  1059. __Pyx_RefNannyFinishContext();
  1060. return 0;
  1061. }
  1062. #if PY_MAJOR_VERSION < 3
  1063. #ifdef CYTHON_NO_PYINIT_EXPORT
  1064. #define __Pyx_PyMODINIT_FUNC void
  1065. #else
  1066. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  1067. #endif
  1068. #else
  1069. #ifdef CYTHON_NO_PYINIT_EXPORT
  1070. #define __Pyx_PyMODINIT_FUNC PyObject *
  1071. #else
  1072. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  1073. #endif
  1074. #endif
  1075. #ifndef CYTHON_SMALL_CODE
  1076. #if defined(__clang__)
  1077. #define CYTHON_SMALL_CODE
  1078. #elif defined(__GNUC__) && (!(defined(__cplusplus)) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)))
  1079. #define CYTHON_SMALL_CODE __attribute__((optimize("Os")))
  1080. #else
  1081. #define CYTHON_SMALL_CODE
  1082. #endif
  1083. #endif
  1084. #if PY_MAJOR_VERSION < 3
  1085. __Pyx_PyMODINIT_FUNC initcytpl(void) CYTHON_SMALL_CODE; /*proto*/
  1086. __Pyx_PyMODINIT_FUNC initcytpl(void)
  1087. #else
  1088. __Pyx_PyMODINIT_FUNC PyInit_cytpl(void) CYTHON_SMALL_CODE; /*proto*/
  1089. __Pyx_PyMODINIT_FUNC PyInit_cytpl(void)
  1090. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1091. {
  1092. return PyModuleDef_Init(&__pyx_moduledef);
  1093. }
  1094. static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) {
  1095. PyObject *value = PyObject_GetAttrString(spec, from_name);
  1096. int result = 0;
  1097. if (likely(value)) {
  1098. result = PyDict_SetItemString(moddict, to_name, value);
  1099. Py_DECREF(value);
  1100. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  1101. PyErr_Clear();
  1102. } else {
  1103. result = -1;
  1104. }
  1105. return result;
  1106. }
  1107. static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  1108. PyObject *module = NULL, *moddict, *modname;
  1109. if (__pyx_m)
  1110. return __Pyx_NewRef(__pyx_m);
  1111. modname = PyObject_GetAttrString(spec, "name");
  1112. if (unlikely(!modname)) goto bad;
  1113. module = PyModule_NewObject(modname);
  1114. Py_DECREF(modname);
  1115. if (unlikely(!module)) goto bad;
  1116. moddict = PyModule_GetDict(module);
  1117. if (unlikely(!moddict)) goto bad;
  1118. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__") < 0)) goto bad;
  1119. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad;
  1120. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad;
  1121. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad;
  1122. return module;
  1123. bad:
  1124. Py_XDECREF(module);
  1125. return NULL;
  1126. }
  1127. static int __pyx_pymod_exec_cytpl(PyObject *__pyx_pyinit_module)
  1128. #endif
  1129. #endif
  1130. {
  1131. PyObject *__pyx_t_1 = NULL;
  1132. __Pyx_RefNannyDeclarations
  1133. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1134. if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0;
  1135. #elif PY_MAJOR_VERSION >= 3
  1136. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  1137. #endif
  1138. #if CYTHON_REFNANNY
  1139. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  1140. if (!__Pyx_RefNanny) {
  1141. PyErr_Clear();
  1142. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  1143. if (!__Pyx_RefNanny)
  1144. Py_FatalError("failed to import 'refnanny' module");
  1145. }
  1146. #endif
  1147. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_cytpl(void)", 0);
  1148. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1149. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  1150. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  1151. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  1152. #ifdef __Pyx_CyFunction_USED
  1153. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1154. #endif
  1155. #ifdef __Pyx_FusedFunction_USED
  1156. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1157. #endif
  1158. #ifdef __Pyx_Coroutine_USED
  1159. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1160. #endif
  1161. #ifdef __Pyx_Generator_USED
  1162. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1163. #endif
  1164. #ifdef __Pyx_AsyncGen_USED
  1165. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1166. #endif
  1167. #ifdef __Pyx_StopAsyncIteration_USED
  1168. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1169. #endif
  1170. /*--- Library function declarations ---*/
  1171. /*--- Threads initialization code ---*/
  1172. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  1173. #ifdef WITH_THREAD /* Python build with threading support? */
  1174. PyEval_InitThreads();
  1175. #endif
  1176. #endif
  1177. /*--- Module creation code ---*/
  1178. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1179. __pyx_m = __pyx_pyinit_module;
  1180. Py_INCREF(__pyx_m);
  1181. #else
  1182. #if PY_MAJOR_VERSION < 3
  1183. __pyx_m = Py_InitModule4("cytpl", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  1184. #else
  1185. __pyx_m = PyModule_Create(&__pyx_moduledef);
  1186. #endif
  1187. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  1188. #endif
  1189. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  1190. Py_INCREF(__pyx_d);
  1191. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  1192. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  1193. #if CYTHON_COMPILING_IN_PYPY
  1194. Py_INCREF(__pyx_b);
  1195. #endif
  1196. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  1197. /*--- Initialize various global constants etc. ---*/
  1198. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1199. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  1200. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1201. #endif
  1202. if (__pyx_module_is_main_lakesuperior__cy_include__cytpl) {
  1203. if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1204. }
  1205. #if PY_MAJOR_VERSION >= 3
  1206. {
  1207. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  1208. if (!PyDict_GetItemString(modules, "lakesuperior.cy_include.cytpl")) {
  1209. if (unlikely(PyDict_SetItemString(modules, "lakesuperior.cy_include.cytpl", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  1210. }
  1211. }
  1212. #endif
  1213. /*--- Builtin init code ---*/
  1214. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1215. /*--- Constants init code ---*/
  1216. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1217. /*--- Global type/function init code ---*/
  1218. (void)__Pyx_modinit_global_init_code();
  1219. (void)__Pyx_modinit_variable_export_code();
  1220. (void)__Pyx_modinit_function_export_code();
  1221. (void)__Pyx_modinit_type_init_code();
  1222. if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
  1223. (void)__Pyx_modinit_variable_import_code();
  1224. (void)__Pyx_modinit_function_import_code();
  1225. /*--- Execution code ---*/
  1226. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  1227. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1228. #endif
  1229. /* "lakesuperior/cy_include/cytpl.pxd":1
  1230. * from cpython.string cimport va_list # <<<<<<<<<<<<<<
  1231. * from libc.stdint cimport uint32_t
  1232. *
  1233. */
  1234. __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  1235. __Pyx_GOTREF(__pyx_t_1);
  1236. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1237. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1238. /*--- Wrapped vars code ---*/
  1239. goto __pyx_L0;
  1240. __pyx_L1_error:;
  1241. __Pyx_XDECREF(__pyx_t_1);
  1242. if (__pyx_m) {
  1243. if (__pyx_d) {
  1244. __Pyx_AddTraceback("init lakesuperior.cy_include.cytpl", 0, __pyx_lineno, __pyx_filename);
  1245. }
  1246. Py_DECREF(__pyx_m); __pyx_m = 0;
  1247. } else if (!PyErr_Occurred()) {
  1248. PyErr_SetString(PyExc_ImportError, "init lakesuperior.cy_include.cytpl");
  1249. }
  1250. __pyx_L0:;
  1251. __Pyx_RefNannyFinishContext();
  1252. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1253. return (__pyx_m != NULL) ? 0 : -1;
  1254. #elif PY_MAJOR_VERSION >= 3
  1255. return __pyx_m;
  1256. #else
  1257. return;
  1258. #endif
  1259. }
  1260. /* --- Runtime support code --- */
  1261. /* Refnanny */
  1262. #if CYTHON_REFNANNY
  1263. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  1264. PyObject *m = NULL, *p = NULL;
  1265. void *r = NULL;
  1266. m = PyImport_ImportModule((char *)modname);
  1267. if (!m) goto end;
  1268. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  1269. if (!p) goto end;
  1270. r = PyLong_AsVoidPtr(p);
  1271. end:
  1272. Py_XDECREF(p);
  1273. Py_XDECREF(m);
  1274. return (__Pyx_RefNannyAPIStruct *)r;
  1275. }
  1276. #endif
  1277. /* PyObjectGetAttrStr */
  1278. #if CYTHON_USE_TYPE_SLOTS
  1279. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  1280. PyTypeObject* tp = Py_TYPE(obj);
  1281. if (likely(tp->tp_getattro))
  1282. return tp->tp_getattro(obj, attr_name);
  1283. #if PY_MAJOR_VERSION < 3
  1284. if (likely(tp->tp_getattr))
  1285. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  1286. #endif
  1287. return PyObject_GetAttr(obj, attr_name);
  1288. }
  1289. #endif
  1290. /* PyErrFetchRestore */
  1291. #if CYTHON_FAST_THREAD_STATE
  1292. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  1293. PyObject *tmp_type, *tmp_value, *tmp_tb;
  1294. tmp_type = tstate->curexc_type;
  1295. tmp_value = tstate->curexc_value;
  1296. tmp_tb = tstate->curexc_traceback;
  1297. tstate->curexc_type = type;
  1298. tstate->curexc_value = value;
  1299. tstate->curexc_traceback = tb;
  1300. Py_XDECREF(tmp_type);
  1301. Py_XDECREF(tmp_value);
  1302. Py_XDECREF(tmp_tb);
  1303. }
  1304. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  1305. *type = tstate->curexc_type;
  1306. *value = tstate->curexc_value;
  1307. *tb = tstate->curexc_traceback;
  1308. tstate->curexc_type = 0;
  1309. tstate->curexc_value = 0;
  1310. tstate->curexc_traceback = 0;
  1311. }
  1312. #endif
  1313. /* CLineInTraceback */
  1314. #ifndef CYTHON_CLINE_IN_TRACEBACK
  1315. static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) {
  1316. PyObject *use_cline;
  1317. PyObject *ptype, *pvalue, *ptraceback;
  1318. #if CYTHON_COMPILING_IN_CPYTHON
  1319. PyObject **cython_runtime_dict;
  1320. #endif
  1321. if (unlikely(!__pyx_cython_runtime)) {
  1322. return c_line;
  1323. }
  1324. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  1325. #if CYTHON_COMPILING_IN_CPYTHON
  1326. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  1327. if (likely(cython_runtime_dict)) {
  1328. use_cline = __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback);
  1329. } else
  1330. #endif
  1331. {
  1332. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  1333. if (use_cline_obj) {
  1334. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  1335. Py_DECREF(use_cline_obj);
  1336. } else {
  1337. PyErr_Clear();
  1338. use_cline = NULL;
  1339. }
  1340. }
  1341. if (!use_cline) {
  1342. c_line = 0;
  1343. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  1344. }
  1345. else if (PyObject_Not(use_cline) != 0) {
  1346. c_line = 0;
  1347. }
  1348. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  1349. return c_line;
  1350. }
  1351. #endif
  1352. /* CodeObjectCache */
  1353. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  1354. int start = 0, mid = 0, end = count - 1;
  1355. if (end >= 0 && code_line > entries[end].code_line) {
  1356. return count;
  1357. }
  1358. while (start < end) {
  1359. mid = start + (end - start) / 2;
  1360. if (code_line < entries[mid].code_line) {
  1361. end = mid;
  1362. } else if (code_line > entries[mid].code_line) {
  1363. start = mid + 1;
  1364. } else {
  1365. return mid;
  1366. }
  1367. }
  1368. if (code_line <= entries[mid].code_line) {
  1369. return mid;
  1370. } else {
  1371. return mid + 1;
  1372. }
  1373. }
  1374. static PyCodeObject *__pyx_find_code_object(int code_line) {
  1375. PyCodeObject* code_object;
  1376. int pos;
  1377. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  1378. return NULL;
  1379. }
  1380. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  1381. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  1382. return NULL;
  1383. }
  1384. code_object = __pyx_code_cache.entries[pos].code_object;
  1385. Py_INCREF(code_object);
  1386. return code_object;
  1387. }
  1388. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  1389. int pos, i;
  1390. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  1391. if (unlikely(!code_line)) {
  1392. return;
  1393. }
  1394. if (unlikely(!entries)) {
  1395. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  1396. if (likely(entries)) {
  1397. __pyx_code_cache.entries = entries;
  1398. __pyx_code_cache.max_count = 64;
  1399. __pyx_code_cache.count = 1;
  1400. entries[0].code_line = code_line;
  1401. entries[0].code_object = code_object;
  1402. Py_INCREF(code_object);
  1403. }
  1404. return;
  1405. }
  1406. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  1407. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  1408. PyCodeObject* tmp = entries[pos].code_object;
  1409. entries[pos].code_object = code_object;
  1410. Py_DECREF(tmp);
  1411. return;
  1412. }
  1413. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  1414. int new_max = __pyx_code_cache.max_count + 64;
  1415. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  1416. __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  1417. if (unlikely(!entries)) {
  1418. return;
  1419. }
  1420. __pyx_code_cache.entries = entries;
  1421. __pyx_code_cache.max_count = new_max;
  1422. }
  1423. for (i=__pyx_code_cache.count; i>pos; i--) {
  1424. entries[i] = entries[i-1];
  1425. }
  1426. entries[pos].code_line = code_line;
  1427. entries[pos].code_object = code_object;
  1428. __pyx_code_cache.count++;
  1429. Py_INCREF(code_object);
  1430. }
  1431. /* AddTraceback */
  1432. #include "compile.h"
  1433. #include "frameobject.h"
  1434. #include "traceback.h"
  1435. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  1436. const char *funcname, int c_line,
  1437. int py_line, const char *filename) {
  1438. PyCodeObject *py_code = 0;
  1439. PyObject *py_srcfile = 0;
  1440. PyObject *py_funcname = 0;
  1441. #if PY_MAJOR_VERSION < 3
  1442. py_srcfile = PyString_FromString(filename);
  1443. #else
  1444. py_srcfile = PyUnicode_FromString(filename);
  1445. #endif
  1446. if (!py_srcfile) goto bad;
  1447. if (c_line) {
  1448. #if PY_MAJOR_VERSION < 3
  1449. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  1450. #else
  1451. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  1452. #endif
  1453. }
  1454. else {
  1455. #if PY_MAJOR_VERSION < 3
  1456. py_funcname = PyString_FromString(funcname);
  1457. #else
  1458. py_funcname = PyUnicode_FromString(funcname);
  1459. #endif
  1460. }
  1461. if (!py_funcname) goto bad;
  1462. py_code = __Pyx_PyCode_New(
  1463. 0,
  1464. 0,
  1465. 0,
  1466. 0,
  1467. 0,
  1468. __pyx_empty_bytes, /*PyObject *code,*/
  1469. __pyx_empty_tuple, /*PyObject *consts,*/
  1470. __pyx_empty_tuple, /*PyObject *names,*/
  1471. __pyx_empty_tuple, /*PyObject *varnames,*/
  1472. __pyx_empty_tuple, /*PyObject *freevars,*/
  1473. __pyx_empty_tuple, /*PyObject *cellvars,*/
  1474. py_srcfile, /*PyObject *filename,*/
  1475. py_funcname, /*PyObject *name,*/
  1476. py_line,
  1477. __pyx_empty_bytes /*PyObject *lnotab*/
  1478. );
  1479. Py_DECREF(py_srcfile);
  1480. Py_DECREF(py_funcname);
  1481. return py_code;
  1482. bad:
  1483. Py_XDECREF(py_srcfile);
  1484. Py_XDECREF(py_funcname);
  1485. return NULL;
  1486. }
  1487. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1488. int py_line, const char *filename) {
  1489. PyCodeObject *py_code = 0;
  1490. PyFrameObject *py_frame = 0;
  1491. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  1492. if (c_line) {
  1493. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  1494. }
  1495. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  1496. if (!py_code) {
  1497. py_code = __Pyx_CreateCodeObjectForTraceback(
  1498. funcname, c_line, py_line, filename);
  1499. if (!py_code) goto bad;
  1500. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  1501. }
  1502. py_frame = PyFrame_New(
  1503. tstate, /*PyThreadState *tstate,*/
  1504. py_code, /*PyCodeObject *code,*/
  1505. __pyx_d, /*PyObject *globals,*/
  1506. 0 /*PyObject *locals*/
  1507. );
  1508. if (!py_frame) goto bad;
  1509. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  1510. PyTraceBack_Here(py_frame);
  1511. bad:
  1512. Py_XDECREF(py_code);
  1513. Py_XDECREF(py_frame);
  1514. }
  1515. /* CIntToPy */
  1516. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  1517. const long neg_one = (long) -1, const_zero = (long) 0;
  1518. const int is_unsigned = neg_one > const_zero;
  1519. if (is_unsigned) {
  1520. if (sizeof(long) < sizeof(long)) {
  1521. return PyInt_FromLong((long) value);
  1522. } else if (sizeof(long) <= sizeof(unsigned long)) {
  1523. return PyLong_FromUnsignedLong((unsigned long) value);
  1524. #ifdef HAVE_LONG_LONG
  1525. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  1526. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  1527. #endif
  1528. }
  1529. } else {
  1530. if (sizeof(long) <= sizeof(long)) {
  1531. return PyInt_FromLong((long) value);
  1532. #ifdef HAVE_LONG_LONG
  1533. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  1534. return PyLong_FromLongLong((PY_LONG_LONG) value);
  1535. #endif
  1536. }
  1537. }
  1538. {
  1539. int one = 1; int little = (int)*(unsigned char *)&one;
  1540. unsigned char *bytes = (unsigned char *)&value;
  1541. return _PyLong_FromByteArray(bytes, sizeof(long),
  1542. little, !is_unsigned);
  1543. }
  1544. }
  1545. /* CIntFromPyVerify */
  1546. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  1547. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  1548. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  1549. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  1550. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  1551. {\
  1552. func_type value = func_value;\
  1553. if (sizeof(target_type) < sizeof(func_type)) {\
  1554. if (unlikely(value != (func_type) (target_type) value)) {\
  1555. func_type zero = 0;\
  1556. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  1557. return (target_type) -1;\
  1558. if (is_unsigned && unlikely(value < zero))\
  1559. goto raise_neg_overflow;\
  1560. else\
  1561. goto raise_overflow;\
  1562. }\
  1563. }\
  1564. return (target_type) value;\
  1565. }
  1566. /* CIntFromPy */
  1567. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  1568. const long neg_one = (long) -1, const_zero = (long) 0;
  1569. const int is_unsigned = neg_one > const_zero;
  1570. #if PY_MAJOR_VERSION < 3
  1571. if (likely(PyInt_Check(x))) {
  1572. if (sizeof(long) < sizeof(long)) {
  1573. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  1574. } else {
  1575. long val = PyInt_AS_LONG(x);
  1576. if (is_unsigned && unlikely(val < 0)) {
  1577. goto raise_neg_overflow;
  1578. }
  1579. return (long) val;
  1580. }
  1581. } else
  1582. #endif
  1583. if (likely(PyLong_Check(x))) {
  1584. if (is_unsigned) {
  1585. #if CYTHON_USE_PYLONG_INTERNALS
  1586. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1587. switch (Py_SIZE(x)) {
  1588. case 0: return (long) 0;
  1589. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  1590. case 2:
  1591. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  1592. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1593. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1594. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  1595. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  1596. }
  1597. }
  1598. break;
  1599. case 3:
  1600. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  1601. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1602. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1603. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  1604. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  1605. }
  1606. }
  1607. break;
  1608. case 4:
  1609. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  1610. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1611. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1612. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  1613. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  1614. }
  1615. }
  1616. break;
  1617. }
  1618. #endif
  1619. #if CYTHON_COMPILING_IN_CPYTHON
  1620. if (unlikely(Py_SIZE(x) < 0)) {
  1621. goto raise_neg_overflow;
  1622. }
  1623. #else
  1624. {
  1625. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  1626. if (unlikely(result < 0))
  1627. return (long) -1;
  1628. if (unlikely(result == 1))
  1629. goto raise_neg_overflow;
  1630. }
  1631. #endif
  1632. if (sizeof(long) <= sizeof(unsigned long)) {
  1633. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  1634. #ifdef HAVE_LONG_LONG
  1635. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  1636. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  1637. #endif
  1638. }
  1639. } else {
  1640. #if CYTHON_USE_PYLONG_INTERNALS
  1641. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1642. switch (Py_SIZE(x)) {
  1643. case 0: return (long) 0;
  1644. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  1645. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  1646. case -2:
  1647. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  1648. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1649. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1650. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  1651. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1652. }
  1653. }
  1654. break;
  1655. case 2:
  1656. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  1657. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1658. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1659. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  1660. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1661. }
  1662. }
  1663. break;
  1664. case -3:
  1665. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  1666. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1667. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1668. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  1669. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1670. }
  1671. }
  1672. break;
  1673. case 3:
  1674. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  1675. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1676. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1677. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  1678. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1679. }
  1680. }
  1681. break;
  1682. case -4:
  1683. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  1684. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1685. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1686. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  1687. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1688. }
  1689. }
  1690. break;
  1691. case 4:
  1692. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  1693. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1694. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1695. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  1696. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  1697. }
  1698. }
  1699. break;
  1700. }
  1701. #endif
  1702. if (sizeof(long) <= sizeof(long)) {
  1703. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  1704. #ifdef HAVE_LONG_LONG
  1705. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  1706. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  1707. #endif
  1708. }
  1709. }
  1710. {
  1711. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  1712. PyErr_SetString(PyExc_RuntimeError,
  1713. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  1714. #else
  1715. long val;
  1716. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  1717. #if PY_MAJOR_VERSION < 3
  1718. if (likely(v) && !PyLong_Check(v)) {
  1719. PyObject *tmp = v;
  1720. v = PyNumber_Long(tmp);
  1721. Py_DECREF(tmp);
  1722. }
  1723. #endif
  1724. if (likely(v)) {
  1725. int one = 1; int is_little = (int)*(unsigned char *)&one;
  1726. unsigned char *bytes = (unsigned char *)&val;
  1727. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  1728. bytes, sizeof(val),
  1729. is_little, !is_unsigned);
  1730. Py_DECREF(v);
  1731. if (likely(!ret))
  1732. return val;
  1733. }
  1734. #endif
  1735. return (long) -1;
  1736. }
  1737. } else {
  1738. long val;
  1739. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  1740. if (!tmp) return (long) -1;
  1741. val = __Pyx_PyInt_As_long(tmp);
  1742. Py_DECREF(tmp);
  1743. return val;
  1744. }
  1745. raise_overflow:
  1746. PyErr_SetString(PyExc_OverflowError,
  1747. "value too large to convert to long");
  1748. return (long) -1;
  1749. raise_neg_overflow:
  1750. PyErr_SetString(PyExc_OverflowError,
  1751. "can't convert negative value to long");
  1752. return (long) -1;
  1753. }
  1754. /* CIntFromPy */
  1755. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  1756. const int neg_one = (int) -1, const_zero = (int) 0;
  1757. const int is_unsigned = neg_one > const_zero;
  1758. #if PY_MAJOR_VERSION < 3
  1759. if (likely(PyInt_Check(x))) {
  1760. if (sizeof(int) < sizeof(long)) {
  1761. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  1762. } else {
  1763. long val = PyInt_AS_LONG(x);
  1764. if (is_unsigned && unlikely(val < 0)) {
  1765. goto raise_neg_overflow;
  1766. }
  1767. return (int) val;
  1768. }
  1769. } else
  1770. #endif
  1771. if (likely(PyLong_Check(x))) {
  1772. if (is_unsigned) {
  1773. #if CYTHON_USE_PYLONG_INTERNALS
  1774. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1775. switch (Py_SIZE(x)) {
  1776. case 0: return (int) 0;
  1777. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  1778. case 2:
  1779. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  1780. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1781. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1782. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  1783. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  1784. }
  1785. }
  1786. break;
  1787. case 3:
  1788. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  1789. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1790. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1791. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  1792. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  1793. }
  1794. }
  1795. break;
  1796. case 4:
  1797. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  1798. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1799. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1800. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  1801. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  1802. }
  1803. }
  1804. break;
  1805. }
  1806. #endif
  1807. #if CYTHON_COMPILING_IN_CPYTHON
  1808. if (unlikely(Py_SIZE(x) < 0)) {
  1809. goto raise_neg_overflow;
  1810. }
  1811. #else
  1812. {
  1813. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  1814. if (unlikely(result < 0))
  1815. return (int) -1;
  1816. if (unlikely(result == 1))
  1817. goto raise_neg_overflow;
  1818. }
  1819. #endif
  1820. if (sizeof(int) <= sizeof(unsigned long)) {
  1821. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  1822. #ifdef HAVE_LONG_LONG
  1823. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  1824. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  1825. #endif
  1826. }
  1827. } else {
  1828. #if CYTHON_USE_PYLONG_INTERNALS
  1829. const digit* digits = ((PyLongObject*)x)->ob_digit;
  1830. switch (Py_SIZE(x)) {
  1831. case 0: return (int) 0;
  1832. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  1833. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  1834. case -2:
  1835. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  1836. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1837. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1838. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  1839. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1840. }
  1841. }
  1842. break;
  1843. case 2:
  1844. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  1845. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  1846. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1847. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  1848. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1849. }
  1850. }
  1851. break;
  1852. case -3:
  1853. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  1854. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1855. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1856. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  1857. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1858. }
  1859. }
  1860. break;
  1861. case 3:
  1862. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  1863. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  1864. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1865. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  1866. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1867. }
  1868. }
  1869. break;
  1870. case -4:
  1871. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  1872. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1873. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1874. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  1875. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1876. }
  1877. }
  1878. break;
  1879. case 4:
  1880. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  1881. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  1882. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  1883. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  1884. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  1885. }
  1886. }
  1887. break;
  1888. }
  1889. #endif
  1890. if (sizeof(int) <= sizeof(long)) {
  1891. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  1892. #ifdef HAVE_LONG_LONG
  1893. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  1894. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  1895. #endif
  1896. }
  1897. }
  1898. {
  1899. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  1900. PyErr_SetString(PyExc_RuntimeError,
  1901. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  1902. #else
  1903. int val;
  1904. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  1905. #if PY_MAJOR_VERSION < 3
  1906. if (likely(v) && !PyLong_Check(v)) {
  1907. PyObject *tmp = v;
  1908. v = PyNumber_Long(tmp);
  1909. Py_DECREF(tmp);
  1910. }
  1911. #endif
  1912. if (likely(v)) {
  1913. int one = 1; int is_little = (int)*(unsigned char *)&one;
  1914. unsigned char *bytes = (unsigned char *)&val;
  1915. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  1916. bytes, sizeof(val),
  1917. is_little, !is_unsigned);
  1918. Py_DECREF(v);
  1919. if (likely(!ret))
  1920. return val;
  1921. }
  1922. #endif
  1923. return (int) -1;
  1924. }
  1925. } else {
  1926. int val;
  1927. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  1928. if (!tmp) return (int) -1;
  1929. val = __Pyx_PyInt_As_int(tmp);
  1930. Py_DECREF(tmp);
  1931. return val;
  1932. }
  1933. raise_overflow:
  1934. PyErr_SetString(PyExc_OverflowError,
  1935. "value too large to convert to int");
  1936. return (int) -1;
  1937. raise_neg_overflow:
  1938. PyErr_SetString(PyExc_OverflowError,
  1939. "can't convert negative value to int");
  1940. return (int) -1;
  1941. }
  1942. /* FastTypeChecks */
  1943. #if CYTHON_COMPILING_IN_CPYTHON
  1944. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  1945. while (a) {
  1946. a = a->tp_base;
  1947. if (a == b)
  1948. return 1;
  1949. }
  1950. return b == &PyBaseObject_Type;
  1951. }
  1952. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  1953. PyObject *mro;
  1954. if (a == b) return 1;
  1955. mro = a->tp_mro;
  1956. if (likely(mro)) {
  1957. Py_ssize_t i, n;
  1958. n = PyTuple_GET_SIZE(mro);
  1959. for (i = 0; i < n; i++) {
  1960. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  1961. return 1;
  1962. }
  1963. return 0;
  1964. }
  1965. return __Pyx_InBases(a, b);
  1966. }
  1967. #if PY_MAJOR_VERSION == 2
  1968. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  1969. PyObject *exception, *value, *tb;
  1970. int res;
  1971. __Pyx_PyThreadState_declare
  1972. __Pyx_PyThreadState_assign
  1973. __Pyx_ErrFetch(&exception, &value, &tb);
  1974. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  1975. if (unlikely(res == -1)) {
  1976. PyErr_WriteUnraisable(err);
  1977. res = 0;
  1978. }
  1979. if (!res) {
  1980. res = PyObject_IsSubclass(err, exc_type2);
  1981. if (unlikely(res == -1)) {
  1982. PyErr_WriteUnraisable(err);
  1983. res = 0;
  1984. }
  1985. }
  1986. __Pyx_ErrRestore(exception, value, tb);
  1987. return res;
  1988. }
  1989. #else
  1990. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  1991. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  1992. if (!res) {
  1993. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  1994. }
  1995. return res;
  1996. }
  1997. #endif
  1998. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  1999. Py_ssize_t i, n;
  2000. assert(PyExceptionClass_Check(exc_type));
  2001. n = PyTuple_GET_SIZE(tuple);
  2002. #if PY_MAJOR_VERSION >= 3
  2003. for (i=0; i<n; i++) {
  2004. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  2005. }
  2006. #endif
  2007. for (i=0; i<n; i++) {
  2008. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  2009. #if PY_MAJOR_VERSION < 3
  2010. if (likely(exc_type == t)) return 1;
  2011. #endif
  2012. if (likely(PyExceptionClass_Check(t))) {
  2013. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  2014. } else {
  2015. }
  2016. }
  2017. return 0;
  2018. }
  2019. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  2020. if (likely(err == exc_type)) return 1;
  2021. if (likely(PyExceptionClass_Check(err))) {
  2022. if (likely(PyExceptionClass_Check(exc_type))) {
  2023. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  2024. } else if (likely(PyTuple_Check(exc_type))) {
  2025. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  2026. } else {
  2027. }
  2028. }
  2029. return PyErr_GivenExceptionMatches(err, exc_type);
  2030. }
  2031. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  2032. assert(PyExceptionClass_Check(exc_type1));
  2033. assert(PyExceptionClass_Check(exc_type2));
  2034. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  2035. if (likely(PyExceptionClass_Check(err))) {
  2036. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  2037. }
  2038. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  2039. }
  2040. #endif
  2041. /* CheckBinaryVersion */
  2042. static int __Pyx_check_binary_version(void) {
  2043. char ctversion[4], rtversion[4];
  2044. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  2045. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  2046. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  2047. char message[200];
  2048. PyOS_snprintf(message, sizeof(message),
  2049. "compiletime version %s of module '%.100s' "
  2050. "does not match runtime version %s",
  2051. ctversion, __Pyx_MODULE_NAME, rtversion);
  2052. return PyErr_WarnEx(NULL, message, 1);
  2053. }
  2054. return 0;
  2055. }
  2056. /* ModuleImport */
  2057. #ifndef __PYX_HAVE_RT_ImportModule
  2058. #define __PYX_HAVE_RT_ImportModule
  2059. static PyObject *__Pyx_ImportModule(const char *name) {
  2060. PyObject *py_name = 0;
  2061. PyObject *py_module = 0;
  2062. py_name = __Pyx_PyIdentifier_FromString(name);
  2063. if (!py_name)
  2064. goto bad;
  2065. py_module = PyImport_Import(py_name);
  2066. Py_DECREF(py_name);
  2067. return py_module;
  2068. bad:
  2069. Py_XDECREF(py_name);
  2070. return 0;
  2071. }
  2072. #endif
  2073. /* TypeImport */
  2074. #ifndef __PYX_HAVE_RT_ImportType
  2075. #define __PYX_HAVE_RT_ImportType
  2076. static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
  2077. size_t size, int strict)
  2078. {
  2079. PyObject *py_module = 0;
  2080. PyObject *result = 0;
  2081. PyObject *py_name = 0;
  2082. char warning[200];
  2083. Py_ssize_t basicsize;
  2084. #ifdef Py_LIMITED_API
  2085. PyObject *py_basicsize;
  2086. #endif
  2087. py_module = __Pyx_ImportModule(module_name);
  2088. if (!py_module)
  2089. goto bad;
  2090. py_name = __Pyx_PyIdentifier_FromString(class_name);
  2091. if (!py_name)
  2092. goto bad;
  2093. result = PyObject_GetAttr(py_module, py_name);
  2094. Py_DECREF(py_name);
  2095. py_name = 0;
  2096. Py_DECREF(py_module);
  2097. py_module = 0;
  2098. if (!result)
  2099. goto bad;
  2100. if (!PyType_Check(result)) {
  2101. PyErr_Format(PyExc_TypeError,
  2102. "%.200s.%.200s is not a type object",
  2103. module_name, class_name);
  2104. goto bad;
  2105. }
  2106. #ifndef Py_LIMITED_API
  2107. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  2108. #else
  2109. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  2110. if (!py_basicsize)
  2111. goto bad;
  2112. basicsize = PyLong_AsSsize_t(py_basicsize);
  2113. Py_DECREF(py_basicsize);
  2114. py_basicsize = 0;
  2115. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  2116. goto bad;
  2117. #endif
  2118. if (!strict && (size_t)basicsize > size) {
  2119. PyOS_snprintf(warning, sizeof(warning),
  2120. "%s.%s size changed, may indicate binary incompatibility. Expected %zd, got %zd",
  2121. module_name, class_name, basicsize, size);
  2122. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  2123. }
  2124. else if ((size_t)basicsize != size) {
  2125. PyErr_Format(PyExc_ValueError,
  2126. "%.200s.%.200s has the wrong size, try recompiling. Expected %zd, got %zd",
  2127. module_name, class_name, basicsize, size);
  2128. goto bad;
  2129. }
  2130. return (PyTypeObject *)result;
  2131. bad:
  2132. Py_XDECREF(py_module);
  2133. Py_XDECREF(result);
  2134. return NULL;
  2135. }
  2136. #endif
  2137. /* InitStrings */
  2138. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  2139. while (t->p) {
  2140. #if PY_MAJOR_VERSION < 3
  2141. if (t->is_unicode) {
  2142. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  2143. } else if (t->intern) {
  2144. *t->p = PyString_InternFromString(t->s);
  2145. } else {
  2146. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  2147. }
  2148. #else
  2149. if (t->is_unicode | t->is_str) {
  2150. if (t->intern) {
  2151. *t->p = PyUnicode_InternFromString(t->s);
  2152. } else if (t->encoding) {
  2153. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  2154. } else {
  2155. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  2156. }
  2157. } else {
  2158. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  2159. }
  2160. #endif
  2161. if (!*t->p)
  2162. return -1;
  2163. if (PyObject_Hash(*t->p) == -1)
  2164. return -1;
  2165. ++t;
  2166. }
  2167. return 0;
  2168. }
  2169. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  2170. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  2171. }
  2172. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  2173. Py_ssize_t ignore;
  2174. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  2175. }
  2176. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  2177. #if !CYTHON_PEP393_ENABLED
  2178. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  2179. char* defenc_c;
  2180. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  2181. if (!defenc) return NULL;
  2182. defenc_c = PyBytes_AS_STRING(defenc);
  2183. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  2184. {
  2185. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  2186. char* c;
  2187. for (c = defenc_c; c < end; c++) {
  2188. if ((unsigned char) (*c) >= 128) {
  2189. PyUnicode_AsASCIIString(o);
  2190. return NULL;
  2191. }
  2192. }
  2193. }
  2194. #endif
  2195. *length = PyBytes_GET_SIZE(defenc);
  2196. return defenc_c;
  2197. }
  2198. #else
  2199. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  2200. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  2201. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  2202. if (likely(PyUnicode_IS_ASCII(o))) {
  2203. *length = PyUnicode_GET_LENGTH(o);
  2204. return PyUnicode_AsUTF8(o);
  2205. } else {
  2206. PyUnicode_AsASCIIString(o);
  2207. return NULL;
  2208. }
  2209. #else
  2210. return PyUnicode_AsUTF8AndSize(o, length);
  2211. #endif
  2212. }
  2213. #endif
  2214. #endif
  2215. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  2216. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  2217. if (
  2218. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  2219. __Pyx_sys_getdefaultencoding_not_ascii &&
  2220. #endif
  2221. PyUnicode_Check(o)) {
  2222. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  2223. } else
  2224. #endif
  2225. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  2226. if (PyByteArray_Check(o)) {
  2227. *length = PyByteArray_GET_SIZE(o);
  2228. return PyByteArray_AS_STRING(o);
  2229. } else
  2230. #endif
  2231. {
  2232. char* result;
  2233. int r = PyBytes_AsStringAndSize(o, &result, length);
  2234. if (unlikely(r < 0)) {
  2235. return NULL;
  2236. } else {
  2237. return result;
  2238. }
  2239. }
  2240. }
  2241. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  2242. int is_true = x == Py_True;
  2243. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  2244. else return PyObject_IsTrue(x);
  2245. }
  2246. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  2247. #if PY_MAJOR_VERSION >= 3
  2248. if (PyLong_Check(result)) {
  2249. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  2250. "__int__ returned non-int (type %.200s). "
  2251. "The ability to return an instance of a strict subclass of int "
  2252. "is deprecated, and may be removed in a future version of Python.",
  2253. Py_TYPE(result)->tp_name)) {
  2254. Py_DECREF(result);
  2255. return NULL;
  2256. }
  2257. return result;
  2258. }
  2259. #endif
  2260. PyErr_Format(PyExc_TypeError,
  2261. "__%.4s__ returned non-%.4s (type %.200s)",
  2262. type_name, type_name, Py_TYPE(result)->tp_name);
  2263. Py_DECREF(result);
  2264. return NULL;
  2265. }
  2266. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  2267. #if CYTHON_USE_TYPE_SLOTS
  2268. PyNumberMethods *m;
  2269. #endif
  2270. const char *name = NULL;
  2271. PyObject *res = NULL;
  2272. #if PY_MAJOR_VERSION < 3
  2273. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  2274. #else
  2275. if (likely(PyLong_Check(x)))
  2276. #endif
  2277. return __Pyx_NewRef(x);
  2278. #if CYTHON_USE_TYPE_SLOTS
  2279. m = Py_TYPE(x)->tp_as_number;
  2280. #if PY_MAJOR_VERSION < 3
  2281. if (m && m->nb_int) {
  2282. name = "int";
  2283. res = m->nb_int(x);
  2284. }
  2285. else if (m && m->nb_long) {
  2286. name = "long";
  2287. res = m->nb_long(x);
  2288. }
  2289. #else
  2290. if (likely(m && m->nb_int)) {
  2291. name = "int";
  2292. res = m->nb_int(x);
  2293. }
  2294. #endif
  2295. #else
  2296. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  2297. res = PyNumber_Int(x);
  2298. }
  2299. #endif
  2300. if (likely(res)) {
  2301. #if PY_MAJOR_VERSION < 3
  2302. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  2303. #else
  2304. if (unlikely(!PyLong_CheckExact(res))) {
  2305. #endif
  2306. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  2307. }
  2308. }
  2309. else if (!PyErr_Occurred()) {
  2310. PyErr_SetString(PyExc_TypeError,
  2311. "an integer is required");
  2312. }
  2313. return res;
  2314. }
  2315. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  2316. Py_ssize_t ival;
  2317. PyObject *x;
  2318. #if PY_MAJOR_VERSION < 3
  2319. if (likely(PyInt_CheckExact(b))) {
  2320. if (sizeof(Py_ssize_t) >= sizeof(long))
  2321. return PyInt_AS_LONG(b);
  2322. else
  2323. return PyInt_AsSsize_t(x);
  2324. }
  2325. #endif
  2326. if (likely(PyLong_CheckExact(b))) {
  2327. #if CYTHON_USE_PYLONG_INTERNALS
  2328. const digit* digits = ((PyLongObject*)b)->ob_digit;
  2329. const Py_ssize_t size = Py_SIZE(b);
  2330. if (likely(__Pyx_sst_abs(size) <= 1)) {
  2331. ival = likely(size) ? digits[0] : 0;
  2332. if (size == -1) ival = -ival;
  2333. return ival;
  2334. } else {
  2335. switch (size) {
  2336. case 2:
  2337. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  2338. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2339. }
  2340. break;
  2341. case -2:
  2342. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  2343. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2344. }
  2345. break;
  2346. case 3:
  2347. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  2348. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2349. }
  2350. break;
  2351. case -3:
  2352. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  2353. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2354. }
  2355. break;
  2356. case 4:
  2357. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  2358. return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2359. }
  2360. break;
  2361. case -4:
  2362. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  2363. return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  2364. }
  2365. break;
  2366. }
  2367. }
  2368. #endif
  2369. return PyLong_AsSsize_t(b);
  2370. }
  2371. x = PyNumber_Index(b);
  2372. if (!x) return -1;
  2373. ival = PyInt_AsSsize_t(x);
  2374. Py_DECREF(x);
  2375. return ival;
  2376. }
  2377. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  2378. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  2379. }
  2380. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  2381. return PyInt_FromSize_t(ival);
  2382. }
  2383. #endif /* Py_PYTHON_H */