ink.c 181 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232
  1. /* Generated by Cython 0.20.1 on Sun Mar 16 22:58:14 2014 */
  2. #define PY_SSIZE_T_CLEAN
  3. #ifndef CYTHON_USE_PYLONG_INTERNALS
  4. #ifdef PYLONG_BITS_IN_DIGIT
  5. #define CYTHON_USE_PYLONG_INTERNALS 0
  6. #else
  7. #include "pyconfig.h"
  8. #ifdef PYLONG_BITS_IN_DIGIT
  9. #define CYTHON_USE_PYLONG_INTERNALS 1
  10. #else
  11. #define CYTHON_USE_PYLONG_INTERNALS 0
  12. #endif
  13. #endif
  14. #endif
  15. #include "Python.h"
  16. #ifndef Py_PYTHON_H
  17. #error Python headers needed to compile C extensions, please install development version of Python.
  18. #elif PY_VERSION_HEX < 0x02040000
  19. #error Cython requires Python 2.4+.
  20. #else
  21. #define CYTHON_ABI "0_20_1"
  22. #include <stddef.h> /* For offsetof */
  23. #ifndef offsetof
  24. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  25. #endif
  26. #if !defined(WIN32) && !defined(MS_WINDOWS)
  27. #ifndef __stdcall
  28. #define __stdcall
  29. #endif
  30. #ifndef __cdecl
  31. #define __cdecl
  32. #endif
  33. #ifndef __fastcall
  34. #define __fastcall
  35. #endif
  36. #endif
  37. #ifndef DL_IMPORT
  38. #define DL_IMPORT(t) t
  39. #endif
  40. #ifndef DL_EXPORT
  41. #define DL_EXPORT(t) t
  42. #endif
  43. #ifndef PY_LONG_LONG
  44. #define PY_LONG_LONG LONG_LONG
  45. #endif
  46. #ifndef Py_HUGE_VAL
  47. #define Py_HUGE_VAL HUGE_VAL
  48. #endif
  49. #ifdef PYPY_VERSION
  50. #define CYTHON_COMPILING_IN_PYPY 1
  51. #define CYTHON_COMPILING_IN_CPYTHON 0
  52. #else
  53. #define CYTHON_COMPILING_IN_PYPY 0
  54. #define CYTHON_COMPILING_IN_CPYTHON 1
  55. #endif
  56. #if CYTHON_COMPILING_IN_PYPY
  57. #define Py_OptimizeFlag 0
  58. #endif
  59. #if PY_VERSION_HEX < 0x02050000
  60. typedef int Py_ssize_t;
  61. #define PY_SSIZE_T_MAX INT_MAX
  62. #define PY_SSIZE_T_MIN INT_MIN
  63. #define PY_FORMAT_SIZE_T ""
  64. #define CYTHON_FORMAT_SSIZE_T ""
  65. #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  66. #define PyInt_AsSsize_t(o) __Pyx_PyInt_As_int(o)
  67. #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
  68. (PyErr_Format(PyExc_TypeError, \
  69. "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
  70. (PyObject*)0))
  71. #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
  72. !PyComplex_Check(o))
  73. #define PyIndex_Check __Pyx_PyIndex_Check
  74. #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
  75. #define __PYX_BUILD_PY_SSIZE_T "i"
  76. #else
  77. #define __PYX_BUILD_PY_SSIZE_T "n"
  78. #define CYTHON_FORMAT_SSIZE_T "z"
  79. #define __Pyx_PyIndex_Check PyIndex_Check
  80. #endif
  81. #if PY_VERSION_HEX < 0x02060000
  82. #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  83. #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
  84. #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
  85. #define PyVarObject_HEAD_INIT(type, size) \
  86. PyObject_HEAD_INIT(type) size,
  87. #define PyType_Modified(t)
  88. typedef struct {
  89. void *buf;
  90. PyObject *obj;
  91. Py_ssize_t len;
  92. Py_ssize_t itemsize;
  93. int readonly;
  94. int ndim;
  95. char *format;
  96. Py_ssize_t *shape;
  97. Py_ssize_t *strides;
  98. Py_ssize_t *suboffsets;
  99. void *internal;
  100. } Py_buffer;
  101. #define PyBUF_SIMPLE 0
  102. #define PyBUF_WRITABLE 0x0001
  103. #define PyBUF_FORMAT 0x0004
  104. #define PyBUF_ND 0x0008
  105. #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  106. #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  107. #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  108. #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  109. #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
  110. #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
  111. #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
  112. typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
  113. typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
  114. #endif
  115. #if PY_MAJOR_VERSION < 3
  116. #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
  117. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
  118. PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  119. #define __Pyx_DefaultClassType PyClass_Type
  120. #else
  121. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  122. #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
  123. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  124. #define __Pyx_DefaultClassType PyType_Type
  125. #endif
  126. #if PY_VERSION_HEX < 0x02060000
  127. #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
  128. #endif
  129. #if PY_MAJOR_VERSION >= 3
  130. #define Py_TPFLAGS_CHECKTYPES 0
  131. #define Py_TPFLAGS_HAVE_INDEX 0
  132. #endif
  133. #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  134. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  135. #endif
  136. #if PY_VERSION_HEX < 0x02060000
  137. #define Py_TPFLAGS_HAVE_VERSION_TAG 0
  138. #endif
  139. #if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT)
  140. #define Py_TPFLAGS_IS_ABSTRACT 0
  141. #endif
  142. #if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
  143. #define Py_TPFLAGS_HAVE_FINALIZE 0
  144. #endif
  145. #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
  146. #define CYTHON_PEP393_ENABLED 1
  147. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \
  148. 0 : _PyUnicode_Ready((PyObject *)(op)))
  149. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
  150. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  151. #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
  152. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  153. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  154. #else
  155. #define CYTHON_PEP393_ENABLED 0
  156. #define __Pyx_PyUnicode_READY(op) (0)
  157. #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
  158. #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
  159. #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
  160. #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
  161. #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
  162. #endif
  163. #if CYTHON_COMPILING_IN_PYPY
  164. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  165. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  166. #else
  167. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  168. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
  169. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  170. #endif
  171. #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
  172. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  173. #if PY_MAJOR_VERSION >= 3
  174. #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
  175. #else
  176. #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
  177. #endif
  178. #if PY_MAJOR_VERSION >= 3
  179. #define PyBaseString_Type PyUnicode_Type
  180. #define PyStringObject PyUnicodeObject
  181. #define PyString_Type PyUnicode_Type
  182. #define PyString_Check PyUnicode_Check
  183. #define PyString_CheckExact PyUnicode_CheckExact
  184. #endif
  185. #if PY_VERSION_HEX < 0x02060000
  186. #define PyBytesObject PyStringObject
  187. #define PyBytes_Type PyString_Type
  188. #define PyBytes_Check PyString_Check
  189. #define PyBytes_CheckExact PyString_CheckExact
  190. #define PyBytes_FromString PyString_FromString
  191. #define PyBytes_FromStringAndSize PyString_FromStringAndSize
  192. #define PyBytes_FromFormat PyString_FromFormat
  193. #define PyBytes_DecodeEscape PyString_DecodeEscape
  194. #define PyBytes_AsString PyString_AsString
  195. #define PyBytes_AsStringAndSize PyString_AsStringAndSize
  196. #define PyBytes_Size PyString_Size
  197. #define PyBytes_AS_STRING PyString_AS_STRING
  198. #define PyBytes_GET_SIZE PyString_GET_SIZE
  199. #define PyBytes_Repr PyString_Repr
  200. #define PyBytes_Concat PyString_Concat
  201. #define PyBytes_ConcatAndDel PyString_ConcatAndDel
  202. #endif
  203. #if PY_MAJOR_VERSION >= 3
  204. #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
  205. #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
  206. #else
  207. #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
  208. PyString_Check(obj) || PyUnicode_Check(obj))
  209. #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
  210. #endif
  211. #if PY_VERSION_HEX < 0x02060000
  212. #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
  213. #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
  214. #endif
  215. #ifndef PySet_CheckExact
  216. #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
  217. #endif
  218. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  219. #if PY_MAJOR_VERSION >= 3
  220. #define PyIntObject PyLongObject
  221. #define PyInt_Type PyLong_Type
  222. #define PyInt_Check(op) PyLong_Check(op)
  223. #define PyInt_CheckExact(op) PyLong_CheckExact(op)
  224. #define PyInt_FromString PyLong_FromString
  225. #define PyInt_FromUnicode PyLong_FromUnicode
  226. #define PyInt_FromLong PyLong_FromLong
  227. #define PyInt_FromSize_t PyLong_FromSize_t
  228. #define PyInt_FromSsize_t PyLong_FromSsize_t
  229. #define PyInt_AsLong PyLong_AsLong
  230. #define PyInt_AS_LONG PyLong_AS_LONG
  231. #define PyInt_AsSsize_t PyLong_AsSsize_t
  232. #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
  233. #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
  234. #define PyNumber_Int PyNumber_Long
  235. #endif
  236. #if PY_MAJOR_VERSION >= 3
  237. #define PyBoolObject PyLongObject
  238. #endif
  239. #if PY_VERSION_HEX < 0x030200A4
  240. typedef long Py_hash_t;
  241. #define __Pyx_PyInt_FromHash_t PyInt_FromLong
  242. #define __Pyx_PyInt_AsHash_t PyInt_AsLong
  243. #else
  244. #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
  245. #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
  246. #endif
  247. #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  248. #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  249. #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  250. #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
  251. #else
  252. #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
  253. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
  254. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
  255. (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  256. #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
  257. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  258. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
  259. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  260. #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
  261. (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
  262. (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
  263. (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
  264. #endif
  265. #if PY_MAJOR_VERSION >= 3
  266. #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
  267. #endif
  268. #if PY_VERSION_HEX < 0x02050000
  269. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
  270. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  271. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
  272. #else
  273. #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
  274. #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  275. #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
  276. #endif
  277. #if PY_VERSION_HEX < 0x02050000
  278. #define __Pyx_NAMESTR(n) ((char *)(n))
  279. #define __Pyx_DOCSTR(n) ((char *)(n))
  280. #else
  281. #define __Pyx_NAMESTR(n) (n)
  282. #define __Pyx_DOCSTR(n) (n)
  283. #endif
  284. #ifndef CYTHON_INLINE
  285. #if defined(__GNUC__)
  286. #define CYTHON_INLINE __inline__
  287. #elif defined(_MSC_VER)
  288. #define CYTHON_INLINE __inline
  289. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  290. #define CYTHON_INLINE inline
  291. #else
  292. #define CYTHON_INLINE
  293. #endif
  294. #endif
  295. #ifndef CYTHON_RESTRICT
  296. #if defined(__GNUC__)
  297. #define CYTHON_RESTRICT __restrict__
  298. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  299. #define CYTHON_RESTRICT __restrict
  300. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  301. #define CYTHON_RESTRICT restrict
  302. #else
  303. #define CYTHON_RESTRICT
  304. #endif
  305. #endif
  306. #ifdef NAN
  307. #define __PYX_NAN() ((float) NAN)
  308. #else
  309. static CYTHON_INLINE float __PYX_NAN() {
  310. /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
  311. a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
  312. a quiet NaN. */
  313. float value;
  314. memset(&value, 0xFF, sizeof(value));
  315. return value;
  316. }
  317. #endif
  318. #if PY_MAJOR_VERSION >= 3
  319. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  320. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  321. #else
  322. #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
  323. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
  324. #endif
  325. #ifndef __PYX_EXTERN_C
  326. #ifdef __cplusplus
  327. #define __PYX_EXTERN_C extern "C"
  328. #else
  329. #define __PYX_EXTERN_C extern
  330. #endif
  331. #endif
  332. #if defined(WIN32) || defined(MS_WINDOWS)
  333. #define _USE_MATH_DEFINES
  334. #endif
  335. #include <math.h>
  336. #define __PYX_HAVE__lib__Naked__toolshed__c__ink
  337. #define __PYX_HAVE_API__lib__Naked__toolshed__c__ink
  338. #ifdef _OPENMP
  339. #include <omp.h>
  340. #endif /* _OPENMP */
  341. #ifdef PYREX_WITHOUT_ASSERTIONS
  342. #define CYTHON_WITHOUT_ASSERTIONS
  343. #endif
  344. #ifndef CYTHON_UNUSED
  345. # if defined(__GNUC__)
  346. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  347. # define CYTHON_UNUSED __attribute__ ((__unused__))
  348. # else
  349. # define CYTHON_UNUSED
  350. # endif
  351. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  352. # define CYTHON_UNUSED __attribute__ ((__unused__))
  353. # else
  354. # define CYTHON_UNUSED
  355. # endif
  356. #endif
  357. typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
  358. const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
  359. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  360. #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
  361. #define __PYX_DEFAULT_STRING_ENCODING ""
  362. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  363. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  364. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \
  365. (sizeof(type) < sizeof(Py_ssize_t)) || \
  366. (sizeof(type) > sizeof(Py_ssize_t) && \
  367. likely(v < (type)PY_SSIZE_T_MAX || \
  368. v == (type)PY_SSIZE_T_MAX) && \
  369. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \
  370. v == (type)PY_SSIZE_T_MIN))) || \
  371. (sizeof(type) == sizeof(Py_ssize_t) && \
  372. (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \
  373. v == (type)PY_SSIZE_T_MAX))) )
  374. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
  375. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  376. #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
  377. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  378. #define __Pyx_PyBytes_FromString PyBytes_FromString
  379. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  380. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char*);
  381. #if PY_MAJOR_VERSION < 3
  382. #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
  383. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  384. #else
  385. #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
  386. #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
  387. #endif
  388. #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
  389. #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
  390. #define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((char*)s)
  391. #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s)
  392. #define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((char*)s)
  393. #define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((char*)s)
  394. #define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((char*)s)
  395. #if PY_MAJOR_VERSION < 3
  396. static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
  397. {
  398. const Py_UNICODE *u_end = u;
  399. while (*u_end++) ;
  400. return u_end - u - 1;
  401. }
  402. #else
  403. #define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
  404. #endif
  405. #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
  406. #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
  407. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  408. #define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
  409. #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
  410. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  411. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
  412. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  413. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
  414. #if CYTHON_COMPILING_IN_CPYTHON
  415. #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  416. #else
  417. #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  418. #endif
  419. #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
  420. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  421. static int __Pyx_sys_getdefaultencoding_not_ascii;
  422. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  423. PyObject* sys = NULL;
  424. PyObject* default_encoding = NULL;
  425. PyObject* ascii_chars_u = NULL;
  426. PyObject* ascii_chars_b = NULL;
  427. sys = PyImport_ImportModule("sys");
  428. if (sys == NULL) goto bad;
  429. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  430. if (default_encoding == NULL) goto bad;
  431. if (strcmp(PyBytes_AsString(default_encoding), "ascii") == 0) {
  432. __Pyx_sys_getdefaultencoding_not_ascii = 0;
  433. } else {
  434. const char* default_encoding_c = PyBytes_AS_STRING(default_encoding);
  435. char ascii_chars[128];
  436. int c;
  437. for (c = 0; c < 128; c++) {
  438. ascii_chars[c] = c;
  439. }
  440. __Pyx_sys_getdefaultencoding_not_ascii = 1;
  441. ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
  442. if (ascii_chars_u == NULL) goto bad;
  443. ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
  444. if (ascii_chars_b == NULL || strncmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
  445. PyErr_Format(
  446. PyExc_ValueError,
  447. "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
  448. default_encoding_c);
  449. goto bad;
  450. }
  451. }
  452. Py_XDECREF(sys);
  453. Py_XDECREF(default_encoding);
  454. Py_XDECREF(ascii_chars_u);
  455. Py_XDECREF(ascii_chars_b);
  456. return 0;
  457. bad:
  458. Py_XDECREF(sys);
  459. Py_XDECREF(default_encoding);
  460. Py_XDECREF(ascii_chars_u);
  461. Py_XDECREF(ascii_chars_b);
  462. return -1;
  463. }
  464. #endif
  465. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
  466. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  467. #else
  468. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  469. #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  470. static char* __PYX_DEFAULT_STRING_ENCODING;
  471. static int __Pyx_init_sys_getdefaultencoding_params(void) {
  472. PyObject* sys = NULL;
  473. PyObject* default_encoding = NULL;
  474. char* default_encoding_c;
  475. sys = PyImport_ImportModule("sys");
  476. if (sys == NULL) goto bad;
  477. default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
  478. if (default_encoding == NULL) goto bad;
  479. default_encoding_c = PyBytes_AS_STRING(default_encoding);
  480. __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
  481. strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
  482. Py_DECREF(sys);
  483. Py_DECREF(default_encoding);
  484. return 0;
  485. bad:
  486. Py_XDECREF(sys);
  487. Py_XDECREF(default_encoding);
  488. return -1;
  489. }
  490. #endif
  491. #endif
  492. #ifdef __GNUC__
  493. /* Test for GCC > 2.95 */
  494. #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
  495. #define likely(x) __builtin_expect(!!(x), 1)
  496. #define unlikely(x) __builtin_expect(!!(x), 0)
  497. #else /* __GNUC__ > 2 ... */
  498. #define likely(x) (x)
  499. #define unlikely(x) (x)
  500. #endif /* __GNUC__ > 2 ... */
  501. #else /* __GNUC__ */
  502. #define likely(x) (x)
  503. #define unlikely(x) (x)
  504. #endif /* __GNUC__ */
  505. static PyObject *__pyx_m;
  506. static PyObject *__pyx_d;
  507. static PyObject *__pyx_b;
  508. static PyObject *__pyx_empty_tuple;
  509. static PyObject *__pyx_empty_bytes;
  510. static int __pyx_lineno;
  511. static int __pyx_clineno = 0;
  512. static const char * __pyx_cfilenm= __FILE__;
  513. static const char *__pyx_filename;
  514. static const char *__pyx_f[] = {
  515. "ink.pyx",
  516. };
  517. /*--- Type declarations ---*/
  518. #ifndef CYTHON_REFNANNY
  519. #define CYTHON_REFNANNY 0
  520. #endif
  521. #if CYTHON_REFNANNY
  522. typedef struct {
  523. void (*INCREF)(void*, PyObject*, int);
  524. void (*DECREF)(void*, PyObject*, int);
  525. void (*GOTREF)(void*, PyObject*, int);
  526. void (*GIVEREF)(void*, PyObject*, int);
  527. void* (*SetupContext)(const char*, int, const char*);
  528. void (*FinishContext)(void**);
  529. } __Pyx_RefNannyAPIStruct;
  530. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  531. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
  532. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  533. #ifdef WITH_THREAD
  534. #define __Pyx_RefNannySetupContext(name, acquire_gil) \
  535. if (acquire_gil) { \
  536. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
  537. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
  538. PyGILState_Release(__pyx_gilstate_save); \
  539. } else { \
  540. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
  541. }
  542. #else
  543. #define __Pyx_RefNannySetupContext(name, acquire_gil) \
  544. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  545. #endif
  546. #define __Pyx_RefNannyFinishContext() \
  547. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  548. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  549. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  550. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  551. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  552. #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
  553. #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
  554. #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
  555. #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
  556. #else
  557. #define __Pyx_RefNannyDeclarations
  558. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  559. #define __Pyx_RefNannyFinishContext()
  560. #define __Pyx_INCREF(r) Py_INCREF(r)
  561. #define __Pyx_DECREF(r) Py_DECREF(r)
  562. #define __Pyx_GOTREF(r)
  563. #define __Pyx_GIVEREF(r)
  564. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  565. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  566. #define __Pyx_XGOTREF(r)
  567. #define __Pyx_XGIVEREF(r)
  568. #endif /* CYTHON_REFNANNY */
  569. #define __Pyx_XDECREF_SET(r, v) do { \
  570. PyObject *tmp = (PyObject *) r; \
  571. r = v; __Pyx_XDECREF(tmp); \
  572. } while (0)
  573. #define __Pyx_DECREF_SET(r, v) do { \
  574. PyObject *tmp = (PyObject *) r; \
  575. r = v; __Pyx_DECREF(tmp); \
  576. } while (0)
  577. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  578. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  579. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  580. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
  581. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
  582. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
  583. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
  584. const char* function_name); /*proto*/
  585. #if CYTHON_COMPILING_IN_CPYTHON
  586. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  587. PyTypeObject* tp = Py_TYPE(obj);
  588. if (likely(tp->tp_getattro))
  589. return tp->tp_getattro(obj, attr_name);
  590. #if PY_MAJOR_VERSION < 3
  591. if (likely(tp->tp_getattr))
  592. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  593. #endif
  594. return PyObject_GetAttr(obj, attr_name);
  595. }
  596. #else
  597. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  598. #endif
  599. #if CYTHON_COMPILING_IN_CPYTHON
  600. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/
  601. #else
  602. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  603. #endif
  604. #if CYTHON_COMPILING_IN_CPYTHON
  605. #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
  606. static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
  607. PyTypeObject* tp = Py_TYPE(obj);
  608. if (likely(tp->tp_setattro))
  609. return tp->tp_setattro(obj, attr_name, value);
  610. #if PY_MAJOR_VERSION < 3
  611. if (likely(tp->tp_setattr))
  612. return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
  613. #endif
  614. return PyObject_SetAttr(obj, attr_name, value);
  615. }
  616. #else
  617. #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
  618. #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
  619. #endif
  620. static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
  621. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/
  622. #if PY_VERSION_HEX < 0x02050000
  623. #ifndef PyAnySet_CheckExact
  624. #define PyAnySet_CheckExact(ob) \
  625. ((ob)->ob_type == &PySet_Type || \
  626. (ob)->ob_type == &PyFrozenSet_Type)
  627. #define PySet_New(iterable) \
  628. PyObject_CallFunctionObjArgs((PyObject *)&PySet_Type, (iterable), NULL)
  629. #define Pyx_PyFrozenSet_New(iterable) \
  630. PyObject_CallFunctionObjArgs((PyObject *)&PyFrozenSet_Type, (iterable), NULL)
  631. #define PySet_Size(anyset) \
  632. PyObject_Size((anyset))
  633. #define PySet_Contains(anyset, key) \
  634. PySequence_Contains((anyset), (key))
  635. #define PySet_Pop(set) \
  636. PyObject_CallMethod((set), (char*)"pop", NULL)
  637. static CYTHON_INLINE int PySet_Clear(PyObject *set) {
  638. PyObject *ret = PyObject_CallMethod(set, (char*)"clear", NULL);
  639. if (!ret) return -1;
  640. Py_DECREF(ret); return 0;
  641. }
  642. static CYTHON_INLINE int PySet_Discard(PyObject *set, PyObject *key) {
  643. PyObject *ret = PyObject_CallMethod(set, (char*)"discard", (char*)"(O)", key);
  644. if (!ret) return -1;
  645. Py_DECREF(ret); return 0;
  646. }
  647. static CYTHON_INLINE int PySet_Add(PyObject *set, PyObject *key) {
  648. PyObject *ret = PyObject_CallMethod(set, (char*)"add", (char*)"(O)", key);
  649. if (!ret) return -1;
  650. Py_DECREF(ret); return 0;
  651. }
  652. #endif /* PyAnySet_CheckExact (<= Py2.4) */
  653. #endif /* < Py2.5 */
  654. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/
  655. static CYTHON_INLINE int __Pyx_PySequence_Contains(PyObject* item, PyObject* seq, int eq) {
  656. int result = PySequence_Contains(seq, item);
  657. return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
  658. }
  659. static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
  660. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
  661. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
  662. #define __Pyx_CyFunction_USED 1
  663. #include <structmember.h>
  664. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  665. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  666. #define __Pyx_CYFUNCTION_CCLASS 0x04
  667. #define __Pyx_CyFunction_GetClosure(f) \
  668. (((__pyx_CyFunctionObject *) (f))->func_closure)
  669. #define __Pyx_CyFunction_GetClassObj(f) \
  670. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  671. #define __Pyx_CyFunction_Defaults(type, f) \
  672. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  673. #define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
  674. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  675. typedef struct {
  676. PyCFunctionObject func;
  677. PyObject *func_dict;
  678. PyObject *func_weakreflist;
  679. PyObject *func_name;
  680. PyObject *func_qualname;
  681. PyObject *func_doc;
  682. PyObject *func_globals;
  683. PyObject *func_code;
  684. PyObject *func_closure;
  685. PyObject *func_classobj; /* No-args super() class cell */
  686. void *defaults;
  687. int defaults_pyobjects;
  688. int flags;
  689. PyObject *defaults_tuple; /* Const defaults tuple */
  690. PyObject *defaults_kwdict; /* Const kwonly defaults dict */
  691. PyObject *(*defaults_getter)(PyObject *);
  692. PyObject *func_annotations; /* function annotations dict */
  693. } __pyx_CyFunctionObject;
  694. static PyTypeObject *__pyx_CyFunctionType = 0;
  695. #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \
  696. __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
  697. static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
  698. int flags, PyObject* qualname,
  699. PyObject *self,
  700. PyObject *module, PyObject *globals,
  701. PyObject* code);
  702. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
  703. size_t size,
  704. int pyobjects);
  705. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  706. PyObject *tuple);
  707. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  708. PyObject *dict);
  709. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  710. PyObject *dict);
  711. static int __Pyx_CyFunction_init(void);
  712. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
  713. PyObject *mkw, PyObject *modname, PyObject *doc); /*proto*/
  714. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
  715. PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass); /*proto*/
  716. #include <string.h>
  717. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  718. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  719. #if PY_MAJOR_VERSION >= 3
  720. #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  721. #else
  722. #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  723. #endif
  724. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/
  725. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  726. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  727. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  728. static int __Pyx_check_binary_version(void);
  729. typedef struct {
  730. int code_line;
  731. PyCodeObject* code_object;
  732. } __Pyx_CodeObjectCacheEntry;
  733. struct __Pyx_CodeObjectCache {
  734. int count;
  735. int max_count;
  736. __Pyx_CodeObjectCacheEntry* entries;
  737. };
  738. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  739. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  740. static PyCodeObject *__pyx_find_code_object(int code_line);
  741. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  742. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  743. int py_line, const char *filename); /*proto*/
  744. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
  745. /* Module declarations from 'lib.Naked.toolshed.c.ink' */
  746. #define __Pyx_MODULE_NAME "lib.Naked.toolshed.c.ink"
  747. int __pyx_module_is_main_lib__Naked__toolshed__c__ink = 0;
  748. /* Implementation of 'lib.Naked.toolshed.c.ink' */
  749. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_template_text, PyObject *__pyx_v_open_delimiter, PyObject *__pyx_v_close_delimiter, PyObject *__pyx_v_escape_regex); /* proto */
  750. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template_2_make_var_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_template_text, PyObject *__pyx_v_escape_regex); /* proto */
  751. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template_4_escape_regex_special_chars(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_test_escape_string); /* proto */
  752. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Renderer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_template, PyObject *__pyx_v_key, PyObject *__pyx_v_html_entities); /* proto */
  753. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Renderer_2render(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
  754. static char __pyx_k_[] = "{{";
  755. static char __pyx_k__2[] = "}}";
  756. static char __pyx_k__3[] = "(.*?)";
  757. static char __pyx_k_re[] = "re";
  758. static char __pyx_k_cls[] = "cls";
  759. static char __pyx_k_doc[] = "__doc__";
  760. static char __pyx_k_key[] = "key";
  761. static char __pyx_k_new[] = "__new__";
  762. static char __pyx_k_obj[] = "obj";
  763. static char __pyx_k_cdel[] = "cdel";
  764. static char __pyx_k_init[] = "__init__";
  765. static char __pyx_k_main[] = "__main__";
  766. static char __pyx_k_name[] = "__name__";
  767. static char __pyx_k_odel[] = "odel";
  768. static char __pyx_k_self[] = "self";
  769. static char __pyx_k_test[] = "__test__";
  770. static char __pyx_k_value[] = "value";
  771. static char __pyx_k_escape[] = "escape";
  772. static char __pyx_k_import[] = "__import__";
  773. static char __pyx_k_module[] = "__module__";
  774. static char __pyx_k_render[] = "render";
  775. static char __pyx_k_findall[] = "findall";
  776. static char __pyx_k_prepare[] = "__prepare__";
  777. static char __pyx_k_replace[] = "replace";
  778. static char __pyx_k_varlist[] = "varlist";
  779. static char __pyx_k_Renderer[] = "Renderer";
  780. static char __pyx_k_Template[] = "Template";
  781. static char __pyx_k_key_dict[] = "key_dict";
  782. static char __pyx_k_qualname[] = "__qualname__";
  783. static char __pyx_k_template[] = "template";
  784. static char __pyx_k_var_list[] = "var_list";
  785. static char __pyx_k_match_pat[] = "match_pat";
  786. static char __pyx_k_metaclass[] = "__metaclass__";
  787. static char __pyx_k_local_cdel[] = "local_cdel";
  788. static char __pyx_k_local_dict[] = "local_dict";
  789. static char __pyx_k_local_odel[] = "local_odel";
  790. static char __pyx_k_escape_regex[] = "escape_regex";
  791. static char __pyx_k_html_entities[] = "html_entities";
  792. static char __pyx_k_local_htmlent[] = "local_htmlent";
  793. static char __pyx_k_local_varlist[] = "local_varlist";
  794. static char __pyx_k_make_var_list[] = "_make_var_list";
  795. static char __pyx_k_template_text[] = "template_text";
  796. static char __pyx_k_Template___new[] = "Template.__new__";
  797. static char __pyx_k_local_template[] = "local_template";
  798. static char __pyx_k_open_delimiter[] = "open_delimiter";
  799. static char __pyx_k_open_match_pat[] = "open_match_pat";
  800. static char __pyx_k_replace_string[] = "replace_string";
  801. static char __pyx_k_Renderer___init[] = "Renderer.__init__";
  802. static char __pyx_k_Renderer_render[] = "Renderer.render";
  803. static char __pyx_k_close_delimiter[] = "close_delimiter";
  804. static char __pyx_k_close_match_pat[] = "close_match_pat";
  805. static char __pyx_k_xml_sax_saxutils[] = "xml.sax.saxutils";
  806. static char __pyx_k_test_escape_string[] = "test_escape_string";
  807. static char __pyx_k_Template__make_var_list[] = "Template._make_var_list";
  808. static char __pyx_k_lib_Naked_toolshed_c_ink[] = "lib.Naked.toolshed.c.ink";
  809. static char __pyx_k_escape_regex_special_chars[] = "_escape_regex_special_chars";
  810. static char __pyx_k_Users_ces_Desktop_code_naked_li[] = "/Users/ces/Desktop/code/naked/lib/Naked/toolshed/c/ink.pyx";
  811. static char __pyx_k_Template__escape_regex_special_c[] = "Template._escape_regex_special_chars";
  812. static PyObject *__pyx_kp_s_;
  813. static PyObject *__pyx_n_s_Renderer;
  814. static PyObject *__pyx_n_s_Renderer___init;
  815. static PyObject *__pyx_n_s_Renderer_render;
  816. static PyObject *__pyx_n_s_Template;
  817. static PyObject *__pyx_n_s_Template___new;
  818. static PyObject *__pyx_n_s_Template__escape_regex_special_c;
  819. static PyObject *__pyx_n_s_Template__make_var_list;
  820. static PyObject *__pyx_kp_s_Users_ces_Desktop_code_naked_li;
  821. static PyObject *__pyx_kp_s__2;
  822. static PyObject *__pyx_kp_s__3;
  823. static PyObject *__pyx_n_s_cdel;
  824. static PyObject *__pyx_n_s_close_delimiter;
  825. static PyObject *__pyx_n_s_close_match_pat;
  826. static PyObject *__pyx_n_s_cls;
  827. static PyObject *__pyx_n_s_doc;
  828. static PyObject *__pyx_n_s_escape;
  829. static PyObject *__pyx_n_s_escape_regex;
  830. static PyObject *__pyx_n_s_escape_regex_special_chars;
  831. static PyObject *__pyx_n_s_findall;
  832. static PyObject *__pyx_n_s_html_entities;
  833. static PyObject *__pyx_n_s_import;
  834. static PyObject *__pyx_n_s_init;
  835. static PyObject *__pyx_n_s_key;
  836. static PyObject *__pyx_n_s_key_dict;
  837. static PyObject *__pyx_n_s_lib_Naked_toolshed_c_ink;
  838. static PyObject *__pyx_n_s_local_cdel;
  839. static PyObject *__pyx_n_s_local_dict;
  840. static PyObject *__pyx_n_s_local_htmlent;
  841. static PyObject *__pyx_n_s_local_odel;
  842. static PyObject *__pyx_n_s_local_template;
  843. static PyObject *__pyx_n_s_local_varlist;
  844. static PyObject *__pyx_n_s_main;
  845. static PyObject *__pyx_n_s_make_var_list;
  846. static PyObject *__pyx_n_s_match_pat;
  847. static PyObject *__pyx_n_s_metaclass;
  848. static PyObject *__pyx_n_s_module;
  849. static PyObject *__pyx_n_s_name;
  850. static PyObject *__pyx_n_s_new;
  851. static PyObject *__pyx_n_s_obj;
  852. static PyObject *__pyx_n_s_odel;
  853. static PyObject *__pyx_n_s_open_delimiter;
  854. static PyObject *__pyx_n_s_open_match_pat;
  855. static PyObject *__pyx_n_s_prepare;
  856. static PyObject *__pyx_n_s_qualname;
  857. static PyObject *__pyx_n_s_re;
  858. static PyObject *__pyx_n_s_render;
  859. static PyObject *__pyx_n_s_replace;
  860. static PyObject *__pyx_n_s_replace_string;
  861. static PyObject *__pyx_n_s_self;
  862. static PyObject *__pyx_n_s_template;
  863. static PyObject *__pyx_n_s_template_text;
  864. static PyObject *__pyx_n_s_test;
  865. static PyObject *__pyx_n_s_test_escape_string;
  866. static PyObject *__pyx_n_s_value;
  867. static PyObject *__pyx_n_s_var_list;
  868. static PyObject *__pyx_n_s_varlist;
  869. static PyObject *__pyx_n_s_xml_sax_saxutils;
  870. static PyObject *__pyx_tuple__4;
  871. static PyObject *__pyx_tuple__6;
  872. static PyObject *__pyx_tuple__7;
  873. static PyObject *__pyx_tuple__9;
  874. static PyObject *__pyx_tuple__10;
  875. static PyObject *__pyx_tuple__12;
  876. static PyObject *__pyx_tuple__14;
  877. static PyObject *__pyx_tuple__15;
  878. static PyObject *__pyx_codeobj__5;
  879. static PyObject *__pyx_codeobj__8;
  880. static PyObject *__pyx_codeobj__11;
  881. static PyObject *__pyx_codeobj__13;
  882. static PyObject *__pyx_codeobj__16;
  883. /* "lib/Naked/toolshed/c/ink.pyx":26
  884. * #------------------------------------------------------------------------------
  885. * class Template(str):
  886. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False): # <<<<<<<<<<<<<<
  887. * obj = str.__new__(cls, template_text)
  888. * obj.odel = open_delimiter
  889. */
  890. /* Python wrapper */
  891. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  892. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Template_1__new__ = {__Pyx_NAMESTR("__new__"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_1__new__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  893. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_1__new__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  894. PyObject *__pyx_v_cls = 0;
  895. PyObject *__pyx_v_template_text = 0;
  896. PyObject *__pyx_v_open_delimiter = 0;
  897. PyObject *__pyx_v_close_delimiter = 0;
  898. PyObject *__pyx_v_escape_regex = 0;
  899. int __pyx_lineno = 0;
  900. const char *__pyx_filename = NULL;
  901. int __pyx_clineno = 0;
  902. PyObject *__pyx_r = 0;
  903. __Pyx_RefNannyDeclarations
  904. __Pyx_RefNannySetupContext("__new__ (wrapper)", 0);
  905. {
  906. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_cls,&__pyx_n_s_template_text,&__pyx_n_s_open_delimiter,&__pyx_n_s_close_delimiter,&__pyx_n_s_escape_regex,0};
  907. PyObject* values[5] = {0,0,0,0,0};
  908. values[2] = ((PyObject *)((PyObject*)__pyx_kp_s_));
  909. values[3] = ((PyObject *)((PyObject*)__pyx_kp_s__2));
  910. values[4] = ((PyObject *)((PyObject *)Py_False));
  911. if (unlikely(__pyx_kwds)) {
  912. Py_ssize_t kw_args;
  913. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  914. switch (pos_args) {
  915. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  916. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  917. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  918. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  919. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  920. case 0: break;
  921. default: goto __pyx_L5_argtuple_error;
  922. }
  923. kw_args = PyDict_Size(__pyx_kwds);
  924. switch (pos_args) {
  925. case 0:
  926. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cls)) != 0)) kw_args--;
  927. else goto __pyx_L5_argtuple_error;
  928. case 1:
  929. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_template_text)) != 0)) kw_args--;
  930. else {
  931. __Pyx_RaiseArgtupleInvalid("__new__", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  932. }
  933. case 2:
  934. if (kw_args > 0) {
  935. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_open_delimiter);
  936. if (value) { values[2] = value; kw_args--; }
  937. }
  938. case 3:
  939. if (kw_args > 0) {
  940. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_close_delimiter);
  941. if (value) { values[3] = value; kw_args--; }
  942. }
  943. case 4:
  944. if (kw_args > 0) {
  945. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_escape_regex);
  946. if (value) { values[4] = value; kw_args--; }
  947. }
  948. }
  949. if (unlikely(kw_args > 0)) {
  950. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__new__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  951. }
  952. } else {
  953. switch (PyTuple_GET_SIZE(__pyx_args)) {
  954. case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
  955. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  956. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  957. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  958. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  959. break;
  960. default: goto __pyx_L5_argtuple_error;
  961. }
  962. }
  963. __pyx_v_cls = values[0];
  964. __pyx_v_template_text = values[1];
  965. __pyx_v_open_delimiter = values[2];
  966. __pyx_v_close_delimiter = values[3];
  967. __pyx_v_escape_regex = values[4];
  968. }
  969. goto __pyx_L4_argument_unpacking_done;
  970. __pyx_L5_argtuple_error:;
  971. __Pyx_RaiseArgtupleInvalid("__new__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  972. __pyx_L3_error:;
  973. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Template.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  974. __Pyx_RefNannyFinishContext();
  975. return NULL;
  976. __pyx_L4_argument_unpacking_done:;
  977. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template___new__(__pyx_self, __pyx_v_cls, __pyx_v_template_text, __pyx_v_open_delimiter, __pyx_v_close_delimiter, __pyx_v_escape_regex);
  978. /* function exit code */
  979. __Pyx_RefNannyFinishContext();
  980. return __pyx_r;
  981. }
  982. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template___new__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_cls, PyObject *__pyx_v_template_text, PyObject *__pyx_v_open_delimiter, PyObject *__pyx_v_close_delimiter, PyObject *__pyx_v_escape_regex) {
  983. PyObject *__pyx_v_obj = NULL;
  984. PyObject *__pyx_r = NULL;
  985. __Pyx_RefNannyDeclarations
  986. PyObject *__pyx_t_1 = NULL;
  987. PyObject *__pyx_t_2 = NULL;
  988. PyObject *__pyx_t_3 = NULL;
  989. int __pyx_lineno = 0;
  990. const char *__pyx_filename = NULL;
  991. int __pyx_clineno = 0;
  992. __Pyx_RefNannySetupContext("__new__", 0);
  993. /* "lib/Naked/toolshed/c/ink.pyx":27
  994. * class Template(str):
  995. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False):
  996. * obj = str.__new__(cls, template_text) # <<<<<<<<<<<<<<
  997. * obj.odel = open_delimiter
  998. * obj.cdel = close_delimiter
  999. */
  1000. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)((PyObject*)(&PyString_Type))), __pyx_n_s_new); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1001. __Pyx_GOTREF(__pyx_t_1);
  1002. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1003. __Pyx_GOTREF(__pyx_t_2);
  1004. __Pyx_INCREF(__pyx_v_cls);
  1005. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_cls);
  1006. __Pyx_GIVEREF(__pyx_v_cls);
  1007. __Pyx_INCREF(__pyx_v_template_text);
  1008. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_template_text);
  1009. __Pyx_GIVEREF(__pyx_v_template_text);
  1010. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1011. __Pyx_GOTREF(__pyx_t_3);
  1012. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1013. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1014. __pyx_v_obj = __pyx_t_3;
  1015. __pyx_t_3 = 0;
  1016. /* "lib/Naked/toolshed/c/ink.pyx":28
  1017. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False):
  1018. * obj = str.__new__(cls, template_text)
  1019. * obj.odel = open_delimiter # <<<<<<<<<<<<<<
  1020. * obj.cdel = close_delimiter
  1021. * obj.varlist = obj._make_var_list(template_text, escape_regex) #contains all unique parsed variables from the template in a list
  1022. */
  1023. if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_odel, __pyx_v_open_delimiter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1024. /* "lib/Naked/toolshed/c/ink.pyx":29
  1025. * obj = str.__new__(cls, template_text)
  1026. * obj.odel = open_delimiter
  1027. * obj.cdel = close_delimiter # <<<<<<<<<<<<<<
  1028. * obj.varlist = obj._make_var_list(template_text, escape_regex) #contains all unique parsed variables from the template in a list
  1029. * return obj
  1030. */
  1031. if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_cdel, __pyx_v_close_delimiter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1032. /* "lib/Naked/toolshed/c/ink.pyx":30
  1033. * obj.odel = open_delimiter
  1034. * obj.cdel = close_delimiter
  1035. * obj.varlist = obj._make_var_list(template_text, escape_regex) #contains all unique parsed variables from the template in a list # <<<<<<<<<<<<<<
  1036. * return obj
  1037. *
  1038. */
  1039. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_obj, __pyx_n_s_make_var_list); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1040. __Pyx_GOTREF(__pyx_t_3);
  1041. __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1042. __Pyx_GOTREF(__pyx_t_2);
  1043. __Pyx_INCREF(__pyx_v_template_text);
  1044. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_template_text);
  1045. __Pyx_GIVEREF(__pyx_v_template_text);
  1046. __Pyx_INCREF(__pyx_v_escape_regex);
  1047. PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_escape_regex);
  1048. __Pyx_GIVEREF(__pyx_v_escape_regex);
  1049. __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1050. __Pyx_GOTREF(__pyx_t_1);
  1051. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1052. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1053. if (__Pyx_PyObject_SetAttrStr(__pyx_v_obj, __pyx_n_s_varlist, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1054. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1055. /* "lib/Naked/toolshed/c/ink.pyx":31
  1056. * obj.cdel = close_delimiter
  1057. * obj.varlist = obj._make_var_list(template_text, escape_regex) #contains all unique parsed variables from the template in a list
  1058. * return obj # <<<<<<<<<<<<<<
  1059. *
  1060. * #------------------------------------------------------------------------------
  1061. */
  1062. __Pyx_XDECREF(__pyx_r);
  1063. __Pyx_INCREF(__pyx_v_obj);
  1064. __pyx_r = __pyx_v_obj;
  1065. goto __pyx_L0;
  1066. /* "lib/Naked/toolshed/c/ink.pyx":26
  1067. * #------------------------------------------------------------------------------
  1068. * class Template(str):
  1069. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False): # <<<<<<<<<<<<<<
  1070. * obj = str.__new__(cls, template_text)
  1071. * obj.odel = open_delimiter
  1072. */
  1073. /* function exit code */
  1074. __pyx_L1_error:;
  1075. __Pyx_XDECREF(__pyx_t_1);
  1076. __Pyx_XDECREF(__pyx_t_2);
  1077. __Pyx_XDECREF(__pyx_t_3);
  1078. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Template.__new__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1079. __pyx_r = NULL;
  1080. __pyx_L0:;
  1081. __Pyx_XDECREF(__pyx_v_obj);
  1082. __Pyx_XGIVEREF(__pyx_r);
  1083. __Pyx_RefNannyFinishContext();
  1084. return __pyx_r;
  1085. }
  1086. /* "lib/Naked/toolshed/c/ink.pyx":38
  1087. * # Returns a list of the variable names as strings
  1088. * #------------------------------------------------------------------------------
  1089. * def _make_var_list(self, template_text, escape_regex=False): # <<<<<<<<<<<<<<
  1090. * if escape_regex:
  1091. * open_match_pat = self._escape_regex_special_chars(self.odel)
  1092. */
  1093. /* Python wrapper */
  1094. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_3_make_var_list(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1095. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Template_3_make_var_list = {__Pyx_NAMESTR("_make_var_list"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_3_make_var_list, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1096. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_3_make_var_list(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1097. PyObject *__pyx_v_self = 0;
  1098. PyObject *__pyx_v_template_text = 0;
  1099. PyObject *__pyx_v_escape_regex = 0;
  1100. int __pyx_lineno = 0;
  1101. const char *__pyx_filename = NULL;
  1102. int __pyx_clineno = 0;
  1103. PyObject *__pyx_r = 0;
  1104. __Pyx_RefNannyDeclarations
  1105. __Pyx_RefNannySetupContext("_make_var_list (wrapper)", 0);
  1106. {
  1107. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_template_text,&__pyx_n_s_escape_regex,0};
  1108. PyObject* values[3] = {0,0,0};
  1109. values[2] = ((PyObject *)((PyObject *)Py_False));
  1110. if (unlikely(__pyx_kwds)) {
  1111. Py_ssize_t kw_args;
  1112. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1113. switch (pos_args) {
  1114. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1115. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1116. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1117. case 0: break;
  1118. default: goto __pyx_L5_argtuple_error;
  1119. }
  1120. kw_args = PyDict_Size(__pyx_kwds);
  1121. switch (pos_args) {
  1122. case 0:
  1123. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  1124. else goto __pyx_L5_argtuple_error;
  1125. case 1:
  1126. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_template_text)) != 0)) kw_args--;
  1127. else {
  1128. __Pyx_RaiseArgtupleInvalid("_make_var_list", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1129. }
  1130. case 2:
  1131. if (kw_args > 0) {
  1132. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_escape_regex);
  1133. if (value) { values[2] = value; kw_args--; }
  1134. }
  1135. }
  1136. if (unlikely(kw_args > 0)) {
  1137. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_make_var_list") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1138. }
  1139. } else {
  1140. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1141. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1142. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1143. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1144. break;
  1145. default: goto __pyx_L5_argtuple_error;
  1146. }
  1147. }
  1148. __pyx_v_self = values[0];
  1149. __pyx_v_template_text = values[1];
  1150. __pyx_v_escape_regex = values[2];
  1151. }
  1152. goto __pyx_L4_argument_unpacking_done;
  1153. __pyx_L5_argtuple_error:;
  1154. __Pyx_RaiseArgtupleInvalid("_make_var_list", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1155. __pyx_L3_error:;
  1156. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Template._make_var_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1157. __Pyx_RefNannyFinishContext();
  1158. return NULL;
  1159. __pyx_L4_argument_unpacking_done:;
  1160. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template_2_make_var_list(__pyx_self, __pyx_v_self, __pyx_v_template_text, __pyx_v_escape_regex);
  1161. /* function exit code */
  1162. __Pyx_RefNannyFinishContext();
  1163. return __pyx_r;
  1164. }
  1165. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template_2_make_var_list(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_template_text, PyObject *__pyx_v_escape_regex) {
  1166. PyObject *__pyx_v_open_match_pat = NULL;
  1167. PyObject *__pyx_v_close_match_pat = NULL;
  1168. PyObject *__pyx_v_match_pat = NULL;
  1169. PyObject *__pyx_v_var_list = NULL;
  1170. PyObject *__pyx_r = NULL;
  1171. __Pyx_RefNannyDeclarations
  1172. int __pyx_t_1;
  1173. PyObject *__pyx_t_2 = NULL;
  1174. PyObject *__pyx_t_3 = NULL;
  1175. PyObject *__pyx_t_4 = NULL;
  1176. int __pyx_lineno = 0;
  1177. const char *__pyx_filename = NULL;
  1178. int __pyx_clineno = 0;
  1179. __Pyx_RefNannySetupContext("_make_var_list", 0);
  1180. /* "lib/Naked/toolshed/c/ink.pyx":39
  1181. * #------------------------------------------------------------------------------
  1182. * def _make_var_list(self, template_text, escape_regex=False):
  1183. * if escape_regex: # <<<<<<<<<<<<<<
  1184. * open_match_pat = self._escape_regex_special_chars(self.odel)
  1185. * close_match_pat = self._escape_regex_special_chars(self.cdel)
  1186. */
  1187. __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_escape_regex); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1188. if (__pyx_t_1) {
  1189. /* "lib/Naked/toolshed/c/ink.pyx":40
  1190. * def _make_var_list(self, template_text, escape_regex=False):
  1191. * if escape_regex:
  1192. * open_match_pat = self._escape_regex_special_chars(self.odel) # <<<<<<<<<<<<<<
  1193. * close_match_pat = self._escape_regex_special_chars(self.cdel)
  1194. * match_pat = open_match_pat + r'(.*?)' + close_match_pat # capture group contains the variable name used between the opening and closing delimiters
  1195. */
  1196. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_escape_regex_special_chars); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1197. __Pyx_GOTREF(__pyx_t_2);
  1198. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_odel); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1199. __Pyx_GOTREF(__pyx_t_3);
  1200. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1201. __Pyx_GOTREF(__pyx_t_4);
  1202. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
  1203. __Pyx_GIVEREF(__pyx_t_3);
  1204. __pyx_t_3 = 0;
  1205. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1206. __Pyx_GOTREF(__pyx_t_3);
  1207. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1208. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1209. __pyx_v_open_match_pat = __pyx_t_3;
  1210. __pyx_t_3 = 0;
  1211. /* "lib/Naked/toolshed/c/ink.pyx":41
  1212. * if escape_regex:
  1213. * open_match_pat = self._escape_regex_special_chars(self.odel)
  1214. * close_match_pat = self._escape_regex_special_chars(self.cdel) # <<<<<<<<<<<<<<
  1215. * match_pat = open_match_pat + r'(.*?)' + close_match_pat # capture group contains the variable name used between the opening and closing delimiters
  1216. * else:
  1217. */
  1218. __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_escape_regex_special_chars); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1219. __Pyx_GOTREF(__pyx_t_3);
  1220. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cdel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1221. __Pyx_GOTREF(__pyx_t_4);
  1222. __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1223. __Pyx_GOTREF(__pyx_t_2);
  1224. PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
  1225. __Pyx_GIVEREF(__pyx_t_4);
  1226. __pyx_t_4 = 0;
  1227. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1228. __Pyx_GOTREF(__pyx_t_4);
  1229. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1230. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1231. __pyx_v_close_match_pat = __pyx_t_4;
  1232. __pyx_t_4 = 0;
  1233. /* "lib/Naked/toolshed/c/ink.pyx":42
  1234. * open_match_pat = self._escape_regex_special_chars(self.odel)
  1235. * close_match_pat = self._escape_regex_special_chars(self.cdel)
  1236. * match_pat = open_match_pat + r'(.*?)' + close_match_pat # capture group contains the variable name used between the opening and closing delimiters # <<<<<<<<<<<<<<
  1237. * else:
  1238. * match_pat = self.odel + r'(.*?)' + self.cdel
  1239. */
  1240. __pyx_t_4 = PyNumber_Add(__pyx_v_open_match_pat, __pyx_kp_s__3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1241. __Pyx_GOTREF(__pyx_t_4);
  1242. __pyx_t_2 = PyNumber_Add(__pyx_t_4, __pyx_v_close_match_pat); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1243. __Pyx_GOTREF(__pyx_t_2);
  1244. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1245. __pyx_v_match_pat = __pyx_t_2;
  1246. __pyx_t_2 = 0;
  1247. goto __pyx_L3;
  1248. }
  1249. /*else*/ {
  1250. /* "lib/Naked/toolshed/c/ink.pyx":44
  1251. * match_pat = open_match_pat + r'(.*?)' + close_match_pat # capture group contains the variable name used between the opening and closing delimiters
  1252. * else:
  1253. * match_pat = self.odel + r'(.*?)' + self.cdel # <<<<<<<<<<<<<<
  1254. * var_list = re.findall(match_pat, template_text) #generate a list that contains the capture group from the matches (i.e. the variables in the template)
  1255. * return set(var_list) # remove duplicate entries by converting to set (and lookup speed improvement from hashing)
  1256. */
  1257. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_odel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1258. __Pyx_GOTREF(__pyx_t_2);
  1259. __pyx_t_4 = PyNumber_Add(__pyx_t_2, __pyx_kp_s__3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1260. __Pyx_GOTREF(__pyx_t_4);
  1261. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1262. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cdel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1263. __Pyx_GOTREF(__pyx_t_2);
  1264. __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1265. __Pyx_GOTREF(__pyx_t_3);
  1266. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1267. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1268. __pyx_v_match_pat = __pyx_t_3;
  1269. __pyx_t_3 = 0;
  1270. }
  1271. __pyx_L3:;
  1272. /* "lib/Naked/toolshed/c/ink.pyx":45
  1273. * else:
  1274. * match_pat = self.odel + r'(.*?)' + self.cdel
  1275. * var_list = re.findall(match_pat, template_text) #generate a list that contains the capture group from the matches (i.e. the variables in the template) # <<<<<<<<<<<<<<
  1276. * return set(var_list) # remove duplicate entries by converting to set (and lookup speed improvement from hashing)
  1277. *
  1278. */
  1279. __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1280. __Pyx_GOTREF(__pyx_t_3);
  1281. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_findall); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1282. __Pyx_GOTREF(__pyx_t_2);
  1283. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1284. __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1285. __Pyx_GOTREF(__pyx_t_3);
  1286. __Pyx_INCREF(__pyx_v_match_pat);
  1287. PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_match_pat);
  1288. __Pyx_GIVEREF(__pyx_v_match_pat);
  1289. __Pyx_INCREF(__pyx_v_template_text);
  1290. PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_template_text);
  1291. __Pyx_GIVEREF(__pyx_v_template_text);
  1292. __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1293. __Pyx_GOTREF(__pyx_t_4);
  1294. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1295. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  1296. __pyx_v_var_list = __pyx_t_4;
  1297. __pyx_t_4 = 0;
  1298. /* "lib/Naked/toolshed/c/ink.pyx":46
  1299. * match_pat = self.odel + r'(.*?)' + self.cdel
  1300. * var_list = re.findall(match_pat, template_text) #generate a list that contains the capture group from the matches (i.e. the variables in the template)
  1301. * return set(var_list) # remove duplicate entries by converting to set (and lookup speed improvement from hashing) # <<<<<<<<<<<<<<
  1302. *
  1303. * #------------------------------------------------------------------------------
  1304. */
  1305. __Pyx_XDECREF(__pyx_r);
  1306. __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1307. __Pyx_GOTREF(__pyx_t_4);
  1308. __Pyx_INCREF(__pyx_v_var_list);
  1309. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_var_list);
  1310. __Pyx_GIVEREF(__pyx_v_var_list);
  1311. __pyx_t_3 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PySet_Type))), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1312. __Pyx_GOTREF(__pyx_t_3);
  1313. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1314. __pyx_r = __pyx_t_3;
  1315. __pyx_t_3 = 0;
  1316. goto __pyx_L0;
  1317. /* "lib/Naked/toolshed/c/ink.pyx":38
  1318. * # Returns a list of the variable names as strings
  1319. * #------------------------------------------------------------------------------
  1320. * def _make_var_list(self, template_text, escape_regex=False): # <<<<<<<<<<<<<<
  1321. * if escape_regex:
  1322. * open_match_pat = self._escape_regex_special_chars(self.odel)
  1323. */
  1324. /* function exit code */
  1325. __pyx_L1_error:;
  1326. __Pyx_XDECREF(__pyx_t_2);
  1327. __Pyx_XDECREF(__pyx_t_3);
  1328. __Pyx_XDECREF(__pyx_t_4);
  1329. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Template._make_var_list", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1330. __pyx_r = NULL;
  1331. __pyx_L0:;
  1332. __Pyx_XDECREF(__pyx_v_open_match_pat);
  1333. __Pyx_XDECREF(__pyx_v_close_match_pat);
  1334. __Pyx_XDECREF(__pyx_v_match_pat);
  1335. __Pyx_XDECREF(__pyx_v_var_list);
  1336. __Pyx_XGIVEREF(__pyx_r);
  1337. __Pyx_RefNannyFinishContext();
  1338. return __pyx_r;
  1339. }
  1340. /* "lib/Naked/toolshed/c/ink.pyx":53
  1341. * # Returns a string with the escaped character modifications
  1342. * #------------------------------------------------------------------------------
  1343. * def _escape_regex_special_chars(self, test_escape_string): # <<<<<<<<<<<<<<
  1344. * return re.escape(test_escape_string)
  1345. *
  1346. */
  1347. /* Python wrapper */
  1348. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_5_escape_regex_special_chars(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1349. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Template_5_escape_regex_special_chars = {__Pyx_NAMESTR("_escape_regex_special_chars"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_5_escape_regex_special_chars, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1350. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Template_5_escape_regex_special_chars(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1351. CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  1352. PyObject *__pyx_v_test_escape_string = 0;
  1353. int __pyx_lineno = 0;
  1354. const char *__pyx_filename = NULL;
  1355. int __pyx_clineno = 0;
  1356. PyObject *__pyx_r = 0;
  1357. __Pyx_RefNannyDeclarations
  1358. __Pyx_RefNannySetupContext("_escape_regex_special_chars (wrapper)", 0);
  1359. {
  1360. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_test_escape_string,0};
  1361. PyObject* values[2] = {0,0};
  1362. if (unlikely(__pyx_kwds)) {
  1363. Py_ssize_t kw_args;
  1364. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1365. switch (pos_args) {
  1366. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1367. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1368. case 0: break;
  1369. default: goto __pyx_L5_argtuple_error;
  1370. }
  1371. kw_args = PyDict_Size(__pyx_kwds);
  1372. switch (pos_args) {
  1373. case 0:
  1374. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  1375. else goto __pyx_L5_argtuple_error;
  1376. case 1:
  1377. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_test_escape_string)) != 0)) kw_args--;
  1378. else {
  1379. __Pyx_RaiseArgtupleInvalid("_escape_regex_special_chars", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1380. }
  1381. }
  1382. if (unlikely(kw_args > 0)) {
  1383. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_escape_regex_special_chars") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1384. }
  1385. } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
  1386. goto __pyx_L5_argtuple_error;
  1387. } else {
  1388. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1389. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1390. }
  1391. __pyx_v_self = values[0];
  1392. __pyx_v_test_escape_string = values[1];
  1393. }
  1394. goto __pyx_L4_argument_unpacking_done;
  1395. __pyx_L5_argtuple_error:;
  1396. __Pyx_RaiseArgtupleInvalid("_escape_regex_special_chars", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1397. __pyx_L3_error:;
  1398. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Template._escape_regex_special_chars", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1399. __Pyx_RefNannyFinishContext();
  1400. return NULL;
  1401. __pyx_L4_argument_unpacking_done:;
  1402. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template_4_escape_regex_special_chars(__pyx_self, __pyx_v_self, __pyx_v_test_escape_string);
  1403. /* function exit code */
  1404. __Pyx_RefNannyFinishContext();
  1405. return __pyx_r;
  1406. }
  1407. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Template_4_escape_regex_special_chars(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_test_escape_string) {
  1408. PyObject *__pyx_r = NULL;
  1409. __Pyx_RefNannyDeclarations
  1410. PyObject *__pyx_t_1 = NULL;
  1411. PyObject *__pyx_t_2 = NULL;
  1412. PyObject *__pyx_t_3 = NULL;
  1413. int __pyx_lineno = 0;
  1414. const char *__pyx_filename = NULL;
  1415. int __pyx_clineno = 0;
  1416. __Pyx_RefNannySetupContext("_escape_regex_special_chars", 0);
  1417. /* "lib/Naked/toolshed/c/ink.pyx":54
  1418. * #------------------------------------------------------------------------------
  1419. * def _escape_regex_special_chars(self, test_escape_string):
  1420. * return re.escape(test_escape_string) # <<<<<<<<<<<<<<
  1421. *
  1422. * #------------------------------------------------------------------------------
  1423. */
  1424. __Pyx_XDECREF(__pyx_r);
  1425. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1426. __Pyx_GOTREF(__pyx_t_1);
  1427. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_escape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1428. __Pyx_GOTREF(__pyx_t_2);
  1429. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1430. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1431. __Pyx_GOTREF(__pyx_t_1);
  1432. __Pyx_INCREF(__pyx_v_test_escape_string);
  1433. PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_test_escape_string);
  1434. __Pyx_GIVEREF(__pyx_v_test_escape_string);
  1435. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1436. __Pyx_GOTREF(__pyx_t_3);
  1437. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1438. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1439. __pyx_r = __pyx_t_3;
  1440. __pyx_t_3 = 0;
  1441. goto __pyx_L0;
  1442. /* "lib/Naked/toolshed/c/ink.pyx":53
  1443. * # Returns a string with the escaped character modifications
  1444. * #------------------------------------------------------------------------------
  1445. * def _escape_regex_special_chars(self, test_escape_string): # <<<<<<<<<<<<<<
  1446. * return re.escape(test_escape_string)
  1447. *
  1448. */
  1449. /* function exit code */
  1450. __pyx_L1_error:;
  1451. __Pyx_XDECREF(__pyx_t_1);
  1452. __Pyx_XDECREF(__pyx_t_2);
  1453. __Pyx_XDECREF(__pyx_t_3);
  1454. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Template._escape_regex_special_chars", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1455. __pyx_r = NULL;
  1456. __pyx_L0:;
  1457. __Pyx_XGIVEREF(__pyx_r);
  1458. __Pyx_RefNannyFinishContext();
  1459. return __pyx_r;
  1460. }
  1461. /* "lib/Naked/toolshed/c/ink.pyx":68
  1462. *
  1463. * class Renderer:
  1464. * def __init__(self, template, key, html_entities=False): # <<<<<<<<<<<<<<
  1465. * self.odel = template.odel
  1466. * self.cdel = template.cdel
  1467. */
  1468. /* Python wrapper */
  1469. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Renderer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1470. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Renderer_1__init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Renderer_1__init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1471. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Renderer_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1472. PyObject *__pyx_v_self = 0;
  1473. PyObject *__pyx_v_template = 0;
  1474. PyObject *__pyx_v_key = 0;
  1475. PyObject *__pyx_v_html_entities = 0;
  1476. int __pyx_lineno = 0;
  1477. const char *__pyx_filename = NULL;
  1478. int __pyx_clineno = 0;
  1479. PyObject *__pyx_r = 0;
  1480. __Pyx_RefNannyDeclarations
  1481. __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  1482. {
  1483. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_template,&__pyx_n_s_key,&__pyx_n_s_html_entities,0};
  1484. PyObject* values[4] = {0,0,0,0};
  1485. values[3] = ((PyObject *)((PyObject *)Py_False));
  1486. if (unlikely(__pyx_kwds)) {
  1487. Py_ssize_t kw_args;
  1488. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1489. switch (pos_args) {
  1490. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  1491. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1492. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1493. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1494. case 0: break;
  1495. default: goto __pyx_L5_argtuple_error;
  1496. }
  1497. kw_args = PyDict_Size(__pyx_kwds);
  1498. switch (pos_args) {
  1499. case 0:
  1500. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
  1501. else goto __pyx_L5_argtuple_error;
  1502. case 1:
  1503. if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_template)) != 0)) kw_args--;
  1504. else {
  1505. __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1506. }
  1507. case 2:
  1508. if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_key)) != 0)) kw_args--;
  1509. else {
  1510. __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1511. }
  1512. case 3:
  1513. if (kw_args > 0) {
  1514. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_html_entities);
  1515. if (value) { values[3] = value; kw_args--; }
  1516. }
  1517. }
  1518. if (unlikely(kw_args > 0)) {
  1519. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1520. }
  1521. } else {
  1522. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1523. case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
  1524. case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
  1525. values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1526. values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1527. break;
  1528. default: goto __pyx_L5_argtuple_error;
  1529. }
  1530. }
  1531. __pyx_v_self = values[0];
  1532. __pyx_v_template = values[1];
  1533. __pyx_v_key = values[2];
  1534. __pyx_v_html_entities = values[3];
  1535. }
  1536. goto __pyx_L4_argument_unpacking_done;
  1537. __pyx_L5_argtuple_error:;
  1538. __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1539. __pyx_L3_error:;
  1540. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Renderer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1541. __Pyx_RefNannyFinishContext();
  1542. return NULL;
  1543. __pyx_L4_argument_unpacking_done:;
  1544. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Renderer___init__(__pyx_self, __pyx_v_self, __pyx_v_template, __pyx_v_key, __pyx_v_html_entities);
  1545. /* function exit code */
  1546. __Pyx_RefNannyFinishContext();
  1547. return __pyx_r;
  1548. }
  1549. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Renderer___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_template, PyObject *__pyx_v_key, PyObject *__pyx_v_html_entities) {
  1550. PyObject *__pyx_r = NULL;
  1551. __Pyx_RefNannyDeclarations
  1552. PyObject *__pyx_t_1 = NULL;
  1553. int __pyx_lineno = 0;
  1554. const char *__pyx_filename = NULL;
  1555. int __pyx_clineno = 0;
  1556. __Pyx_RefNannySetupContext("__init__", 0);
  1557. /* "lib/Naked/toolshed/c/ink.pyx":69
  1558. * class Renderer:
  1559. * def __init__(self, template, key, html_entities=False):
  1560. * self.odel = template.odel # <<<<<<<<<<<<<<
  1561. * self.cdel = template.cdel
  1562. * self.template = template
  1563. */
  1564. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_template, __pyx_n_s_odel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1565. __Pyx_GOTREF(__pyx_t_1);
  1566. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_odel, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1567. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1568. /* "lib/Naked/toolshed/c/ink.pyx":70
  1569. * def __init__(self, template, key, html_entities=False):
  1570. * self.odel = template.odel
  1571. * self.cdel = template.cdel # <<<<<<<<<<<<<<
  1572. * self.template = template
  1573. * self.html_entities = html_entities
  1574. */
  1575. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_template, __pyx_n_s_cdel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1576. __Pyx_GOTREF(__pyx_t_1);
  1577. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_cdel, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1578. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1579. /* "lib/Naked/toolshed/c/ink.pyx":71
  1580. * self.odel = template.odel
  1581. * self.cdel = template.cdel
  1582. * self.template = template # <<<<<<<<<<<<<<
  1583. * self.html_entities = html_entities
  1584. * self.key_dict = key
  1585. */
  1586. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_template, __pyx_v_template) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1587. /* "lib/Naked/toolshed/c/ink.pyx":72
  1588. * self.cdel = template.cdel
  1589. * self.template = template
  1590. * self.html_entities = html_entities # <<<<<<<<<<<<<<
  1591. * self.key_dict = key
  1592. *
  1593. */
  1594. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_html_entities, __pyx_v_html_entities) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1595. /* "lib/Naked/toolshed/c/ink.pyx":73
  1596. * self.template = template
  1597. * self.html_entities = html_entities
  1598. * self.key_dict = key # <<<<<<<<<<<<<<
  1599. *
  1600. * #------------------------------------------------------------------------------
  1601. */
  1602. if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_key_dict, __pyx_v_key) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1603. /* "lib/Naked/toolshed/c/ink.pyx":68
  1604. *
  1605. * class Renderer:
  1606. * def __init__(self, template, key, html_entities=False): # <<<<<<<<<<<<<<
  1607. * self.odel = template.odel
  1608. * self.cdel = template.cdel
  1609. */
  1610. /* function exit code */
  1611. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  1612. goto __pyx_L0;
  1613. __pyx_L1_error:;
  1614. __Pyx_XDECREF(__pyx_t_1);
  1615. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Renderer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1616. __pyx_r = NULL;
  1617. __pyx_L0:;
  1618. __Pyx_XGIVEREF(__pyx_r);
  1619. __Pyx_RefNannyFinishContext();
  1620. return __pyx_r;
  1621. }
  1622. /* "lib/Naked/toolshed/c/ink.pyx":80
  1623. * # returns the rendered template as a string
  1624. * #------------------------------------------------------------------------------
  1625. * def render(self): # <<<<<<<<<<<<<<
  1626. * # make local variables for the loop below (faster)
  1627. * local_dict = self.key_dict
  1628. */
  1629. /* Python wrapper */
  1630. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Renderer_3render(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
  1631. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Renderer_3render = {__Pyx_NAMESTR("render"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Renderer_3render, METH_O, __Pyx_DOCSTR(0)};
  1632. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_3ink_8Renderer_3render(PyObject *__pyx_self, PyObject *__pyx_v_self) {
  1633. PyObject *__pyx_r = 0;
  1634. __Pyx_RefNannyDeclarations
  1635. __Pyx_RefNannySetupContext("render (wrapper)", 0);
  1636. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Renderer_2render(__pyx_self, ((PyObject *)__pyx_v_self));
  1637. /* function exit code */
  1638. __Pyx_RefNannyFinishContext();
  1639. return __pyx_r;
  1640. }
  1641. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_3ink_8Renderer_2render(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  1642. PyObject *__pyx_v_local_dict = NULL;
  1643. PyObject *__pyx_v_local_template = NULL;
  1644. PyObject *__pyx_v_local_varlist = NULL;
  1645. PyObject *__pyx_v_local_odel = NULL;
  1646. PyObject *__pyx_v_local_cdel = NULL;
  1647. PyObject *__pyx_v_local_htmlent = NULL;
  1648. PyObject *__pyx_v_escape = NULL;
  1649. PyObject *__pyx_v_key = NULL;
  1650. PyObject *__pyx_v_value = NULL;
  1651. PyObject *__pyx_v_replace_string = NULL;
  1652. PyObject *__pyx_r = NULL;
  1653. __Pyx_RefNannyDeclarations
  1654. PyObject *__pyx_t_1 = NULL;
  1655. PyObject *__pyx_t_2 = NULL;
  1656. int __pyx_t_3;
  1657. Py_ssize_t __pyx_t_4;
  1658. PyObject *(*__pyx_t_5)(PyObject *);
  1659. int __pyx_t_6;
  1660. PyObject *__pyx_t_7 = NULL;
  1661. PyObject *__pyx_t_8 = NULL;
  1662. int __pyx_lineno = 0;
  1663. const char *__pyx_filename = NULL;
  1664. int __pyx_clineno = 0;
  1665. __Pyx_RefNannySetupContext("render", 0);
  1666. /* "lib/Naked/toolshed/c/ink.pyx":82
  1667. * def render(self):
  1668. * # make local variables for the loop below (faster)
  1669. * local_dict = self.key_dict # <<<<<<<<<<<<<<
  1670. * local_template = self.template
  1671. * local_varlist = self.template.varlist
  1672. */
  1673. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_key_dict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1674. __Pyx_GOTREF(__pyx_t_1);
  1675. __pyx_v_local_dict = __pyx_t_1;
  1676. __pyx_t_1 = 0;
  1677. /* "lib/Naked/toolshed/c/ink.pyx":83
  1678. * # make local variables for the loop below (faster)
  1679. * local_dict = self.key_dict
  1680. * local_template = self.template # <<<<<<<<<<<<<<
  1681. * local_varlist = self.template.varlist
  1682. * local_odel = self.odel
  1683. */
  1684. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_template); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1685. __Pyx_GOTREF(__pyx_t_1);
  1686. __pyx_v_local_template = __pyx_t_1;
  1687. __pyx_t_1 = 0;
  1688. /* "lib/Naked/toolshed/c/ink.pyx":84
  1689. * local_dict = self.key_dict
  1690. * local_template = self.template
  1691. * local_varlist = self.template.varlist # <<<<<<<<<<<<<<
  1692. * local_odel = self.odel
  1693. * local_cdel = self.cdel
  1694. */
  1695. __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_template); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1696. __Pyx_GOTREF(__pyx_t_1);
  1697. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_varlist); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1698. __Pyx_GOTREF(__pyx_t_2);
  1699. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1700. __pyx_v_local_varlist = __pyx_t_2;
  1701. __pyx_t_2 = 0;
  1702. /* "lib/Naked/toolshed/c/ink.pyx":85
  1703. * local_template = self.template
  1704. * local_varlist = self.template.varlist
  1705. * local_odel = self.odel # <<<<<<<<<<<<<<
  1706. * local_cdel = self.cdel
  1707. * local_htmlent = self.html_entities
  1708. */
  1709. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_odel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1710. __Pyx_GOTREF(__pyx_t_2);
  1711. __pyx_v_local_odel = __pyx_t_2;
  1712. __pyx_t_2 = 0;
  1713. /* "lib/Naked/toolshed/c/ink.pyx":86
  1714. * local_varlist = self.template.varlist
  1715. * local_odel = self.odel
  1716. * local_cdel = self.cdel # <<<<<<<<<<<<<<
  1717. * local_htmlent = self.html_entities
  1718. * if local_htmlent:
  1719. */
  1720. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_cdel); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1721. __Pyx_GOTREF(__pyx_t_2);
  1722. __pyx_v_local_cdel = __pyx_t_2;
  1723. __pyx_t_2 = 0;
  1724. /* "lib/Naked/toolshed/c/ink.pyx":87
  1725. * local_odel = self.odel
  1726. * local_cdel = self.cdel
  1727. * local_htmlent = self.html_entities # <<<<<<<<<<<<<<
  1728. * if local_htmlent:
  1729. * from xml.sax.saxutils import escape #from Python std lib
  1730. */
  1731. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_html_entities); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1732. __Pyx_GOTREF(__pyx_t_2);
  1733. __pyx_v_local_htmlent = __pyx_t_2;
  1734. __pyx_t_2 = 0;
  1735. /* "lib/Naked/toolshed/c/ink.pyx":88
  1736. * local_cdel = self.cdel
  1737. * local_htmlent = self.html_entities
  1738. * if local_htmlent: # <<<<<<<<<<<<<<
  1739. * from xml.sax.saxutils import escape #from Python std lib
  1740. * for key in local_dict:
  1741. */
  1742. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_local_htmlent); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1743. if (__pyx_t_3) {
  1744. /* "lib/Naked/toolshed/c/ink.pyx":89
  1745. * local_htmlent = self.html_entities
  1746. * if local_htmlent:
  1747. * from xml.sax.saxutils import escape #from Python std lib # <<<<<<<<<<<<<<
  1748. * for key in local_dict:
  1749. * if key in local_varlist:
  1750. */
  1751. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1752. __Pyx_GOTREF(__pyx_t_2);
  1753. __Pyx_INCREF(__pyx_n_s_escape);
  1754. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_escape);
  1755. __Pyx_GIVEREF(__pyx_n_s_escape);
  1756. __pyx_t_1 = __Pyx_Import(__pyx_n_s_xml_sax_saxutils, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1757. __Pyx_GOTREF(__pyx_t_1);
  1758. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1759. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_escape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1760. __Pyx_GOTREF(__pyx_t_2);
  1761. __Pyx_INCREF(__pyx_t_2);
  1762. __pyx_v_escape = __pyx_t_2;
  1763. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1764. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1765. goto __pyx_L3;
  1766. }
  1767. __pyx_L3:;
  1768. /* "lib/Naked/toolshed/c/ink.pyx":90
  1769. * if local_htmlent:
  1770. * from xml.sax.saxutils import escape #from Python std lib
  1771. * for key in local_dict: # <<<<<<<<<<<<<<
  1772. * if key in local_varlist:
  1773. * value = local_dict[key]
  1774. */
  1775. if (PyList_CheckExact(__pyx_v_local_dict) || PyTuple_CheckExact(__pyx_v_local_dict)) {
  1776. __pyx_t_1 = __pyx_v_local_dict; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0;
  1777. __pyx_t_5 = NULL;
  1778. } else {
  1779. __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_local_dict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1780. __Pyx_GOTREF(__pyx_t_1);
  1781. __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext;
  1782. }
  1783. for (;;) {
  1784. if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) {
  1785. if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break;
  1786. #if CYTHON_COMPILING_IN_CPYTHON
  1787. __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1788. #else
  1789. __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1790. #endif
  1791. } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) {
  1792. if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
  1793. #if CYTHON_COMPILING_IN_CPYTHON
  1794. __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_2); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1795. #else
  1796. __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1797. #endif
  1798. } else {
  1799. __pyx_t_2 = __pyx_t_5(__pyx_t_1);
  1800. if (unlikely(!__pyx_t_2)) {
  1801. PyObject* exc_type = PyErr_Occurred();
  1802. if (exc_type) {
  1803. if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  1804. else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1805. }
  1806. break;
  1807. }
  1808. __Pyx_GOTREF(__pyx_t_2);
  1809. }
  1810. __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2);
  1811. __pyx_t_2 = 0;
  1812. /* "lib/Naked/toolshed/c/ink.pyx":91
  1813. * from xml.sax.saxutils import escape #from Python std lib
  1814. * for key in local_dict:
  1815. * if key in local_varlist: # <<<<<<<<<<<<<<
  1816. * value = local_dict[key]
  1817. * replace_string = local_odel + key + local_cdel
  1818. */
  1819. __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_key, __pyx_v_local_varlist, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1820. __pyx_t_6 = (__pyx_t_3 != 0);
  1821. if (__pyx_t_6) {
  1822. /* "lib/Naked/toolshed/c/ink.pyx":92
  1823. * for key in local_dict:
  1824. * if key in local_varlist:
  1825. * value = local_dict[key] # <<<<<<<<<<<<<<
  1826. * replace_string = local_odel + key + local_cdel
  1827. * if local_htmlent:
  1828. */
  1829. __pyx_t_2 = PyObject_GetItem(__pyx_v_local_dict, __pyx_v_key); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  1830. __Pyx_GOTREF(__pyx_t_2);
  1831. __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_2);
  1832. __pyx_t_2 = 0;
  1833. /* "lib/Naked/toolshed/c/ink.pyx":93
  1834. * if key in local_varlist:
  1835. * value = local_dict[key]
  1836. * replace_string = local_odel + key + local_cdel # <<<<<<<<<<<<<<
  1837. * if local_htmlent:
  1838. * value = escape(value) #xml.sax.saxutils function
  1839. */
  1840. __pyx_t_2 = PyNumber_Add(__pyx_v_local_odel, __pyx_v_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1841. __Pyx_GOTREF(__pyx_t_2);
  1842. __pyx_t_7 = PyNumber_Add(__pyx_t_2, __pyx_v_local_cdel); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1843. __Pyx_GOTREF(__pyx_t_7);
  1844. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1845. __Pyx_XDECREF_SET(__pyx_v_replace_string, __pyx_t_7);
  1846. __pyx_t_7 = 0;
  1847. /* "lib/Naked/toolshed/c/ink.pyx":94
  1848. * value = local_dict[key]
  1849. * replace_string = local_odel + key + local_cdel
  1850. * if local_htmlent: # <<<<<<<<<<<<<<
  1851. * value = escape(value) #xml.sax.saxutils function
  1852. * local_template = local_template.replace(replace_string, value)
  1853. */
  1854. __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_v_local_htmlent); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1855. if (__pyx_t_6) {
  1856. /* "lib/Naked/toolshed/c/ink.pyx":95
  1857. * replace_string = local_odel + key + local_cdel
  1858. * if local_htmlent:
  1859. * value = escape(value) #xml.sax.saxutils function # <<<<<<<<<<<<<<
  1860. * local_template = local_template.replace(replace_string, value)
  1861. * return local_template
  1862. */
  1863. if (unlikely(!__pyx_v_escape)) { __Pyx_RaiseUnboundLocalError("escape"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
  1864. __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1865. __Pyx_GOTREF(__pyx_t_7);
  1866. __Pyx_INCREF(__pyx_v_value);
  1867. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_value);
  1868. __Pyx_GIVEREF(__pyx_v_value);
  1869. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_escape, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1870. __Pyx_GOTREF(__pyx_t_2);
  1871. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1872. __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_2);
  1873. __pyx_t_2 = 0;
  1874. goto __pyx_L7;
  1875. }
  1876. __pyx_L7:;
  1877. /* "lib/Naked/toolshed/c/ink.pyx":96
  1878. * if local_htmlent:
  1879. * value = escape(value) #xml.sax.saxutils function
  1880. * local_template = local_template.replace(replace_string, value) # <<<<<<<<<<<<<<
  1881. * return local_template
  1882. *
  1883. */
  1884. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_local_template, __pyx_n_s_replace); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1885. __Pyx_GOTREF(__pyx_t_2);
  1886. __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1887. __Pyx_GOTREF(__pyx_t_7);
  1888. __Pyx_INCREF(__pyx_v_replace_string);
  1889. PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_replace_string);
  1890. __Pyx_GIVEREF(__pyx_v_replace_string);
  1891. __Pyx_INCREF(__pyx_v_value);
  1892. PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_value);
  1893. __Pyx_GIVEREF(__pyx_v_value);
  1894. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  1895. __Pyx_GOTREF(__pyx_t_8);
  1896. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  1897. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  1898. __Pyx_DECREF_SET(__pyx_v_local_template, __pyx_t_8);
  1899. __pyx_t_8 = 0;
  1900. goto __pyx_L6;
  1901. }
  1902. __pyx_L6:;
  1903. }
  1904. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  1905. /* "lib/Naked/toolshed/c/ink.pyx":97
  1906. * value = escape(value) #xml.sax.saxutils function
  1907. * local_template = local_template.replace(replace_string, value)
  1908. * return local_template # <<<<<<<<<<<<<<
  1909. *
  1910. * ##TODO : multiple file render method?
  1911. */
  1912. __Pyx_XDECREF(__pyx_r);
  1913. __Pyx_INCREF(__pyx_v_local_template);
  1914. __pyx_r = __pyx_v_local_template;
  1915. goto __pyx_L0;
  1916. /* "lib/Naked/toolshed/c/ink.pyx":80
  1917. * # returns the rendered template as a string
  1918. * #------------------------------------------------------------------------------
  1919. * def render(self): # <<<<<<<<<<<<<<
  1920. * # make local variables for the loop below (faster)
  1921. * local_dict = self.key_dict
  1922. */
  1923. /* function exit code */
  1924. __pyx_L1_error:;
  1925. __Pyx_XDECREF(__pyx_t_1);
  1926. __Pyx_XDECREF(__pyx_t_2);
  1927. __Pyx_XDECREF(__pyx_t_7);
  1928. __Pyx_XDECREF(__pyx_t_8);
  1929. __Pyx_AddTraceback("lib.Naked.toolshed.c.ink.Renderer.render", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1930. __pyx_r = NULL;
  1931. __pyx_L0:;
  1932. __Pyx_XDECREF(__pyx_v_local_dict);
  1933. __Pyx_XDECREF(__pyx_v_local_template);
  1934. __Pyx_XDECREF(__pyx_v_local_varlist);
  1935. __Pyx_XDECREF(__pyx_v_local_odel);
  1936. __Pyx_XDECREF(__pyx_v_local_cdel);
  1937. __Pyx_XDECREF(__pyx_v_local_htmlent);
  1938. __Pyx_XDECREF(__pyx_v_escape);
  1939. __Pyx_XDECREF(__pyx_v_key);
  1940. __Pyx_XDECREF(__pyx_v_value);
  1941. __Pyx_XDECREF(__pyx_v_replace_string);
  1942. __Pyx_XGIVEREF(__pyx_r);
  1943. __Pyx_RefNannyFinishContext();
  1944. return __pyx_r;
  1945. }
  1946. static PyMethodDef __pyx_methods[] = {
  1947. {0, 0, 0, 0}
  1948. };
  1949. #if PY_MAJOR_VERSION >= 3
  1950. static struct PyModuleDef __pyx_moduledef = {
  1951. #if PY_VERSION_HEX < 0x03020000
  1952. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  1953. #else
  1954. PyModuleDef_HEAD_INIT,
  1955. #endif
  1956. __Pyx_NAMESTR("ink"),
  1957. 0, /* m_doc */
  1958. -1, /* m_size */
  1959. __pyx_methods /* m_methods */,
  1960. NULL, /* m_reload */
  1961. NULL, /* m_traverse */
  1962. NULL, /* m_clear */
  1963. NULL /* m_free */
  1964. };
  1965. #endif
  1966. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  1967. {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
  1968. {&__pyx_n_s_Renderer, __pyx_k_Renderer, sizeof(__pyx_k_Renderer), 0, 0, 1, 1},
  1969. {&__pyx_n_s_Renderer___init, __pyx_k_Renderer___init, sizeof(__pyx_k_Renderer___init), 0, 0, 1, 1},
  1970. {&__pyx_n_s_Renderer_render, __pyx_k_Renderer_render, sizeof(__pyx_k_Renderer_render), 0, 0, 1, 1},
  1971. {&__pyx_n_s_Template, __pyx_k_Template, sizeof(__pyx_k_Template), 0, 0, 1, 1},
  1972. {&__pyx_n_s_Template___new, __pyx_k_Template___new, sizeof(__pyx_k_Template___new), 0, 0, 1, 1},
  1973. {&__pyx_n_s_Template__escape_regex_special_c, __pyx_k_Template__escape_regex_special_c, sizeof(__pyx_k_Template__escape_regex_special_c), 0, 0, 1, 1},
  1974. {&__pyx_n_s_Template__make_var_list, __pyx_k_Template__make_var_list, sizeof(__pyx_k_Template__make_var_list), 0, 0, 1, 1},
  1975. {&__pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_k_Users_ces_Desktop_code_naked_li, sizeof(__pyx_k_Users_ces_Desktop_code_naked_li), 0, 0, 1, 0},
  1976. {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
  1977. {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
  1978. {&__pyx_n_s_cdel, __pyx_k_cdel, sizeof(__pyx_k_cdel), 0, 0, 1, 1},
  1979. {&__pyx_n_s_close_delimiter, __pyx_k_close_delimiter, sizeof(__pyx_k_close_delimiter), 0, 0, 1, 1},
  1980. {&__pyx_n_s_close_match_pat, __pyx_k_close_match_pat, sizeof(__pyx_k_close_match_pat), 0, 0, 1, 1},
  1981. {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
  1982. {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
  1983. {&__pyx_n_s_escape, __pyx_k_escape, sizeof(__pyx_k_escape), 0, 0, 1, 1},
  1984. {&__pyx_n_s_escape_regex, __pyx_k_escape_regex, sizeof(__pyx_k_escape_regex), 0, 0, 1, 1},
  1985. {&__pyx_n_s_escape_regex_special_chars, __pyx_k_escape_regex_special_chars, sizeof(__pyx_k_escape_regex_special_chars), 0, 0, 1, 1},
  1986. {&__pyx_n_s_findall, __pyx_k_findall, sizeof(__pyx_k_findall), 0, 0, 1, 1},
  1987. {&__pyx_n_s_html_entities, __pyx_k_html_entities, sizeof(__pyx_k_html_entities), 0, 0, 1, 1},
  1988. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  1989. {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
  1990. {&__pyx_n_s_key, __pyx_k_key, sizeof(__pyx_k_key), 0, 0, 1, 1},
  1991. {&__pyx_n_s_key_dict, __pyx_k_key_dict, sizeof(__pyx_k_key_dict), 0, 0, 1, 1},
  1992. {&__pyx_n_s_lib_Naked_toolshed_c_ink, __pyx_k_lib_Naked_toolshed_c_ink, sizeof(__pyx_k_lib_Naked_toolshed_c_ink), 0, 0, 1, 1},
  1993. {&__pyx_n_s_local_cdel, __pyx_k_local_cdel, sizeof(__pyx_k_local_cdel), 0, 0, 1, 1},
  1994. {&__pyx_n_s_local_dict, __pyx_k_local_dict, sizeof(__pyx_k_local_dict), 0, 0, 1, 1},
  1995. {&__pyx_n_s_local_htmlent, __pyx_k_local_htmlent, sizeof(__pyx_k_local_htmlent), 0, 0, 1, 1},
  1996. {&__pyx_n_s_local_odel, __pyx_k_local_odel, sizeof(__pyx_k_local_odel), 0, 0, 1, 1},
  1997. {&__pyx_n_s_local_template, __pyx_k_local_template, sizeof(__pyx_k_local_template), 0, 0, 1, 1},
  1998. {&__pyx_n_s_local_varlist, __pyx_k_local_varlist, sizeof(__pyx_k_local_varlist), 0, 0, 1, 1},
  1999. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  2000. {&__pyx_n_s_make_var_list, __pyx_k_make_var_list, sizeof(__pyx_k_make_var_list), 0, 0, 1, 1},
  2001. {&__pyx_n_s_match_pat, __pyx_k_match_pat, sizeof(__pyx_k_match_pat), 0, 0, 1, 1},
  2002. {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
  2003. {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
  2004. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  2005. {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
  2006. {&__pyx_n_s_obj, __pyx_k_obj, sizeof(__pyx_k_obj), 0, 0, 1, 1},
  2007. {&__pyx_n_s_odel, __pyx_k_odel, sizeof(__pyx_k_odel), 0, 0, 1, 1},
  2008. {&__pyx_n_s_open_delimiter, __pyx_k_open_delimiter, sizeof(__pyx_k_open_delimiter), 0, 0, 1, 1},
  2009. {&__pyx_n_s_open_match_pat, __pyx_k_open_match_pat, sizeof(__pyx_k_open_match_pat), 0, 0, 1, 1},
  2010. {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
  2011. {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
  2012. {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
  2013. {&__pyx_n_s_render, __pyx_k_render, sizeof(__pyx_k_render), 0, 0, 1, 1},
  2014. {&__pyx_n_s_replace, __pyx_k_replace, sizeof(__pyx_k_replace), 0, 0, 1, 1},
  2015. {&__pyx_n_s_replace_string, __pyx_k_replace_string, sizeof(__pyx_k_replace_string), 0, 0, 1, 1},
  2016. {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
  2017. {&__pyx_n_s_template, __pyx_k_template, sizeof(__pyx_k_template), 0, 0, 1, 1},
  2018. {&__pyx_n_s_template_text, __pyx_k_template_text, sizeof(__pyx_k_template_text), 0, 0, 1, 1},
  2019. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  2020. {&__pyx_n_s_test_escape_string, __pyx_k_test_escape_string, sizeof(__pyx_k_test_escape_string), 0, 0, 1, 1},
  2021. {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
  2022. {&__pyx_n_s_var_list, __pyx_k_var_list, sizeof(__pyx_k_var_list), 0, 0, 1, 1},
  2023. {&__pyx_n_s_varlist, __pyx_k_varlist, sizeof(__pyx_k_varlist), 0, 0, 1, 1},
  2024. {&__pyx_n_s_xml_sax_saxutils, __pyx_k_xml_sax_saxutils, sizeof(__pyx_k_xml_sax_saxutils), 0, 0, 1, 1},
  2025. {0, 0, 0, 0, 0, 0, 0}
  2026. };
  2027. static int __Pyx_InitCachedBuiltins(void) {
  2028. return 0;
  2029. }
  2030. static int __Pyx_InitCachedConstants(void) {
  2031. __Pyx_RefNannyDeclarations
  2032. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  2033. /* "lib/Naked/toolshed/c/ink.pyx":26
  2034. * #------------------------------------------------------------------------------
  2035. * class Template(str):
  2036. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False): # <<<<<<<<<<<<<<
  2037. * obj = str.__new__(cls, template_text)
  2038. * obj.odel = open_delimiter
  2039. */
  2040. __pyx_tuple__4 = PyTuple_Pack(6, __pyx_n_s_cls, __pyx_n_s_template_text, __pyx_n_s_open_delimiter, __pyx_n_s_close_delimiter, __pyx_n_s_escape_regex, __pyx_n_s_obj); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2041. __Pyx_GOTREF(__pyx_tuple__4);
  2042. __Pyx_GIVEREF(__pyx_tuple__4);
  2043. __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_new, 26, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2044. __pyx_tuple__6 = PyTuple_Pack(3, ((PyObject*)__pyx_kp_s_), ((PyObject*)__pyx_kp_s__2), ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2045. __Pyx_GOTREF(__pyx_tuple__6);
  2046. __Pyx_GIVEREF(__pyx_tuple__6);
  2047. /* "lib/Naked/toolshed/c/ink.pyx":38
  2048. * # Returns a list of the variable names as strings
  2049. * #------------------------------------------------------------------------------
  2050. * def _make_var_list(self, template_text, escape_regex=False): # <<<<<<<<<<<<<<
  2051. * if escape_regex:
  2052. * open_match_pat = self._escape_regex_special_chars(self.odel)
  2053. */
  2054. __pyx_tuple__7 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_template_text, __pyx_n_s_escape_regex, __pyx_n_s_open_match_pat, __pyx_n_s_close_match_pat, __pyx_n_s_match_pat, __pyx_n_s_var_list); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2055. __Pyx_GOTREF(__pyx_tuple__7);
  2056. __Pyx_GIVEREF(__pyx_tuple__7);
  2057. __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_make_var_list, 38, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2058. __pyx_tuple__9 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2059. __Pyx_GOTREF(__pyx_tuple__9);
  2060. __Pyx_GIVEREF(__pyx_tuple__9);
  2061. /* "lib/Naked/toolshed/c/ink.pyx":53
  2062. * # Returns a string with the escaped character modifications
  2063. * #------------------------------------------------------------------------------
  2064. * def _escape_regex_special_chars(self, test_escape_string): # <<<<<<<<<<<<<<
  2065. * return re.escape(test_escape_string)
  2066. *
  2067. */
  2068. __pyx_tuple__10 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_test_escape_string); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2069. __Pyx_GOTREF(__pyx_tuple__10);
  2070. __Pyx_GIVEREF(__pyx_tuple__10);
  2071. __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_escape_regex_special_chars, 53, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2072. /* "lib/Naked/toolshed/c/ink.pyx":68
  2073. *
  2074. * class Renderer:
  2075. * def __init__(self, template, key, html_entities=False): # <<<<<<<<<<<<<<
  2076. * self.odel = template.odel
  2077. * self.cdel = template.cdel
  2078. */
  2079. __pyx_tuple__12 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_template, __pyx_n_s_key, __pyx_n_s_html_entities); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2080. __Pyx_GOTREF(__pyx_tuple__12);
  2081. __Pyx_GIVEREF(__pyx_tuple__12);
  2082. __pyx_codeobj__13 = (PyObject*)__Pyx_PyCode_New(4, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__12, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_init, 68, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2083. __pyx_tuple__14 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2084. __Pyx_GOTREF(__pyx_tuple__14);
  2085. __Pyx_GIVEREF(__pyx_tuple__14);
  2086. /* "lib/Naked/toolshed/c/ink.pyx":80
  2087. * # returns the rendered template as a string
  2088. * #------------------------------------------------------------------------------
  2089. * def render(self): # <<<<<<<<<<<<<<
  2090. * # make local variables for the loop below (faster)
  2091. * local_dict = self.key_dict
  2092. */
  2093. __pyx_tuple__15 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_local_dict, __pyx_n_s_local_template, __pyx_n_s_local_varlist, __pyx_n_s_local_odel, __pyx_n_s_local_cdel, __pyx_n_s_local_htmlent, __pyx_n_s_escape, __pyx_n_s_key, __pyx_n_s_value, __pyx_n_s_replace_string); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2094. __Pyx_GOTREF(__pyx_tuple__15);
  2095. __Pyx_GIVEREF(__pyx_tuple__15);
  2096. __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_render, 80, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2097. __Pyx_RefNannyFinishContext();
  2098. return 0;
  2099. __pyx_L1_error:;
  2100. __Pyx_RefNannyFinishContext();
  2101. return -1;
  2102. }
  2103. static int __Pyx_InitGlobals(void) {
  2104. if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  2105. return 0;
  2106. __pyx_L1_error:;
  2107. return -1;
  2108. }
  2109. #if PY_MAJOR_VERSION < 3
  2110. PyMODINIT_FUNC initink(void); /*proto*/
  2111. PyMODINIT_FUNC initink(void)
  2112. #else
  2113. PyMODINIT_FUNC PyInit_ink(void); /*proto*/
  2114. PyMODINIT_FUNC PyInit_ink(void)
  2115. #endif
  2116. {
  2117. PyObject *__pyx_t_1 = NULL;
  2118. PyObject *__pyx_t_2 = NULL;
  2119. PyObject *__pyx_t_3 = NULL;
  2120. PyObject *__pyx_t_4 = NULL;
  2121. int __pyx_t_5;
  2122. int __pyx_lineno = 0;
  2123. const char *__pyx_filename = NULL;
  2124. int __pyx_clineno = 0;
  2125. __Pyx_RefNannyDeclarations
  2126. #if CYTHON_REFNANNY
  2127. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  2128. if (!__Pyx_RefNanny) {
  2129. PyErr_Clear();
  2130. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  2131. if (!__Pyx_RefNanny)
  2132. Py_FatalError("failed to import 'refnanny' module");
  2133. }
  2134. #endif
  2135. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_ink(void)", 0);
  2136. if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2137. __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2138. __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2139. #ifdef __Pyx_CyFunction_USED
  2140. if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2141. #endif
  2142. #ifdef __Pyx_FusedFunction_USED
  2143. if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2144. #endif
  2145. #ifdef __Pyx_Generator_USED
  2146. if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2147. #endif
  2148. /*--- Library function declarations ---*/
  2149. /*--- Threads initialization code ---*/
  2150. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  2151. #ifdef WITH_THREAD /* Python build with threading support? */
  2152. PyEval_InitThreads();
  2153. #endif
  2154. #endif
  2155. /*--- Module creation code ---*/
  2156. #if PY_MAJOR_VERSION < 3
  2157. __pyx_m = Py_InitModule4(__Pyx_NAMESTR("ink"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  2158. #else
  2159. __pyx_m = PyModule_Create(&__pyx_moduledef);
  2160. #endif
  2161. if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2162. __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2163. Py_INCREF(__pyx_d);
  2164. __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2165. #if CYTHON_COMPILING_IN_PYPY
  2166. Py_INCREF(__pyx_b);
  2167. #endif
  2168. if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  2169. /*--- Initialize various global constants etc. ---*/
  2170. if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2171. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  2172. if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2173. #endif
  2174. if (__pyx_module_is_main_lib__Naked__toolshed__c__ink) {
  2175. if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  2176. }
  2177. #if PY_MAJOR_VERSION >= 3
  2178. {
  2179. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2180. if (!PyDict_GetItemString(modules, "lib.Naked.toolshed.c.ink")) {
  2181. if (unlikely(PyDict_SetItemString(modules, "lib.Naked.toolshed.c.ink", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2182. }
  2183. }
  2184. #endif
  2185. /*--- Builtin init code ---*/
  2186. if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2187. /*--- Constants init code ---*/
  2188. if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2189. /*--- Global init code ---*/
  2190. /*--- Variable export code ---*/
  2191. /*--- Function export code ---*/
  2192. /*--- Type init code ---*/
  2193. /*--- Type import code ---*/
  2194. /*--- Variable import code ---*/
  2195. /*--- Function import code ---*/
  2196. /*--- Execution code ---*/
  2197. /* "lib/Naked/toolshed/c/ink.pyx":11
  2198. * # MIT License
  2199. * #------------------------------------------------------------------------------
  2200. * import re # <<<<<<<<<<<<<<
  2201. *
  2202. * #------------------------------------------------------------------------------
  2203. */
  2204. __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2205. __Pyx_GOTREF(__pyx_t_1);
  2206. if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2207. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2208. /* "lib/Naked/toolshed/c/ink.pyx":25
  2209. * # `escape_regex` boolean is a speedup, avoids Python escape of special regex chars if you do not need it
  2210. * #------------------------------------------------------------------------------
  2211. * class Template(str): # <<<<<<<<<<<<<<
  2212. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False):
  2213. * obj = str.__new__(cls, template_text)
  2214. */
  2215. __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2216. __Pyx_GOTREF(__pyx_t_1);
  2217. __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
  2218. PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
  2219. __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
  2220. __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2221. __Pyx_GOTREF(__pyx_t_2);
  2222. __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_Template, __pyx_n_s_Template, (PyObject *) NULL, __pyx_n_s_lib_Naked_toolshed_c_ink, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2223. __Pyx_GOTREF(__pyx_t_3);
  2224. /* "lib/Naked/toolshed/c/ink.pyx":26
  2225. * #------------------------------------------------------------------------------
  2226. * class Template(str):
  2227. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False): # <<<<<<<<<<<<<<
  2228. * obj = str.__new__(cls, template_text)
  2229. * obj.odel = open_delimiter
  2230. */
  2231. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Template_1__new__, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_n_s_Template___new, NULL, __pyx_n_s_lib_Naked_toolshed_c_ink, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2232. __Pyx_GOTREF(__pyx_t_4);
  2233. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__6);
  2234. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_new, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2235. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2236. /* "lib/Naked/toolshed/c/ink.pyx":38
  2237. * # Returns a list of the variable names as strings
  2238. * #------------------------------------------------------------------------------
  2239. * def _make_var_list(self, template_text, escape_regex=False): # <<<<<<<<<<<<<<
  2240. * if escape_regex:
  2241. * open_match_pat = self._escape_regex_special_chars(self.odel)
  2242. */
  2243. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Template_3_make_var_list, 0, __pyx_n_s_Template__make_var_list, NULL, __pyx_n_s_lib_Naked_toolshed_c_ink, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2244. __Pyx_GOTREF(__pyx_t_4);
  2245. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_tuple__9);
  2246. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_make_var_list, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2247. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2248. /* "lib/Naked/toolshed/c/ink.pyx":53
  2249. * # Returns a string with the escaped character modifications
  2250. * #------------------------------------------------------------------------------
  2251. * def _escape_regex_special_chars(self, test_escape_string): # <<<<<<<<<<<<<<
  2252. * return re.escape(test_escape_string)
  2253. *
  2254. */
  2255. __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Template_5_escape_regex_special_chars, 0, __pyx_n_s_Template__escape_regex_special_c, NULL, __pyx_n_s_lib_Naked_toolshed_c_ink, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__11)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2256. __Pyx_GOTREF(__pyx_t_4);
  2257. if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_escape_regex_special_chars, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2258. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2259. /* "lib/Naked/toolshed/c/ink.pyx":25
  2260. * # `escape_regex` boolean is a speedup, avoids Python escape of special regex chars if you do not need it
  2261. * #------------------------------------------------------------------------------
  2262. * class Template(str): # <<<<<<<<<<<<<<
  2263. * def __new__(cls, template_text, open_delimiter="{{", close_delimiter="}}", escape_regex=False):
  2264. * obj = str.__new__(cls, template_text)
  2265. */
  2266. __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_Template, __pyx_t_1, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2267. __Pyx_GOTREF(__pyx_t_4);
  2268. if (PyDict_SetItem(__pyx_d, __pyx_n_s_Template, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2269. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2270. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  2271. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2272. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2273. /* "lib/Naked/toolshed/c/ink.pyx":67
  2274. * #------------------------------------------------------------------------------
  2275. *
  2276. * class Renderer: # <<<<<<<<<<<<<<
  2277. * def __init__(self, template, key, html_entities=False):
  2278. * self.odel = template.odel
  2279. */
  2280. __pyx_t_1 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_Renderer, __pyx_n_s_Renderer, (PyObject *) NULL, __pyx_n_s_lib_Naked_toolshed_c_ink, (PyObject *) NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2281. __Pyx_GOTREF(__pyx_t_1);
  2282. /* "lib/Naked/toolshed/c/ink.pyx":68
  2283. *
  2284. * class Renderer:
  2285. * def __init__(self, template, key, html_entities=False): # <<<<<<<<<<<<<<
  2286. * self.odel = template.odel
  2287. * self.cdel = template.cdel
  2288. */
  2289. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Renderer_1__init__, 0, __pyx_n_s_Renderer___init, NULL, __pyx_n_s_lib_Naked_toolshed_c_ink, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__13)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2290. __Pyx_GOTREF(__pyx_t_2);
  2291. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_tuple__14);
  2292. if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_init, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2293. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2294. /* "lib/Naked/toolshed/c/ink.pyx":80
  2295. * # returns the rendered template as a string
  2296. * #------------------------------------------------------------------------------
  2297. * def render(self): # <<<<<<<<<<<<<<
  2298. * # make local variables for the loop below (faster)
  2299. * local_dict = self.key_dict
  2300. */
  2301. __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_3ink_8Renderer_3render, 0, __pyx_n_s_Renderer_render, NULL, __pyx_n_s_lib_Naked_toolshed_c_ink, PyModule_GetDict(__pyx_m), ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2302. __Pyx_GOTREF(__pyx_t_2);
  2303. if (PyObject_SetItem(__pyx_t_1, __pyx_n_s_render, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2304. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2305. /* "lib/Naked/toolshed/c/ink.pyx":67
  2306. * #------------------------------------------------------------------------------
  2307. *
  2308. * class Renderer: # <<<<<<<<<<<<<<
  2309. * def __init__(self, template, key, html_entities=False):
  2310. * self.odel = template.odel
  2311. */
  2312. __pyx_t_2 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_Renderer, __pyx_empty_tuple, __pyx_t_1, NULL, 0, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2313. __Pyx_GOTREF(__pyx_t_2);
  2314. if (PyDict_SetItem(__pyx_d, __pyx_n_s_Renderer, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2315. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  2316. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2317. /* "lib/Naked/toolshed/c/ink.pyx":102
  2318. *
  2319. *
  2320. * if __name__ == '__main__': # <<<<<<<<<<<<<<
  2321. * pass
  2322. * # template = Template("This is a of the {{test}} of the {{document}} {{type}} and more of the {{test}} {{document}} {{type}}")
  2323. */
  2324. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2325. __Pyx_GOTREF(__pyx_t_1);
  2326. __pyx_t_5 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_main, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2327. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2328. if (__pyx_t_5) {
  2329. goto __pyx_L2;
  2330. }
  2331. __pyx_L2:;
  2332. /* "lib/Naked/toolshed/c/ink.pyx":1
  2333. * #!/usr/bin/env python # <<<<<<<<<<<<<<
  2334. * # encoding: utf-8
  2335. * # cython: profile=False
  2336. */
  2337. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2338. __Pyx_GOTREF(__pyx_t_1);
  2339. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2340. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  2341. goto __pyx_L0;
  2342. __pyx_L1_error:;
  2343. __Pyx_XDECREF(__pyx_t_1);
  2344. __Pyx_XDECREF(__pyx_t_2);
  2345. __Pyx_XDECREF(__pyx_t_3);
  2346. __Pyx_XDECREF(__pyx_t_4);
  2347. if (__pyx_m) {
  2348. __Pyx_AddTraceback("init lib.Naked.toolshed.c.ink", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2349. Py_DECREF(__pyx_m); __pyx_m = 0;
  2350. } else if (!PyErr_Occurred()) {
  2351. PyErr_SetString(PyExc_ImportError, "init lib.Naked.toolshed.c.ink");
  2352. }
  2353. __pyx_L0:;
  2354. __Pyx_RefNannyFinishContext();
  2355. #if PY_MAJOR_VERSION < 3
  2356. return;
  2357. #else
  2358. return __pyx_m;
  2359. #endif
  2360. }
  2361. /* Runtime support code */
  2362. #if CYTHON_REFNANNY
  2363. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  2364. PyObject *m = NULL, *p = NULL;
  2365. void *r = NULL;
  2366. m = PyImport_ImportModule((char *)modname);
  2367. if (!m) goto end;
  2368. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  2369. if (!p) goto end;
  2370. r = PyLong_AsVoidPtr(p);
  2371. end:
  2372. Py_XDECREF(p);
  2373. Py_XDECREF(m);
  2374. return (__Pyx_RefNannyAPIStruct *)r;
  2375. }
  2376. #endif /* CYTHON_REFNANNY */
  2377. static void __Pyx_RaiseArgtupleInvalid(
  2378. const char* func_name,
  2379. int exact,
  2380. Py_ssize_t num_min,
  2381. Py_ssize_t num_max,
  2382. Py_ssize_t num_found)
  2383. {
  2384. Py_ssize_t num_expected;
  2385. const char *more_or_less;
  2386. if (num_found < num_min) {
  2387. num_expected = num_min;
  2388. more_or_less = "at least";
  2389. } else {
  2390. num_expected = num_max;
  2391. more_or_less = "at most";
  2392. }
  2393. if (exact) {
  2394. more_or_less = "exactly";
  2395. }
  2396. PyErr_Format(PyExc_TypeError,
  2397. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  2398. func_name, more_or_less, num_expected,
  2399. (num_expected == 1) ? "" : "s", num_found);
  2400. }
  2401. static void __Pyx_RaiseDoubleKeywordsError(
  2402. const char* func_name,
  2403. PyObject* kw_name)
  2404. {
  2405. PyErr_Format(PyExc_TypeError,
  2406. #if PY_MAJOR_VERSION >= 3
  2407. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  2408. #else
  2409. "%s() got multiple values for keyword argument '%s'", func_name,
  2410. PyString_AsString(kw_name));
  2411. #endif
  2412. }
  2413. static int __Pyx_ParseOptionalKeywords(
  2414. PyObject *kwds,
  2415. PyObject **argnames[],
  2416. PyObject *kwds2,
  2417. PyObject *values[],
  2418. Py_ssize_t num_pos_args,
  2419. const char* function_name)
  2420. {
  2421. PyObject *key = 0, *value = 0;
  2422. Py_ssize_t pos = 0;
  2423. PyObject*** name;
  2424. PyObject*** first_kw_arg = argnames + num_pos_args;
  2425. while (PyDict_Next(kwds, &pos, &key, &value)) {
  2426. name = first_kw_arg;
  2427. while (*name && (**name != key)) name++;
  2428. if (*name) {
  2429. values[name-argnames] = value;
  2430. continue;
  2431. }
  2432. name = first_kw_arg;
  2433. #if PY_MAJOR_VERSION < 3
  2434. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  2435. while (*name) {
  2436. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  2437. && _PyString_Eq(**name, key)) {
  2438. values[name-argnames] = value;
  2439. break;
  2440. }
  2441. name++;
  2442. }
  2443. if (*name) continue;
  2444. else {
  2445. PyObject*** argname = argnames;
  2446. while (argname != first_kw_arg) {
  2447. if ((**argname == key) || (
  2448. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  2449. && _PyString_Eq(**argname, key))) {
  2450. goto arg_passed_twice;
  2451. }
  2452. argname++;
  2453. }
  2454. }
  2455. } else
  2456. #endif
  2457. if (likely(PyUnicode_Check(key))) {
  2458. while (*name) {
  2459. int cmp = (**name == key) ? 0 :
  2460. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  2461. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  2462. #endif
  2463. PyUnicode_Compare(**name, key);
  2464. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  2465. if (cmp == 0) {
  2466. values[name-argnames] = value;
  2467. break;
  2468. }
  2469. name++;
  2470. }
  2471. if (*name) continue;
  2472. else {
  2473. PyObject*** argname = argnames;
  2474. while (argname != first_kw_arg) {
  2475. int cmp = (**argname == key) ? 0 :
  2476. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  2477. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  2478. #endif
  2479. PyUnicode_Compare(**argname, key);
  2480. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  2481. if (cmp == 0) goto arg_passed_twice;
  2482. argname++;
  2483. }
  2484. }
  2485. } else
  2486. goto invalid_keyword_type;
  2487. if (kwds2) {
  2488. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  2489. } else {
  2490. goto invalid_keyword;
  2491. }
  2492. }
  2493. return 0;
  2494. arg_passed_twice:
  2495. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  2496. goto bad;
  2497. invalid_keyword_type:
  2498. PyErr_Format(PyExc_TypeError,
  2499. "%.200s() keywords must be strings", function_name);
  2500. goto bad;
  2501. invalid_keyword:
  2502. PyErr_Format(PyExc_TypeError,
  2503. #if PY_MAJOR_VERSION < 3
  2504. "%.200s() got an unexpected keyword argument '%.200s'",
  2505. function_name, PyString_AsString(key));
  2506. #else
  2507. "%s() got an unexpected keyword argument '%U'",
  2508. function_name, key);
  2509. #endif
  2510. bad:
  2511. return -1;
  2512. }
  2513. #if CYTHON_COMPILING_IN_CPYTHON
  2514. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  2515. PyObject *result;
  2516. ternaryfunc call = func->ob_type->tp_call;
  2517. if (unlikely(!call))
  2518. return PyObject_Call(func, arg, kw);
  2519. #if PY_VERSION_HEX >= 0x02060000
  2520. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  2521. return NULL;
  2522. #endif
  2523. result = (*call)(func, arg, kw);
  2524. #if PY_VERSION_HEX >= 0x02060000
  2525. Py_LeaveRecursiveCall();
  2526. #endif
  2527. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  2528. PyErr_SetString(
  2529. PyExc_SystemError,
  2530. "NULL result without error in PyObject_Call");
  2531. }
  2532. return result;
  2533. }
  2534. #endif
  2535. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  2536. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  2537. if (unlikely(!result)) {
  2538. PyErr_Format(PyExc_NameError,
  2539. #if PY_MAJOR_VERSION >= 3
  2540. "name '%U' is not defined", name);
  2541. #else
  2542. "name '%.200s' is not defined", PyString_AS_STRING(name));
  2543. #endif
  2544. }
  2545. return result;
  2546. }
  2547. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  2548. PyObject *result;
  2549. #if CYTHON_COMPILING_IN_CPYTHON
  2550. result = PyDict_GetItem(__pyx_d, name);
  2551. if (result) {
  2552. Py_INCREF(result);
  2553. } else {
  2554. #else
  2555. result = PyObject_GetItem(__pyx_d, name);
  2556. if (!result) {
  2557. PyErr_Clear();
  2558. #endif
  2559. result = __Pyx_GetBuiltinName(name);
  2560. }
  2561. return result;
  2562. }
  2563. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  2564. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  2565. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  2566. PyErr_Format(PyExc_ImportError,
  2567. #if PY_MAJOR_VERSION < 3
  2568. "cannot import name %.230s", PyString_AS_STRING(name));
  2569. #else
  2570. "cannot import name %S", name);
  2571. #endif
  2572. }
  2573. return value;
  2574. }
  2575. static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
  2576. PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
  2577. }
  2578. static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
  2579. Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
  2580. for (i=0; i < nbases; i++) {
  2581. PyTypeObject *tmptype;
  2582. PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  2583. tmptype = Py_TYPE(tmp);
  2584. #if PY_MAJOR_VERSION < 3
  2585. if (tmptype == &PyClass_Type)
  2586. continue;
  2587. #endif
  2588. if (!metaclass) {
  2589. metaclass = tmptype;
  2590. continue;
  2591. }
  2592. if (PyType_IsSubtype(metaclass, tmptype))
  2593. continue;
  2594. if (PyType_IsSubtype(tmptype, metaclass)) {
  2595. metaclass = tmptype;
  2596. continue;
  2597. }
  2598. PyErr_SetString(PyExc_TypeError,
  2599. "metaclass conflict: "
  2600. "the metaclass of a derived class "
  2601. "must be a (non-strict) subclass "
  2602. "of the metaclasses of all its bases");
  2603. return NULL;
  2604. }
  2605. if (!metaclass) {
  2606. #if PY_MAJOR_VERSION < 3
  2607. metaclass = &PyClass_Type;
  2608. #else
  2609. metaclass = &PyType_Type;
  2610. #endif
  2611. }
  2612. Py_INCREF((PyObject*) metaclass);
  2613. return (PyObject*) metaclass;
  2614. }
  2615. static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
  2616. PyObject* fake_module;
  2617. PyTypeObject* cached_type = NULL;
  2618. fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
  2619. if (!fake_module) return NULL;
  2620. Py_INCREF(fake_module);
  2621. cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
  2622. if (cached_type) {
  2623. if (!PyType_Check((PyObject*)cached_type)) {
  2624. PyErr_Format(PyExc_TypeError,
  2625. "Shared Cython type %.200s is not a type object",
  2626. type->tp_name);
  2627. goto bad;
  2628. }
  2629. if (cached_type->tp_basicsize != type->tp_basicsize) {
  2630. PyErr_Format(PyExc_TypeError,
  2631. "Shared Cython type %.200s has the wrong size, try recompiling",
  2632. type->tp_name);
  2633. goto bad;
  2634. }
  2635. } else {
  2636. if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
  2637. PyErr_Clear();
  2638. if (PyType_Ready(type) < 0) goto bad;
  2639. if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
  2640. goto bad;
  2641. Py_INCREF(type);
  2642. cached_type = type;
  2643. }
  2644. done:
  2645. Py_DECREF(fake_module);
  2646. return cached_type;
  2647. bad:
  2648. Py_XDECREF(cached_type);
  2649. cached_type = NULL;
  2650. goto done;
  2651. }
  2652. static PyObject *
  2653. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
  2654. {
  2655. if (unlikely(op->func_doc == NULL)) {
  2656. if (op->func.m_ml->ml_doc) {
  2657. #if PY_MAJOR_VERSION >= 3
  2658. op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
  2659. #else
  2660. op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
  2661. #endif
  2662. if (unlikely(op->func_doc == NULL))
  2663. return NULL;
  2664. } else {
  2665. Py_INCREF(Py_None);
  2666. return Py_None;
  2667. }
  2668. }
  2669. Py_INCREF(op->func_doc);
  2670. return op->func_doc;
  2671. }
  2672. static int
  2673. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
  2674. {
  2675. PyObject *tmp = op->func_doc;
  2676. if (value == NULL)
  2677. value = Py_None; /* Mark as deleted */
  2678. Py_INCREF(value);
  2679. op->func_doc = value;
  2680. Py_XDECREF(tmp);
  2681. return 0;
  2682. }
  2683. static PyObject *
  2684. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
  2685. {
  2686. if (unlikely(op->func_name == NULL)) {
  2687. #if PY_MAJOR_VERSION >= 3
  2688. op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
  2689. #else
  2690. op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
  2691. #endif
  2692. if (unlikely(op->func_name == NULL))
  2693. return NULL;
  2694. }
  2695. Py_INCREF(op->func_name);
  2696. return op->func_name;
  2697. }
  2698. static int
  2699. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
  2700. {
  2701. PyObject *tmp;
  2702. #if PY_MAJOR_VERSION >= 3
  2703. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  2704. #else
  2705. if (unlikely(value == NULL || !PyString_Check(value))) {
  2706. #endif
  2707. PyErr_SetString(PyExc_TypeError,
  2708. "__name__ must be set to a string object");
  2709. return -1;
  2710. }
  2711. tmp = op->func_name;
  2712. Py_INCREF(value);
  2713. op->func_name = value;
  2714. Py_XDECREF(tmp);
  2715. return 0;
  2716. }
  2717. static PyObject *
  2718. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
  2719. {
  2720. Py_INCREF(op->func_qualname);
  2721. return op->func_qualname;
  2722. }
  2723. static int
  2724. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
  2725. {
  2726. PyObject *tmp;
  2727. #if PY_MAJOR_VERSION >= 3
  2728. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  2729. #else
  2730. if (unlikely(value == NULL || !PyString_Check(value))) {
  2731. #endif
  2732. PyErr_SetString(PyExc_TypeError,
  2733. "__qualname__ must be set to a string object");
  2734. return -1;
  2735. }
  2736. tmp = op->func_qualname;
  2737. Py_INCREF(value);
  2738. op->func_qualname = value;
  2739. Py_XDECREF(tmp);
  2740. return 0;
  2741. }
  2742. static PyObject *
  2743. __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
  2744. {
  2745. PyObject *self;
  2746. self = m->func_closure;
  2747. if (self == NULL)
  2748. self = Py_None;
  2749. Py_INCREF(self);
  2750. return self;
  2751. }
  2752. static PyObject *
  2753. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
  2754. {
  2755. if (unlikely(op->func_dict == NULL)) {
  2756. op->func_dict = PyDict_New();
  2757. if (unlikely(op->func_dict == NULL))
  2758. return NULL;
  2759. }
  2760. Py_INCREF(op->func_dict);
  2761. return op->func_dict;
  2762. }
  2763. static int
  2764. __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
  2765. {
  2766. PyObject *tmp;
  2767. if (unlikely(value == NULL)) {
  2768. PyErr_SetString(PyExc_TypeError,
  2769. "function's dictionary may not be deleted");
  2770. return -1;
  2771. }
  2772. if (unlikely(!PyDict_Check(value))) {
  2773. PyErr_SetString(PyExc_TypeError,
  2774. "setting function's dictionary to a non-dict");
  2775. return -1;
  2776. }
  2777. tmp = op->func_dict;
  2778. Py_INCREF(value);
  2779. op->func_dict = value;
  2780. Py_XDECREF(tmp);
  2781. return 0;
  2782. }
  2783. static PyObject *
  2784. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
  2785. {
  2786. Py_INCREF(op->func_globals);
  2787. return op->func_globals;
  2788. }
  2789. static PyObject *
  2790. __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
  2791. {
  2792. Py_INCREF(Py_None);
  2793. return Py_None;
  2794. }
  2795. static PyObject *
  2796. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
  2797. {
  2798. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  2799. Py_INCREF(result);
  2800. return result;
  2801. }
  2802. static int
  2803. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  2804. PyObject *res = op->defaults_getter((PyObject *) op);
  2805. if (unlikely(!res))
  2806. return -1;
  2807. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  2808. Py_INCREF(op->defaults_tuple);
  2809. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  2810. Py_INCREF(op->defaults_kwdict);
  2811. Py_DECREF(res);
  2812. return 0;
  2813. }
  2814. static int
  2815. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
  2816. PyObject* tmp;
  2817. if (!value) {
  2818. value = Py_None;
  2819. } else if (value != Py_None && !PyTuple_Check(value)) {
  2820. PyErr_SetString(PyExc_TypeError,
  2821. "__defaults__ must be set to a tuple object");
  2822. return -1;
  2823. }
  2824. Py_INCREF(value);
  2825. tmp = op->defaults_tuple;
  2826. op->defaults_tuple = value;
  2827. Py_XDECREF(tmp);
  2828. return 0;
  2829. }
  2830. static PyObject *
  2831. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
  2832. PyObject* result = op->defaults_tuple;
  2833. if (unlikely(!result)) {
  2834. if (op->defaults_getter) {
  2835. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  2836. result = op->defaults_tuple;
  2837. } else {
  2838. result = Py_None;
  2839. }
  2840. }
  2841. Py_INCREF(result);
  2842. return result;
  2843. }
  2844. static int
  2845. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
  2846. PyObject* tmp;
  2847. if (!value) {
  2848. value = Py_None;
  2849. } else if (value != Py_None && !PyDict_Check(value)) {
  2850. PyErr_SetString(PyExc_TypeError,
  2851. "__kwdefaults__ must be set to a dict object");
  2852. return -1;
  2853. }
  2854. Py_INCREF(value);
  2855. tmp = op->defaults_kwdict;
  2856. op->defaults_kwdict = value;
  2857. Py_XDECREF(tmp);
  2858. return 0;
  2859. }
  2860. static PyObject *
  2861. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
  2862. PyObject* result = op->defaults_kwdict;
  2863. if (unlikely(!result)) {
  2864. if (op->defaults_getter) {
  2865. if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
  2866. result = op->defaults_kwdict;
  2867. } else {
  2868. result = Py_None;
  2869. }
  2870. }
  2871. Py_INCREF(result);
  2872. return result;
  2873. }
  2874. static int
  2875. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
  2876. PyObject* tmp;
  2877. if (!value || value == Py_None) {
  2878. value = NULL;
  2879. } else if (!PyDict_Check(value)) {
  2880. PyErr_SetString(PyExc_TypeError,
  2881. "__annotations__ must be set to a dict object");
  2882. return -1;
  2883. }
  2884. Py_XINCREF(value);
  2885. tmp = op->func_annotations;
  2886. op->func_annotations = value;
  2887. Py_XDECREF(tmp);
  2888. return 0;
  2889. }
  2890. static PyObject *
  2891. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
  2892. PyObject* result = op->func_annotations;
  2893. if (unlikely(!result)) {
  2894. result = PyDict_New();
  2895. if (unlikely(!result)) return NULL;
  2896. op->func_annotations = result;
  2897. }
  2898. Py_INCREF(result);
  2899. return result;
  2900. }
  2901. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  2902. {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  2903. {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  2904. {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  2905. {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  2906. {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  2907. {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
  2908. {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  2909. {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
  2910. {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  2911. {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  2912. {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  2913. {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  2914. {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  2915. {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  2916. {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  2917. {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  2918. {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  2919. {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  2920. {0, 0, 0, 0, 0}
  2921. };
  2922. #ifndef PY_WRITE_RESTRICTED /* < Py2.5 */
  2923. #define PY_WRITE_RESTRICTED WRITE_RESTRICTED
  2924. #endif
  2925. static PyMemberDef __pyx_CyFunction_members[] = {
  2926. {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
  2927. {0, 0, 0, 0, 0}
  2928. };
  2929. static PyObject *
  2930. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
  2931. {
  2932. #if PY_MAJOR_VERSION >= 3
  2933. return PyUnicode_FromString(m->func.m_ml->ml_name);
  2934. #else
  2935. return PyString_FromString(m->func.m_ml->ml_name);
  2936. #endif
  2937. }
  2938. static PyMethodDef __pyx_CyFunction_methods[] = {
  2939. {__Pyx_NAMESTR("__reduce__"), (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  2940. {0, 0, 0, 0}
  2941. };
  2942. static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
  2943. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  2944. __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
  2945. if (op == NULL)
  2946. return NULL;
  2947. op->flags = flags;
  2948. op->func_weakreflist = NULL;
  2949. op->func.m_ml = ml;
  2950. op->func.m_self = (PyObject *) op;
  2951. Py_XINCREF(closure);
  2952. op->func_closure = closure;
  2953. Py_XINCREF(module);
  2954. op->func.m_module = module;
  2955. op->func_dict = NULL;
  2956. op->func_name = NULL;
  2957. Py_INCREF(qualname);
  2958. op->func_qualname = qualname;
  2959. op->func_doc = NULL;
  2960. op->func_classobj = NULL;
  2961. op->func_globals = globals;
  2962. Py_INCREF(op->func_globals);
  2963. Py_XINCREF(code);
  2964. op->func_code = code;
  2965. op->defaults_pyobjects = 0;
  2966. op->defaults = NULL;
  2967. op->defaults_tuple = NULL;
  2968. op->defaults_kwdict = NULL;
  2969. op->defaults_getter = NULL;
  2970. op->func_annotations = NULL;
  2971. PyObject_GC_Track(op);
  2972. return (PyObject *) op;
  2973. }
  2974. static int
  2975. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  2976. {
  2977. Py_CLEAR(m->func_closure);
  2978. Py_CLEAR(m->func.m_module);
  2979. Py_CLEAR(m->func_dict);
  2980. Py_CLEAR(m->func_name);
  2981. Py_CLEAR(m->func_qualname);
  2982. Py_CLEAR(m->func_doc);
  2983. Py_CLEAR(m->func_globals);
  2984. Py_CLEAR(m->func_code);
  2985. Py_CLEAR(m->func_classobj);
  2986. Py_CLEAR(m->defaults_tuple);
  2987. Py_CLEAR(m->defaults_kwdict);
  2988. Py_CLEAR(m->func_annotations);
  2989. if (m->defaults) {
  2990. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  2991. int i;
  2992. for (i = 0; i < m->defaults_pyobjects; i++)
  2993. Py_XDECREF(pydefaults[i]);
  2994. PyMem_Free(m->defaults);
  2995. m->defaults = NULL;
  2996. }
  2997. return 0;
  2998. }
  2999. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  3000. {
  3001. PyObject_GC_UnTrack(m);
  3002. if (m->func_weakreflist != NULL)
  3003. PyObject_ClearWeakRefs((PyObject *) m);
  3004. __Pyx_CyFunction_clear(m);
  3005. PyObject_GC_Del(m);
  3006. }
  3007. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  3008. {
  3009. Py_VISIT(m->func_closure);
  3010. Py_VISIT(m->func.m_module);
  3011. Py_VISIT(m->func_dict);
  3012. Py_VISIT(m->func_name);
  3013. Py_VISIT(m->func_qualname);
  3014. Py_VISIT(m->func_doc);
  3015. Py_VISIT(m->func_globals);
  3016. Py_VISIT(m->func_code);
  3017. Py_VISIT(m->func_classobj);
  3018. Py_VISIT(m->defaults_tuple);
  3019. Py_VISIT(m->defaults_kwdict);
  3020. if (m->defaults) {
  3021. PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
  3022. int i;
  3023. for (i = 0; i < m->defaults_pyobjects; i++)
  3024. Py_VISIT(pydefaults[i]);
  3025. }
  3026. return 0;
  3027. }
  3028. static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
  3029. {
  3030. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  3031. if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
  3032. Py_INCREF(func);
  3033. return func;
  3034. }
  3035. if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
  3036. if (type == NULL)
  3037. type = (PyObject *)(Py_TYPE(obj));
  3038. return PyMethod_New(func,
  3039. type, (PyObject *)(Py_TYPE(type)));
  3040. }
  3041. if (obj == Py_None)
  3042. obj = NULL;
  3043. return PyMethod_New(func, obj, type);
  3044. }
  3045. static PyObject*
  3046. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  3047. {
  3048. #if PY_MAJOR_VERSION >= 3
  3049. return PyUnicode_FromFormat("<cyfunction %U at %p>",
  3050. op->func_qualname, (void *)op);
  3051. #else
  3052. return PyString_FromFormat("<cyfunction %s at %p>",
  3053. PyString_AsString(op->func_qualname), (void *)op);
  3054. #endif
  3055. }
  3056. #if CYTHON_COMPILING_IN_PYPY
  3057. static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  3058. PyCFunctionObject* f = (PyCFunctionObject*)func;
  3059. PyCFunction meth = PyCFunction_GET_FUNCTION(func);
  3060. PyObject *self = PyCFunction_GET_SELF(func);
  3061. Py_ssize_t size;
  3062. switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
  3063. case METH_VARARGS:
  3064. if (likely(kw == NULL) || PyDict_Size(kw) == 0)
  3065. return (*meth)(self, arg);
  3066. break;
  3067. case METH_VARARGS | METH_KEYWORDS:
  3068. return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
  3069. case METH_NOARGS:
  3070. if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
  3071. size = PyTuple_GET_SIZE(arg);
  3072. if (size == 0)
  3073. return (*meth)(self, NULL);
  3074. PyErr_Format(PyExc_TypeError,
  3075. "%.200s() takes no arguments (%zd given)",
  3076. f->m_ml->ml_name, size);
  3077. return NULL;
  3078. }
  3079. break;
  3080. case METH_O:
  3081. if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
  3082. size = PyTuple_GET_SIZE(arg);
  3083. if (size == 1)
  3084. return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
  3085. PyErr_Format(PyExc_TypeError,
  3086. "%.200s() takes exactly one argument (%zd given)",
  3087. f->m_ml->ml_name, size);
  3088. return NULL;
  3089. }
  3090. break;
  3091. default:
  3092. PyErr_SetString(PyExc_SystemError, "Bad call flags in "
  3093. "__Pyx_CyFunction_Call. METH_OLDARGS is no "
  3094. "longer supported!");
  3095. return NULL;
  3096. }
  3097. PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
  3098. f->m_ml->ml_name);
  3099. return NULL;
  3100. }
  3101. #else
  3102. static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  3103. return PyCFunction_Call(func, arg, kw);
  3104. }
  3105. #endif
  3106. static PyTypeObject __pyx_CyFunctionType_type = {
  3107. PyVarObject_HEAD_INIT(0, 0)
  3108. __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/
  3109. sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/
  3110. 0, /*tp_itemsize*/
  3111. (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/
  3112. 0, /*tp_print*/
  3113. 0, /*tp_getattr*/
  3114. 0, /*tp_setattr*/
  3115. #if PY_MAJOR_VERSION < 3
  3116. 0, /*tp_compare*/
  3117. #else
  3118. 0, /*reserved*/
  3119. #endif
  3120. (reprfunc) __Pyx_CyFunction_repr, /*tp_repr*/
  3121. 0, /*tp_as_number*/
  3122. 0, /*tp_as_sequence*/
  3123. 0, /*tp_as_mapping*/
  3124. 0, /*tp_hash*/
  3125. __Pyx_CyFunction_Call, /*tp_call*/
  3126. 0, /*tp_str*/
  3127. 0, /*tp_getattro*/
  3128. 0, /*tp_setattro*/
  3129. 0, /*tp_as_buffer*/
  3130. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/
  3131. 0, /*tp_doc*/
  3132. (traverseproc) __Pyx_CyFunction_traverse, /*tp_traverse*/
  3133. (inquiry) __Pyx_CyFunction_clear, /*tp_clear*/
  3134. 0, /*tp_richcompare*/
  3135. offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */
  3136. 0, /*tp_iter*/
  3137. 0, /*tp_iternext*/
  3138. __pyx_CyFunction_methods, /*tp_methods*/
  3139. __pyx_CyFunction_members, /*tp_members*/
  3140. __pyx_CyFunction_getsets, /*tp_getset*/
  3141. 0, /*tp_base*/
  3142. 0, /*tp_dict*/
  3143. __Pyx_CyFunction_descr_get, /*tp_descr_get*/
  3144. 0, /*tp_descr_set*/
  3145. offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/
  3146. 0, /*tp_init*/
  3147. 0, /*tp_alloc*/
  3148. 0, /*tp_new*/
  3149. 0, /*tp_free*/
  3150. 0, /*tp_is_gc*/
  3151. 0, /*tp_bases*/
  3152. 0, /*tp_mro*/
  3153. 0, /*tp_cache*/
  3154. 0, /*tp_subclasses*/
  3155. 0, /*tp_weaklist*/
  3156. 0, /*tp_del*/
  3157. #if PY_VERSION_HEX >= 0x02060000
  3158. 0, /*tp_version_tag*/
  3159. #endif
  3160. #if PY_VERSION_HEX >= 0x030400a1
  3161. 0, /*tp_finalize*/
  3162. #endif
  3163. };
  3164. static int __Pyx_CyFunction_init(void) {
  3165. #if !CYTHON_COMPILING_IN_PYPY
  3166. __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
  3167. #endif
  3168. __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
  3169. if (__pyx_CyFunctionType == NULL) {
  3170. return -1;
  3171. }
  3172. return 0;
  3173. }
  3174. static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
  3175. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  3176. m->defaults = PyMem_Malloc(size);
  3177. if (!m->defaults)
  3178. return PyErr_NoMemory();
  3179. memset(m->defaults, 0, size);
  3180. m->defaults_pyobjects = pyobjects;
  3181. return m->defaults;
  3182. }
  3183. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  3184. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  3185. m->defaults_tuple = tuple;
  3186. Py_INCREF(tuple);
  3187. }
  3188. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  3189. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  3190. m->defaults_kwdict = dict;
  3191. Py_INCREF(dict);
  3192. }
  3193. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  3194. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  3195. m->func_annotations = dict;
  3196. Py_INCREF(dict);
  3197. }
  3198. static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
  3199. PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
  3200. PyObject *ns;
  3201. if (metaclass) {
  3202. PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
  3203. if (prep) {
  3204. PyObject *pargs = PyTuple_Pack(2, name, bases);
  3205. if (unlikely(!pargs)) {
  3206. Py_DECREF(prep);
  3207. return NULL;
  3208. }
  3209. ns = PyObject_Call(prep, pargs, mkw);
  3210. Py_DECREF(prep);
  3211. Py_DECREF(pargs);
  3212. } else {
  3213. if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
  3214. return NULL;
  3215. PyErr_Clear();
  3216. ns = PyDict_New();
  3217. }
  3218. } else {
  3219. ns = PyDict_New();
  3220. }
  3221. if (unlikely(!ns))
  3222. return NULL;
  3223. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
  3224. if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
  3225. if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
  3226. return ns;
  3227. bad:
  3228. Py_DECREF(ns);
  3229. return NULL;
  3230. }
  3231. static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
  3232. PyObject *dict, PyObject *mkw,
  3233. int calculate_metaclass, int allow_py2_metaclass) {
  3234. PyObject *result, *margs;
  3235. PyObject *owned_metaclass = NULL;
  3236. if (allow_py2_metaclass) {
  3237. owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
  3238. if (owned_metaclass) {
  3239. metaclass = owned_metaclass;
  3240. } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
  3241. PyErr_Clear();
  3242. } else {
  3243. return NULL;
  3244. }
  3245. }
  3246. if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
  3247. metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
  3248. Py_XDECREF(owned_metaclass);
  3249. if (unlikely(!metaclass))
  3250. return NULL;
  3251. owned_metaclass = metaclass;
  3252. }
  3253. margs = PyTuple_Pack(3, name, bases, dict);
  3254. if (unlikely(!margs)) {
  3255. result = NULL;
  3256. } else {
  3257. result = PyObject_Call(metaclass, margs, mkw);
  3258. Py_DECREF(margs);
  3259. }
  3260. Py_XDECREF(owned_metaclass);
  3261. return result;
  3262. }
  3263. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  3264. #if CYTHON_COMPILING_IN_PYPY
  3265. return PyObject_RichCompareBool(s1, s2, equals);
  3266. #else
  3267. if (s1 == s2) {
  3268. return (equals == Py_EQ);
  3269. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  3270. const char *ps1, *ps2;
  3271. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  3272. if (length != PyBytes_GET_SIZE(s2))
  3273. return (equals == Py_NE);
  3274. ps1 = PyBytes_AS_STRING(s1);
  3275. ps2 = PyBytes_AS_STRING(s2);
  3276. if (ps1[0] != ps2[0]) {
  3277. return (equals == Py_NE);
  3278. } else if (length == 1) {
  3279. return (equals == Py_EQ);
  3280. } else {
  3281. int result = memcmp(ps1, ps2, (size_t)length);
  3282. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  3283. }
  3284. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  3285. return (equals == Py_NE);
  3286. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  3287. return (equals == Py_NE);
  3288. } else {
  3289. int result;
  3290. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  3291. if (!py_result)
  3292. return -1;
  3293. result = __Pyx_PyObject_IsTrue(py_result);
  3294. Py_DECREF(py_result);
  3295. return result;
  3296. }
  3297. #endif
  3298. }
  3299. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  3300. #if CYTHON_COMPILING_IN_PYPY
  3301. return PyObject_RichCompareBool(s1, s2, equals);
  3302. #else
  3303. #if PY_MAJOR_VERSION < 3
  3304. PyObject* owned_ref = NULL;
  3305. #endif
  3306. int s1_is_unicode, s2_is_unicode;
  3307. if (s1 == s2) {
  3308. goto return_eq;
  3309. }
  3310. s1_is_unicode = PyUnicode_CheckExact(s1);
  3311. s2_is_unicode = PyUnicode_CheckExact(s2);
  3312. #if PY_MAJOR_VERSION < 3
  3313. if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
  3314. owned_ref = PyUnicode_FromObject(s2);
  3315. if (unlikely(!owned_ref))
  3316. return -1;
  3317. s2 = owned_ref;
  3318. s2_is_unicode = 1;
  3319. } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
  3320. owned_ref = PyUnicode_FromObject(s1);
  3321. if (unlikely(!owned_ref))
  3322. return -1;
  3323. s1 = owned_ref;
  3324. s1_is_unicode = 1;
  3325. } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
  3326. return __Pyx_PyBytes_Equals(s1, s2, equals);
  3327. }
  3328. #endif
  3329. if (s1_is_unicode & s2_is_unicode) {
  3330. Py_ssize_t length;
  3331. int kind;
  3332. void *data1, *data2;
  3333. #if CYTHON_PEP393_ENABLED
  3334. if (unlikely(PyUnicode_READY(s1) < 0) || unlikely(PyUnicode_READY(s2) < 0))
  3335. return -1;
  3336. #endif
  3337. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  3338. if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
  3339. goto return_ne;
  3340. }
  3341. kind = __Pyx_PyUnicode_KIND(s1);
  3342. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  3343. goto return_ne;
  3344. }
  3345. data1 = __Pyx_PyUnicode_DATA(s1);
  3346. data2 = __Pyx_PyUnicode_DATA(s2);
  3347. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  3348. goto return_ne;
  3349. } else if (length == 1) {
  3350. goto return_eq;
  3351. } else {
  3352. int result = memcmp(data1, data2, length * kind);
  3353. #if PY_MAJOR_VERSION < 3
  3354. Py_XDECREF(owned_ref);
  3355. #endif
  3356. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  3357. }
  3358. } else if ((s1 == Py_None) & s2_is_unicode) {
  3359. goto return_ne;
  3360. } else if ((s2 == Py_None) & s1_is_unicode) {
  3361. goto return_ne;
  3362. } else {
  3363. int result;
  3364. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  3365. if (!py_result)
  3366. return -1;
  3367. result = __Pyx_PyObject_IsTrue(py_result);
  3368. Py_DECREF(py_result);
  3369. return result;
  3370. }
  3371. return_eq:
  3372. #if PY_MAJOR_VERSION < 3
  3373. Py_XDECREF(owned_ref);
  3374. #endif
  3375. return (equals == Py_EQ);
  3376. return_ne:
  3377. #if PY_MAJOR_VERSION < 3
  3378. Py_XDECREF(owned_ref);
  3379. #endif
  3380. return (equals == Py_NE);
  3381. #endif
  3382. }
  3383. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  3384. PyObject *empty_list = 0;
  3385. PyObject *module = 0;
  3386. PyObject *global_dict = 0;
  3387. PyObject *empty_dict = 0;
  3388. PyObject *list;
  3389. #if PY_VERSION_HEX < 0x03030000
  3390. PyObject *py_import;
  3391. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  3392. if (!py_import)
  3393. goto bad;
  3394. #endif
  3395. if (from_list)
  3396. list = from_list;
  3397. else {
  3398. empty_list = PyList_New(0);
  3399. if (!empty_list)
  3400. goto bad;
  3401. list = empty_list;
  3402. }
  3403. global_dict = PyModule_GetDict(__pyx_m);
  3404. if (!global_dict)
  3405. goto bad;
  3406. empty_dict = PyDict_New();
  3407. if (!empty_dict)
  3408. goto bad;
  3409. #if PY_VERSION_HEX >= 0x02050000
  3410. {
  3411. #if PY_MAJOR_VERSION >= 3
  3412. if (level == -1) {
  3413. if (strchr(__Pyx_MODULE_NAME, '.')) {
  3414. #if PY_VERSION_HEX < 0x03030000
  3415. PyObject *py_level = PyInt_FromLong(1);
  3416. if (!py_level)
  3417. goto bad;
  3418. module = PyObject_CallFunctionObjArgs(py_import,
  3419. name, global_dict, empty_dict, list, py_level, NULL);
  3420. Py_DECREF(py_level);
  3421. #else
  3422. module = PyImport_ImportModuleLevelObject(
  3423. name, global_dict, empty_dict, list, 1);
  3424. #endif
  3425. if (!module) {
  3426. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  3427. goto bad;
  3428. PyErr_Clear();
  3429. }
  3430. }
  3431. level = 0; /* try absolute import on failure */
  3432. }
  3433. #endif
  3434. if (!module) {
  3435. #if PY_VERSION_HEX < 0x03030000
  3436. PyObject *py_level = PyInt_FromLong(level);
  3437. if (!py_level)
  3438. goto bad;
  3439. module = PyObject_CallFunctionObjArgs(py_import,
  3440. name, global_dict, empty_dict, list, py_level, NULL);
  3441. Py_DECREF(py_level);
  3442. #else
  3443. module = PyImport_ImportModuleLevelObject(
  3444. name, global_dict, empty_dict, list, level);
  3445. #endif
  3446. }
  3447. }
  3448. #else
  3449. if (level>0) {
  3450. PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
  3451. goto bad;
  3452. }
  3453. module = PyObject_CallFunctionObjArgs(py_import,
  3454. name, global_dict, empty_dict, list, NULL);
  3455. #endif
  3456. bad:
  3457. #if PY_VERSION_HEX < 0x03030000
  3458. Py_XDECREF(py_import);
  3459. #endif
  3460. Py_XDECREF(empty_list);
  3461. Py_XDECREF(empty_dict);
  3462. return module;
  3463. }
  3464. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  3465. const long neg_one = (long) -1, const_zero = 0;
  3466. const int is_unsigned = neg_one > const_zero;
  3467. if (is_unsigned) {
  3468. if (sizeof(long) < sizeof(long)) {
  3469. return PyInt_FromLong((long) value);
  3470. } else if (sizeof(long) <= sizeof(unsigned long)) {
  3471. return PyLong_FromUnsignedLong((unsigned long) value);
  3472. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  3473. return PyLong_FromUnsignedLongLong((unsigned long long) value);
  3474. }
  3475. } else {
  3476. if (sizeof(long) <= sizeof(long)) {
  3477. return PyInt_FromLong((long) value);
  3478. } else if (sizeof(long) <= sizeof(long long)) {
  3479. return PyLong_FromLongLong((long long) value);
  3480. }
  3481. }
  3482. {
  3483. int one = 1; int little = (int)*(unsigned char *)&one;
  3484. unsigned char *bytes = (unsigned char *)&value;
  3485. return _PyLong_FromByteArray(bytes, sizeof(long),
  3486. little, !is_unsigned);
  3487. }
  3488. }
  3489. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \
  3490. { \
  3491. func_type value = func(x); \
  3492. if (sizeof(target_type) < sizeof(func_type)) { \
  3493. if (unlikely(value != (func_type) (target_type) value)) { \
  3494. func_type zero = 0; \
  3495. PyErr_SetString(PyExc_OverflowError, \
  3496. (is_unsigned && unlikely(value < zero)) ? \
  3497. "can't convert negative value to " #target_type : \
  3498. "value too large to convert to " #target_type); \
  3499. return (target_type) -1; \
  3500. } \
  3501. } \
  3502. return (target_type) value; \
  3503. }
  3504. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  3505. #if CYTHON_USE_PYLONG_INTERNALS
  3506. #include "longintrepr.h"
  3507. #endif
  3508. #endif
  3509. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  3510. const long neg_one = (long) -1, const_zero = 0;
  3511. const int is_unsigned = neg_one > const_zero;
  3512. #if PY_MAJOR_VERSION < 3
  3513. if (likely(PyInt_Check(x))) {
  3514. if (sizeof(long) < sizeof(long)) {
  3515. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG)
  3516. } else {
  3517. long val = PyInt_AS_LONG(x);
  3518. if (is_unsigned && unlikely(val < 0)) {
  3519. PyErr_SetString(PyExc_OverflowError,
  3520. "can't convert negative value to long");
  3521. return (long) -1;
  3522. }
  3523. return (long) val;
  3524. }
  3525. } else
  3526. #endif
  3527. if (likely(PyLong_Check(x))) {
  3528. if (is_unsigned) {
  3529. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  3530. #if CYTHON_USE_PYLONG_INTERNALS
  3531. if (sizeof(digit) <= sizeof(long)) {
  3532. switch (Py_SIZE(x)) {
  3533. case 0: return 0;
  3534. case 1: return (long) ((PyLongObject*)x)->ob_digit[0];
  3535. }
  3536. }
  3537. #endif
  3538. #endif
  3539. if (unlikely(Py_SIZE(x) < 0)) {
  3540. PyErr_SetString(PyExc_OverflowError,
  3541. "can't convert negative value to long");
  3542. return (long) -1;
  3543. }
  3544. if (sizeof(long) <= sizeof(unsigned long)) {
  3545. __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong)
  3546. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  3547. __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong)
  3548. }
  3549. } else {
  3550. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  3551. #if CYTHON_USE_PYLONG_INTERNALS
  3552. if (sizeof(digit) <= sizeof(long)) {
  3553. switch (Py_SIZE(x)) {
  3554. case 0: return 0;
  3555. case 1: return +(long) ((PyLongObject*)x)->ob_digit[0];
  3556. case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
  3557. }
  3558. }
  3559. #endif
  3560. #endif
  3561. if (sizeof(long) <= sizeof(long)) {
  3562. __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong)
  3563. } else if (sizeof(long) <= sizeof(long long)) {
  3564. __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong)
  3565. }
  3566. }
  3567. {
  3568. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  3569. PyErr_SetString(PyExc_RuntimeError,
  3570. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  3571. #else
  3572. long val;
  3573. PyObject *v = __Pyx_PyNumber_Int(x);
  3574. #if PY_MAJOR_VERSION < 3
  3575. if (likely(v) && !PyLong_Check(v)) {
  3576. PyObject *tmp = v;
  3577. v = PyNumber_Long(tmp);
  3578. Py_DECREF(tmp);
  3579. }
  3580. #endif
  3581. if (likely(v)) {
  3582. int one = 1; int is_little = (int)*(unsigned char *)&one;
  3583. unsigned char *bytes = (unsigned char *)&val;
  3584. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  3585. bytes, sizeof(val),
  3586. is_little, !is_unsigned);
  3587. Py_DECREF(v);
  3588. if (likely(!ret))
  3589. return val;
  3590. }
  3591. #endif
  3592. return (long) -1;
  3593. }
  3594. } else {
  3595. long val;
  3596. PyObject *tmp = __Pyx_PyNumber_Int(x);
  3597. if (!tmp) return (long) -1;
  3598. val = __Pyx_PyInt_As_long(tmp);
  3599. Py_DECREF(tmp);
  3600. return val;
  3601. }
  3602. }
  3603. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  3604. #if CYTHON_USE_PYLONG_INTERNALS
  3605. #include "longintrepr.h"
  3606. #endif
  3607. #endif
  3608. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  3609. const int neg_one = (int) -1, const_zero = 0;
  3610. const int is_unsigned = neg_one > const_zero;
  3611. #if PY_MAJOR_VERSION < 3
  3612. if (likely(PyInt_Check(x))) {
  3613. if (sizeof(int) < sizeof(long)) {
  3614. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG)
  3615. } else {
  3616. long val = PyInt_AS_LONG(x);
  3617. if (is_unsigned && unlikely(val < 0)) {
  3618. PyErr_SetString(PyExc_OverflowError,
  3619. "can't convert negative value to int");
  3620. return (int) -1;
  3621. }
  3622. return (int) val;
  3623. }
  3624. } else
  3625. #endif
  3626. if (likely(PyLong_Check(x))) {
  3627. if (is_unsigned) {
  3628. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  3629. #if CYTHON_USE_PYLONG_INTERNALS
  3630. if (sizeof(digit) <= sizeof(int)) {
  3631. switch (Py_SIZE(x)) {
  3632. case 0: return 0;
  3633. case 1: return (int) ((PyLongObject*)x)->ob_digit[0];
  3634. }
  3635. }
  3636. #endif
  3637. #endif
  3638. if (unlikely(Py_SIZE(x) < 0)) {
  3639. PyErr_SetString(PyExc_OverflowError,
  3640. "can't convert negative value to int");
  3641. return (int) -1;
  3642. }
  3643. if (sizeof(int) <= sizeof(unsigned long)) {
  3644. __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong)
  3645. } else if (sizeof(int) <= sizeof(unsigned long long)) {
  3646. __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong)
  3647. }
  3648. } else {
  3649. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  3650. #if CYTHON_USE_PYLONG_INTERNALS
  3651. if (sizeof(digit) <= sizeof(int)) {
  3652. switch (Py_SIZE(x)) {
  3653. case 0: return 0;
  3654. case 1: return +(int) ((PyLongObject*)x)->ob_digit[0];
  3655. case -1: return -(int) ((PyLongObject*)x)->ob_digit[0];
  3656. }
  3657. }
  3658. #endif
  3659. #endif
  3660. if (sizeof(int) <= sizeof(long)) {
  3661. __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong)
  3662. } else if (sizeof(int) <= sizeof(long long)) {
  3663. __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong)
  3664. }
  3665. }
  3666. {
  3667. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  3668. PyErr_SetString(PyExc_RuntimeError,
  3669. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  3670. #else
  3671. int val;
  3672. PyObject *v = __Pyx_PyNumber_Int(x);
  3673. #if PY_MAJOR_VERSION < 3
  3674. if (likely(v) && !PyLong_Check(v)) {
  3675. PyObject *tmp = v;
  3676. v = PyNumber_Long(tmp);
  3677. Py_DECREF(tmp);
  3678. }
  3679. #endif
  3680. if (likely(v)) {
  3681. int one = 1; int is_little = (int)*(unsigned char *)&one;
  3682. unsigned char *bytes = (unsigned char *)&val;
  3683. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  3684. bytes, sizeof(val),
  3685. is_little, !is_unsigned);
  3686. Py_DECREF(v);
  3687. if (likely(!ret))
  3688. return val;
  3689. }
  3690. #endif
  3691. return (int) -1;
  3692. }
  3693. } else {
  3694. int val;
  3695. PyObject *tmp = __Pyx_PyNumber_Int(x);
  3696. if (!tmp) return (int) -1;
  3697. val = __Pyx_PyInt_As_int(tmp);
  3698. Py_DECREF(tmp);
  3699. return val;
  3700. }
  3701. }
  3702. static int __Pyx_check_binary_version(void) {
  3703. char ctversion[4], rtversion[4];
  3704. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  3705. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  3706. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  3707. char message[200];
  3708. PyOS_snprintf(message, sizeof(message),
  3709. "compiletime version %s of module '%.100s' "
  3710. "does not match runtime version %s",
  3711. ctversion, __Pyx_MODULE_NAME, rtversion);
  3712. #if PY_VERSION_HEX < 0x02050000
  3713. return PyErr_Warn(NULL, message);
  3714. #else
  3715. return PyErr_WarnEx(NULL, message, 1);
  3716. #endif
  3717. }
  3718. return 0;
  3719. }
  3720. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  3721. int start = 0, mid = 0, end = count - 1;
  3722. if (end >= 0 && code_line > entries[end].code_line) {
  3723. return count;
  3724. }
  3725. while (start < end) {
  3726. mid = (start + end) / 2;
  3727. if (code_line < entries[mid].code_line) {
  3728. end = mid;
  3729. } else if (code_line > entries[mid].code_line) {
  3730. start = mid + 1;
  3731. } else {
  3732. return mid;
  3733. }
  3734. }
  3735. if (code_line <= entries[mid].code_line) {
  3736. return mid;
  3737. } else {
  3738. return mid + 1;
  3739. }
  3740. }
  3741. static PyCodeObject *__pyx_find_code_object(int code_line) {
  3742. PyCodeObject* code_object;
  3743. int pos;
  3744. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  3745. return NULL;
  3746. }
  3747. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  3748. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  3749. return NULL;
  3750. }
  3751. code_object = __pyx_code_cache.entries[pos].code_object;
  3752. Py_INCREF(code_object);
  3753. return code_object;
  3754. }
  3755. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  3756. int pos, i;
  3757. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  3758. if (unlikely(!code_line)) {
  3759. return;
  3760. }
  3761. if (unlikely(!entries)) {
  3762. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  3763. if (likely(entries)) {
  3764. __pyx_code_cache.entries = entries;
  3765. __pyx_code_cache.max_count = 64;
  3766. __pyx_code_cache.count = 1;
  3767. entries[0].code_line = code_line;
  3768. entries[0].code_object = code_object;
  3769. Py_INCREF(code_object);
  3770. }
  3771. return;
  3772. }
  3773. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  3774. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  3775. PyCodeObject* tmp = entries[pos].code_object;
  3776. entries[pos].code_object = code_object;
  3777. Py_DECREF(tmp);
  3778. return;
  3779. }
  3780. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  3781. int new_max = __pyx_code_cache.max_count + 64;
  3782. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  3783. __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  3784. if (unlikely(!entries)) {
  3785. return;
  3786. }
  3787. __pyx_code_cache.entries = entries;
  3788. __pyx_code_cache.max_count = new_max;
  3789. }
  3790. for (i=__pyx_code_cache.count; i>pos; i--) {
  3791. entries[i] = entries[i-1];
  3792. }
  3793. entries[pos].code_line = code_line;
  3794. entries[pos].code_object = code_object;
  3795. __pyx_code_cache.count++;
  3796. Py_INCREF(code_object);
  3797. }
  3798. #include "compile.h"
  3799. #include "frameobject.h"
  3800. #include "traceback.h"
  3801. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  3802. const char *funcname, int c_line,
  3803. int py_line, const char *filename) {
  3804. PyCodeObject *py_code = 0;
  3805. PyObject *py_srcfile = 0;
  3806. PyObject *py_funcname = 0;
  3807. #if PY_MAJOR_VERSION < 3
  3808. py_srcfile = PyString_FromString(filename);
  3809. #else
  3810. py_srcfile = PyUnicode_FromString(filename);
  3811. #endif
  3812. if (!py_srcfile) goto bad;
  3813. if (c_line) {
  3814. #if PY_MAJOR_VERSION < 3
  3815. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  3816. #else
  3817. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  3818. #endif
  3819. }
  3820. else {
  3821. #if PY_MAJOR_VERSION < 3
  3822. py_funcname = PyString_FromString(funcname);
  3823. #else
  3824. py_funcname = PyUnicode_FromString(funcname);
  3825. #endif
  3826. }
  3827. if (!py_funcname) goto bad;
  3828. py_code = __Pyx_PyCode_New(
  3829. 0, /*int argcount,*/
  3830. 0, /*int kwonlyargcount,*/
  3831. 0, /*int nlocals,*/
  3832. 0, /*int stacksize,*/
  3833. 0, /*int flags,*/
  3834. __pyx_empty_bytes, /*PyObject *code,*/
  3835. __pyx_empty_tuple, /*PyObject *consts,*/
  3836. __pyx_empty_tuple, /*PyObject *names,*/
  3837. __pyx_empty_tuple, /*PyObject *varnames,*/
  3838. __pyx_empty_tuple, /*PyObject *freevars,*/
  3839. __pyx_empty_tuple, /*PyObject *cellvars,*/
  3840. py_srcfile, /*PyObject *filename,*/
  3841. py_funcname, /*PyObject *name,*/
  3842. py_line, /*int firstlineno,*/
  3843. __pyx_empty_bytes /*PyObject *lnotab*/
  3844. );
  3845. Py_DECREF(py_srcfile);
  3846. Py_DECREF(py_funcname);
  3847. return py_code;
  3848. bad:
  3849. Py_XDECREF(py_srcfile);
  3850. Py_XDECREF(py_funcname);
  3851. return NULL;
  3852. }
  3853. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  3854. int py_line, const char *filename) {
  3855. PyCodeObject *py_code = 0;
  3856. PyObject *py_globals = 0;
  3857. PyFrameObject *py_frame = 0;
  3858. py_code = __pyx_find_code_object(c_line ? c_line : py_line);
  3859. if (!py_code) {
  3860. py_code = __Pyx_CreateCodeObjectForTraceback(
  3861. funcname, c_line, py_line, filename);
  3862. if (!py_code) goto bad;
  3863. __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
  3864. }
  3865. py_globals = PyModule_GetDict(__pyx_m);
  3866. if (!py_globals) goto bad;
  3867. py_frame = PyFrame_New(
  3868. PyThreadState_GET(), /*PyThreadState *tstate,*/
  3869. py_code, /*PyCodeObject *code,*/
  3870. py_globals, /*PyObject *globals,*/
  3871. 0 /*PyObject *locals*/
  3872. );
  3873. if (!py_frame) goto bad;
  3874. py_frame->f_lineno = py_line;
  3875. PyTraceBack_Here(py_frame);
  3876. bad:
  3877. Py_XDECREF(py_code);
  3878. Py_XDECREF(py_frame);
  3879. }
  3880. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  3881. while (t->p) {
  3882. #if PY_MAJOR_VERSION < 3
  3883. if (t->is_unicode) {
  3884. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  3885. } else if (t->intern) {
  3886. *t->p = PyString_InternFromString(t->s);
  3887. } else {
  3888. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  3889. }
  3890. #else /* Python 3+ has unicode identifiers */
  3891. if (t->is_unicode | t->is_str) {
  3892. if (t->intern) {
  3893. *t->p = PyUnicode_InternFromString(t->s);
  3894. } else if (t->encoding) {
  3895. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  3896. } else {
  3897. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  3898. }
  3899. } else {
  3900. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  3901. }
  3902. #endif
  3903. if (!*t->p)
  3904. return -1;
  3905. ++t;
  3906. }
  3907. return 0;
  3908. }
  3909. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
  3910. return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
  3911. }
  3912. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
  3913. Py_ssize_t ignore;
  3914. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  3915. }
  3916. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  3917. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  3918. if (
  3919. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  3920. __Pyx_sys_getdefaultencoding_not_ascii &&
  3921. #endif
  3922. PyUnicode_Check(o)) {
  3923. #if PY_VERSION_HEX < 0x03030000
  3924. char* defenc_c;
  3925. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  3926. if (!defenc) return NULL;
  3927. defenc_c = PyBytes_AS_STRING(defenc);
  3928. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  3929. {
  3930. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  3931. char* c;
  3932. for (c = defenc_c; c < end; c++) {
  3933. if ((unsigned char) (*c) >= 128) {
  3934. PyUnicode_AsASCIIString(o);
  3935. return NULL;
  3936. }
  3937. }
  3938. }
  3939. #endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
  3940. *length = PyBytes_GET_SIZE(defenc);
  3941. return defenc_c;
  3942. #else /* PY_VERSION_HEX < 0x03030000 */
  3943. if (PyUnicode_READY(o) == -1) return NULL;
  3944. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  3945. if (PyUnicode_IS_ASCII(o)) {
  3946. *length = PyUnicode_GET_DATA_SIZE(o);
  3947. return PyUnicode_AsUTF8(o);
  3948. } else {
  3949. PyUnicode_AsASCIIString(o);
  3950. return NULL;
  3951. }
  3952. #else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  3953. return PyUnicode_AsUTF8AndSize(o, length);
  3954. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  3955. #endif /* PY_VERSION_HEX < 0x03030000 */
  3956. } else
  3957. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
  3958. #if !CYTHON_COMPILING_IN_PYPY
  3959. #if PY_VERSION_HEX >= 0x02060000
  3960. if (PyByteArray_Check(o)) {
  3961. *length = PyByteArray_GET_SIZE(o);
  3962. return PyByteArray_AS_STRING(o);
  3963. } else
  3964. #endif
  3965. #endif
  3966. {
  3967. char* result;
  3968. int r = PyBytes_AsStringAndSize(o, &result, length);
  3969. if (unlikely(r < 0)) {
  3970. return NULL;
  3971. } else {
  3972. return result;
  3973. }
  3974. }
  3975. }
  3976. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  3977. int is_true = x == Py_True;
  3978. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  3979. else return PyObject_IsTrue(x);
  3980. }
  3981. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  3982. PyNumberMethods *m;
  3983. const char *name = NULL;
  3984. PyObject *res = NULL;
  3985. #if PY_MAJOR_VERSION < 3
  3986. if (PyInt_Check(x) || PyLong_Check(x))
  3987. #else
  3988. if (PyLong_Check(x))
  3989. #endif
  3990. return Py_INCREF(x), x;
  3991. m = Py_TYPE(x)->tp_as_number;
  3992. #if PY_MAJOR_VERSION < 3
  3993. if (m && m->nb_int) {
  3994. name = "int";
  3995. res = PyNumber_Int(x);
  3996. }
  3997. else if (m && m->nb_long) {
  3998. name = "long";
  3999. res = PyNumber_Long(x);
  4000. }
  4001. #else
  4002. if (m && m->nb_int) {
  4003. name = "int";
  4004. res = PyNumber_Long(x);
  4005. }
  4006. #endif
  4007. if (res) {
  4008. #if PY_MAJOR_VERSION < 3
  4009. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  4010. #else
  4011. if (!PyLong_Check(res)) {
  4012. #endif
  4013. PyErr_Format(PyExc_TypeError,
  4014. "__%.4s__ returned non-%.4s (type %.200s)",
  4015. name, name, Py_TYPE(res)->tp_name);
  4016. Py_DECREF(res);
  4017. return NULL;
  4018. }
  4019. }
  4020. else if (!PyErr_Occurred()) {
  4021. PyErr_SetString(PyExc_TypeError,
  4022. "an integer is required");
  4023. }
  4024. return res;
  4025. }
  4026. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4027. #if CYTHON_USE_PYLONG_INTERNALS
  4028. #include "longintrepr.h"
  4029. #endif
  4030. #endif
  4031. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  4032. Py_ssize_t ival;
  4033. PyObject *x;
  4034. #if PY_MAJOR_VERSION < 3
  4035. if (likely(PyInt_CheckExact(b)))
  4036. return PyInt_AS_LONG(b);
  4037. #endif
  4038. if (likely(PyLong_CheckExact(b))) {
  4039. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4040. #if CYTHON_USE_PYLONG_INTERNALS
  4041. switch (Py_SIZE(b)) {
  4042. case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
  4043. case 0: return 0;
  4044. case 1: return ((PyLongObject*)b)->ob_digit[0];
  4045. }
  4046. #endif
  4047. #endif
  4048. #if PY_VERSION_HEX < 0x02060000
  4049. return PyInt_AsSsize_t(b);
  4050. #else
  4051. return PyLong_AsSsize_t(b);
  4052. #endif
  4053. }
  4054. x = PyNumber_Index(b);
  4055. if (!x) return -1;
  4056. ival = PyInt_AsSsize_t(x);
  4057. Py_DECREF(x);
  4058. return ival;
  4059. }
  4060. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  4061. #if PY_VERSION_HEX < 0x02050000
  4062. if (ival <= LONG_MAX)
  4063. return PyInt_FromLong((long)ival);
  4064. else {
  4065. unsigned char *bytes = (unsigned char *) &ival;
  4066. int one = 1; int little = (int)*(unsigned char*)&one;
  4067. return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
  4068. }
  4069. #else
  4070. return PyInt_FromSize_t(ival);
  4071. #endif
  4072. }
  4073. #endif /* Py_PYTHON_H */