_websocket.c 134 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588
  1. /* Generated by Cython 0.29.21 */
  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_29_21"
  10. #define CYTHON_HEX_VERSION 0x001D15F0
  11. #define CYTHON_FUTURE_DIVISION 1
  12. #include <stddef.h>
  13. #ifndef offsetof
  14. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  15. #endif
  16. #if !defined(WIN32) && !defined(MS_WINDOWS)
  17. #ifndef __stdcall
  18. #define __stdcall
  19. #endif
  20. #ifndef __cdecl
  21. #define __cdecl
  22. #endif
  23. #ifndef __fastcall
  24. #define __fastcall
  25. #endif
  26. #endif
  27. #ifndef DL_IMPORT
  28. #define DL_IMPORT(t) t
  29. #endif
  30. #ifndef DL_EXPORT
  31. #define DL_EXPORT(t) t
  32. #endif
  33. #define __PYX_COMMA ,
  34. #ifndef HAVE_LONG_LONG
  35. #if PY_VERSION_HEX >= 0x02070000
  36. #define HAVE_LONG_LONG
  37. #endif
  38. #endif
  39. #ifndef PY_LONG_LONG
  40. #define PY_LONG_LONG LONG_LONG
  41. #endif
  42. #ifndef Py_HUGE_VAL
  43. #define Py_HUGE_VAL HUGE_VAL
  44. #endif
  45. #ifdef PYPY_VERSION
  46. #define CYTHON_COMPILING_IN_PYPY 1
  47. #define CYTHON_COMPILING_IN_PYSTON 0
  48. #define CYTHON_COMPILING_IN_CPYTHON 0
  49. #undef CYTHON_USE_TYPE_SLOTS
  50. #define CYTHON_USE_TYPE_SLOTS 0
  51. #undef CYTHON_USE_PYTYPE_LOOKUP
  52. #define CYTHON_USE_PYTYPE_LOOKUP 0
  53. #if PY_VERSION_HEX < 0x03050000
  54. #undef CYTHON_USE_ASYNC_SLOTS
  55. #define CYTHON_USE_ASYNC_SLOTS 0
  56. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  57. #define CYTHON_USE_ASYNC_SLOTS 1
  58. #endif
  59. #undef CYTHON_USE_PYLIST_INTERNALS
  60. #define CYTHON_USE_PYLIST_INTERNALS 0
  61. #undef CYTHON_USE_UNICODE_INTERNALS
  62. #define CYTHON_USE_UNICODE_INTERNALS 0
  63. #undef CYTHON_USE_UNICODE_WRITER
  64. #define CYTHON_USE_UNICODE_WRITER 0
  65. #undef CYTHON_USE_PYLONG_INTERNALS
  66. #define CYTHON_USE_PYLONG_INTERNALS 0
  67. #undef CYTHON_AVOID_BORROWED_REFS
  68. #define CYTHON_AVOID_BORROWED_REFS 1
  69. #undef CYTHON_ASSUME_SAFE_MACROS
  70. #define CYTHON_ASSUME_SAFE_MACROS 0
  71. #undef CYTHON_UNPACK_METHODS
  72. #define CYTHON_UNPACK_METHODS 0
  73. #undef CYTHON_FAST_THREAD_STATE
  74. #define CYTHON_FAST_THREAD_STATE 0
  75. #undef CYTHON_FAST_PYCALL
  76. #define CYTHON_FAST_PYCALL 0
  77. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  78. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  79. #undef CYTHON_USE_TP_FINALIZE
  80. #define CYTHON_USE_TP_FINALIZE 0
  81. #undef CYTHON_USE_DICT_VERSIONS
  82. #define CYTHON_USE_DICT_VERSIONS 0
  83. #undef CYTHON_USE_EXC_INFO_STACK
  84. #define CYTHON_USE_EXC_INFO_STACK 0
  85. #elif defined(PYSTON_VERSION)
  86. #define CYTHON_COMPILING_IN_PYPY 0
  87. #define CYTHON_COMPILING_IN_PYSTON 1
  88. #define CYTHON_COMPILING_IN_CPYTHON 0
  89. #ifndef CYTHON_USE_TYPE_SLOTS
  90. #define CYTHON_USE_TYPE_SLOTS 1
  91. #endif
  92. #undef CYTHON_USE_PYTYPE_LOOKUP
  93. #define CYTHON_USE_PYTYPE_LOOKUP 0
  94. #undef CYTHON_USE_ASYNC_SLOTS
  95. #define CYTHON_USE_ASYNC_SLOTS 0
  96. #undef CYTHON_USE_PYLIST_INTERNALS
  97. #define CYTHON_USE_PYLIST_INTERNALS 0
  98. #ifndef CYTHON_USE_UNICODE_INTERNALS
  99. #define CYTHON_USE_UNICODE_INTERNALS 1
  100. #endif
  101. #undef CYTHON_USE_UNICODE_WRITER
  102. #define CYTHON_USE_UNICODE_WRITER 0
  103. #undef CYTHON_USE_PYLONG_INTERNALS
  104. #define CYTHON_USE_PYLONG_INTERNALS 0
  105. #ifndef CYTHON_AVOID_BORROWED_REFS
  106. #define CYTHON_AVOID_BORROWED_REFS 0
  107. #endif
  108. #ifndef CYTHON_ASSUME_SAFE_MACROS
  109. #define CYTHON_ASSUME_SAFE_MACROS 1
  110. #endif
  111. #ifndef CYTHON_UNPACK_METHODS
  112. #define CYTHON_UNPACK_METHODS 1
  113. #endif
  114. #undef CYTHON_FAST_THREAD_STATE
  115. #define CYTHON_FAST_THREAD_STATE 0
  116. #undef CYTHON_FAST_PYCALL
  117. #define CYTHON_FAST_PYCALL 0
  118. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  119. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  120. #undef CYTHON_USE_TP_FINALIZE
  121. #define CYTHON_USE_TP_FINALIZE 0
  122. #undef CYTHON_USE_DICT_VERSIONS
  123. #define CYTHON_USE_DICT_VERSIONS 0
  124. #undef CYTHON_USE_EXC_INFO_STACK
  125. #define CYTHON_USE_EXC_INFO_STACK 0
  126. #else
  127. #define CYTHON_COMPILING_IN_PYPY 0
  128. #define CYTHON_COMPILING_IN_PYSTON 0
  129. #define CYTHON_COMPILING_IN_CPYTHON 1
  130. #ifndef CYTHON_USE_TYPE_SLOTS
  131. #define CYTHON_USE_TYPE_SLOTS 1
  132. #endif
  133. #if PY_VERSION_HEX < 0x02070000
  134. #undef CYTHON_USE_PYTYPE_LOOKUP
  135. #define CYTHON_USE_PYTYPE_LOOKUP 0
  136. #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
  137. #define CYTHON_USE_PYTYPE_LOOKUP 1
  138. #endif
  139. #if PY_MAJOR_VERSION < 3
  140. #undef CYTHON_USE_ASYNC_SLOTS
  141. #define CYTHON_USE_ASYNC_SLOTS 0
  142. #elif !defined(CYTHON_USE_ASYNC_SLOTS)
  143. #define CYTHON_USE_ASYNC_SLOTS 1
  144. #endif
  145. #if PY_VERSION_HEX < 0x02070000
  146. #undef CYTHON_USE_PYLONG_INTERNALS
  147. #define CYTHON_USE_PYLONG_INTERNALS 0
  148. #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
  149. #define CYTHON_USE_PYLONG_INTERNALS 1
  150. #endif
  151. #ifndef CYTHON_USE_PYLIST_INTERNALS
  152. #define CYTHON_USE_PYLIST_INTERNALS 1
  153. #endif
  154. #ifndef CYTHON_USE_UNICODE_INTERNALS
  155. #define CYTHON_USE_UNICODE_INTERNALS 1
  156. #endif
  157. #if PY_VERSION_HEX < 0x030300F0
  158. #undef CYTHON_USE_UNICODE_WRITER
  159. #define CYTHON_USE_UNICODE_WRITER 0
  160. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  161. #define CYTHON_USE_UNICODE_WRITER 1
  162. #endif
  163. #ifndef CYTHON_AVOID_BORROWED_REFS
  164. #define CYTHON_AVOID_BORROWED_REFS 0
  165. #endif
  166. #ifndef CYTHON_ASSUME_SAFE_MACROS
  167. #define CYTHON_ASSUME_SAFE_MACROS 1
  168. #endif
  169. #ifndef CYTHON_UNPACK_METHODS
  170. #define CYTHON_UNPACK_METHODS 1
  171. #endif
  172. #ifndef CYTHON_FAST_THREAD_STATE
  173. #define CYTHON_FAST_THREAD_STATE 1
  174. #endif
  175. #ifndef CYTHON_FAST_PYCALL
  176. #define CYTHON_FAST_PYCALL 1
  177. #endif
  178. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  179. #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
  180. #endif
  181. #ifndef CYTHON_USE_TP_FINALIZE
  182. #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
  183. #endif
  184. #ifndef CYTHON_USE_DICT_VERSIONS
  185. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
  186. #endif
  187. #ifndef CYTHON_USE_EXC_INFO_STACK
  188. #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
  189. #endif
  190. #endif
  191. #if !defined(CYTHON_FAST_PYCCALL)
  192. #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
  193. #endif
  194. #if CYTHON_USE_PYLONG_INTERNALS
  195. #include "longintrepr.h"
  196. #undef SHIFT
  197. #undef BASE
  198. #undef MASK
  199. #ifdef SIZEOF_VOID_P
  200. enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  201. #endif
  202. #endif
  203. #ifndef __has_attribute
  204. #define __has_attribute(x) 0
  205. #endif
  206. #ifndef __has_cpp_attribute
  207. #define __has_cpp_attribute(x) 0
  208. #endif
  209. #ifndef CYTHON_RESTRICT
  210. #if defined(__GNUC__)
  211. #define CYTHON_RESTRICT __restrict__
  212. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  213. #define CYTHON_RESTRICT __restrict
  214. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  215. #define CYTHON_RESTRICT restrict
  216. #else
  217. #define CYTHON_RESTRICT
  218. #endif
  219. #endif
  220. #ifndef CYTHON_UNUSED
  221. # if defined(__GNUC__)
  222. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  223. # define CYTHON_UNUSED __attribute__ ((__unused__))
  224. # else
  225. # define CYTHON_UNUSED
  226. # endif
  227. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  228. # define CYTHON_UNUSED __attribute__ ((__unused__))
  229. # else
  230. # define CYTHON_UNUSED
  231. # endif
  232. #endif
  233. #ifndef CYTHON_MAYBE_UNUSED_VAR
  234. # if defined(__cplusplus)
  235. template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
  236. # else
  237. # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
  238. # endif
  239. #endif
  240. #ifndef CYTHON_NCP_UNUSED
  241. # if CYTHON_COMPILING_IN_CPYTHON
  242. # define CYTHON_NCP_UNUSED
  243. # else
  244. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  245. # endif
  246. #endif
  247. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  248. #ifdef _MSC_VER
  249. #ifndef _MSC_STDINT_H_
  250. #if _MSC_VER < 1300
  251. typedef unsigned char uint8_t;
  252. typedef unsigned int uint32_t;
  253. #else
  254. typedef unsigned __int8 uint8_t;
  255. typedef unsigned __int32 uint32_t;
  256. #endif
  257. #endif
  258. #else
  259. #include <stdint.h>
  260. #endif
  261. #ifndef CYTHON_FALLTHROUGH
  262. #if defined(__cplusplus) && __cplusplus >= 201103L
  263. #if __has_cpp_attribute(fallthrough)
  264. #define CYTHON_FALLTHROUGH [[fallthrough]]
  265. #elif __has_cpp_attribute(clang::fallthrough)
  266. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  267. #elif __has_cpp_attribute(gnu::fallthrough)
  268. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  269. #endif
  270. #endif
  271. #ifndef CYTHON_FALLTHROUGH
  272. #if __has_attribute(fallthrough)
  273. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  274. #else
  275. #define CYTHON_FALLTHROUGH
  276. #endif
  277. #endif
  278. #if defined(__clang__ ) && defined(__apple_build_version__)
  279. #if __apple_build_version__ < 7000000
  280. #undef CYTHON_FALLTHROUGH
  281. #define CYTHON_FALLTHROUGH
  282. #endif
  283. #endif
  284. #endif
  285. #ifndef CYTHON_INLINE
  286. #if defined(__clang__)
  287. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  288. #elif defined(__GNUC__)
  289. #define CYTHON_INLINE __inline__
  290. #elif defined(_MSC_VER)
  291. #define CYTHON_INLINE __inline
  292. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  293. #define CYTHON_INLINE inline
  294. #else
  295. #define CYTHON_INLINE
  296. #endif
  297. #endif
  298. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
  299. #define Py_OptimizeFlag 0
  300. #endif
  301. #define __PYX_BUILD_PY_SSIZE_T "n"
  302. #define CYTHON_FORMAT_SSIZE_T "z"
  303. #if PY_MAJOR_VERSION < 3
  304. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  305. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  306. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  307. #define __Pyx_DefaultClassType PyClass_Type
  308. #else
  309. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  310. #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
  311. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  312. PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  313. #else
  314. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  315. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  316. #endif
  317. #define __Pyx_DefaultClassType PyType_Type
  318. #endif
  319. #ifndef Py_TPFLAGS_CHECKTYPES
  320. #define Py_TPFLAGS_CHECKTYPES 0
  321. #endif
  322. #ifndef Py_TPFLAGS_HAVE_INDEX
  323. #define Py_TPFLAGS_HAVE_INDEX 0
  324. #endif
  325. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  326. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  327. #endif
  328. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  329. #define Py_TPFLAGS_HAVE_FINALIZE 0
  330. #endif
  331. #ifndef METH_STACKLESS
  332. #define METH_STACKLESS 0
  333. #endif
  334. #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
  335. #ifndef METH_FASTCALL
  336. #define METH_FASTCALL 0x80
  337. #endif
  338. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  339. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  340. Py_ssize_t nargs, PyObject *kwnames);
  341. #else
  342. #define __Pyx_PyCFunctionFast _PyCFunctionFast
  343. #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  344. #endif
  345. #if CYTHON_FAST_PYCCALL
  346. #define __Pyx_PyFastCFunction_Check(func)\
  347. ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
  348. #else
  349. #define __Pyx_PyFastCFunction_Check(func) 0
  350. #endif
  351. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  352. #define PyObject_Malloc(s) PyMem_Malloc(s)
  353. #define PyObject_Free(p) PyMem_Free(p)
  354. #define PyObject_Realloc(p) PyMem_Realloc(p)
  355. #endif
  356. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
  357. #define PyMem_RawMalloc(n) PyMem_Malloc(n)
  358. #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
  359. #define PyMem_RawFree(p) PyMem_Free(p)
  360. #endif
  361. #if CYTHON_COMPILING_IN_PYSTON
  362. #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
  363. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
  364. #else
  365. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  366. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  367. #endif
  368. #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
  369. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  370. #elif PY_VERSION_HEX >= 0x03060000
  371. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  372. #elif PY_VERSION_HEX >= 0x03000000
  373. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  374. #else
  375. #define __Pyx_PyThreadState_Current _PyThreadState_Current
  376. #endif
  377. #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
  378. #include "pythread.h"
  379. #define Py_tss_NEEDS_INIT 0
  380. typedef int Py_tss_t;
  381. static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
  382. *key = PyThread_create_key();
  383. return 0;
  384. }
  385. static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
  386. Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
  387. *key = Py_tss_NEEDS_INIT;
  388. return key;
  389. }
  390. static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
  391. PyObject_Free(key);
  392. }
  393. static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
  394. return *key != Py_tss_NEEDS_INIT;
  395. }
  396. static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
  397. PyThread_delete_key(*key);
  398. *key = Py_tss_NEEDS_INIT;
  399. }
  400. static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
  401. return PyThread_set_key_value(*key, value);
  402. }
  403. static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
  404. return PyThread_get_key_value(*key);
  405. }
  406. #endif
  407. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  408. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  409. #else
  410. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  411. #endif
  412. #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
  413. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  414. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  415. #else
  416. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  417. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  418. #endif
  419. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
  420. #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  421. #else
  422. #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
  423. #endif
  424. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  425. #define CYTHON_PEP393_ENABLED 1
  426. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  427. 0 : _PyUnicode_Ready((PyObject *)(op)))
  428. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  429. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  430. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  431. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  432. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  433. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  434. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
  435. #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
  436. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  437. #else
  438. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
  439. #endif
  440. #else
  441. #define CYTHON_PEP393_ENABLED 0
  442. #define PyUnicode_1BYTE_KIND 1
  443. #define PyUnicode_2BYTE_KIND 2
  444. #define PyUnicode_4BYTE_KIND 4
  445. #define __Pyx_PyUnicode_READY(op) (0)
  446. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  447. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  448. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
  449. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  450. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  451. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  452. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
  453. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
  454. #endif
  455. #if CYTHON_COMPILING_IN_PYPY
  456. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  457. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  458. #else
  459. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  460. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  461. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  462. #endif
  463. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
  464. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  465. #endif
  466. #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
  467. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  468. #endif
  469. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
  470. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  471. #endif
  472. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  473. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  474. #if PY_MAJOR_VERSION >= 3
  475. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  476. #else
  477. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  478. #endif
  479. #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
  480. #define PyObject_ASCII(o) PyObject_Repr(o)
  481. #endif
  482. #if PY_MAJOR_VERSION >= 3
  483. #define PyBaseString_Type PyUnicode_Type
  484. #define PyStringObject PyUnicodeObject
  485. #define PyString_Type PyUnicode_Type
  486. #define PyString_Check PyUnicode_Check
  487. #define PyString_CheckExact PyUnicode_CheckExact
  488. #ifndef PyObject_Unicode
  489. #define PyObject_Unicode PyObject_Str
  490. #endif
  491. #endif
  492. #if PY_MAJOR_VERSION >= 3
  493. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  494. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  495. #else
  496. #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
  497. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  498. #endif
  499. #ifndef PySet_CheckExact
  500. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  501. #endif
  502. #if PY_VERSION_HEX >= 0x030900A4
  503. #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  504. #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
  505. #else
  506. #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  507. #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
  508. #endif
  509. #if CYTHON_ASSUME_SAFE_MACROS
  510. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  511. #else
  512. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  513. #endif
  514. #if PY_MAJOR_VERSION >= 3
  515. #define PyIntObject PyLongObject
  516. #define PyInt_Type PyLong_Type
  517. #define PyInt_Check(op) PyLong_Check(op)
  518. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  519. #define PyInt_FromString PyLong_FromString
  520. #define PyInt_FromUnicode PyLong_FromUnicode
  521. #define PyInt_FromLong PyLong_FromLong
  522. #define PyInt_FromSize_t PyLong_FromSize_t
  523. #define PyInt_FromSsize_t PyLong_FromSsize_t
  524. #define PyInt_AsLong PyLong_AsLong
  525. #define PyInt_AS_LONG PyLong_AS_LONG
  526. #define PyInt_AsSsize_t PyLong_AsSsize_t
  527. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  528. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  529. #define PyNumber_Int PyNumber_Long
  530. #endif
  531. #if PY_MAJOR_VERSION >= 3
  532. #define PyBoolObject PyLongObject
  533. #endif
  534. #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
  535. #ifndef PyUnicode_InternFromString
  536. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  537. #endif
  538. #endif
  539. #if PY_VERSION_HEX < 0x030200A4
  540. typedef long Py_hash_t;
  541. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  542. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  543. #else
  544. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  545. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  546. #endif
  547. #if PY_MAJOR_VERSION >= 3
  548. #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
  549. #else
  550. #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
  551. #endif
  552. #if CYTHON_USE_ASYNC_SLOTS
  553. #if PY_VERSION_HEX >= 0x030500B1
  554. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  555. #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
  556. #else
  557. #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
  558. #endif
  559. #else
  560. #define __Pyx_PyType_AsAsync(obj) NULL
  561. #endif
  562. #ifndef __Pyx_PyAsyncMethodsStruct
  563. typedef struct {
  564. unaryfunc am_await;
  565. unaryfunc am_aiter;
  566. unaryfunc am_anext;
  567. } __Pyx_PyAsyncMethodsStruct;
  568. #endif
  569. #if defined(WIN32) || defined(MS_WINDOWS)
  570. #define _USE_MATH_DEFINES
  571. #endif
  572. #include <math.h>
  573. #ifdef NAN
  574. #define __PYX_NAN() ((float) NAN)
  575. #else
  576. static CYTHON_INLINE float __PYX_NAN() {
  577. float value;
  578. memset(&value, 0xFF, sizeof(value));
  579. return value;
  580. }
  581. #endif
  582. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  583. #define __Pyx_truncl trunc
  584. #else
  585. #define __Pyx_truncl truncl
  586. #endif
  587. #define __PYX_MARK_ERR_POS(f_index, lineno) \
  588. { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
  589. #define __PYX_ERR(f_index, lineno, Ln_error) \
  590. { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
  591. #ifndef __PYX_EXTERN_C
  592. #ifdef __cplusplus
  593. #define __PYX_EXTERN_C extern "C"
  594. #else
  595. #define __PYX_EXTERN_C extern
  596. #endif
  597. #endif
  598. #define __PYX_HAVE__aiohttp___websocket
  599. #define __PYX_HAVE_API__aiohttp___websocket
  600. /* Early includes */
  601. #include <string.h>
  602. #include <stdio.h>
  603. #include "pythread.h"
  604. #include <stdint.h>
  605. #ifdef _OPENMP
  606. #include <omp.h>
  607. #endif /* _OPENMP */
  608. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  609. #define CYTHON_WITHOUT_ASSERTIONS
  610. #endif
  611. typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
  612. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
  613. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  614. #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
  615. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
  616. #define __PYX_DEFAULT_STRING_ENCODING ""
  617. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  618. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  619. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  620. #define __Pyx_long_cast(x) ((long)x)
  621. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  622. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  623. (sizeof(type) > sizeof(Py_ssize_t) &&\
  624. likely(v < (type)PY_SSIZE_T_MAX ||\
  625. v == (type)PY_SSIZE_T_MAX) &&\
  626. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  627. v == (type)PY_SSIZE_T_MIN))) ||\
  628. (sizeof(type) == sizeof(Py_ssize_t) &&\
  629. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  630. v == (type)PY_SSIZE_T_MAX))) )
  631. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  632. return (size_t) i < (size_t) limit;
  633. }
  634. #if defined (__cplusplus) && __cplusplus >= 201103L
  635. #include <cstdlib>
  636. #define __Pyx_sst_abs(value) std::abs(value)
  637. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  638. #define __Pyx_sst_abs(value) abs(value)
  639. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  640. #define __Pyx_sst_abs(value) labs(value)
  641. #elif defined (_MSC_VER)
  642. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  643. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  644. #define __Pyx_sst_abs(value) llabs(value)
  645. #elif defined (__GNUC__)
  646. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  647. #else
  648. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  649. #endif
  650. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  651. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  652. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  653. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  654. #define __Pyx_PyBytes_FromString PyBytes_FromString
  655. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  656. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  657. #if PY_MAJOR_VERSION < 3
  658. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  659. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  660. #else
  661. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  662. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  663. #endif
  664. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  665. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  666. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  667. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  668. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  669. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  670. #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
  671. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  672. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  673. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  674. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  675. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  676. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  677. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  678. #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
  679. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  680. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
  681. const Py_UNICODE *u_end = u;
  682. while (*u_end++) ;
  683. return (size_t)(u_end - u - 1);
  684. }
  685. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  686. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  687. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  688. #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
  689. #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
  690. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  691. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  692. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  693. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
  694. #define __Pyx_PySequence_Tuple(obj)\
  695. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  696. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  697. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  698. #if CYTHON_ASSUME_SAFE_MACROS
  699. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  700. #else
  701. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  702. #endif
  703. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  704. #if PY_MAJOR_VERSION >= 3
  705. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  706. #else
  707. #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
  708. #endif
  709. #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
  710. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  711. static int __Pyx_sys_getdefaultencoding_not_ascii;
  712. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  713. PyObject* sys;
  714. PyObject* default_encoding = NULL;
  715. PyObject* ascii_chars_u = NULL;
  716. PyObject* ascii_chars_b = NULL;
  717. const char* default_encoding_c;
  718. sys = PyImport_ImportModule("sys");
  719. if (!sys) goto bad;
  720. default_encoding = PyObject_CallMethod(sys, (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. if (strcmp(default_encoding_c, "ascii") == 0) {
  726. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  727. } else {
  728. char ascii_chars[128];
  729. int c;
  730. for (c = 0; c < 128; c++) {
  731. ascii_chars[c] = c;
  732. }
  733. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  734. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  735. if (!ascii_chars_u) goto bad;
  736. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  737. if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  738. PyErr_Format(
  739. PyExc_ValueError,
  740. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  741. default_encoding_c);
  742. goto bad;
  743. }
  744. Py_DECREF(ascii_chars_u);
  745. Py_DECREF(ascii_chars_b);
  746. }
  747. Py_DECREF(default_encoding);
  748. return 0;
  749. bad:
  750. Py_XDECREF(default_encoding);
  751. Py_XDECREF(ascii_chars_u);
  752. Py_XDECREF(ascii_chars_b);
  753. return -1;
  754. }
  755. #endif
  756. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  757. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  758. #else
  759. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  760. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  761. static char* __PYX_DEFAULT_STRING_ENCODING;
  762. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  763. PyObject* sys;
  764. PyObject* default_encoding = NULL;
  765. char* default_encoding_c;
  766. sys = PyImport_ImportModule("sys");
  767. if (!sys) goto bad;
  768. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  769. Py_DECREF(sys);
  770. if (!default_encoding) goto bad;
  771. default_encoding_c = PyBytes_AsString(default_encoding);
  772. if (!default_encoding_c) goto bad;
  773. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
  774. if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
  775. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  776. Py_DECREF(default_encoding);
  777. return 0;
  778. bad:
  779. Py_XDECREF(default_encoding);
  780. return -1;
  781. }
  782. #endif
  783. #endif
  784. /* Test for GCC > 2.95 */
  785. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  786. #define likely(x) __builtin_expect(!!(x), 1)
  787. #define unlikely(x) __builtin_expect(!!(x), 0)
  788. #else /* !__GNUC__ or GCC < 2.95 */
  789. #define likely(x) (x)
  790. #define unlikely(x) (x)
  791. #endif /* __GNUC__ */
  792. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  793. static PyObject *__pyx_m = NULL;
  794. static PyObject *__pyx_d;
  795. static PyObject *__pyx_b;
  796. static PyObject *__pyx_cython_runtime = NULL;
  797. static PyObject *__pyx_empty_tuple;
  798. static PyObject *__pyx_empty_bytes;
  799. static PyObject *__pyx_empty_unicode;
  800. static int __pyx_lineno;
  801. static int __pyx_clineno = 0;
  802. static const char * __pyx_cfilenm= __FILE__;
  803. static const char *__pyx_filename;
  804. static const char *__pyx_f[] = {
  805. "aiohttp/_websocket.pyx",
  806. "type.pxd",
  807. "bool.pxd",
  808. "complex.pxd",
  809. };
  810. /*--- Type declarations ---*/
  811. /* --- Runtime support code (head) --- */
  812. /* Refnanny.proto */
  813. #ifndef CYTHON_REFNANNY
  814. #define CYTHON_REFNANNY 0
  815. #endif
  816. #if CYTHON_REFNANNY
  817. typedef struct {
  818. void (*INCREF)(void*, PyObject*, int);
  819. void (*DECREF)(void*, PyObject*, int);
  820. void (*GOTREF)(void*, PyObject*, int);
  821. void (*GIVEREF)(void*, PyObject*, int);
  822. void* (*SetupContext)(const char*, int, const char*);
  823. void (*FinishContext)(void**);
  824. } __Pyx_RefNannyAPIStruct;
  825. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  826. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  827. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  828. #ifdef WITH_THREAD
  829. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  830. if (acquire_gil) {\
  831. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  832. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  833. PyGILState_Release(__pyx_gilstate_save);\
  834. } else {\
  835. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
  836. }
  837. #else
  838. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  839. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  840. #endif
  841. #define __Pyx_RefNannyFinishContext()\
  842. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  843. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  844. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  845. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  846. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  847. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  848. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  849. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  850. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  851. #else
  852. #define __Pyx_RefNannyDeclarations
  853. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  854. #define __Pyx_RefNannyFinishContext()
  855. #define __Pyx_INCREF(r) Py_INCREF(r)
  856. #define __Pyx_DECREF(r) Py_DECREF(r)
  857. #define __Pyx_GOTREF(r)
  858. #define __Pyx_GIVEREF(r)
  859. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  860. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  861. #define __Pyx_XGOTREF(r)
  862. #define __Pyx_XGIVEREF(r)
  863. #endif
  864. #define __Pyx_XDECREF_SET(r, v) do {\
  865. PyObject *tmp = (PyObject *) r;\
  866. r = v; __Pyx_XDECREF(tmp);\
  867. } while (0)
  868. #define __Pyx_DECREF_SET(r, v) do {\
  869. PyObject *tmp = (PyObject *) r;\
  870. r = v; __Pyx_DECREF(tmp);\
  871. } while (0)
  872. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  873. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  874. /* PyObjectGetAttrStr.proto */
  875. #if CYTHON_USE_TYPE_SLOTS
  876. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  877. #else
  878. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  879. #endif
  880. /* GetBuiltinName.proto */
  881. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  882. /* RaiseArgTupleInvalid.proto */
  883. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  884. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  885. /* RaiseDoubleKeywords.proto */
  886. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  887. /* ParseKeywords.proto */
  888. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
  889. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
  890. const char* function_name);
  891. /* PyCFunctionFastCall.proto */
  892. #if CYTHON_FAST_PYCCALL
  893. static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
  894. #else
  895. #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
  896. #endif
  897. /* PyFunctionFastCall.proto */
  898. #if CYTHON_FAST_PYCALL
  899. #define __Pyx_PyFunction_FastCall(func, args, nargs)\
  900. __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
  901. #if 1 || PY_VERSION_HEX < 0x030600B1
  902. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
  903. #else
  904. #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
  905. #endif
  906. #define __Pyx_BUILD_ASSERT_EXPR(cond)\
  907. (sizeof(char [1 - 2*!(cond)]) - 1)
  908. #ifndef Py_MEMBER_SIZE
  909. #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
  910. #endif
  911. static size_t __pyx_pyframe_localsplus_offset = 0;
  912. #include "frameobject.h"
  913. #define __Pxy_PyFrame_Initialize_Offsets()\
  914. ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
  915. (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
  916. #define __Pyx_PyFrame_GetLocalsplus(frame)\
  917. (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
  918. #endif
  919. /* PyObjectCall.proto */
  920. #if CYTHON_COMPILING_IN_CPYTHON
  921. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  922. #else
  923. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  924. #endif
  925. /* PyObjectCallMethO.proto */
  926. #if CYTHON_COMPILING_IN_CPYTHON
  927. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  928. #endif
  929. /* PyObjectCallOneArg.proto */
  930. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  931. /* TypeImport.proto */
  932. #ifndef __PYX_HAVE_RT_ImportType_proto
  933. #define __PYX_HAVE_RT_ImportType_proto
  934. enum __Pyx_ImportType_CheckSize {
  935. __Pyx_ImportType_CheckSize_Error = 0,
  936. __Pyx_ImportType_CheckSize_Warn = 1,
  937. __Pyx_ImportType_CheckSize_Ignore = 2
  938. };
  939. static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
  940. #endif
  941. /* PyDictVersioning.proto */
  942. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  943. #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
  944. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  945. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  946. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  947. (cache_var) = (value);
  948. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  949. static PY_UINT64_T __pyx_dict_version = 0;\
  950. static PyObject *__pyx_dict_cached_value = NULL;\
  951. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  952. (VAR) = __pyx_dict_cached_value;\
  953. } else {\
  954. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  955. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  956. }\
  957. }
  958. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
  959. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
  960. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
  961. #else
  962. #define __PYX_GET_DICT_VERSION(dict) (0)
  963. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  964. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  965. #endif
  966. /* PyThreadStateGet.proto */
  967. #if CYTHON_FAST_THREAD_STATE
  968. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  969. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  970. #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
  971. #else
  972. #define __Pyx_PyThreadState_declare
  973. #define __Pyx_PyThreadState_assign
  974. #define __Pyx_PyErr_Occurred() PyErr_Occurred()
  975. #endif
  976. /* PyErrFetchRestore.proto */
  977. #if CYTHON_FAST_THREAD_STATE
  978. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  979. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  980. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  981. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  982. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  983. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  984. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  985. #if CYTHON_COMPILING_IN_CPYTHON
  986. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  987. #else
  988. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  989. #endif
  990. #else
  991. #define __Pyx_PyErr_Clear() PyErr_Clear()
  992. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  993. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  994. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  995. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  996. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  997. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  998. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  999. #endif
  1000. /* CLineInTraceback.proto */
  1001. #ifdef CYTHON_CLINE_IN_TRACEBACK
  1002. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  1003. #else
  1004. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  1005. #endif
  1006. /* CodeObjectCache.proto */
  1007. typedef struct {
  1008. PyCodeObject* code_object;
  1009. int code_line;
  1010. } __Pyx_CodeObjectCacheEntry;
  1011. struct __Pyx_CodeObjectCache {
  1012. int count;
  1013. int max_count;
  1014. __Pyx_CodeObjectCacheEntry* entries;
  1015. };
  1016. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  1017. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  1018. static PyCodeObject *__pyx_find_code_object(int code_line);
  1019. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  1020. /* AddTraceback.proto */
  1021. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  1022. int py_line, const char *filename);
  1023. /* CIntToPy.proto */
  1024. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  1025. /* CIntFromPy.proto */
  1026. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  1027. /* CIntFromPy.proto */
  1028. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  1029. /* FastTypeChecks.proto */
  1030. #if CYTHON_COMPILING_IN_CPYTHON
  1031. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  1032. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  1033. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  1034. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  1035. #else
  1036. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  1037. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  1038. #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
  1039. #endif
  1040. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  1041. /* CheckBinaryVersion.proto */
  1042. static int __Pyx_check_binary_version(void);
  1043. /* InitStrings.proto */
  1044. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
  1045. /* Module declarations from 'cpython.version' */
  1046. /* Module declarations from '__builtin__' */
  1047. /* Module declarations from 'cpython.type' */
  1048. static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
  1049. /* Module declarations from 'libc.string' */
  1050. /* Module declarations from 'libc.stdio' */
  1051. /* Module declarations from 'cpython.object' */
  1052. /* Module declarations from 'cpython.ref' */
  1053. /* Module declarations from 'cpython.exc' */
  1054. /* Module declarations from 'cpython.module' */
  1055. /* Module declarations from 'cpython.mem' */
  1056. /* Module declarations from 'cpython.tuple' */
  1057. /* Module declarations from 'cpython.list' */
  1058. /* Module declarations from 'cpython.sequence' */
  1059. /* Module declarations from 'cpython.mapping' */
  1060. /* Module declarations from 'cpython.iterator' */
  1061. /* Module declarations from 'cpython.number' */
  1062. /* Module declarations from 'cpython.int' */
  1063. /* Module declarations from '__builtin__' */
  1064. /* Module declarations from 'cpython.bool' */
  1065. static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
  1066. /* Module declarations from 'cpython.long' */
  1067. /* Module declarations from 'cpython.float' */
  1068. /* Module declarations from '__builtin__' */
  1069. /* Module declarations from 'cpython.complex' */
  1070. static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
  1071. /* Module declarations from 'cpython.string' */
  1072. /* Module declarations from 'cpython.unicode' */
  1073. /* Module declarations from 'cpython.dict' */
  1074. /* Module declarations from 'cpython.instance' */
  1075. /* Module declarations from 'cpython.function' */
  1076. /* Module declarations from 'cpython.method' */
  1077. /* Module declarations from 'cpython.weakref' */
  1078. /* Module declarations from 'cpython.getargs' */
  1079. /* Module declarations from 'cpython.pythread' */
  1080. /* Module declarations from 'cpython.pystate' */
  1081. /* Module declarations from 'cpython.cobject' */
  1082. /* Module declarations from 'cpython.oldbuffer' */
  1083. /* Module declarations from 'cpython.set' */
  1084. /* Module declarations from 'cpython.buffer' */
  1085. /* Module declarations from 'cpython.bytes' */
  1086. /* Module declarations from 'cpython.pycapsule' */
  1087. /* Module declarations from 'cpython' */
  1088. /* Module declarations from 'libc.stdint' */
  1089. /* Module declarations from 'aiohttp._websocket' */
  1090. #define __Pyx_MODULE_NAME "aiohttp._websocket"
  1091. extern int __pyx_module_is_main_aiohttp___websocket;
  1092. int __pyx_module_is_main_aiohttp___websocket = 0;
  1093. /* Implementation of 'aiohttp._websocket' */
  1094. static PyObject *__pyx_builtin_range;
  1095. static const char __pyx_k_i[] = "i";
  1096. static const char __pyx_k_data[] = "data";
  1097. static const char __pyx_k_main[] = "__main__";
  1098. static const char __pyx_k_mask[] = "mask";
  1099. static const char __pyx_k_name[] = "__name__";
  1100. static const char __pyx_k_test[] = "__test__";
  1101. static const char __pyx_k_range[] = "range";
  1102. static const char __pyx_k_in_buf[] = "in_buf";
  1103. static const char __pyx_k_data_len[] = "data_len";
  1104. static const char __pyx_k_mask_buf[] = "mask_buf";
  1105. static const char __pyx_k_uint32_msk[] = "uint32_msk";
  1106. static const char __pyx_k_uint64_msk[] = "uint64_msk";
  1107. static const char __pyx_k_aiohttp__websocket[] = "aiohttp._websocket";
  1108. static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
  1109. static const char __pyx_k_websocket_mask_cython[] = "_websocket_mask_cython";
  1110. static const char __pyx_k_aiohttp__websocket_pyx[] = "aiohttp/_websocket.pyx";
  1111. static PyObject *__pyx_n_s_aiohttp__websocket;
  1112. static PyObject *__pyx_kp_s_aiohttp__websocket_pyx;
  1113. static PyObject *__pyx_n_s_cline_in_traceback;
  1114. static PyObject *__pyx_n_s_data;
  1115. static PyObject *__pyx_n_s_data_len;
  1116. static PyObject *__pyx_n_s_i;
  1117. static PyObject *__pyx_n_s_in_buf;
  1118. static PyObject *__pyx_n_s_main;
  1119. static PyObject *__pyx_n_s_mask;
  1120. static PyObject *__pyx_n_s_mask_buf;
  1121. static PyObject *__pyx_n_s_name;
  1122. static PyObject *__pyx_n_s_range;
  1123. static PyObject *__pyx_n_s_test;
  1124. static PyObject *__pyx_n_s_uint32_msk;
  1125. static PyObject *__pyx_n_s_uint64_msk;
  1126. static PyObject *__pyx_n_s_websocket_mask_cython;
  1127. static PyObject *__pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_data); /* proto */
  1128. static PyObject *__pyx_tuple_;
  1129. static PyObject *__pyx_codeobj__2;
  1130. /* Late includes */
  1131. /* "aiohttp/_websocket.pyx":11
  1132. *
  1133. *
  1134. * def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
  1135. * """Note, this function mutates its `data` argument
  1136. * """
  1137. */
  1138. /* Python wrapper */
  1139. static PyObject *__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1140. static char __pyx_doc_7aiohttp_10_websocket__websocket_mask_cython[] = "Note, this function mutates its `data` argument\n ";
  1141. static PyMethodDef __pyx_mdef_7aiohttp_10_websocket_1_websocket_mask_cython = {"_websocket_mask_cython", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_7aiohttp_10_websocket__websocket_mask_cython};
  1142. static PyObject *__pyx_pw_7aiohttp_10_websocket_1_websocket_mask_cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1143. PyObject *__pyx_v_mask = 0;
  1144. PyObject *__pyx_v_data = 0;
  1145. int __pyx_lineno = 0;
  1146. const char *__pyx_filename = NULL;
  1147. int __pyx_clineno = 0;
  1148. PyObject *__pyx_r = 0;
  1149. __Pyx_RefNannyDeclarations
  1150. __Pyx_RefNannySetupContext("_websocket_mask_cython (wrapper)", 0);
  1151. {
  1152. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_mask,&__pyx_n_s_data,0};
  1153. PyObject* values[2] = {0,0};
  1154. if (unlikely(__pyx_kwds)) {
  1155. Py_ssize_t kw_args;
  1156. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1157. switch (pos_args) {
  1158. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1159. CYTHON_FALLTHROUGH;
  1160. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1161. CYTHON_FALLTHROUGH;
  1162. case 0: break;
  1163. default: goto __pyx_L5_argtuple_error;
  1164. }
  1165. kw_args = PyDict_Size(__pyx_kwds);
  1166. switch (pos_args) {
  1167. case 0:
  1168. if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_mask)) != 0)) kw_args--;
  1169. else goto __pyx_L5_argtuple_error;
  1170. CYTHON_FALLTHROUGH;
  1171. case 1:
  1172. if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
  1173. else {
  1174. __Pyx_RaiseArgtupleInvalid("_websocket_mask_cython", 1, 2, 2, 1); __PYX_ERR(0, 11, __pyx_L3_error)
  1175. }
  1176. }
  1177. if (unlikely(kw_args > 0)) {
  1178. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_websocket_mask_cython") < 0)) __PYX_ERR(0, 11, __pyx_L3_error)
  1179. }
  1180. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1181. goto __pyx_L5_argtuple_error;
  1182. } else {
  1183. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1184. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1185. }
  1186. __pyx_v_mask = values[0];
  1187. __pyx_v_data = values[1];
  1188. }
  1189. goto __pyx_L4_argument_unpacking_done;
  1190. __pyx_L5_argtuple_error:;
  1191. __Pyx_RaiseArgtupleInvalid("_websocket_mask_cython", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 11, __pyx_L3_error)
  1192. __pyx_L3_error:;
  1193. __Pyx_AddTraceback("aiohttp._websocket._websocket_mask_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1194. __Pyx_RefNannyFinishContext();
  1195. return NULL;
  1196. __pyx_L4_argument_unpacking_done:;
  1197. __pyx_r = __pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(__pyx_self, __pyx_v_mask, __pyx_v_data);
  1198. /* function exit code */
  1199. __Pyx_RefNannyFinishContext();
  1200. return __pyx_r;
  1201. }
  1202. static PyObject *__pyx_pf_7aiohttp_10_websocket__websocket_mask_cython(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mask, PyObject *__pyx_v_data) {
  1203. Py_ssize_t __pyx_v_data_len;
  1204. Py_ssize_t __pyx_v_i;
  1205. unsigned char *__pyx_v_in_buf;
  1206. unsigned char const *__pyx_v_mask_buf;
  1207. uint32_t __pyx_v_uint32_msk;
  1208. uint64_t __pyx_v_uint64_msk;
  1209. PyObject *__pyx_r = NULL;
  1210. __Pyx_RefNannyDeclarations
  1211. Py_ssize_t __pyx_t_1;
  1212. int __pyx_t_2;
  1213. int __pyx_t_3;
  1214. PyObject *__pyx_t_4 = NULL;
  1215. char *__pyx_t_5;
  1216. uint64_t *__pyx_t_6;
  1217. long __pyx_t_7;
  1218. uint32_t *__pyx_t_8;
  1219. Py_ssize_t __pyx_t_9;
  1220. Py_ssize_t __pyx_t_10;
  1221. Py_ssize_t __pyx_t_11;
  1222. int __pyx_lineno = 0;
  1223. const char *__pyx_filename = NULL;
  1224. int __pyx_clineno = 0;
  1225. __Pyx_RefNannySetupContext("_websocket_mask_cython", 0);
  1226. __Pyx_INCREF(__pyx_v_mask);
  1227. __Pyx_INCREF(__pyx_v_data);
  1228. /* "aiohttp/_websocket.pyx":22
  1229. * uint64_t uint64_msk
  1230. *
  1231. * assert len(mask) == 4 # <<<<<<<<<<<<<<
  1232. *
  1233. * if not isinstance(mask, bytes):
  1234. */
  1235. #ifndef CYTHON_WITHOUT_ASSERTIONS
  1236. if (unlikely(!Py_OptimizeFlag)) {
  1237. __pyx_t_1 = PyObject_Length(__pyx_v_mask); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 22, __pyx_L1_error)
  1238. if (unlikely(!((__pyx_t_1 == 4) != 0))) {
  1239. PyErr_SetNone(PyExc_AssertionError);
  1240. __PYX_ERR(0, 22, __pyx_L1_error)
  1241. }
  1242. }
  1243. #endif
  1244. /* "aiohttp/_websocket.pyx":24
  1245. * assert len(mask) == 4
  1246. *
  1247. * if not isinstance(mask, bytes): # <<<<<<<<<<<<<<
  1248. * mask = bytes(mask)
  1249. *
  1250. */
  1251. __pyx_t_2 = PyBytes_Check(__pyx_v_mask);
  1252. __pyx_t_3 = ((!(__pyx_t_2 != 0)) != 0);
  1253. if (__pyx_t_3) {
  1254. /* "aiohttp/_websocket.pyx":25
  1255. *
  1256. * if not isinstance(mask, bytes):
  1257. * mask = bytes(mask) # <<<<<<<<<<<<<<
  1258. *
  1259. * if isinstance(data, bytearray):
  1260. */
  1261. __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_v_mask); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 25, __pyx_L1_error)
  1262. __Pyx_GOTREF(__pyx_t_4);
  1263. __Pyx_DECREF_SET(__pyx_v_mask, __pyx_t_4);
  1264. __pyx_t_4 = 0;
  1265. /* "aiohttp/_websocket.pyx":24
  1266. * assert len(mask) == 4
  1267. *
  1268. * if not isinstance(mask, bytes): # <<<<<<<<<<<<<<
  1269. * mask = bytes(mask)
  1270. *
  1271. */
  1272. }
  1273. /* "aiohttp/_websocket.pyx":27
  1274. * mask = bytes(mask)
  1275. *
  1276. * if isinstance(data, bytearray): # <<<<<<<<<<<<<<
  1277. * data = <bytearray>data
  1278. * else:
  1279. */
  1280. __pyx_t_3 = PyByteArray_Check(__pyx_v_data);
  1281. __pyx_t_2 = (__pyx_t_3 != 0);
  1282. if (__pyx_t_2) {
  1283. /* "aiohttp/_websocket.pyx":28
  1284. *
  1285. * if isinstance(data, bytearray):
  1286. * data = <bytearray>data # <<<<<<<<<<<<<<
  1287. * else:
  1288. * data = bytearray(data)
  1289. */
  1290. __pyx_t_4 = __pyx_v_data;
  1291. __Pyx_INCREF(__pyx_t_4);
  1292. __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_4);
  1293. __pyx_t_4 = 0;
  1294. /* "aiohttp/_websocket.pyx":27
  1295. * mask = bytes(mask)
  1296. *
  1297. * if isinstance(data, bytearray): # <<<<<<<<<<<<<<
  1298. * data = <bytearray>data
  1299. * else:
  1300. */
  1301. goto __pyx_L4;
  1302. }
  1303. /* "aiohttp/_websocket.pyx":30
  1304. * data = <bytearray>data
  1305. * else:
  1306. * data = bytearray(data) # <<<<<<<<<<<<<<
  1307. *
  1308. * data_len = len(data)
  1309. */
  1310. /*else*/ {
  1311. __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_v_data); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error)
  1312. __Pyx_GOTREF(__pyx_t_4);
  1313. __Pyx_DECREF_SET(__pyx_v_data, __pyx_t_4);
  1314. __pyx_t_4 = 0;
  1315. }
  1316. __pyx_L4:;
  1317. /* "aiohttp/_websocket.pyx":32
  1318. * data = bytearray(data)
  1319. *
  1320. * data_len = len(data) # <<<<<<<<<<<<<<
  1321. * in_buf = <unsigned char*>PyByteArray_AsString(data)
  1322. * mask_buf = <const unsigned char*>PyBytes_AsString(mask)
  1323. */
  1324. __pyx_t_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 32, __pyx_L1_error)
  1325. __pyx_v_data_len = __pyx_t_1;
  1326. /* "aiohttp/_websocket.pyx":33
  1327. *
  1328. * data_len = len(data)
  1329. * in_buf = <unsigned char*>PyByteArray_AsString(data) # <<<<<<<<<<<<<<
  1330. * mask_buf = <const unsigned char*>PyBytes_AsString(mask)
  1331. * uint32_msk = (<uint32_t*>mask_buf)[0]
  1332. */
  1333. if (!(likely(PyByteArray_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_v_data)->tp_name), 0))) __PYX_ERR(0, 33, __pyx_L1_error)
  1334. __pyx_t_5 = PyByteArray_AsString(((PyObject*)__pyx_v_data)); if (unlikely(__pyx_t_5 == ((char *)NULL))) __PYX_ERR(0, 33, __pyx_L1_error)
  1335. __pyx_v_in_buf = ((unsigned char *)__pyx_t_5);
  1336. /* "aiohttp/_websocket.pyx":34
  1337. * data_len = len(data)
  1338. * in_buf = <unsigned char*>PyByteArray_AsString(data)
  1339. * mask_buf = <const unsigned char*>PyBytes_AsString(mask) # <<<<<<<<<<<<<<
  1340. * uint32_msk = (<uint32_t*>mask_buf)[0]
  1341. *
  1342. */
  1343. __pyx_t_5 = PyBytes_AsString(__pyx_v_mask); if (unlikely(__pyx_t_5 == ((char *)NULL))) __PYX_ERR(0, 34, __pyx_L1_error)
  1344. __pyx_v_mask_buf = ((unsigned char const *)__pyx_t_5);
  1345. /* "aiohttp/_websocket.pyx":35
  1346. * in_buf = <unsigned char*>PyByteArray_AsString(data)
  1347. * mask_buf = <const unsigned char*>PyBytes_AsString(mask)
  1348. * uint32_msk = (<uint32_t*>mask_buf)[0] # <<<<<<<<<<<<<<
  1349. *
  1350. * # TODO: align in_data ptr to achieve even faster speeds
  1351. */
  1352. __pyx_v_uint32_msk = (((uint32_t *)__pyx_v_mask_buf)[0]);
  1353. /* "aiohttp/_websocket.pyx":40
  1354. * # does it need in python ?! malloc() always aligns to sizeof(long) bytes
  1355. *
  1356. * if sizeof(size_t) >= 8: # <<<<<<<<<<<<<<
  1357. * uint64_msk = uint32_msk
  1358. * uint64_msk = (uint64_msk << 32) | uint32_msk
  1359. */
  1360. __pyx_t_2 = (((sizeof(size_t)) >= 8) != 0);
  1361. if (__pyx_t_2) {
  1362. /* "aiohttp/_websocket.pyx":41
  1363. *
  1364. * if sizeof(size_t) >= 8:
  1365. * uint64_msk = uint32_msk # <<<<<<<<<<<<<<
  1366. * uint64_msk = (uint64_msk << 32) | uint32_msk
  1367. *
  1368. */
  1369. __pyx_v_uint64_msk = __pyx_v_uint32_msk;
  1370. /* "aiohttp/_websocket.pyx":42
  1371. * if sizeof(size_t) >= 8:
  1372. * uint64_msk = uint32_msk
  1373. * uint64_msk = (uint64_msk << 32) | uint32_msk # <<<<<<<<<<<<<<
  1374. *
  1375. * while data_len >= 8:
  1376. */
  1377. __pyx_v_uint64_msk = ((__pyx_v_uint64_msk << 32) | __pyx_v_uint32_msk);
  1378. /* "aiohttp/_websocket.pyx":44
  1379. * uint64_msk = (uint64_msk << 32) | uint32_msk
  1380. *
  1381. * while data_len >= 8: # <<<<<<<<<<<<<<
  1382. * (<uint64_t*>in_buf)[0] ^= uint64_msk
  1383. * in_buf += 8
  1384. */
  1385. while (1) {
  1386. __pyx_t_2 = ((__pyx_v_data_len >= 8) != 0);
  1387. if (!__pyx_t_2) break;
  1388. /* "aiohttp/_websocket.pyx":45
  1389. *
  1390. * while data_len >= 8:
  1391. * (<uint64_t*>in_buf)[0] ^= uint64_msk # <<<<<<<<<<<<<<
  1392. * in_buf += 8
  1393. * data_len -= 8
  1394. */
  1395. __pyx_t_6 = ((uint64_t *)__pyx_v_in_buf);
  1396. __pyx_t_7 = 0;
  1397. (__pyx_t_6[__pyx_t_7]) = ((__pyx_t_6[__pyx_t_7]) ^ __pyx_v_uint64_msk);
  1398. /* "aiohttp/_websocket.pyx":46
  1399. * while data_len >= 8:
  1400. * (<uint64_t*>in_buf)[0] ^= uint64_msk
  1401. * in_buf += 8 # <<<<<<<<<<<<<<
  1402. * data_len -= 8
  1403. *
  1404. */
  1405. __pyx_v_in_buf = (__pyx_v_in_buf + 8);
  1406. /* "aiohttp/_websocket.pyx":47
  1407. * (<uint64_t*>in_buf)[0] ^= uint64_msk
  1408. * in_buf += 8
  1409. * data_len -= 8 # <<<<<<<<<<<<<<
  1410. *
  1411. *
  1412. */
  1413. __pyx_v_data_len = (__pyx_v_data_len - 8);
  1414. }
  1415. /* "aiohttp/_websocket.pyx":40
  1416. * # does it need in python ?! malloc() always aligns to sizeof(long) bytes
  1417. *
  1418. * if sizeof(size_t) >= 8: # <<<<<<<<<<<<<<
  1419. * uint64_msk = uint32_msk
  1420. * uint64_msk = (uint64_msk << 32) | uint32_msk
  1421. */
  1422. }
  1423. /* "aiohttp/_websocket.pyx":50
  1424. *
  1425. *
  1426. * while data_len >= 4: # <<<<<<<<<<<<<<
  1427. * (<uint32_t*>in_buf)[0] ^= uint32_msk
  1428. * in_buf += 4
  1429. */
  1430. while (1) {
  1431. __pyx_t_2 = ((__pyx_v_data_len >= 4) != 0);
  1432. if (!__pyx_t_2) break;
  1433. /* "aiohttp/_websocket.pyx":51
  1434. *
  1435. * while data_len >= 4:
  1436. * (<uint32_t*>in_buf)[0] ^= uint32_msk # <<<<<<<<<<<<<<
  1437. * in_buf += 4
  1438. * data_len -= 4
  1439. */
  1440. __pyx_t_8 = ((uint32_t *)__pyx_v_in_buf);
  1441. __pyx_t_7 = 0;
  1442. (__pyx_t_8[__pyx_t_7]) = ((__pyx_t_8[__pyx_t_7]) ^ __pyx_v_uint32_msk);
  1443. /* "aiohttp/_websocket.pyx":52
  1444. * while data_len >= 4:
  1445. * (<uint32_t*>in_buf)[0] ^= uint32_msk
  1446. * in_buf += 4 # <<<<<<<<<<<<<<
  1447. * data_len -= 4
  1448. *
  1449. */
  1450. __pyx_v_in_buf = (__pyx_v_in_buf + 4);
  1451. /* "aiohttp/_websocket.pyx":53
  1452. * (<uint32_t*>in_buf)[0] ^= uint32_msk
  1453. * in_buf += 4
  1454. * data_len -= 4 # <<<<<<<<<<<<<<
  1455. *
  1456. * for i in range(0, data_len):
  1457. */
  1458. __pyx_v_data_len = (__pyx_v_data_len - 4);
  1459. }
  1460. /* "aiohttp/_websocket.pyx":55
  1461. * data_len -= 4
  1462. *
  1463. * for i in range(0, data_len): # <<<<<<<<<<<<<<
  1464. * in_buf[i] ^= mask_buf[i]
  1465. */
  1466. __pyx_t_1 = __pyx_v_data_len;
  1467. __pyx_t_9 = __pyx_t_1;
  1468. for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) {
  1469. __pyx_v_i = __pyx_t_10;
  1470. /* "aiohttp/_websocket.pyx":56
  1471. *
  1472. * for i in range(0, data_len):
  1473. * in_buf[i] ^= mask_buf[i] # <<<<<<<<<<<<<<
  1474. */
  1475. __pyx_t_11 = __pyx_v_i;
  1476. (__pyx_v_in_buf[__pyx_t_11]) = ((__pyx_v_in_buf[__pyx_t_11]) ^ (__pyx_v_mask_buf[__pyx_v_i]));
  1477. }
  1478. /* "aiohttp/_websocket.pyx":11
  1479. *
  1480. *
  1481. * def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
  1482. * """Note, this function mutates its `data` argument
  1483. * """
  1484. */
  1485. /* function exit code */
  1486. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1487. goto __pyx_L0;
  1488. __pyx_L1_error:;
  1489. __Pyx_XDECREF(__pyx_t_4);
  1490. __Pyx_AddTraceback("aiohttp._websocket._websocket_mask_cython", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1491. __pyx_r = NULL;
  1492. __pyx_L0:;
  1493. __Pyx_XDECREF(__pyx_v_mask);
  1494. __Pyx_XDECREF(__pyx_v_data);
  1495. __Pyx_XGIVEREF(__pyx_r);
  1496. __Pyx_RefNannyFinishContext();
  1497. return __pyx_r;
  1498. }
  1499. static PyMethodDef __pyx_methods[] = {
  1500. {0, 0, 0, 0}
  1501. };
  1502. #if PY_MAJOR_VERSION >= 3
  1503. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1504. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  1505. static int __pyx_pymod_exec__websocket(PyObject* module); /*proto*/
  1506. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  1507. {Py_mod_create, (void*)__pyx_pymod_create},
  1508. {Py_mod_exec, (void*)__pyx_pymod_exec__websocket},
  1509. {0, NULL}
  1510. };
  1511. #endif
  1512. static struct PyModuleDef __pyx_moduledef = {
  1513. PyModuleDef_HEAD_INIT,
  1514. "_websocket",
  1515. 0, /* m_doc */
  1516. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1517. 0, /* m_size */
  1518. #else
  1519. -1, /* m_size */
  1520. #endif
  1521. __pyx_methods /* m_methods */,
  1522. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1523. __pyx_moduledef_slots, /* m_slots */
  1524. #else
  1525. NULL, /* m_reload */
  1526. #endif
  1527. NULL, /* m_traverse */
  1528. NULL, /* m_clear */
  1529. NULL /* m_free */
  1530. };
  1531. #endif
  1532. #ifndef CYTHON_SMALL_CODE
  1533. #if defined(__clang__)
  1534. #define CYTHON_SMALL_CODE
  1535. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  1536. #define CYTHON_SMALL_CODE __attribute__((cold))
  1537. #else
  1538. #define CYTHON_SMALL_CODE
  1539. #endif
  1540. #endif
  1541. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  1542. {&__pyx_n_s_aiohttp__websocket, __pyx_k_aiohttp__websocket, sizeof(__pyx_k_aiohttp__websocket), 0, 0, 1, 1},
  1543. {&__pyx_kp_s_aiohttp__websocket_pyx, __pyx_k_aiohttp__websocket_pyx, sizeof(__pyx_k_aiohttp__websocket_pyx), 0, 0, 1, 0},
  1544. {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
  1545. {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
  1546. {&__pyx_n_s_data_len, __pyx_k_data_len, sizeof(__pyx_k_data_len), 0, 0, 1, 1},
  1547. {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
  1548. {&__pyx_n_s_in_buf, __pyx_k_in_buf, sizeof(__pyx_k_in_buf), 0, 0, 1, 1},
  1549. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  1550. {&__pyx_n_s_mask, __pyx_k_mask, sizeof(__pyx_k_mask), 0, 0, 1, 1},
  1551. {&__pyx_n_s_mask_buf, __pyx_k_mask_buf, sizeof(__pyx_k_mask_buf), 0, 0, 1, 1},
  1552. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  1553. {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
  1554. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  1555. {&__pyx_n_s_uint32_msk, __pyx_k_uint32_msk, sizeof(__pyx_k_uint32_msk), 0, 0, 1, 1},
  1556. {&__pyx_n_s_uint64_msk, __pyx_k_uint64_msk, sizeof(__pyx_k_uint64_msk), 0, 0, 1, 1},
  1557. {&__pyx_n_s_websocket_mask_cython, __pyx_k_websocket_mask_cython, sizeof(__pyx_k_websocket_mask_cython), 0, 0, 1, 1},
  1558. {0, 0, 0, 0, 0, 0, 0}
  1559. };
  1560. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
  1561. __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 55, __pyx_L1_error)
  1562. return 0;
  1563. __pyx_L1_error:;
  1564. return -1;
  1565. }
  1566. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
  1567. __Pyx_RefNannyDeclarations
  1568. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  1569. /* "aiohttp/_websocket.pyx":11
  1570. *
  1571. *
  1572. * def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
  1573. * """Note, this function mutates its `data` argument
  1574. * """
  1575. */
  1576. __pyx_tuple_ = PyTuple_Pack(8, __pyx_n_s_mask, __pyx_n_s_data, __pyx_n_s_data_len, __pyx_n_s_i, __pyx_n_s_in_buf, __pyx_n_s_mask_buf, __pyx_n_s_uint32_msk, __pyx_n_s_uint64_msk); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 11, __pyx_L1_error)
  1577. __Pyx_GOTREF(__pyx_tuple_);
  1578. __Pyx_GIVEREF(__pyx_tuple_);
  1579. __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(2, 0, 8, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_aiohttp__websocket_pyx, __pyx_n_s_websocket_mask_cython, 11, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 11, __pyx_L1_error)
  1580. __Pyx_RefNannyFinishContext();
  1581. return 0;
  1582. __pyx_L1_error:;
  1583. __Pyx_RefNannyFinishContext();
  1584. return -1;
  1585. }
  1586. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
  1587. if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  1588. return 0;
  1589. __pyx_L1_error:;
  1590. return -1;
  1591. }
  1592. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
  1593. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
  1594. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
  1595. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
  1596. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
  1597. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
  1598. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
  1599. static int __Pyx_modinit_global_init_code(void) {
  1600. __Pyx_RefNannyDeclarations
  1601. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  1602. /*--- Global init code ---*/
  1603. __Pyx_RefNannyFinishContext();
  1604. return 0;
  1605. }
  1606. static int __Pyx_modinit_variable_export_code(void) {
  1607. __Pyx_RefNannyDeclarations
  1608. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  1609. /*--- Variable export code ---*/
  1610. __Pyx_RefNannyFinishContext();
  1611. return 0;
  1612. }
  1613. static int __Pyx_modinit_function_export_code(void) {
  1614. __Pyx_RefNannyDeclarations
  1615. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  1616. /*--- Function export code ---*/
  1617. __Pyx_RefNannyFinishContext();
  1618. return 0;
  1619. }
  1620. static int __Pyx_modinit_type_init_code(void) {
  1621. __Pyx_RefNannyDeclarations
  1622. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  1623. /*--- Type init code ---*/
  1624. __Pyx_RefNannyFinishContext();
  1625. return 0;
  1626. }
  1627. static int __Pyx_modinit_type_import_code(void) {
  1628. __Pyx_RefNannyDeclarations
  1629. PyObject *__pyx_t_1 = NULL;
  1630. int __pyx_lineno = 0;
  1631. const char *__pyx_filename = NULL;
  1632. int __pyx_clineno = 0;
  1633. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  1634. /*--- Type import code ---*/
  1635. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
  1636. __Pyx_GOTREF(__pyx_t_1);
  1637. __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
  1638. #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
  1639. sizeof(PyTypeObject),
  1640. #else
  1641. sizeof(PyHeapTypeObject),
  1642. #endif
  1643. __Pyx_ImportType_CheckSize_Warn);
  1644. if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(1, 9, __pyx_L1_error)
  1645. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1646. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
  1647. __Pyx_GOTREF(__pyx_t_1);
  1648. __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
  1649. if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(2, 8, __pyx_L1_error)
  1650. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1651. __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 15, __pyx_L1_error)
  1652. __Pyx_GOTREF(__pyx_t_1);
  1653. __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
  1654. if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(3, 15, __pyx_L1_error)
  1655. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1656. __Pyx_RefNannyFinishContext();
  1657. return 0;
  1658. __pyx_L1_error:;
  1659. __Pyx_XDECREF(__pyx_t_1);
  1660. __Pyx_RefNannyFinishContext();
  1661. return -1;
  1662. }
  1663. static int __Pyx_modinit_variable_import_code(void) {
  1664. __Pyx_RefNannyDeclarations
  1665. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  1666. /*--- Variable import code ---*/
  1667. __Pyx_RefNannyFinishContext();
  1668. return 0;
  1669. }
  1670. static int __Pyx_modinit_function_import_code(void) {
  1671. __Pyx_RefNannyDeclarations
  1672. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  1673. /*--- Function import code ---*/
  1674. __Pyx_RefNannyFinishContext();
  1675. return 0;
  1676. }
  1677. #ifndef CYTHON_NO_PYINIT_EXPORT
  1678. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  1679. #elif PY_MAJOR_VERSION < 3
  1680. #ifdef __cplusplus
  1681. #define __Pyx_PyMODINIT_FUNC extern "C" void
  1682. #else
  1683. #define __Pyx_PyMODINIT_FUNC void
  1684. #endif
  1685. #else
  1686. #ifdef __cplusplus
  1687. #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
  1688. #else
  1689. #define __Pyx_PyMODINIT_FUNC PyObject *
  1690. #endif
  1691. #endif
  1692. #if PY_MAJOR_VERSION < 3
  1693. __Pyx_PyMODINIT_FUNC init_websocket(void) CYTHON_SMALL_CODE; /*proto*/
  1694. __Pyx_PyMODINIT_FUNC init_websocket(void)
  1695. #else
  1696. __Pyx_PyMODINIT_FUNC PyInit__websocket(void) CYTHON_SMALL_CODE; /*proto*/
  1697. __Pyx_PyMODINIT_FUNC PyInit__websocket(void)
  1698. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1699. {
  1700. return PyModuleDef_Init(&__pyx_moduledef);
  1701. }
  1702. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  1703. #if PY_VERSION_HEX >= 0x030700A1
  1704. static PY_INT64_T main_interpreter_id = -1;
  1705. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  1706. if (main_interpreter_id == -1) {
  1707. main_interpreter_id = current_id;
  1708. return (unlikely(current_id == -1)) ? -1 : 0;
  1709. } else if (unlikely(main_interpreter_id != current_id))
  1710. #else
  1711. static PyInterpreterState *main_interpreter = NULL;
  1712. PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
  1713. if (!main_interpreter) {
  1714. main_interpreter = current_interpreter;
  1715. } else if (unlikely(main_interpreter != current_interpreter))
  1716. #endif
  1717. {
  1718. PyErr_SetString(
  1719. PyExc_ImportError,
  1720. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  1721. return -1;
  1722. }
  1723. return 0;
  1724. }
  1725. static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
  1726. PyObject *value = PyObject_GetAttrString(spec, from_name);
  1727. int result = 0;
  1728. if (likely(value)) {
  1729. if (allow_none || value != Py_None) {
  1730. result = PyDict_SetItemString(moddict, to_name, value);
  1731. }
  1732. Py_DECREF(value);
  1733. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  1734. PyErr_Clear();
  1735. } else {
  1736. result = -1;
  1737. }
  1738. return result;
  1739. }
  1740. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
  1741. PyObject *module = NULL, *moddict, *modname;
  1742. if (__Pyx_check_single_interpreter())
  1743. return NULL;
  1744. if (__pyx_m)
  1745. return __Pyx_NewRef(__pyx_m);
  1746. modname = PyObject_GetAttrString(spec, "name");
  1747. if (unlikely(!modname)) goto bad;
  1748. module = PyModule_NewObject(modname);
  1749. Py_DECREF(modname);
  1750. if (unlikely(!module)) goto bad;
  1751. moddict = PyModule_GetDict(module);
  1752. if (unlikely(!moddict)) goto bad;
  1753. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  1754. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  1755. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  1756. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  1757. return module;
  1758. bad:
  1759. Py_XDECREF(module);
  1760. return NULL;
  1761. }
  1762. static CYTHON_SMALL_CODE int __pyx_pymod_exec__websocket(PyObject *__pyx_pyinit_module)
  1763. #endif
  1764. #endif
  1765. {
  1766. PyObject *__pyx_t_1 = NULL;
  1767. int __pyx_lineno = 0;
  1768. const char *__pyx_filename = NULL;
  1769. int __pyx_clineno = 0;
  1770. __Pyx_RefNannyDeclarations
  1771. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1772. if (__pyx_m) {
  1773. if (__pyx_m == __pyx_pyinit_module) return 0;
  1774. PyErr_SetString(PyExc_RuntimeError, "Module '_websocket' has already been imported. Re-initialisation is not supported.");
  1775. return -1;
  1776. }
  1777. #elif PY_MAJOR_VERSION >= 3
  1778. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  1779. #endif
  1780. #if CYTHON_REFNANNY
  1781. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  1782. if (!__Pyx_RefNanny) {
  1783. PyErr_Clear();
  1784. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  1785. if (!__Pyx_RefNanny)
  1786. Py_FatalError("failed to import 'refnanny' module");
  1787. }
  1788. #endif
  1789. __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit__websocket(void)", 0);
  1790. if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1791. #ifdef __Pxy_PyFrame_Initialize_Offsets
  1792. __Pxy_PyFrame_Initialize_Offsets();
  1793. #endif
  1794. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  1795. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  1796. __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  1797. #ifdef __Pyx_CyFunction_USED
  1798. if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1799. #endif
  1800. #ifdef __Pyx_FusedFunction_USED
  1801. if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1802. #endif
  1803. #ifdef __Pyx_Coroutine_USED
  1804. if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1805. #endif
  1806. #ifdef __Pyx_Generator_USED
  1807. if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1808. #endif
  1809. #ifdef __Pyx_AsyncGen_USED
  1810. if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1811. #endif
  1812. #ifdef __Pyx_StopAsyncIteration_USED
  1813. if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1814. #endif
  1815. /*--- Library function declarations ---*/
  1816. /*--- Threads initialization code ---*/
  1817. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  1818. #ifdef WITH_THREAD /* Python build with threading support? */
  1819. PyEval_InitThreads();
  1820. #endif
  1821. #endif
  1822. /*--- Module creation code ---*/
  1823. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1824. __pyx_m = __pyx_pyinit_module;
  1825. Py_INCREF(__pyx_m);
  1826. #else
  1827. #if PY_MAJOR_VERSION < 3
  1828. __pyx_m = Py_InitModule4("_websocket", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  1829. #else
  1830. __pyx_m = PyModule_Create(&__pyx_moduledef);
  1831. #endif
  1832. if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
  1833. #endif
  1834. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  1835. Py_INCREF(__pyx_d);
  1836. __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  1837. Py_INCREF(__pyx_b);
  1838. __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  1839. Py_INCREF(__pyx_cython_runtime);
  1840. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
  1841. /*--- Initialize various global constants etc. ---*/
  1842. if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1843. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  1844. if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1845. #endif
  1846. if (__pyx_module_is_main_aiohttp___websocket) {
  1847. if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1848. }
  1849. #if PY_MAJOR_VERSION >= 3
  1850. {
  1851. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  1852. if (!PyDict_GetItemString(modules, "aiohttp._websocket")) {
  1853. if (unlikely(PyDict_SetItemString(modules, "aiohttp._websocket", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  1854. }
  1855. }
  1856. #endif
  1857. /*--- Builtin init code ---*/
  1858. if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1859. /*--- Constants init code ---*/
  1860. if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1861. /*--- Global type/function init code ---*/
  1862. (void)__Pyx_modinit_global_init_code();
  1863. (void)__Pyx_modinit_variable_export_code();
  1864. (void)__Pyx_modinit_function_export_code();
  1865. (void)__Pyx_modinit_type_init_code();
  1866. if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
  1867. (void)__Pyx_modinit_variable_import_code();
  1868. (void)__Pyx_modinit_function_import_code();
  1869. /*--- Execution code ---*/
  1870. #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
  1871. if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1872. #endif
  1873. /* "aiohttp/_websocket.pyx":11
  1874. *
  1875. *
  1876. * def _websocket_mask_cython(object mask, object data): # <<<<<<<<<<<<<<
  1877. * """Note, this function mutates its `data` argument
  1878. * """
  1879. */
  1880. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_7aiohttp_10_websocket_1_websocket_mask_cython, NULL, __pyx_n_s_aiohttp__websocket); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
  1881. __Pyx_GOTREF(__pyx_t_1);
  1882. if (PyDict_SetItem(__pyx_d, __pyx_n_s_websocket_mask_cython, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
  1883. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1884. /* "aiohttp/_websocket.pyx":1
  1885. * from cpython cimport PyBytes_AsString # <<<<<<<<<<<<<<
  1886. *
  1887. *
  1888. */
  1889. __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  1890. __Pyx_GOTREF(__pyx_t_1);
  1891. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  1892. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1893. /*--- Wrapped vars code ---*/
  1894. goto __pyx_L0;
  1895. __pyx_L1_error:;
  1896. __Pyx_XDECREF(__pyx_t_1);
  1897. if (__pyx_m) {
  1898. if (__pyx_d) {
  1899. __Pyx_AddTraceback("init aiohttp._websocket", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1900. }
  1901. Py_CLEAR(__pyx_m);
  1902. } else if (!PyErr_Occurred()) {
  1903. PyErr_SetString(PyExc_ImportError, "init aiohttp._websocket");
  1904. }
  1905. __pyx_L0:;
  1906. __Pyx_RefNannyFinishContext();
  1907. #if CYTHON_PEP489_MULTI_PHASE_INIT
  1908. return (__pyx_m != NULL) ? 0 : -1;
  1909. #elif PY_MAJOR_VERSION >= 3
  1910. return __pyx_m;
  1911. #else
  1912. return;
  1913. #endif
  1914. }
  1915. /* --- Runtime support code --- */
  1916. /* Refnanny */
  1917. #if CYTHON_REFNANNY
  1918. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  1919. PyObject *m = NULL, *p = NULL;
  1920. void *r = NULL;
  1921. m = PyImport_ImportModule(modname);
  1922. if (!m) goto end;
  1923. p = PyObject_GetAttrString(m, "RefNannyAPI");
  1924. if (!p) goto end;
  1925. r = PyLong_AsVoidPtr(p);
  1926. end:
  1927. Py_XDECREF(p);
  1928. Py_XDECREF(m);
  1929. return (__Pyx_RefNannyAPIStruct *)r;
  1930. }
  1931. #endif
  1932. /* PyObjectGetAttrStr */
  1933. #if CYTHON_USE_TYPE_SLOTS
  1934. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  1935. PyTypeObject* tp = Py_TYPE(obj);
  1936. if (likely(tp->tp_getattro))
  1937. return tp->tp_getattro(obj, attr_name);
  1938. #if PY_MAJOR_VERSION < 3
  1939. if (likely(tp->tp_getattr))
  1940. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  1941. #endif
  1942. return PyObject_GetAttr(obj, attr_name);
  1943. }
  1944. #endif
  1945. /* GetBuiltinName */
  1946. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  1947. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  1948. if (unlikely(!result)) {
  1949. PyErr_Format(PyExc_NameError,
  1950. #if PY_MAJOR_VERSION >= 3
  1951. "name '%U' is not defined", name);
  1952. #else
  1953. "name '%.200s' is not defined", PyString_AS_STRING(name));
  1954. #endif
  1955. }
  1956. return result;
  1957. }
  1958. /* RaiseArgTupleInvalid */
  1959. static void __Pyx_RaiseArgtupleInvalid(
  1960. const char* func_name,
  1961. int exact,
  1962. Py_ssize_t num_min,
  1963. Py_ssize_t num_max,
  1964. Py_ssize_t num_found)
  1965. {
  1966. Py_ssize_t num_expected;
  1967. const char *more_or_less;
  1968. if (num_found < num_min) {
  1969. num_expected = num_min;
  1970. more_or_less = "at least";
  1971. } else {
  1972. num_expected = num_max;
  1973. more_or_less = "at most";
  1974. }
  1975. if (exact) {
  1976. more_or_less = "exactly";
  1977. }
  1978. PyErr_Format(PyExc_TypeError,
  1979. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  1980. func_name, more_or_less, num_expected,
  1981. (num_expected == 1) ? "" : "s", num_found);
  1982. }
  1983. /* RaiseDoubleKeywords */
  1984. static void __Pyx_RaiseDoubleKeywordsError(
  1985. const char* func_name,
  1986. PyObject* kw_name)
  1987. {
  1988. PyErr_Format(PyExc_TypeError,
  1989. #if PY_MAJOR_VERSION >= 3
  1990. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  1991. #else
  1992. "%s() got multiple values for keyword argument '%s'", func_name,
  1993. PyString_AsString(kw_name));
  1994. #endif
  1995. }
  1996. /* ParseKeywords */
  1997. static int __Pyx_ParseOptionalKeywords(
  1998. PyObject *kwds,
  1999. PyObject **argnames[],
  2000. PyObject *kwds2,
  2001. PyObject *values[],
  2002. Py_ssize_t num_pos_args,
  2003. const char* function_name)
  2004. {
  2005. PyObject *key = 0, *value = 0;
  2006. Py_ssize_t pos = 0;
  2007. PyObject*** name;
  2008. PyObject*** first_kw_arg = argnames + num_pos_args;
  2009. while (PyDict_Next(kwds, &pos, &key, &value)) {
  2010. name = first_kw_arg;
  2011. while (*name && (**name != key)) name++;
  2012. if (*name) {
  2013. values[name-argnames] = value;
  2014. continue;
  2015. }
  2016. name = first_kw_arg;
  2017. #if PY_MAJOR_VERSION < 3
  2018. if (likely(PyString_Check(key))) {
  2019. while (*name) {
  2020. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  2021. && _PyString_Eq(**name, key)) {
  2022. values[name-argnames] = value;
  2023. break;
  2024. }
  2025. name++;
  2026. }
  2027. if (*name) continue;
  2028. else {
  2029. PyObject*** argname = argnames;
  2030. while (argname != first_kw_arg) {
  2031. if ((**argname == key) || (
  2032. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  2033. && _PyString_Eq(**argname, key))) {
  2034. goto arg_passed_twice;
  2035. }
  2036. argname++;
  2037. }
  2038. }
  2039. } else
  2040. #endif
  2041. if (likely(PyUnicode_Check(key))) {
  2042. while (*name) {
  2043. int cmp = (**name == key) ? 0 :
  2044. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  2045. (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
  2046. #endif
  2047. PyUnicode_Compare(**name, key);
  2048. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  2049. if (cmp == 0) {
  2050. values[name-argnames] = value;
  2051. break;
  2052. }
  2053. name++;
  2054. }
  2055. if (*name) continue;
  2056. else {
  2057. PyObject*** argname = argnames;
  2058. while (argname != first_kw_arg) {
  2059. int cmp = (**argname == key) ? 0 :
  2060. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  2061. (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
  2062. #endif
  2063. PyUnicode_Compare(**argname, key);
  2064. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  2065. if (cmp == 0) goto arg_passed_twice;
  2066. argname++;
  2067. }
  2068. }
  2069. } else
  2070. goto invalid_keyword_type;
  2071. if (kwds2) {
  2072. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  2073. } else {
  2074. goto invalid_keyword;
  2075. }
  2076. }
  2077. return 0;
  2078. arg_passed_twice:
  2079. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  2080. goto bad;
  2081. invalid_keyword_type:
  2082. PyErr_Format(PyExc_TypeError,
  2083. "%.200s() keywords must be strings", function_name);
  2084. goto bad;
  2085. invalid_keyword:
  2086. PyErr_Format(PyExc_TypeError,
  2087. #if PY_MAJOR_VERSION < 3
  2088. "%.200s() got an unexpected keyword argument '%.200s'",
  2089. function_name, PyString_AsString(key));
  2090. #else
  2091. "%s() got an unexpected keyword argument '%U'",
  2092. function_name, key);
  2093. #endif
  2094. bad:
  2095. return -1;
  2096. }
  2097. /* PyCFunctionFastCall */
  2098. #if CYTHON_FAST_PYCCALL
  2099. static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
  2100. PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
  2101. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  2102. PyObject *self = PyCFunction_GET_SELF(func);
  2103. int flags = PyCFunction_GET_FLAGS(func);
  2104. assert(PyCFunction_Check(func));
  2105. assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
  2106. assert(nargs >= 0);
  2107. assert(nargs == 0 || args != NULL);
  2108. /* _PyCFunction_FastCallDict() must not be called with an exception set,
  2109. because it may clear it (directly or indirectly) and so the
  2110. caller loses its exception */
  2111. assert(!PyErr_Occurred());
  2112. if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
  2113. return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
  2114. } else {
  2115. return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
  2116. }
  2117. }
  2118. #endif
  2119. /* PyFunctionFastCall */
  2120. #if CYTHON_FAST_PYCALL
  2121. static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
  2122. PyObject *globals) {
  2123. PyFrameObject *f;
  2124. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  2125. PyObject **fastlocals;
  2126. Py_ssize_t i;
  2127. PyObject *result;
  2128. assert(globals != NULL);
  2129. /* XXX Perhaps we should create a specialized
  2130. PyFrame_New() that doesn't take locals, but does
  2131. take builtins without sanity checking them.
  2132. */
  2133. assert(tstate != NULL);
  2134. f = PyFrame_New(tstate, co, globals, NULL);
  2135. if (f == NULL) {
  2136. return NULL;
  2137. }
  2138. fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
  2139. for (i = 0; i < na; i++) {
  2140. Py_INCREF(*args);
  2141. fastlocals[i] = *args++;
  2142. }
  2143. result = PyEval_EvalFrameEx(f,0);
  2144. ++tstate->recursion_depth;
  2145. Py_DECREF(f);
  2146. --tstate->recursion_depth;
  2147. return result;
  2148. }
  2149. #if 1 || PY_VERSION_HEX < 0x030600B1
  2150. static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
  2151. PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
  2152. PyObject *globals = PyFunction_GET_GLOBALS(func);
  2153. PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
  2154. PyObject *closure;
  2155. #if PY_MAJOR_VERSION >= 3
  2156. PyObject *kwdefs;
  2157. #endif
  2158. PyObject *kwtuple, **k;
  2159. PyObject **d;
  2160. Py_ssize_t nd;
  2161. Py_ssize_t nk;
  2162. PyObject *result;
  2163. assert(kwargs == NULL || PyDict_Check(kwargs));
  2164. nk = kwargs ? PyDict_Size(kwargs) : 0;
  2165. if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
  2166. return NULL;
  2167. }
  2168. if (
  2169. #if PY_MAJOR_VERSION >= 3
  2170. co->co_kwonlyargcount == 0 &&
  2171. #endif
  2172. likely(kwargs == NULL || nk == 0) &&
  2173. co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
  2174. if (argdefs == NULL && co->co_argcount == nargs) {
  2175. result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
  2176. goto done;
  2177. }
  2178. else if (nargs == 0 && argdefs != NULL
  2179. && co->co_argcount == Py_SIZE(argdefs)) {
  2180. /* function called with no arguments, but all parameters have
  2181. a default value: use default values as arguments .*/
  2182. args = &PyTuple_GET_ITEM(argdefs, 0);
  2183. result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
  2184. goto done;
  2185. }
  2186. }
  2187. if (kwargs != NULL) {
  2188. Py_ssize_t pos, i;
  2189. kwtuple = PyTuple_New(2 * nk);
  2190. if (kwtuple == NULL) {
  2191. result = NULL;
  2192. goto done;
  2193. }
  2194. k = &PyTuple_GET_ITEM(kwtuple, 0);
  2195. pos = i = 0;
  2196. while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
  2197. Py_INCREF(k[i]);
  2198. Py_INCREF(k[i+1]);
  2199. i += 2;
  2200. }
  2201. nk = i / 2;
  2202. }
  2203. else {
  2204. kwtuple = NULL;
  2205. k = NULL;
  2206. }
  2207. closure = PyFunction_GET_CLOSURE(func);
  2208. #if PY_MAJOR_VERSION >= 3
  2209. kwdefs = PyFunction_GET_KW_DEFAULTS(func);
  2210. #endif
  2211. if (argdefs != NULL) {
  2212. d = &PyTuple_GET_ITEM(argdefs, 0);
  2213. nd = Py_SIZE(argdefs);
  2214. }
  2215. else {
  2216. d = NULL;
  2217. nd = 0;
  2218. }
  2219. #if PY_MAJOR_VERSION >= 3
  2220. result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
  2221. args, (int)nargs,
  2222. k, (int)nk,
  2223. d, (int)nd, kwdefs, closure);
  2224. #else
  2225. result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
  2226. args, (int)nargs,
  2227. k, (int)nk,
  2228. d, (int)nd, closure);
  2229. #endif
  2230. Py_XDECREF(kwtuple);
  2231. done:
  2232. Py_LeaveRecursiveCall();
  2233. return result;
  2234. }
  2235. #endif
  2236. #endif
  2237. /* PyObjectCall */
  2238. #if CYTHON_COMPILING_IN_CPYTHON
  2239. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  2240. PyObject *result;
  2241. ternaryfunc call = func->ob_type->tp_call;
  2242. if (unlikely(!call))
  2243. return PyObject_Call(func, arg, kw);
  2244. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  2245. return NULL;
  2246. result = (*call)(func, arg, kw);
  2247. Py_LeaveRecursiveCall();
  2248. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  2249. PyErr_SetString(
  2250. PyExc_SystemError,
  2251. "NULL result without error in PyObject_Call");
  2252. }
  2253. return result;
  2254. }
  2255. #endif
  2256. /* PyObjectCallMethO */
  2257. #if CYTHON_COMPILING_IN_CPYTHON
  2258. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  2259. PyObject *self, *result;
  2260. PyCFunction cfunc;
  2261. cfunc = PyCFunction_GET_FUNCTION(func);
  2262. self = PyCFunction_GET_SELF(func);
  2263. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  2264. return NULL;
  2265. result = cfunc(self, arg);
  2266. Py_LeaveRecursiveCall();
  2267. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  2268. PyErr_SetString(
  2269. PyExc_SystemError,
  2270. "NULL result without error in PyObject_Call");
  2271. }
  2272. return result;
  2273. }
  2274. #endif
  2275. /* PyObjectCallOneArg */
  2276. #if CYTHON_COMPILING_IN_CPYTHON
  2277. static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  2278. PyObject *result;
  2279. PyObject *args = PyTuple_New(1);
  2280. if (unlikely(!args)) return NULL;
  2281. Py_INCREF(arg);
  2282. PyTuple_SET_ITEM(args, 0, arg);
  2283. result = __Pyx_PyObject_Call(func, args, NULL);
  2284. Py_DECREF(args);
  2285. return result;
  2286. }
  2287. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  2288. #if CYTHON_FAST_PYCALL
  2289. if (PyFunction_Check(func)) {
  2290. return __Pyx_PyFunction_FastCall(func, &arg, 1);
  2291. }
  2292. #endif
  2293. if (likely(PyCFunction_Check(func))) {
  2294. if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
  2295. return __Pyx_PyObject_CallMethO(func, arg);
  2296. #if CYTHON_FAST_PYCCALL
  2297. } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
  2298. return __Pyx_PyCFunction_FastCall(func, &arg, 1);
  2299. #endif
  2300. }
  2301. }
  2302. return __Pyx__PyObject_CallOneArg(func, arg);
  2303. }
  2304. #else
  2305. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  2306. PyObject *result;
  2307. PyObject *args = PyTuple_Pack(1, arg);
  2308. if (unlikely(!args)) return NULL;
  2309. result = __Pyx_PyObject_Call(func, args, NULL);
  2310. Py_DECREF(args);
  2311. return result;
  2312. }
  2313. #endif
  2314. /* TypeImport */
  2315. #ifndef __PYX_HAVE_RT_ImportType
  2316. #define __PYX_HAVE_RT_ImportType
  2317. static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
  2318. size_t size, enum __Pyx_ImportType_CheckSize check_size)
  2319. {
  2320. PyObject *result = 0;
  2321. char warning[200];
  2322. Py_ssize_t basicsize;
  2323. #ifdef Py_LIMITED_API
  2324. PyObject *py_basicsize;
  2325. #endif
  2326. result = PyObject_GetAttrString(module, class_name);
  2327. if (!result)
  2328. goto bad;
  2329. if (!PyType_Check(result)) {
  2330. PyErr_Format(PyExc_TypeError,
  2331. "%.200s.%.200s is not a type object",
  2332. module_name, class_name);
  2333. goto bad;
  2334. }
  2335. #ifndef Py_LIMITED_API
  2336. basicsize = ((PyTypeObject *)result)->tp_basicsize;
  2337. #else
  2338. py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
  2339. if (!py_basicsize)
  2340. goto bad;
  2341. basicsize = PyLong_AsSsize_t(py_basicsize);
  2342. Py_DECREF(py_basicsize);
  2343. py_basicsize = 0;
  2344. if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
  2345. goto bad;
  2346. #endif
  2347. if ((size_t)basicsize < size) {
  2348. PyErr_Format(PyExc_ValueError,
  2349. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  2350. "Expected %zd from C header, got %zd from PyObject",
  2351. module_name, class_name, size, basicsize);
  2352. goto bad;
  2353. }
  2354. if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
  2355. PyErr_Format(PyExc_ValueError,
  2356. "%.200s.%.200s size changed, may indicate binary incompatibility. "
  2357. "Expected %zd from C header, got %zd from PyObject",
  2358. module_name, class_name, size, basicsize);
  2359. goto bad;
  2360. }
  2361. else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
  2362. PyOS_snprintf(warning, sizeof(warning),
  2363. "%s.%s size changed, may indicate binary incompatibility. "
  2364. "Expected %zd from C header, got %zd from PyObject",
  2365. module_name, class_name, size, basicsize);
  2366. if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
  2367. }
  2368. return (PyTypeObject *)result;
  2369. bad:
  2370. Py_XDECREF(result);
  2371. return NULL;
  2372. }
  2373. #endif
  2374. /* PyDictVersioning */
  2375. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  2376. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
  2377. PyObject *dict = Py_TYPE(obj)->tp_dict;
  2378. return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
  2379. }
  2380. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
  2381. PyObject **dictptr = NULL;
  2382. Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
  2383. if (offset) {
  2384. #if CYTHON_COMPILING_IN_CPYTHON
  2385. dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
  2386. #else
  2387. dictptr = _PyObject_GetDictPtr(obj);
  2388. #endif
  2389. }
  2390. return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
  2391. }
  2392. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
  2393. PyObject *dict = Py_TYPE(obj)->tp_dict;
  2394. if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
  2395. return 0;
  2396. return obj_dict_version == __Pyx_get_object_dict_version(obj);
  2397. }
  2398. #endif
  2399. /* PyErrFetchRestore */
  2400. #if CYTHON_FAST_THREAD_STATE
  2401. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  2402. PyObject *tmp_type, *tmp_value, *tmp_tb;
  2403. tmp_type = tstate->curexc_type;
  2404. tmp_value = tstate->curexc_value;
  2405. tmp_tb = tstate->curexc_traceback;
  2406. tstate->curexc_type = type;
  2407. tstate->curexc_value = value;
  2408. tstate->curexc_traceback = tb;
  2409. Py_XDECREF(tmp_type);
  2410. Py_XDECREF(tmp_value);
  2411. Py_XDECREF(tmp_tb);
  2412. }
  2413. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  2414. *type = tstate->curexc_type;
  2415. *value = tstate->curexc_value;
  2416. *tb = tstate->curexc_traceback;
  2417. tstate->curexc_type = 0;
  2418. tstate->curexc_value = 0;
  2419. tstate->curexc_traceback = 0;
  2420. }
  2421. #endif
  2422. /* CLineInTraceback */
  2423. #ifndef CYTHON_CLINE_IN_TRACEBACK
  2424. static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
  2425. PyObject *use_cline;
  2426. PyObject *ptype, *pvalue, *ptraceback;
  2427. #if CYTHON_COMPILING_IN_CPYTHON
  2428. PyObject **cython_runtime_dict;
  2429. #endif
  2430. if (unlikely(!__pyx_cython_runtime)) {
  2431. return c_line;
  2432. }
  2433. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  2434. #if CYTHON_COMPILING_IN_CPYTHON
  2435. cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
  2436. if (likely(cython_runtime_dict)) {
  2437. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  2438. use_cline, *cython_runtime_dict,
  2439. __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
  2440. } else
  2441. #endif
  2442. {
  2443. PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
  2444. if (use_cline_obj) {
  2445. use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
  2446. Py_DECREF(use_cline_obj);
  2447. } else {
  2448. PyErr_Clear();
  2449. use_cline = NULL;
  2450. }
  2451. }
  2452. if (!use_cline) {
  2453. c_line = 0;
  2454. PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
  2455. }
  2456. else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  2457. c_line = 0;
  2458. }
  2459. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  2460. return c_line;
  2461. }
  2462. #endif
  2463. /* CodeObjectCache */
  2464. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  2465. int start = 0, mid = 0, end = count - 1;
  2466. if (end >= 0 && code_line > entries[end].code_line) {
  2467. return count;
  2468. }
  2469. while (start < end) {
  2470. mid = start + (end - start) / 2;
  2471. if (code_line < entries[mid].code_line) {
  2472. end = mid;
  2473. } else if (code_line > entries[mid].code_line) {
  2474. start = mid + 1;
  2475. } else {
  2476. return mid;
  2477. }
  2478. }
  2479. if (code_line <= entries[mid].code_line) {
  2480. return mid;
  2481. } else {
  2482. return mid + 1;
  2483. }
  2484. }
  2485. static PyCodeObject *__pyx_find_code_object(int code_line) {
  2486. PyCodeObject* code_object;
  2487. int pos;
  2488. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  2489. return NULL;
  2490. }
  2491. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  2492. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  2493. return NULL;
  2494. }
  2495. code_object = __pyx_code_cache.entries[pos].code_object;
  2496. Py_INCREF(code_object);
  2497. return code_object;
  2498. }
  2499. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  2500. int pos, i;
  2501. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  2502. if (unlikely(!code_line)) {
  2503. return;
  2504. }
  2505. if (unlikely(!entries)) {
  2506. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  2507. if (likely(entries)) {
  2508. __pyx_code_cache.entries = entries;
  2509. __pyx_code_cache.max_count = 64;
  2510. __pyx_code_cache.count = 1;
  2511. entries[0].code_line = code_line;
  2512. entries[0].code_object = code_object;
  2513. Py_INCREF(code_object);
  2514. }
  2515. return;
  2516. }
  2517. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  2518. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  2519. PyCodeObject* tmp = entries[pos].code_object;
  2520. entries[pos].code_object = code_object;
  2521. Py_DECREF(tmp);
  2522. return;
  2523. }
  2524. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  2525. int new_max = __pyx_code_cache.max_count + 64;
  2526. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  2527. __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
  2528. if (unlikely(!entries)) {
  2529. return;
  2530. }
  2531. __pyx_code_cache.entries = entries;
  2532. __pyx_code_cache.max_count = new_max;
  2533. }
  2534. for (i=__pyx_code_cache.count; i>pos; i--) {
  2535. entries[i] = entries[i-1];
  2536. }
  2537. entries[pos].code_line = code_line;
  2538. entries[pos].code_object = code_object;
  2539. __pyx_code_cache.count++;
  2540. Py_INCREF(code_object);
  2541. }
  2542. /* AddTraceback */
  2543. #include "compile.h"
  2544. #include "frameobject.h"
  2545. #include "traceback.h"
  2546. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  2547. const char *funcname, int c_line,
  2548. int py_line, const char *filename) {
  2549. PyCodeObject *py_code = 0;
  2550. PyObject *py_srcfile = 0;
  2551. PyObject *py_funcname = 0;
  2552. #if PY_MAJOR_VERSION < 3
  2553. py_srcfile = PyString_FromString(filename);
  2554. #else
  2555. py_srcfile = PyUnicode_FromString(filename);
  2556. #endif
  2557. if (!py_srcfile) goto bad;
  2558. if (c_line) {
  2559. #if PY_MAJOR_VERSION < 3
  2560. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  2561. #else
  2562. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  2563. #endif
  2564. }
  2565. else {
  2566. #if PY_MAJOR_VERSION < 3
  2567. py_funcname = PyString_FromString(funcname);
  2568. #else
  2569. py_funcname = PyUnicode_FromString(funcname);
  2570. #endif
  2571. }
  2572. if (!py_funcname) goto bad;
  2573. py_code = __Pyx_PyCode_New(
  2574. 0,
  2575. 0,
  2576. 0,
  2577. 0,
  2578. 0,
  2579. __pyx_empty_bytes, /*PyObject *code,*/
  2580. __pyx_empty_tuple, /*PyObject *consts,*/
  2581. __pyx_empty_tuple, /*PyObject *names,*/
  2582. __pyx_empty_tuple, /*PyObject *varnames,*/
  2583. __pyx_empty_tuple, /*PyObject *freevars,*/
  2584. __pyx_empty_tuple, /*PyObject *cellvars,*/
  2585. py_srcfile, /*PyObject *filename,*/
  2586. py_funcname, /*PyObject *name,*/
  2587. py_line,
  2588. __pyx_empty_bytes /*PyObject *lnotab*/
  2589. );
  2590. Py_DECREF(py_srcfile);
  2591. Py_DECREF(py_funcname);
  2592. return py_code;
  2593. bad:
  2594. Py_XDECREF(py_srcfile);
  2595. Py_XDECREF(py_funcname);
  2596. return NULL;
  2597. }
  2598. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  2599. int py_line, const char *filename) {
  2600. PyCodeObject *py_code = 0;
  2601. PyFrameObject *py_frame = 0;
  2602. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  2603. if (c_line) {
  2604. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  2605. }
  2606. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  2607. if (!py_code) {
  2608. py_code = __Pyx_CreateCodeObjectForTraceback(
  2609. funcname, c_line, py_line, filename);
  2610. if (!py_code) goto bad;
  2611. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  2612. }
  2613. py_frame = PyFrame_New(
  2614. tstate, /*PyThreadState *tstate,*/
  2615. py_code, /*PyCodeObject *code,*/
  2616. __pyx_d, /*PyObject *globals,*/
  2617. 0 /*PyObject *locals*/
  2618. );
  2619. if (!py_frame) goto bad;
  2620. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  2621. PyTraceBack_Here(py_frame);
  2622. bad:
  2623. Py_XDECREF(py_code);
  2624. Py_XDECREF(py_frame);
  2625. }
  2626. /* CIntToPy */
  2627. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  2628. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  2629. const int is_unsigned = neg_one > const_zero;
  2630. if (is_unsigned) {
  2631. if (sizeof(long) < sizeof(long)) {
  2632. return PyInt_FromLong((long) value);
  2633. } else if (sizeof(long) <= sizeof(unsigned long)) {
  2634. return PyLong_FromUnsignedLong((unsigned long) value);
  2635. #ifdef HAVE_LONG_LONG
  2636. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  2637. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  2638. #endif
  2639. }
  2640. } else {
  2641. if (sizeof(long) <= sizeof(long)) {
  2642. return PyInt_FromLong((long) value);
  2643. #ifdef HAVE_LONG_LONG
  2644. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  2645. return PyLong_FromLongLong((PY_LONG_LONG) value);
  2646. #endif
  2647. }
  2648. }
  2649. {
  2650. int one = 1; int little = (int)*(unsigned char *)&one;
  2651. unsigned char *bytes = (unsigned char *)&value;
  2652. return _PyLong_FromByteArray(bytes, sizeof(long),
  2653. little, !is_unsigned);
  2654. }
  2655. }
  2656. /* CIntFromPyVerify */
  2657. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  2658. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  2659. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  2660. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  2661. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  2662. {\
  2663. func_type value = func_value;\
  2664. if (sizeof(target_type) < sizeof(func_type)) {\
  2665. if (unlikely(value != (func_type) (target_type) value)) {\
  2666. func_type zero = 0;\
  2667. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  2668. return (target_type) -1;\
  2669. if (is_unsigned && unlikely(value < zero))\
  2670. goto raise_neg_overflow;\
  2671. else\
  2672. goto raise_overflow;\
  2673. }\
  2674. }\
  2675. return (target_type) value;\
  2676. }
  2677. /* CIntFromPy */
  2678. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  2679. const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
  2680. const int is_unsigned = neg_one > const_zero;
  2681. #if PY_MAJOR_VERSION < 3
  2682. if (likely(PyInt_Check(x))) {
  2683. if (sizeof(long) < sizeof(long)) {
  2684. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
  2685. } else {
  2686. long val = PyInt_AS_LONG(x);
  2687. if (is_unsigned && unlikely(val < 0)) {
  2688. goto raise_neg_overflow;
  2689. }
  2690. return (long) val;
  2691. }
  2692. } else
  2693. #endif
  2694. if (likely(PyLong_Check(x))) {
  2695. if (is_unsigned) {
  2696. #if CYTHON_USE_PYLONG_INTERNALS
  2697. const digit* digits = ((PyLongObject*)x)->ob_digit;
  2698. switch (Py_SIZE(x)) {
  2699. case 0: return (long) 0;
  2700. case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
  2701. case 2:
  2702. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  2703. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  2704. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2705. } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
  2706. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  2707. }
  2708. }
  2709. break;
  2710. case 3:
  2711. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  2712. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  2713. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2714. } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
  2715. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  2716. }
  2717. }
  2718. break;
  2719. case 4:
  2720. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  2721. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  2722. __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])))
  2723. } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
  2724. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  2725. }
  2726. }
  2727. break;
  2728. }
  2729. #endif
  2730. #if CYTHON_COMPILING_IN_CPYTHON
  2731. if (unlikely(Py_SIZE(x) < 0)) {
  2732. goto raise_neg_overflow;
  2733. }
  2734. #else
  2735. {
  2736. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  2737. if (unlikely(result < 0))
  2738. return (long) -1;
  2739. if (unlikely(result == 1))
  2740. goto raise_neg_overflow;
  2741. }
  2742. #endif
  2743. if (sizeof(long) <= sizeof(unsigned long)) {
  2744. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  2745. #ifdef HAVE_LONG_LONG
  2746. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  2747. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  2748. #endif
  2749. }
  2750. } else {
  2751. #if CYTHON_USE_PYLONG_INTERNALS
  2752. const digit* digits = ((PyLongObject*)x)->ob_digit;
  2753. switch (Py_SIZE(x)) {
  2754. case 0: return (long) 0;
  2755. case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
  2756. case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
  2757. case -2:
  2758. if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
  2759. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  2760. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2761. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  2762. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  2763. }
  2764. }
  2765. break;
  2766. case 2:
  2767. if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
  2768. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  2769. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2770. } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  2771. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  2772. }
  2773. }
  2774. break;
  2775. case -3:
  2776. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  2777. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  2778. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2779. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  2780. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  2781. }
  2782. }
  2783. break;
  2784. case 3:
  2785. if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
  2786. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  2787. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2788. } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  2789. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  2790. }
  2791. }
  2792. break;
  2793. case -4:
  2794. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  2795. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  2796. __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])))
  2797. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  2798. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  2799. }
  2800. }
  2801. break;
  2802. case 4:
  2803. if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
  2804. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  2805. __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])))
  2806. } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  2807. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  2808. }
  2809. }
  2810. break;
  2811. }
  2812. #endif
  2813. if (sizeof(long) <= sizeof(long)) {
  2814. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  2815. #ifdef HAVE_LONG_LONG
  2816. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  2817. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  2818. #endif
  2819. }
  2820. }
  2821. {
  2822. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  2823. PyErr_SetString(PyExc_RuntimeError,
  2824. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  2825. #else
  2826. long val;
  2827. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  2828. #if PY_MAJOR_VERSION < 3
  2829. if (likely(v) && !PyLong_Check(v)) {
  2830. PyObject *tmp = v;
  2831. v = PyNumber_Long(tmp);
  2832. Py_DECREF(tmp);
  2833. }
  2834. #endif
  2835. if (likely(v)) {
  2836. int one = 1; int is_little = (int)*(unsigned char *)&one;
  2837. unsigned char *bytes = (unsigned char *)&val;
  2838. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  2839. bytes, sizeof(val),
  2840. is_little, !is_unsigned);
  2841. Py_DECREF(v);
  2842. if (likely(!ret))
  2843. return val;
  2844. }
  2845. #endif
  2846. return (long) -1;
  2847. }
  2848. } else {
  2849. long val;
  2850. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  2851. if (!tmp) return (long) -1;
  2852. val = __Pyx_PyInt_As_long(tmp);
  2853. Py_DECREF(tmp);
  2854. return val;
  2855. }
  2856. raise_overflow:
  2857. PyErr_SetString(PyExc_OverflowError,
  2858. "value too large to convert to long");
  2859. return (long) -1;
  2860. raise_neg_overflow:
  2861. PyErr_SetString(PyExc_OverflowError,
  2862. "can't convert negative value to long");
  2863. return (long) -1;
  2864. }
  2865. /* CIntFromPy */
  2866. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  2867. const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
  2868. const int is_unsigned = neg_one > const_zero;
  2869. #if PY_MAJOR_VERSION < 3
  2870. if (likely(PyInt_Check(x))) {
  2871. if (sizeof(int) < sizeof(long)) {
  2872. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
  2873. } else {
  2874. long val = PyInt_AS_LONG(x);
  2875. if (is_unsigned && unlikely(val < 0)) {
  2876. goto raise_neg_overflow;
  2877. }
  2878. return (int) val;
  2879. }
  2880. } else
  2881. #endif
  2882. if (likely(PyLong_Check(x))) {
  2883. if (is_unsigned) {
  2884. #if CYTHON_USE_PYLONG_INTERNALS
  2885. const digit* digits = ((PyLongObject*)x)->ob_digit;
  2886. switch (Py_SIZE(x)) {
  2887. case 0: return (int) 0;
  2888. case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
  2889. case 2:
  2890. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  2891. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  2892. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2893. } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
  2894. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  2895. }
  2896. }
  2897. break;
  2898. case 3:
  2899. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  2900. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  2901. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2902. } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
  2903. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  2904. }
  2905. }
  2906. break;
  2907. case 4:
  2908. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  2909. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  2910. __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])))
  2911. } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
  2912. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  2913. }
  2914. }
  2915. break;
  2916. }
  2917. #endif
  2918. #if CYTHON_COMPILING_IN_CPYTHON
  2919. if (unlikely(Py_SIZE(x) < 0)) {
  2920. goto raise_neg_overflow;
  2921. }
  2922. #else
  2923. {
  2924. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  2925. if (unlikely(result < 0))
  2926. return (int) -1;
  2927. if (unlikely(result == 1))
  2928. goto raise_neg_overflow;
  2929. }
  2930. #endif
  2931. if (sizeof(int) <= sizeof(unsigned long)) {
  2932. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  2933. #ifdef HAVE_LONG_LONG
  2934. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  2935. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  2936. #endif
  2937. }
  2938. } else {
  2939. #if CYTHON_USE_PYLONG_INTERNALS
  2940. const digit* digits = ((PyLongObject*)x)->ob_digit;
  2941. switch (Py_SIZE(x)) {
  2942. case 0: return (int) 0;
  2943. case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
  2944. case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
  2945. case -2:
  2946. if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
  2947. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  2948. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2949. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  2950. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  2951. }
  2952. }
  2953. break;
  2954. case 2:
  2955. if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
  2956. if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
  2957. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2958. } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  2959. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  2960. }
  2961. }
  2962. break;
  2963. case -3:
  2964. if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
  2965. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  2966. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2967. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  2968. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  2969. }
  2970. }
  2971. break;
  2972. case 3:
  2973. if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
  2974. if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
  2975. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  2976. } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  2977. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  2978. }
  2979. }
  2980. break;
  2981. case -4:
  2982. if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
  2983. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  2984. __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])))
  2985. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  2986. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  2987. }
  2988. }
  2989. break;
  2990. case 4:
  2991. if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
  2992. if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
  2993. __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])))
  2994. } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
  2995. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  2996. }
  2997. }
  2998. break;
  2999. }
  3000. #endif
  3001. if (sizeof(int) <= sizeof(long)) {
  3002. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  3003. #ifdef HAVE_LONG_LONG
  3004. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  3005. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  3006. #endif
  3007. }
  3008. }
  3009. {
  3010. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  3011. PyErr_SetString(PyExc_RuntimeError,
  3012. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  3013. #else
  3014. int val;
  3015. PyObject *v = __Pyx_PyNumber_IntOrLong(x);
  3016. #if PY_MAJOR_VERSION < 3
  3017. if (likely(v) && !PyLong_Check(v)) {
  3018. PyObject *tmp = v;
  3019. v = PyNumber_Long(tmp);
  3020. Py_DECREF(tmp);
  3021. }
  3022. #endif
  3023. if (likely(v)) {
  3024. int one = 1; int is_little = (int)*(unsigned char *)&one;
  3025. unsigned char *bytes = (unsigned char *)&val;
  3026. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  3027. bytes, sizeof(val),
  3028. is_little, !is_unsigned);
  3029. Py_DECREF(v);
  3030. if (likely(!ret))
  3031. return val;
  3032. }
  3033. #endif
  3034. return (int) -1;
  3035. }
  3036. } else {
  3037. int val;
  3038. PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
  3039. if (!tmp) return (int) -1;
  3040. val = __Pyx_PyInt_As_int(tmp);
  3041. Py_DECREF(tmp);
  3042. return val;
  3043. }
  3044. raise_overflow:
  3045. PyErr_SetString(PyExc_OverflowError,
  3046. "value too large to convert to int");
  3047. return (int) -1;
  3048. raise_neg_overflow:
  3049. PyErr_SetString(PyExc_OverflowError,
  3050. "can't convert negative value to int");
  3051. return (int) -1;
  3052. }
  3053. /* FastTypeChecks */
  3054. #if CYTHON_COMPILING_IN_CPYTHON
  3055. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  3056. while (a) {
  3057. a = a->tp_base;
  3058. if (a == b)
  3059. return 1;
  3060. }
  3061. return b == &PyBaseObject_Type;
  3062. }
  3063. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  3064. PyObject *mro;
  3065. if (a == b) return 1;
  3066. mro = a->tp_mro;
  3067. if (likely(mro)) {
  3068. Py_ssize_t i, n;
  3069. n = PyTuple_GET_SIZE(mro);
  3070. for (i = 0; i < n; i++) {
  3071. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  3072. return 1;
  3073. }
  3074. return 0;
  3075. }
  3076. return __Pyx_InBases(a, b);
  3077. }
  3078. #if PY_MAJOR_VERSION == 2
  3079. static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
  3080. PyObject *exception, *value, *tb;
  3081. int res;
  3082. __Pyx_PyThreadState_declare
  3083. __Pyx_PyThreadState_assign
  3084. __Pyx_ErrFetch(&exception, &value, &tb);
  3085. res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
  3086. if (unlikely(res == -1)) {
  3087. PyErr_WriteUnraisable(err);
  3088. res = 0;
  3089. }
  3090. if (!res) {
  3091. res = PyObject_IsSubclass(err, exc_type2);
  3092. if (unlikely(res == -1)) {
  3093. PyErr_WriteUnraisable(err);
  3094. res = 0;
  3095. }
  3096. }
  3097. __Pyx_ErrRestore(exception, value, tb);
  3098. return res;
  3099. }
  3100. #else
  3101. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  3102. int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
  3103. if (!res) {
  3104. res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  3105. }
  3106. return res;
  3107. }
  3108. #endif
  3109. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  3110. Py_ssize_t i, n;
  3111. assert(PyExceptionClass_Check(exc_type));
  3112. n = PyTuple_GET_SIZE(tuple);
  3113. #if PY_MAJOR_VERSION >= 3
  3114. for (i=0; i<n; i++) {
  3115. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  3116. }
  3117. #endif
  3118. for (i=0; i<n; i++) {
  3119. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  3120. #if PY_MAJOR_VERSION < 3
  3121. if (likely(exc_type == t)) return 1;
  3122. #endif
  3123. if (likely(PyExceptionClass_Check(t))) {
  3124. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  3125. } else {
  3126. }
  3127. }
  3128. return 0;
  3129. }
  3130. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  3131. if (likely(err == exc_type)) return 1;
  3132. if (likely(PyExceptionClass_Check(err))) {
  3133. if (likely(PyExceptionClass_Check(exc_type))) {
  3134. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  3135. } else if (likely(PyTuple_Check(exc_type))) {
  3136. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  3137. } else {
  3138. }
  3139. }
  3140. return PyErr_GivenExceptionMatches(err, exc_type);
  3141. }
  3142. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  3143. assert(PyExceptionClass_Check(exc_type1));
  3144. assert(PyExceptionClass_Check(exc_type2));
  3145. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  3146. if (likely(PyExceptionClass_Check(err))) {
  3147. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  3148. }
  3149. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  3150. }
  3151. #endif
  3152. /* CheckBinaryVersion */
  3153. static int __Pyx_check_binary_version(void) {
  3154. char ctversion[4], rtversion[4];
  3155. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  3156. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  3157. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  3158. char message[200];
  3159. PyOS_snprintf(message, sizeof(message),
  3160. "compiletime version %s of module '%.100s' "
  3161. "does not match runtime version %s",
  3162. ctversion, __Pyx_MODULE_NAME, rtversion);
  3163. return PyErr_WarnEx(NULL, message, 1);
  3164. }
  3165. return 0;
  3166. }
  3167. /* InitStrings */
  3168. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  3169. while (t->p) {
  3170. #if PY_MAJOR_VERSION < 3
  3171. if (t->is_unicode) {
  3172. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  3173. } else if (t->intern) {
  3174. *t->p = PyString_InternFromString(t->s);
  3175. } else {
  3176. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  3177. }
  3178. #else
  3179. if (t->is_unicode | t->is_str) {
  3180. if (t->intern) {
  3181. *t->p = PyUnicode_InternFromString(t->s);
  3182. } else if (t->encoding) {
  3183. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  3184. } else {
  3185. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  3186. }
  3187. } else {
  3188. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  3189. }
  3190. #endif
  3191. if (!*t->p)
  3192. return -1;
  3193. if (PyObject_Hash(*t->p) == -1)
  3194. return -1;
  3195. ++t;
  3196. }
  3197. return 0;
  3198. }
  3199. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  3200. return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
  3201. }
  3202. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  3203. Py_ssize_t ignore;
  3204. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  3205. }
  3206. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  3207. #if !CYTHON_PEP393_ENABLED
  3208. static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  3209. char* defenc_c;
  3210. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  3211. if (!defenc) return NULL;
  3212. defenc_c = PyBytes_AS_STRING(defenc);
  3213. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  3214. {
  3215. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  3216. char* c;
  3217. for (c = defenc_c; c < end; c++) {
  3218. if ((unsigned char) (*c) >= 128) {
  3219. PyUnicode_AsASCIIString(o);
  3220. return NULL;
  3221. }
  3222. }
  3223. }
  3224. #endif
  3225. *length = PyBytes_GET_SIZE(defenc);
  3226. return defenc_c;
  3227. }
  3228. #else
  3229. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  3230. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  3231. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  3232. if (likely(PyUnicode_IS_ASCII(o))) {
  3233. *length = PyUnicode_GET_LENGTH(o);
  3234. return PyUnicode_AsUTF8(o);
  3235. } else {
  3236. PyUnicode_AsASCIIString(o);
  3237. return NULL;
  3238. }
  3239. #else
  3240. return PyUnicode_AsUTF8AndSize(o, length);
  3241. #endif
  3242. }
  3243. #endif
  3244. #endif
  3245. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  3246. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  3247. if (
  3248. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  3249. __Pyx_sys_getdefaultencoding_not_ascii &&
  3250. #endif
  3251. PyUnicode_Check(o)) {
  3252. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  3253. } else
  3254. #endif
  3255. #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
  3256. if (PyByteArray_Check(o)) {
  3257. *length = PyByteArray_GET_SIZE(o);
  3258. return PyByteArray_AS_STRING(o);
  3259. } else
  3260. #endif
  3261. {
  3262. char* result;
  3263. int r = PyBytes_AsStringAndSize(o, &result, length);
  3264. if (unlikely(r < 0)) {
  3265. return NULL;
  3266. } else {
  3267. return result;
  3268. }
  3269. }
  3270. }
  3271. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  3272. int is_true = x == Py_True;
  3273. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  3274. else return PyObject_IsTrue(x);
  3275. }
  3276. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  3277. int retval;
  3278. if (unlikely(!x)) return -1;
  3279. retval = __Pyx_PyObject_IsTrue(x);
  3280. Py_DECREF(x);
  3281. return retval;
  3282. }
  3283. static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
  3284. #if PY_MAJOR_VERSION >= 3
  3285. if (PyLong_Check(result)) {
  3286. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  3287. "__int__ returned non-int (type %.200s). "
  3288. "The ability to return an instance of a strict subclass of int "
  3289. "is deprecated, and may be removed in a future version of Python.",
  3290. Py_TYPE(result)->tp_name)) {
  3291. Py_DECREF(result);
  3292. return NULL;
  3293. }
  3294. return result;
  3295. }
  3296. #endif
  3297. PyErr_Format(PyExc_TypeError,
  3298. "__%.4s__ returned non-%.4s (type %.200s)",
  3299. type_name, type_name, Py_TYPE(result)->tp_name);
  3300. Py_DECREF(result);
  3301. return NULL;
  3302. }
  3303. static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
  3304. #if CYTHON_USE_TYPE_SLOTS
  3305. PyNumberMethods *m;
  3306. #endif
  3307. const char *name = NULL;
  3308. PyObject *res = NULL;
  3309. #if PY_MAJOR_VERSION < 3
  3310. if (likely(PyInt_Check(x) || PyLong_Check(x)))
  3311. #else
  3312. if (likely(PyLong_Check(x)))
  3313. #endif
  3314. return __Pyx_NewRef(x);
  3315. #if CYTHON_USE_TYPE_SLOTS
  3316. m = Py_TYPE(x)->tp_as_number;
  3317. #if PY_MAJOR_VERSION < 3
  3318. if (m && m->nb_int) {
  3319. name = "int";
  3320. res = m->nb_int(x);
  3321. }
  3322. else if (m && m->nb_long) {
  3323. name = "long";
  3324. res = m->nb_long(x);
  3325. }
  3326. #else
  3327. if (likely(m && m->nb_int)) {
  3328. name = "int";
  3329. res = m->nb_int(x);
  3330. }
  3331. #endif
  3332. #else
  3333. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  3334. res = PyNumber_Int(x);
  3335. }
  3336. #endif
  3337. if (likely(res)) {
  3338. #if PY_MAJOR_VERSION < 3
  3339. if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
  3340. #else
  3341. if (unlikely(!PyLong_CheckExact(res))) {
  3342. #endif
  3343. return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
  3344. }
  3345. }
  3346. else if (!PyErr_Occurred()) {
  3347. PyErr_SetString(PyExc_TypeError,
  3348. "an integer is required");
  3349. }
  3350. return res;
  3351. }
  3352. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  3353. Py_ssize_t ival;
  3354. PyObject *x;
  3355. #if PY_MAJOR_VERSION < 3
  3356. if (likely(PyInt_CheckExact(b))) {
  3357. if (sizeof(Py_ssize_t) >= sizeof(long))
  3358. return PyInt_AS_LONG(b);
  3359. else
  3360. return PyInt_AsSsize_t(b);
  3361. }
  3362. #endif
  3363. if (likely(PyLong_CheckExact(b))) {
  3364. #if CYTHON_USE_PYLONG_INTERNALS
  3365. const digit* digits = ((PyLongObject*)b)->ob_digit;
  3366. const Py_ssize_t size = Py_SIZE(b);
  3367. if (likely(__Pyx_sst_abs(size) <= 1)) {
  3368. ival = likely(size) ? digits[0] : 0;
  3369. if (size == -1) ival = -ival;
  3370. return ival;
  3371. } else {
  3372. switch (size) {
  3373. case 2:
  3374. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  3375. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  3376. }
  3377. break;
  3378. case -2:
  3379. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  3380. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  3381. }
  3382. break;
  3383. case 3:
  3384. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  3385. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  3386. }
  3387. break;
  3388. case -3:
  3389. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  3390. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  3391. }
  3392. break;
  3393. case 4:
  3394. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  3395. 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]));
  3396. }
  3397. break;
  3398. case -4:
  3399. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  3400. 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]));
  3401. }
  3402. break;
  3403. }
  3404. }
  3405. #endif
  3406. return PyLong_AsSsize_t(b);
  3407. }
  3408. x = PyNumber_Index(b);
  3409. if (!x) return -1;
  3410. ival = PyInt_AsSsize_t(x);
  3411. Py_DECREF(x);
  3412. return ival;
  3413. }
  3414. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  3415. return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
  3416. }
  3417. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  3418. return PyInt_FromSize_t(ival);
  3419. }
  3420. #endif /* Py_PYTHON_H */