casts.c 222 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294
  1. /* Generated by Cython 0.20.1 on Sun Mar 16 22:58:13 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__casts
  337. #define __PYX_HAVE_API__lib__Naked__toolshed__c__casts
  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. "casts.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. #if CYTHON_COMPILING_IN_CPYTHON
  580. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  581. PyTypeObject* tp = Py_TYPE(obj);
  582. if (likely(tp->tp_getattro))
  583. return tp->tp_getattro(obj, attr_name);
  584. #if PY_MAJOR_VERSION < 3
  585. if (likely(tp->tp_getattr))
  586. return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
  587. #endif
  588. return PyObject_GetAttr(obj, attr_name);
  589. }
  590. #else
  591. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  592. #endif
  593. static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
  594. #ifndef CYTHON_PROFILE
  595. #define CYTHON_PROFILE 1
  596. #endif
  597. #ifndef CYTHON_TRACE
  598. #define CYTHON_TRACE 0
  599. #endif
  600. #if CYTHON_TRACE
  601. #undef CYTHON_PROFILE_REUSE_FRAME
  602. #endif
  603. #ifndef CYTHON_PROFILE_REUSE_FRAME
  604. #define CYTHON_PROFILE_REUSE_FRAME 0
  605. #endif
  606. #if CYTHON_PROFILE || CYTHON_TRACE
  607. #include "compile.h"
  608. #include "frameobject.h"
  609. #include "traceback.h"
  610. #if CYTHON_PROFILE_REUSE_FRAME
  611. #define CYTHON_FRAME_MODIFIER static
  612. #define CYTHON_FRAME_DEL
  613. #else
  614. #define CYTHON_FRAME_MODIFIER
  615. #define CYTHON_FRAME_DEL Py_CLEAR(__pyx_frame)
  616. #endif
  617. #define __Pyx_TraceDeclarations \
  618. static PyCodeObject *__pyx_frame_code = NULL; \
  619. CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL; \
  620. int __Pyx_use_tracing = 0;
  621. #define __Pyx_TraceCall(funcname, srcfile, firstlineno) \
  622. if (unlikely(PyThreadState_GET()->use_tracing && \
  623. (PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc)))) { \
  624. __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, funcname, srcfile, firstlineno); \
  625. }
  626. #define __Pyx_TraceException() \
  627. if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing && \
  628. (PyThreadState_GET()->c_profilefunc || (CYTHON_TRACE && PyThreadState_GET()->c_tracefunc))) { \
  629. PyThreadState* tstate = PyThreadState_GET(); \
  630. tstate->use_tracing = 0; \
  631. PyObject *exc_info = __Pyx_GetExceptionTuple(); \
  632. if (exc_info) { \
  633. if (CYTHON_TRACE && tstate->c_tracefunc) \
  634. tstate->c_tracefunc( \
  635. tstate->c_traceobj, __pyx_frame, PyTrace_EXCEPTION, exc_info); \
  636. tstate->c_profilefunc( \
  637. tstate->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info); \
  638. Py_DECREF(exc_info); \
  639. } \
  640. tstate->use_tracing = 1; \
  641. }
  642. #define __Pyx_TraceReturn(result) \
  643. if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing) { \
  644. PyThreadState* tstate = PyThreadState_GET(); \
  645. tstate->use_tracing = 0; \
  646. if (CYTHON_TRACE && tstate->c_tracefunc) \
  647. tstate->c_tracefunc( \
  648. tstate->c_traceobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result); \
  649. if (tstate->c_profilefunc) \
  650. tstate->c_profilefunc( \
  651. tstate->c_profileobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result); \
  652. CYTHON_FRAME_DEL; \
  653. tstate->use_tracing = 1; \
  654. }
  655. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno); /*proto*/
  656. static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, const char *funcname, const char *srcfile, int firstlineno); /*proto*/
  657. #else
  658. #define __Pyx_TraceDeclarations
  659. #define __Pyx_TraceCall(funcname, srcfile, firstlineno)
  660. #define __Pyx_TraceException()
  661. #define __Pyx_TraceReturn(result)
  662. #endif /* CYTHON_PROFILE */
  663. #if CYTHON_TRACE
  664. #define __Pyx_TraceLine(lineno) \
  665. if (unlikely(__Pyx_use_tracing) && unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_tracefunc)) { \
  666. PyThreadState* tstate = PyThreadState_GET(); \
  667. __pyx_frame->f_lineno = lineno; \
  668. tstate->use_tracing = 0; \
  669. tstate->c_tracefunc(tstate->c_traceobj, __pyx_frame, PyTrace_LINE, NULL); \
  670. tstate->use_tracing = 1; \
  671. }
  672. #else
  673. #define __Pyx_TraceLine(lineno)
  674. #endif
  675. static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  676. static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  677. static void __Pyx_WriteUnraisable(const char *name, int clineno,
  678. int lineno, const char *filename,
  679. int full_traceback); /*proto*/
  680. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
  681. static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
  682. PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
  683. const char* function_name); /*proto*/
  684. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  685. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
  686. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); /*proto*/
  687. #if CYTHON_COMPILING_IN_CPYTHON
  688. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/
  689. #else
  690. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  691. #endif
  692. static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  693. static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
  694. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
  695. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); /*proto*/
  696. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); /*proto*/
  697. #include <string.h>
  698. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  699. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/
  700. #if PY_MAJOR_VERSION >= 3
  701. #define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
  702. #else
  703. #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
  704. #endif
  705. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
  706. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
  707. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
  708. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
  709. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  710. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
  711. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
  712. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
  713. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  714. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  715. int wraparound, int boundscheck);
  716. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
  717. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
  718. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
  719. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  720. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  721. int wraparound, int boundscheck);
  722. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  723. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  724. int is_list, int wraparound, int boundscheck);
  725. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); /*proto*/
  726. static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/
  727. #if CYTHON_COMPILING_IN_PYPY || PY_MAJOR_VERSION >= 3
  728. static PyObject* __pyx_print = 0;
  729. static PyObject* __pyx_print_kwargs = 0;
  730. #endif
  731. static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/
  732. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
  733. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
  734. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
  735. static int __Pyx_check_binary_version(void);
  736. typedef struct {
  737. int code_line;
  738. PyCodeObject* code_object;
  739. } __Pyx_CodeObjectCacheEntry;
  740. struct __Pyx_CodeObjectCache {
  741. int count;
  742. int max_count;
  743. __Pyx_CodeObjectCacheEntry* entries;
  744. };
  745. static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
  746. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  747. static PyCodeObject *__pyx_find_code_object(int code_line);
  748. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
  749. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  750. int py_line, const char *filename); /*proto*/
  751. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
  752. /* Module declarations from 'lib.Naked.toolshed.c.casts' */
  753. #define __Pyx_MODULE_NAME "lib.Naked.toolshed.c.casts"
  754. int __pyx_module_is_main_lib__Naked__toolshed__c__casts = 0;
  755. /* Implementation of 'lib.Naked.toolshed.c.casts' */
  756. static PyObject *__pyx_builtin_Exception;
  757. static PyObject *__pyx_builtin_TypeError;
  758. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_nob(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_attributes); /* proto */
  759. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_2xd(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dictionary_arg, PyObject *__pyx_v_attributes); /* proto */
  760. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_4xl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_list_arg, PyObject *__pyx_v_attributes); /* proto */
  761. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_6xq(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_queue_arg, PyObject *__pyx_v_attributes); /* proto */
  762. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_8xset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_set_arg, PyObject *__pyx_v_attributes); /* proto */
  763. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_10xfset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_set_arg, PyObject *__pyx_v_attributes); /* proto */
  764. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_12xstr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_string_arg, PyObject *__pyx_v_attributes); /* proto */
  765. static char __pyx_k_2[] = "2";
  766. static char __pyx_k_e[] = "e";
  767. static char __pyx_k_te[] = "te";
  768. static char __pyx_k_xd[] = "xd";
  769. static char __pyx_k_xl[] = "xl";
  770. static char __pyx_k_xq[] = "xq";
  771. static char __pyx_k_end[] = "end";
  772. static char __pyx_k_nob[] = "nob";
  773. static char __pyx_k_XSet[] = "XSet";
  774. static char __pyx_k_arg1[] = "arg1";
  775. static char __pyx_k_file[] = "file";
  776. static char __pyx_k_main[] = "__main__";
  777. static char __pyx_k_name[] = "__name__";
  778. static char __pyx_k_test[] = "test";
  779. static char __pyx_k_xset[] = "xset";
  780. static char __pyx_k_xstr[] = "xstr";
  781. static char __pyx_k_XDict[] = "XDict";
  782. static char __pyx_k_XFSet[] = "XFSet";
  783. static char __pyx_k_XList[] = "XList";
  784. static char __pyx_k_debug[] = "debug";
  785. static char __pyx_k_print[] = "print";
  786. static char __pyx_k_xfset[] = "xfset";
  787. static char __pyx_k_A_test[] = "A test";
  788. static char __pyx_k_XQueue[] = "XQueue";
  789. static char __pyx_k_import[] = "__import__";
  790. static char __pyx_k_test_2[] = "__test__";
  791. static char __pyx_k_XString[] = "XString";
  792. static char __pyx_k_set_arg[] = "set_arg";
  793. static char __pyx_k_list_arg[] = "list_arg";
  794. static char __pyx_k_Exception[] = "Exception";
  795. static char __pyx_k_TypeError[] = "TypeError";
  796. static char __pyx_k_queue_arg[] = "queue_arg";
  797. static char __pyx_k_DEBUG_FLAG[] = "DEBUG_FLAG";
  798. static char __pyx_k_attributes[] = "attributes";
  799. static char __pyx_k_string_arg[] = "string_arg";
  800. static char __pyx_k_NakedObject[] = "NakedObject";
  801. static char __pyx_k_Naked_settings[] = "Naked.settings";
  802. static char __pyx_k_dictionary_arg[] = "dictionary_arg";
  803. static char __pyx_k_Naked_toolshed_c_types[] = "Naked.toolshed.c.types";
  804. static char __pyx_k_lib_Naked_toolshed_c_casts[] = "lib.Naked.toolshed.c.casts";
  805. static char __pyx_k_Naked_Framework_Error_unable_to[] = "Naked Framework Error: unable to create a NakedObject with the requested argument using the nobj() function (Naked.toolshed.casts.py).";
  806. static char __pyx_k_Users_ces_Desktop_code_naked_li[] = "/Users/ces/Desktop/code/naked/lib/Naked/toolshed/c/casts.pyx";
  807. static char __pyx_k_Attempted_to_cast_to_a_XDict_wit[] = "Attempted to cast to a XDict with an incompatible type";
  808. static char __pyx_k_Attempted_to_cast_to_a_XList_wit[] = "Attempted to cast to a XList with an incompatible type";
  809. static char __pyx_k_Attempted_to_cast_to_a_XQueue_wi[] = "Attempted to cast to a XQueue with an incompatible type";
  810. static char __pyx_k_Attempted_to_cast_to_a_XSet_with[] = "Attempted to cast to a XSet with an incompatible type";
  811. static char __pyx_k_Attempted_to_cast_to_a_XString_w[] = "Attempted to cast to a XString with an incompatible type";
  812. static char __pyx_k_Naked_Framework_Error_unable_to_2[] = "Naked Framework Error: unable to cast object to a XDict with the xd() function (Naked.toolshed.casts.py).";
  813. static char __pyx_k_Naked_Framework_Error_unable_to_3[] = "Naked Framework Error: unable to cast object to a XList with the xl() function (Naked.toolshed.casts.py).";
  814. static char __pyx_k_Naked_Framework_Error_unable_to_4[] = "Naked Framework Error: unable to cast object to a XQueue with the xq() function (Naked.toolshed.casts.py).";
  815. static char __pyx_k_Naked_Framework_Error_unable_to_5[] = "Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).";
  816. static char __pyx_k_Naked_Framework_Error_unable_to_6[] = "Naked Framework Error: unable to cast object to a XString with the xstr() function (Naked.toolshed.casts.py).";
  817. static PyObject *__pyx_kp_s_2;
  818. static PyObject *__pyx_kp_s_A_test;
  819. static PyObject *__pyx_kp_s_Attempted_to_cast_to_a_XDict_wit;
  820. static PyObject *__pyx_kp_s_Attempted_to_cast_to_a_XList_wit;
  821. static PyObject *__pyx_kp_s_Attempted_to_cast_to_a_XQueue_wi;
  822. static PyObject *__pyx_kp_s_Attempted_to_cast_to_a_XSet_with;
  823. static PyObject *__pyx_kp_s_Attempted_to_cast_to_a_XString_w;
  824. static PyObject *__pyx_n_s_DEBUG_FLAG;
  825. static PyObject *__pyx_n_s_Exception;
  826. static PyObject *__pyx_n_s_NakedObject;
  827. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to;
  828. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_2;
  829. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_3;
  830. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_4;
  831. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_5;
  832. static PyObject *__pyx_kp_s_Naked_Framework_Error_unable_to_6;
  833. static PyObject *__pyx_n_s_Naked_settings;
  834. static PyObject *__pyx_n_s_Naked_toolshed_c_types;
  835. static PyObject *__pyx_n_s_TypeError;
  836. static PyObject *__pyx_kp_s_Users_ces_Desktop_code_naked_li;
  837. static PyObject *__pyx_n_s_XDict;
  838. static PyObject *__pyx_n_s_XFSet;
  839. static PyObject *__pyx_n_s_XList;
  840. static PyObject *__pyx_n_s_XQueue;
  841. static PyObject *__pyx_n_s_XSet;
  842. static PyObject *__pyx_n_s_XString;
  843. static PyObject *__pyx_n_s_arg1;
  844. static PyObject *__pyx_n_s_attributes;
  845. static PyObject *__pyx_n_s_debug;
  846. static PyObject *__pyx_n_s_dictionary_arg;
  847. static PyObject *__pyx_n_s_e;
  848. static PyObject *__pyx_n_s_end;
  849. static PyObject *__pyx_n_s_file;
  850. static PyObject *__pyx_n_s_import;
  851. static PyObject *__pyx_n_s_lib_Naked_toolshed_c_casts;
  852. static PyObject *__pyx_n_s_list_arg;
  853. static PyObject *__pyx_n_s_main;
  854. static PyObject *__pyx_n_s_name;
  855. static PyObject *__pyx_n_s_nob;
  856. static PyObject *__pyx_n_s_print;
  857. static PyObject *__pyx_n_s_queue_arg;
  858. static PyObject *__pyx_n_s_set_arg;
  859. static PyObject *__pyx_n_s_string_arg;
  860. static PyObject *__pyx_n_s_te;
  861. static PyObject *__pyx_n_s_test;
  862. static PyObject *__pyx_n_s_test_2;
  863. static PyObject *__pyx_n_s_xd;
  864. static PyObject *__pyx_n_s_xfset;
  865. static PyObject *__pyx_n_s_xl;
  866. static PyObject *__pyx_n_s_xq;
  867. static PyObject *__pyx_n_s_xset;
  868. static PyObject *__pyx_n_s_xstr;
  869. static PyObject *__pyx_k_;
  870. static PyObject *__pyx_k__2;
  871. static PyObject *__pyx_k__4;
  872. static PyObject *__pyx_k__6;
  873. static PyObject *__pyx_k__8;
  874. static PyObject *__pyx_k__10;
  875. static PyObject *__pyx_k__12;
  876. static PyObject *__pyx_tuple__3;
  877. static PyObject *__pyx_tuple__5;
  878. static PyObject *__pyx_tuple__7;
  879. static PyObject *__pyx_tuple__9;
  880. static PyObject *__pyx_tuple__11;
  881. static PyObject *__pyx_tuple__13;
  882. static PyObject *__pyx_tuple__14;
  883. static PyObject *__pyx_tuple__16;
  884. static PyObject *__pyx_tuple__18;
  885. static PyObject *__pyx_tuple__20;
  886. static PyObject *__pyx_tuple__22;
  887. static PyObject *__pyx_tuple__24;
  888. static PyObject *__pyx_tuple__26;
  889. static PyObject *__pyx_codeobj__15;
  890. static PyObject *__pyx_codeobj__17;
  891. static PyObject *__pyx_codeobj__19;
  892. static PyObject *__pyx_codeobj__21;
  893. static PyObject *__pyx_codeobj__23;
  894. static PyObject *__pyx_codeobj__25;
  895. static PyObject *__pyx_codeobj__27;
  896. /* "lib/Naked/toolshed/c/casts.pyx":5
  897. * # cython: profile=True
  898. *
  899. * cdef inline int increment(object iterable, object test_string): # <<<<<<<<<<<<<<
  900. * cdef int count = 0
  901. * cdef object thing
  902. */
  903. static CYTHON_INLINE int __pyx_f_3lib_5Naked_8toolshed_1c_5casts_increment(PyObject *__pyx_v_iterable, PyObject *__pyx_v_test_string) {
  904. int __pyx_v_count;
  905. PyObject *__pyx_v_thing = 0;
  906. int __pyx_r;
  907. __Pyx_RefNannyDeclarations
  908. PyObject *__pyx_t_1 = NULL;
  909. Py_ssize_t __pyx_t_2;
  910. PyObject *(*__pyx_t_3)(PyObject *);
  911. PyObject *__pyx_t_4 = NULL;
  912. int __pyx_t_5;
  913. int __pyx_lineno = 0;
  914. const char *__pyx_filename = NULL;
  915. int __pyx_clineno = 0;
  916. __Pyx_TraceDeclarations
  917. __Pyx_RefNannySetupContext("increment", 0);
  918. __Pyx_TraceCall("increment", __pyx_f[0], 5);
  919. /* "lib/Naked/toolshed/c/casts.pyx":6
  920. *
  921. * cdef inline int increment(object iterable, object test_string):
  922. * cdef int count = 0 # <<<<<<<<<<<<<<
  923. * cdef object thing
  924. * for thing in iterable:
  925. */
  926. __pyx_v_count = 0;
  927. /* "lib/Naked/toolshed/c/casts.pyx":8
  928. * cdef int count = 0
  929. * cdef object thing
  930. * for thing in iterable: # <<<<<<<<<<<<<<
  931. * if thing == test_string:
  932. * count += 1
  933. */
  934. if (PyList_CheckExact(__pyx_v_iterable) || PyTuple_CheckExact(__pyx_v_iterable)) {
  935. __pyx_t_1 = __pyx_v_iterable; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
  936. __pyx_t_3 = NULL;
  937. } else {
  938. __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_iterable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  939. __Pyx_GOTREF(__pyx_t_1);
  940. __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext;
  941. }
  942. for (;;) {
  943. if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) {
  944. if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
  945. #if CYTHON_COMPILING_IN_CPYTHON
  946. __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  947. #else
  948. __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  949. #endif
  950. } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) {
  951. if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
  952. #if CYTHON_COMPILING_IN_CPYTHON
  953. __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  954. #else
  955. __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  956. #endif
  957. } else {
  958. __pyx_t_4 = __pyx_t_3(__pyx_t_1);
  959. if (unlikely(!__pyx_t_4)) {
  960. PyObject* exc_type = PyErr_Occurred();
  961. if (exc_type) {
  962. if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
  963. else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  964. }
  965. break;
  966. }
  967. __Pyx_GOTREF(__pyx_t_4);
  968. }
  969. __Pyx_XDECREF_SET(__pyx_v_thing, __pyx_t_4);
  970. __pyx_t_4 = 0;
  971. /* "lib/Naked/toolshed/c/casts.pyx":9
  972. * cdef object thing
  973. * for thing in iterable:
  974. * if thing == test_string: # <<<<<<<<<<<<<<
  975. * count += 1
  976. * return count
  977. */
  978. __pyx_t_4 = PyObject_RichCompare(__pyx_v_thing, __pyx_v_test_string, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  979. __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  980. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  981. if (__pyx_t_5) {
  982. /* "lib/Naked/toolshed/c/casts.pyx":10
  983. * for thing in iterable:
  984. * if thing == test_string:
  985. * count += 1 # <<<<<<<<<<<<<<
  986. * return count
  987. *
  988. */
  989. __pyx_v_count = (__pyx_v_count + 1);
  990. goto __pyx_L5;
  991. }
  992. __pyx_L5:;
  993. }
  994. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  995. /* "lib/Naked/toolshed/c/casts.pyx":11
  996. * if thing == test_string:
  997. * count += 1
  998. * return count # <<<<<<<<<<<<<<
  999. *
  1000. * from Naked.toolshed.c.types import NakedObject, XFSet, XDict, XList, XQueue, XSet, XString
  1001. */
  1002. __pyx_r = __pyx_v_count;
  1003. goto __pyx_L0;
  1004. /* "lib/Naked/toolshed/c/casts.pyx":5
  1005. * # cython: profile=True
  1006. *
  1007. * cdef inline int increment(object iterable, object test_string): # <<<<<<<<<<<<<<
  1008. * cdef int count = 0
  1009. * cdef object thing
  1010. */
  1011. /* function exit code */
  1012. __pyx_L1_error:;
  1013. __Pyx_XDECREF(__pyx_t_1);
  1014. __Pyx_XDECREF(__pyx_t_4);
  1015. __Pyx_WriteUnraisable("lib.Naked.toolshed.c.casts.increment", __pyx_clineno, __pyx_lineno, __pyx_filename, 0);
  1016. __pyx_r = 0;
  1017. __pyx_L0:;
  1018. __Pyx_XDECREF(__pyx_v_thing);
  1019. __Pyx_TraceReturn(Py_None);
  1020. __Pyx_RefNannyFinishContext();
  1021. return __pyx_r;
  1022. }
  1023. /* "lib/Naked/toolshed/c/casts.pyx":20
  1024. * # Cast a dictionary of attributes to a NakedObject with key>attribute mapping
  1025. * #------------------------------------------------------------------------------
  1026. * def nob(attributes={}): # <<<<<<<<<<<<<<
  1027. * try:
  1028. * return NakedObject(attributes)
  1029. */
  1030. /* Python wrapper */
  1031. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_1nob(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1032. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_1nob = {__Pyx_NAMESTR("nob"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_1nob, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1033. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_1nob(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1034. PyObject *__pyx_v_attributes = 0;
  1035. int __pyx_lineno = 0;
  1036. const char *__pyx_filename = NULL;
  1037. int __pyx_clineno = 0;
  1038. PyObject *__pyx_r = 0;
  1039. __Pyx_RefNannyDeclarations
  1040. __Pyx_RefNannySetupContext("nob (wrapper)", 0);
  1041. {
  1042. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_attributes,0};
  1043. PyObject* values[1] = {0};
  1044. values[0] = __pyx_k_;
  1045. if (unlikely(__pyx_kwds)) {
  1046. Py_ssize_t kw_args;
  1047. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1048. switch (pos_args) {
  1049. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1050. case 0: break;
  1051. default: goto __pyx_L5_argtuple_error;
  1052. }
  1053. kw_args = PyDict_Size(__pyx_kwds);
  1054. switch (pos_args) {
  1055. case 0:
  1056. if (kw_args > 0) {
  1057. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attributes);
  1058. if (value) { values[0] = value; kw_args--; }
  1059. }
  1060. }
  1061. if (unlikely(kw_args > 0)) {
  1062. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "nob") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1063. }
  1064. } else {
  1065. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1066. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1067. case 0: break;
  1068. default: goto __pyx_L5_argtuple_error;
  1069. }
  1070. }
  1071. __pyx_v_attributes = values[0];
  1072. }
  1073. goto __pyx_L4_argument_unpacking_done;
  1074. __pyx_L5_argtuple_error:;
  1075. __Pyx_RaiseArgtupleInvalid("nob", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1076. __pyx_L3_error:;
  1077. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.nob", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1078. __Pyx_RefNannyFinishContext();
  1079. return NULL;
  1080. __pyx_L4_argument_unpacking_done:;
  1081. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_5casts_nob(__pyx_self, __pyx_v_attributes);
  1082. /* function exit code */
  1083. __Pyx_RefNannyFinishContext();
  1084. return __pyx_r;
  1085. }
  1086. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_nob(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_attributes) {
  1087. PyObject *__pyx_v_e = NULL;
  1088. PyObject *__pyx_r = NULL;
  1089. __Pyx_RefNannyDeclarations
  1090. PyObject *__pyx_t_1 = NULL;
  1091. PyObject *__pyx_t_2 = NULL;
  1092. PyObject *__pyx_t_3 = NULL;
  1093. PyObject *__pyx_t_4 = NULL;
  1094. PyObject *__pyx_t_5 = NULL;
  1095. PyObject *__pyx_t_6 = NULL;
  1096. int __pyx_t_7;
  1097. PyObject *__pyx_t_8 = NULL;
  1098. int __pyx_t_9;
  1099. int __pyx_lineno = 0;
  1100. const char *__pyx_filename = NULL;
  1101. int __pyx_clineno = 0;
  1102. __Pyx_TraceDeclarations
  1103. __Pyx_RefNannySetupContext("nob", 0);
  1104. __Pyx_TraceCall("nob", __pyx_f[0], 20);
  1105. /* "lib/Naked/toolshed/c/casts.pyx":21
  1106. * #------------------------------------------------------------------------------
  1107. * def nob(attributes={}):
  1108. * try: # <<<<<<<<<<<<<<
  1109. * return NakedObject(attributes)
  1110. * except Exception as e:
  1111. */
  1112. {
  1113. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  1114. __Pyx_XGOTREF(__pyx_t_1);
  1115. __Pyx_XGOTREF(__pyx_t_2);
  1116. __Pyx_XGOTREF(__pyx_t_3);
  1117. /*try:*/ {
  1118. /* "lib/Naked/toolshed/c/casts.pyx":22
  1119. * def nob(attributes={}):
  1120. * try:
  1121. * return NakedObject(attributes) # <<<<<<<<<<<<<<
  1122. * except Exception as e:
  1123. * if DEBUG_FLAG:
  1124. */
  1125. __Pyx_XDECREF(__pyx_r);
  1126. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_NakedObject); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1127. __Pyx_GOTREF(__pyx_t_4);
  1128. __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1129. __Pyx_GOTREF(__pyx_t_5);
  1130. __Pyx_INCREF(__pyx_v_attributes);
  1131. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_attributes);
  1132. __Pyx_GIVEREF(__pyx_v_attributes);
  1133. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1134. __Pyx_GOTREF(__pyx_t_6);
  1135. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1136. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1137. __pyx_r = __pyx_t_6;
  1138. __pyx_t_6 = 0;
  1139. goto __pyx_L7_try_return;
  1140. }
  1141. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  1142. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  1143. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1144. goto __pyx_L10_try_end;
  1145. __pyx_L3_error:;
  1146. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1147. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1148. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1149. /* "lib/Naked/toolshed/c/casts.pyx":23
  1150. * try:
  1151. * return NakedObject(attributes)
  1152. * except Exception as e: # <<<<<<<<<<<<<<
  1153. * if DEBUG_FLAG:
  1154. * print("Naked Framework Error: unable to create a NakedObject with the requested argument using the nobj() function (Naked.toolshed.casts.py).")
  1155. */
  1156. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  1157. if (__pyx_t_7) {
  1158. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.nob", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1159. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1160. __Pyx_GOTREF(__pyx_t_6);
  1161. __Pyx_GOTREF(__pyx_t_5);
  1162. __Pyx_GOTREF(__pyx_t_4);
  1163. __Pyx_INCREF(__pyx_t_5);
  1164. __pyx_v_e = __pyx_t_5;
  1165. /* "lib/Naked/toolshed/c/casts.pyx":24
  1166. * return NakedObject(attributes)
  1167. * except Exception as e:
  1168. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  1169. * print("Naked Framework Error: unable to create a NakedObject with the requested argument using the nobj() function (Naked.toolshed.casts.py).")
  1170. * raise e
  1171. */
  1172. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1173. __Pyx_GOTREF(__pyx_t_8);
  1174. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1175. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1176. if (__pyx_t_9) {
  1177. /* "lib/Naked/toolshed/c/casts.pyx":25
  1178. * except Exception as e:
  1179. * if DEBUG_FLAG:
  1180. * print("Naked Framework Error: unable to create a NakedObject with the requested argument using the nobj() function (Naked.toolshed.casts.py).") # <<<<<<<<<<<<<<
  1181. * raise e
  1182. *
  1183. */
  1184. if (__Pyx_PrintOne(0, __pyx_kp_s_Naked_Framework_Error_unable_to) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1185. goto __pyx_L13;
  1186. }
  1187. __pyx_L13:;
  1188. /* "lib/Naked/toolshed/c/casts.pyx":26
  1189. * if DEBUG_FLAG:
  1190. * print("Naked Framework Error: unable to create a NakedObject with the requested argument using the nobj() function (Naked.toolshed.casts.py).")
  1191. * raise e # <<<<<<<<<<<<<<
  1192. *
  1193. * #------------------------------------------------------------------------------
  1194. */
  1195. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  1196. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1197. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1198. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1199. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1200. goto __pyx_L4_exception_handled;
  1201. }
  1202. goto __pyx_L5_except_error;
  1203. __pyx_L5_except_error:;
  1204. __Pyx_XGIVEREF(__pyx_t_1);
  1205. __Pyx_XGIVEREF(__pyx_t_2);
  1206. __Pyx_XGIVEREF(__pyx_t_3);
  1207. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1208. goto __pyx_L1_error;
  1209. __pyx_L7_try_return:;
  1210. __Pyx_XGIVEREF(__pyx_t_1);
  1211. __Pyx_XGIVEREF(__pyx_t_2);
  1212. __Pyx_XGIVEREF(__pyx_t_3);
  1213. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1214. goto __pyx_L0;
  1215. __pyx_L4_exception_handled:;
  1216. __Pyx_XGIVEREF(__pyx_t_1);
  1217. __Pyx_XGIVEREF(__pyx_t_2);
  1218. __Pyx_XGIVEREF(__pyx_t_3);
  1219. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1220. __pyx_L10_try_end:;
  1221. }
  1222. /* "lib/Naked/toolshed/c/casts.pyx":20
  1223. * # Cast a dictionary of attributes to a NakedObject with key>attribute mapping
  1224. * #------------------------------------------------------------------------------
  1225. * def nob(attributes={}): # <<<<<<<<<<<<<<
  1226. * try:
  1227. * return NakedObject(attributes)
  1228. */
  1229. /* function exit code */
  1230. __pyx_L1_error:;
  1231. __Pyx_XDECREF(__pyx_t_4);
  1232. __Pyx_XDECREF(__pyx_t_5);
  1233. __Pyx_XDECREF(__pyx_t_6);
  1234. __Pyx_XDECREF(__pyx_t_8);
  1235. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.nob", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1236. __pyx_r = NULL;
  1237. __pyx_L0:;
  1238. __Pyx_XDECREF(__pyx_v_e);
  1239. __Pyx_XGIVEREF(__pyx_r);
  1240. __Pyx_TraceReturn(__pyx_r);
  1241. __Pyx_RefNannyFinishContext();
  1242. return __pyx_r;
  1243. }
  1244. /* "lib/Naked/toolshed/c/casts.pyx":32
  1245. * # Cast a Python dictionary to a XDict
  1246. * #------------------------------------------------------------------------------
  1247. * def xd(dictionary_arg, attributes={}): # <<<<<<<<<<<<<<
  1248. * try:
  1249. * return XDict(dictionary_arg, attributes)
  1250. */
  1251. /* Python wrapper */
  1252. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_3xd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1253. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_3xd = {__Pyx_NAMESTR("xd"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_3xd, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1254. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_3xd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1255. PyObject *__pyx_v_dictionary_arg = 0;
  1256. PyObject *__pyx_v_attributes = 0;
  1257. int __pyx_lineno = 0;
  1258. const char *__pyx_filename = NULL;
  1259. int __pyx_clineno = 0;
  1260. PyObject *__pyx_r = 0;
  1261. __Pyx_RefNannyDeclarations
  1262. __Pyx_RefNannySetupContext("xd (wrapper)", 0);
  1263. {
  1264. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dictionary_arg,&__pyx_n_s_attributes,0};
  1265. PyObject* values[2] = {0,0};
  1266. values[1] = __pyx_k__2;
  1267. if (unlikely(__pyx_kwds)) {
  1268. Py_ssize_t kw_args;
  1269. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1270. switch (pos_args) {
  1271. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1272. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1273. case 0: break;
  1274. default: goto __pyx_L5_argtuple_error;
  1275. }
  1276. kw_args = PyDict_Size(__pyx_kwds);
  1277. switch (pos_args) {
  1278. case 0:
  1279. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dictionary_arg)) != 0)) kw_args--;
  1280. else goto __pyx_L5_argtuple_error;
  1281. case 1:
  1282. if (kw_args > 0) {
  1283. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attributes);
  1284. if (value) { values[1] = value; kw_args--; }
  1285. }
  1286. }
  1287. if (unlikely(kw_args > 0)) {
  1288. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1289. }
  1290. } else {
  1291. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1292. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1293. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1294. break;
  1295. default: goto __pyx_L5_argtuple_error;
  1296. }
  1297. }
  1298. __pyx_v_dictionary_arg = values[0];
  1299. __pyx_v_attributes = values[1];
  1300. }
  1301. goto __pyx_L4_argument_unpacking_done;
  1302. __pyx_L5_argtuple_error:;
  1303. __Pyx_RaiseArgtupleInvalid("xd", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1304. __pyx_L3_error:;
  1305. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1306. __Pyx_RefNannyFinishContext();
  1307. return NULL;
  1308. __pyx_L4_argument_unpacking_done:;
  1309. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_5casts_2xd(__pyx_self, __pyx_v_dictionary_arg, __pyx_v_attributes);
  1310. /* function exit code */
  1311. __Pyx_RefNannyFinishContext();
  1312. return __pyx_r;
  1313. }
  1314. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_2xd(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dictionary_arg, PyObject *__pyx_v_attributes) {
  1315. PyObject *__pyx_v_e = NULL;
  1316. PyObject *__pyx_r = NULL;
  1317. __Pyx_RefNannyDeclarations
  1318. PyObject *__pyx_t_1 = NULL;
  1319. PyObject *__pyx_t_2 = NULL;
  1320. PyObject *__pyx_t_3 = NULL;
  1321. PyObject *__pyx_t_4 = NULL;
  1322. PyObject *__pyx_t_5 = NULL;
  1323. PyObject *__pyx_t_6 = NULL;
  1324. int __pyx_t_7;
  1325. PyObject *__pyx_t_8 = NULL;
  1326. int __pyx_t_9;
  1327. int __pyx_lineno = 0;
  1328. const char *__pyx_filename = NULL;
  1329. int __pyx_clineno = 0;
  1330. __Pyx_TraceDeclarations
  1331. __Pyx_RefNannySetupContext("xd", 0);
  1332. __Pyx_TraceCall("xd", __pyx_f[0], 32);
  1333. /* "lib/Naked/toolshed/c/casts.pyx":33
  1334. * #------------------------------------------------------------------------------
  1335. * def xd(dictionary_arg, attributes={}):
  1336. * try: # <<<<<<<<<<<<<<
  1337. * return XDict(dictionary_arg, attributes)
  1338. * except TypeError:
  1339. */
  1340. {
  1341. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  1342. __Pyx_XGOTREF(__pyx_t_1);
  1343. __Pyx_XGOTREF(__pyx_t_2);
  1344. __Pyx_XGOTREF(__pyx_t_3);
  1345. /*try:*/ {
  1346. /* "lib/Naked/toolshed/c/casts.pyx":34
  1347. * def xd(dictionary_arg, attributes={}):
  1348. * try:
  1349. * return XDict(dictionary_arg, attributes) # <<<<<<<<<<<<<<
  1350. * except TypeError:
  1351. * raise TypeError("Attempted to cast to a XDict with an incompatible type")
  1352. */
  1353. __Pyx_XDECREF(__pyx_r);
  1354. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_XDict); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1355. __Pyx_GOTREF(__pyx_t_4);
  1356. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1357. __Pyx_GOTREF(__pyx_t_5);
  1358. __Pyx_INCREF(__pyx_v_dictionary_arg);
  1359. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_dictionary_arg);
  1360. __Pyx_GIVEREF(__pyx_v_dictionary_arg);
  1361. __Pyx_INCREF(__pyx_v_attributes);
  1362. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_attributes);
  1363. __Pyx_GIVEREF(__pyx_v_attributes);
  1364. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1365. __Pyx_GOTREF(__pyx_t_6);
  1366. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1367. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1368. __pyx_r = __pyx_t_6;
  1369. __pyx_t_6 = 0;
  1370. goto __pyx_L7_try_return;
  1371. }
  1372. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  1373. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  1374. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1375. goto __pyx_L10_try_end;
  1376. __pyx_L3_error:;
  1377. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1378. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1379. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1380. /* "lib/Naked/toolshed/c/casts.pyx":35
  1381. * try:
  1382. * return XDict(dictionary_arg, attributes)
  1383. * except TypeError: # <<<<<<<<<<<<<<
  1384. * raise TypeError("Attempted to cast to a XDict with an incompatible type")
  1385. * except Exception as e:
  1386. */
  1387. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
  1388. if (__pyx_t_7) {
  1389. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1390. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1391. __Pyx_GOTREF(__pyx_t_6);
  1392. __Pyx_GOTREF(__pyx_t_5);
  1393. __Pyx_GOTREF(__pyx_t_4);
  1394. /* "lib/Naked/toolshed/c/casts.pyx":36
  1395. * return XDict(dictionary_arg, attributes)
  1396. * except TypeError:
  1397. * raise TypeError("Attempted to cast to a XDict with an incompatible type") # <<<<<<<<<<<<<<
  1398. * except Exception as e:
  1399. * if DEBUG_FLAG:
  1400. */
  1401. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1402. __Pyx_GOTREF(__pyx_t_8);
  1403. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  1404. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1405. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1406. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1407. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1408. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1409. goto __pyx_L4_exception_handled;
  1410. }
  1411. /* "lib/Naked/toolshed/c/casts.pyx":37
  1412. * except TypeError:
  1413. * raise TypeError("Attempted to cast to a XDict with an incompatible type")
  1414. * except Exception as e: # <<<<<<<<<<<<<<
  1415. * if DEBUG_FLAG:
  1416. * print("Naked Framework Error: unable to cast object to a XDict with the xd() function (Naked.toolshed.casts.py).")
  1417. */
  1418. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  1419. if (__pyx_t_7) {
  1420. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1421. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1422. __Pyx_GOTREF(__pyx_t_4);
  1423. __Pyx_GOTREF(__pyx_t_5);
  1424. __Pyx_GOTREF(__pyx_t_6);
  1425. __Pyx_INCREF(__pyx_t_5);
  1426. __pyx_v_e = __pyx_t_5;
  1427. /* "lib/Naked/toolshed/c/casts.pyx":38
  1428. * raise TypeError("Attempted to cast to a XDict with an incompatible type")
  1429. * except Exception as e:
  1430. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  1431. * print("Naked Framework Error: unable to cast object to a XDict with the xd() function (Naked.toolshed.casts.py).")
  1432. * raise e
  1433. */
  1434. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1435. __Pyx_GOTREF(__pyx_t_8);
  1436. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1437. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1438. if (__pyx_t_9) {
  1439. /* "lib/Naked/toolshed/c/casts.pyx":39
  1440. * except Exception as e:
  1441. * if DEBUG_FLAG:
  1442. * print("Naked Framework Error: unable to cast object to a XDict with the xd() function (Naked.toolshed.casts.py).") # <<<<<<<<<<<<<<
  1443. * raise e
  1444. *
  1445. */
  1446. if (__Pyx_PrintOne(0, __pyx_kp_s_Naked_Framework_Error_unable_to_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1447. goto __pyx_L15;
  1448. }
  1449. __pyx_L15:;
  1450. /* "lib/Naked/toolshed/c/casts.pyx":40
  1451. * if DEBUG_FLAG:
  1452. * print("Naked Framework Error: unable to cast object to a XDict with the xd() function (Naked.toolshed.casts.py).")
  1453. * raise e # <<<<<<<<<<<<<<
  1454. *
  1455. * #------------------------------------------------------------------------------
  1456. */
  1457. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  1458. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1459. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1460. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1461. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1462. goto __pyx_L4_exception_handled;
  1463. }
  1464. goto __pyx_L5_except_error;
  1465. __pyx_L5_except_error:;
  1466. __Pyx_XGIVEREF(__pyx_t_1);
  1467. __Pyx_XGIVEREF(__pyx_t_2);
  1468. __Pyx_XGIVEREF(__pyx_t_3);
  1469. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1470. goto __pyx_L1_error;
  1471. __pyx_L7_try_return:;
  1472. __Pyx_XGIVEREF(__pyx_t_1);
  1473. __Pyx_XGIVEREF(__pyx_t_2);
  1474. __Pyx_XGIVEREF(__pyx_t_3);
  1475. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1476. goto __pyx_L0;
  1477. __pyx_L4_exception_handled:;
  1478. __Pyx_XGIVEREF(__pyx_t_1);
  1479. __Pyx_XGIVEREF(__pyx_t_2);
  1480. __Pyx_XGIVEREF(__pyx_t_3);
  1481. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1482. __pyx_L10_try_end:;
  1483. }
  1484. /* "lib/Naked/toolshed/c/casts.pyx":32
  1485. * # Cast a Python dictionary to a XDict
  1486. * #------------------------------------------------------------------------------
  1487. * def xd(dictionary_arg, attributes={}): # <<<<<<<<<<<<<<
  1488. * try:
  1489. * return XDict(dictionary_arg, attributes)
  1490. */
  1491. /* function exit code */
  1492. __pyx_L1_error:;
  1493. __Pyx_XDECREF(__pyx_t_4);
  1494. __Pyx_XDECREF(__pyx_t_5);
  1495. __Pyx_XDECREF(__pyx_t_6);
  1496. __Pyx_XDECREF(__pyx_t_8);
  1497. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xd", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1498. __pyx_r = NULL;
  1499. __pyx_L0:;
  1500. __Pyx_XDECREF(__pyx_v_e);
  1501. __Pyx_XGIVEREF(__pyx_r);
  1502. __Pyx_TraceReturn(__pyx_r);
  1503. __Pyx_RefNannyFinishContext();
  1504. return __pyx_r;
  1505. }
  1506. /* "lib/Naked/toolshed/c/casts.pyx":46
  1507. * # Cast a Python list, set, or tuple to a XList
  1508. * #------------------------------------------------------------------------------
  1509. * def xl(list_arg, attributes={}): # <<<<<<<<<<<<<<
  1510. * try:
  1511. * return XList(list_arg, attributes)
  1512. */
  1513. /* Python wrapper */
  1514. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_5xl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1515. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_5xl = {__Pyx_NAMESTR("xl"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_5xl, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1516. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_5xl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1517. PyObject *__pyx_v_list_arg = 0;
  1518. PyObject *__pyx_v_attributes = 0;
  1519. int __pyx_lineno = 0;
  1520. const char *__pyx_filename = NULL;
  1521. int __pyx_clineno = 0;
  1522. PyObject *__pyx_r = 0;
  1523. __Pyx_RefNannyDeclarations
  1524. __Pyx_RefNannySetupContext("xl (wrapper)", 0);
  1525. {
  1526. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_list_arg,&__pyx_n_s_attributes,0};
  1527. PyObject* values[2] = {0,0};
  1528. values[1] = __pyx_k__4;
  1529. if (unlikely(__pyx_kwds)) {
  1530. Py_ssize_t kw_args;
  1531. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1532. switch (pos_args) {
  1533. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1534. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1535. case 0: break;
  1536. default: goto __pyx_L5_argtuple_error;
  1537. }
  1538. kw_args = PyDict_Size(__pyx_kwds);
  1539. switch (pos_args) {
  1540. case 0:
  1541. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_list_arg)) != 0)) kw_args--;
  1542. else goto __pyx_L5_argtuple_error;
  1543. case 1:
  1544. if (kw_args > 0) {
  1545. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attributes);
  1546. if (value) { values[1] = value; kw_args--; }
  1547. }
  1548. }
  1549. if (unlikely(kw_args > 0)) {
  1550. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xl") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1551. }
  1552. } else {
  1553. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1554. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1555. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1556. break;
  1557. default: goto __pyx_L5_argtuple_error;
  1558. }
  1559. }
  1560. __pyx_v_list_arg = values[0];
  1561. __pyx_v_attributes = values[1];
  1562. }
  1563. goto __pyx_L4_argument_unpacking_done;
  1564. __pyx_L5_argtuple_error:;
  1565. __Pyx_RaiseArgtupleInvalid("xl", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1566. __pyx_L3_error:;
  1567. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1568. __Pyx_RefNannyFinishContext();
  1569. return NULL;
  1570. __pyx_L4_argument_unpacking_done:;
  1571. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_5casts_4xl(__pyx_self, __pyx_v_list_arg, __pyx_v_attributes);
  1572. /* function exit code */
  1573. __Pyx_RefNannyFinishContext();
  1574. return __pyx_r;
  1575. }
  1576. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_4xl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_list_arg, PyObject *__pyx_v_attributes) {
  1577. PyObject *__pyx_v_e = NULL;
  1578. PyObject *__pyx_r = NULL;
  1579. __Pyx_RefNannyDeclarations
  1580. PyObject *__pyx_t_1 = NULL;
  1581. PyObject *__pyx_t_2 = NULL;
  1582. PyObject *__pyx_t_3 = NULL;
  1583. PyObject *__pyx_t_4 = NULL;
  1584. PyObject *__pyx_t_5 = NULL;
  1585. PyObject *__pyx_t_6 = NULL;
  1586. int __pyx_t_7;
  1587. PyObject *__pyx_t_8 = NULL;
  1588. int __pyx_t_9;
  1589. int __pyx_lineno = 0;
  1590. const char *__pyx_filename = NULL;
  1591. int __pyx_clineno = 0;
  1592. __Pyx_TraceDeclarations
  1593. __Pyx_RefNannySetupContext("xl", 0);
  1594. __Pyx_TraceCall("xl", __pyx_f[0], 46);
  1595. /* "lib/Naked/toolshed/c/casts.pyx":47
  1596. * #------------------------------------------------------------------------------
  1597. * def xl(list_arg, attributes={}):
  1598. * try: # <<<<<<<<<<<<<<
  1599. * return XList(list_arg, attributes)
  1600. * except TypeError:
  1601. */
  1602. {
  1603. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  1604. __Pyx_XGOTREF(__pyx_t_1);
  1605. __Pyx_XGOTREF(__pyx_t_2);
  1606. __Pyx_XGOTREF(__pyx_t_3);
  1607. /*try:*/ {
  1608. /* "lib/Naked/toolshed/c/casts.pyx":48
  1609. * def xl(list_arg, attributes={}):
  1610. * try:
  1611. * return XList(list_arg, attributes) # <<<<<<<<<<<<<<
  1612. * except TypeError:
  1613. * raise TypeError("Attempted to cast to a XList with an incompatible type")
  1614. */
  1615. __Pyx_XDECREF(__pyx_r);
  1616. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_XList); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1617. __Pyx_GOTREF(__pyx_t_4);
  1618. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1619. __Pyx_GOTREF(__pyx_t_5);
  1620. __Pyx_INCREF(__pyx_v_list_arg);
  1621. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_list_arg);
  1622. __Pyx_GIVEREF(__pyx_v_list_arg);
  1623. __Pyx_INCREF(__pyx_v_attributes);
  1624. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_attributes);
  1625. __Pyx_GIVEREF(__pyx_v_attributes);
  1626. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1627. __Pyx_GOTREF(__pyx_t_6);
  1628. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1629. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1630. __pyx_r = __pyx_t_6;
  1631. __pyx_t_6 = 0;
  1632. goto __pyx_L7_try_return;
  1633. }
  1634. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  1635. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  1636. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1637. goto __pyx_L10_try_end;
  1638. __pyx_L3_error:;
  1639. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1640. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1641. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1642. /* "lib/Naked/toolshed/c/casts.pyx":49
  1643. * try:
  1644. * return XList(list_arg, attributes)
  1645. * except TypeError: # <<<<<<<<<<<<<<
  1646. * raise TypeError("Attempted to cast to a XList with an incompatible type")
  1647. * except Exception as e:
  1648. */
  1649. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
  1650. if (__pyx_t_7) {
  1651. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1652. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1653. __Pyx_GOTREF(__pyx_t_6);
  1654. __Pyx_GOTREF(__pyx_t_5);
  1655. __Pyx_GOTREF(__pyx_t_4);
  1656. /* "lib/Naked/toolshed/c/casts.pyx":50
  1657. * return XList(list_arg, attributes)
  1658. * except TypeError:
  1659. * raise TypeError("Attempted to cast to a XList with an incompatible type") # <<<<<<<<<<<<<<
  1660. * except Exception as e:
  1661. * if DEBUG_FLAG:
  1662. */
  1663. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1664. __Pyx_GOTREF(__pyx_t_8);
  1665. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  1666. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1667. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1668. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1669. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1670. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1671. goto __pyx_L4_exception_handled;
  1672. }
  1673. /* "lib/Naked/toolshed/c/casts.pyx":51
  1674. * except TypeError:
  1675. * raise TypeError("Attempted to cast to a XList with an incompatible type")
  1676. * except Exception as e: # <<<<<<<<<<<<<<
  1677. * if DEBUG_FLAG:
  1678. * print("Naked Framework Error: unable to cast object to a XList with the xl() function (Naked.toolshed.casts.py).")
  1679. */
  1680. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  1681. if (__pyx_t_7) {
  1682. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1683. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1684. __Pyx_GOTREF(__pyx_t_4);
  1685. __Pyx_GOTREF(__pyx_t_5);
  1686. __Pyx_GOTREF(__pyx_t_6);
  1687. __Pyx_INCREF(__pyx_t_5);
  1688. __pyx_v_e = __pyx_t_5;
  1689. /* "lib/Naked/toolshed/c/casts.pyx":52
  1690. * raise TypeError("Attempted to cast to a XList with an incompatible type")
  1691. * except Exception as e:
  1692. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  1693. * print("Naked Framework Error: unable to cast object to a XList with the xl() function (Naked.toolshed.casts.py).")
  1694. * raise e
  1695. */
  1696. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1697. __Pyx_GOTREF(__pyx_t_8);
  1698. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1699. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1700. if (__pyx_t_9) {
  1701. /* "lib/Naked/toolshed/c/casts.pyx":53
  1702. * except Exception as e:
  1703. * if DEBUG_FLAG:
  1704. * print("Naked Framework Error: unable to cast object to a XList with the xl() function (Naked.toolshed.casts.py).") # <<<<<<<<<<<<<<
  1705. * raise e
  1706. *
  1707. */
  1708. if (__Pyx_PrintOne(0, __pyx_kp_s_Naked_Framework_Error_unable_to_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1709. goto __pyx_L15;
  1710. }
  1711. __pyx_L15:;
  1712. /* "lib/Naked/toolshed/c/casts.pyx":54
  1713. * if DEBUG_FLAG:
  1714. * print("Naked Framework Error: unable to cast object to a XList with the xl() function (Naked.toolshed.casts.py).")
  1715. * raise e # <<<<<<<<<<<<<<
  1716. *
  1717. * #------------------------------------------------------------------------------
  1718. */
  1719. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  1720. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1721. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1722. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1723. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1724. goto __pyx_L4_exception_handled;
  1725. }
  1726. goto __pyx_L5_except_error;
  1727. __pyx_L5_except_error:;
  1728. __Pyx_XGIVEREF(__pyx_t_1);
  1729. __Pyx_XGIVEREF(__pyx_t_2);
  1730. __Pyx_XGIVEREF(__pyx_t_3);
  1731. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1732. goto __pyx_L1_error;
  1733. __pyx_L7_try_return:;
  1734. __Pyx_XGIVEREF(__pyx_t_1);
  1735. __Pyx_XGIVEREF(__pyx_t_2);
  1736. __Pyx_XGIVEREF(__pyx_t_3);
  1737. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1738. goto __pyx_L0;
  1739. __pyx_L4_exception_handled:;
  1740. __Pyx_XGIVEREF(__pyx_t_1);
  1741. __Pyx_XGIVEREF(__pyx_t_2);
  1742. __Pyx_XGIVEREF(__pyx_t_3);
  1743. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1744. __pyx_L10_try_end:;
  1745. }
  1746. /* "lib/Naked/toolshed/c/casts.pyx":46
  1747. * # Cast a Python list, set, or tuple to a XList
  1748. * #------------------------------------------------------------------------------
  1749. * def xl(list_arg, attributes={}): # <<<<<<<<<<<<<<
  1750. * try:
  1751. * return XList(list_arg, attributes)
  1752. */
  1753. /* function exit code */
  1754. __pyx_L1_error:;
  1755. __Pyx_XDECREF(__pyx_t_4);
  1756. __Pyx_XDECREF(__pyx_t_5);
  1757. __Pyx_XDECREF(__pyx_t_6);
  1758. __Pyx_XDECREF(__pyx_t_8);
  1759. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1760. __pyx_r = NULL;
  1761. __pyx_L0:;
  1762. __Pyx_XDECREF(__pyx_v_e);
  1763. __Pyx_XGIVEREF(__pyx_r);
  1764. __Pyx_TraceReturn(__pyx_r);
  1765. __Pyx_RefNannyFinishContext();
  1766. return __pyx_r;
  1767. }
  1768. /* "lib/Naked/toolshed/c/casts.pyx":60
  1769. * # Cast a Python list, set, tuple to a XQueue
  1770. * #------------------------------------------------------------------------------
  1771. * def xq(queue_arg, attributes={}): # <<<<<<<<<<<<<<
  1772. * try:
  1773. * return XQueue(queue_arg, attributes)
  1774. */
  1775. /* Python wrapper */
  1776. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_7xq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  1777. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_7xq = {__Pyx_NAMESTR("xq"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_7xq, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  1778. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_7xq(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  1779. PyObject *__pyx_v_queue_arg = 0;
  1780. PyObject *__pyx_v_attributes = 0;
  1781. int __pyx_lineno = 0;
  1782. const char *__pyx_filename = NULL;
  1783. int __pyx_clineno = 0;
  1784. PyObject *__pyx_r = 0;
  1785. __Pyx_RefNannyDeclarations
  1786. __Pyx_RefNannySetupContext("xq (wrapper)", 0);
  1787. {
  1788. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_queue_arg,&__pyx_n_s_attributes,0};
  1789. PyObject* values[2] = {0,0};
  1790. values[1] = __pyx_k__6;
  1791. if (unlikely(__pyx_kwds)) {
  1792. Py_ssize_t kw_args;
  1793. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  1794. switch (pos_args) {
  1795. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1796. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1797. case 0: break;
  1798. default: goto __pyx_L5_argtuple_error;
  1799. }
  1800. kw_args = PyDict_Size(__pyx_kwds);
  1801. switch (pos_args) {
  1802. case 0:
  1803. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_queue_arg)) != 0)) kw_args--;
  1804. else goto __pyx_L5_argtuple_error;
  1805. case 1:
  1806. if (kw_args > 0) {
  1807. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attributes);
  1808. if (value) { values[1] = value; kw_args--; }
  1809. }
  1810. }
  1811. if (unlikely(kw_args > 0)) {
  1812. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xq") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1813. }
  1814. } else {
  1815. switch (PyTuple_GET_SIZE(__pyx_args)) {
  1816. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  1817. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  1818. break;
  1819. default: goto __pyx_L5_argtuple_error;
  1820. }
  1821. }
  1822. __pyx_v_queue_arg = values[0];
  1823. __pyx_v_attributes = values[1];
  1824. }
  1825. goto __pyx_L4_argument_unpacking_done;
  1826. __pyx_L5_argtuple_error:;
  1827. __Pyx_RaiseArgtupleInvalid("xq", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1828. __pyx_L3_error:;
  1829. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1830. __Pyx_RefNannyFinishContext();
  1831. return NULL;
  1832. __pyx_L4_argument_unpacking_done:;
  1833. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_5casts_6xq(__pyx_self, __pyx_v_queue_arg, __pyx_v_attributes);
  1834. /* function exit code */
  1835. __Pyx_RefNannyFinishContext();
  1836. return __pyx_r;
  1837. }
  1838. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_6xq(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_queue_arg, PyObject *__pyx_v_attributes) {
  1839. PyObject *__pyx_v_e = NULL;
  1840. PyObject *__pyx_r = NULL;
  1841. __Pyx_RefNannyDeclarations
  1842. PyObject *__pyx_t_1 = NULL;
  1843. PyObject *__pyx_t_2 = NULL;
  1844. PyObject *__pyx_t_3 = NULL;
  1845. PyObject *__pyx_t_4 = NULL;
  1846. PyObject *__pyx_t_5 = NULL;
  1847. PyObject *__pyx_t_6 = NULL;
  1848. int __pyx_t_7;
  1849. PyObject *__pyx_t_8 = NULL;
  1850. int __pyx_t_9;
  1851. int __pyx_lineno = 0;
  1852. const char *__pyx_filename = NULL;
  1853. int __pyx_clineno = 0;
  1854. __Pyx_TraceDeclarations
  1855. __Pyx_RefNannySetupContext("xq", 0);
  1856. __Pyx_TraceCall("xq", __pyx_f[0], 60);
  1857. /* "lib/Naked/toolshed/c/casts.pyx":61
  1858. * #------------------------------------------------------------------------------
  1859. * def xq(queue_arg, attributes={}):
  1860. * try: # <<<<<<<<<<<<<<
  1861. * return XQueue(queue_arg, attributes)
  1862. * except TypeError:
  1863. */
  1864. {
  1865. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  1866. __Pyx_XGOTREF(__pyx_t_1);
  1867. __Pyx_XGOTREF(__pyx_t_2);
  1868. __Pyx_XGOTREF(__pyx_t_3);
  1869. /*try:*/ {
  1870. /* "lib/Naked/toolshed/c/casts.pyx":62
  1871. * def xq(queue_arg, attributes={}):
  1872. * try:
  1873. * return XQueue(queue_arg, attributes) # <<<<<<<<<<<<<<
  1874. * except TypeError:
  1875. * raise TypeError("Attempted to cast to a XQueue with an incompatible type")
  1876. */
  1877. __Pyx_XDECREF(__pyx_r);
  1878. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_XQueue); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1879. __Pyx_GOTREF(__pyx_t_4);
  1880. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1881. __Pyx_GOTREF(__pyx_t_5);
  1882. __Pyx_INCREF(__pyx_v_queue_arg);
  1883. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_queue_arg);
  1884. __Pyx_GIVEREF(__pyx_v_queue_arg);
  1885. __Pyx_INCREF(__pyx_v_attributes);
  1886. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_attributes);
  1887. __Pyx_GIVEREF(__pyx_v_attributes);
  1888. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  1889. __Pyx_GOTREF(__pyx_t_6);
  1890. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1891. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1892. __pyx_r = __pyx_t_6;
  1893. __pyx_t_6 = 0;
  1894. goto __pyx_L7_try_return;
  1895. }
  1896. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  1897. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  1898. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  1899. goto __pyx_L10_try_end;
  1900. __pyx_L3_error:;
  1901. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  1902. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  1903. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  1904. /* "lib/Naked/toolshed/c/casts.pyx":63
  1905. * try:
  1906. * return XQueue(queue_arg, attributes)
  1907. * except TypeError: # <<<<<<<<<<<<<<
  1908. * raise TypeError("Attempted to cast to a XQueue with an incompatible type")
  1909. * except Exception as e:
  1910. */
  1911. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
  1912. if (__pyx_t_7) {
  1913. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1914. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1915. __Pyx_GOTREF(__pyx_t_6);
  1916. __Pyx_GOTREF(__pyx_t_5);
  1917. __Pyx_GOTREF(__pyx_t_4);
  1918. /* "lib/Naked/toolshed/c/casts.pyx":64
  1919. * return XQueue(queue_arg, attributes)
  1920. * except TypeError:
  1921. * raise TypeError("Attempted to cast to a XQueue with an incompatible type") # <<<<<<<<<<<<<<
  1922. * except Exception as e:
  1923. * if DEBUG_FLAG:
  1924. */
  1925. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1926. __Pyx_GOTREF(__pyx_t_8);
  1927. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  1928. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1929. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1930. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1931. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1932. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1933. goto __pyx_L4_exception_handled;
  1934. }
  1935. /* "lib/Naked/toolshed/c/casts.pyx":65
  1936. * except TypeError:
  1937. * raise TypeError("Attempted to cast to a XQueue with an incompatible type")
  1938. * except Exception as e: # <<<<<<<<<<<<<<
  1939. * if DEBUG_FLAG:
  1940. * print("Naked Framework Error: unable to cast object to a XQueue with the xq() function (Naked.toolshed.casts.py).")
  1941. */
  1942. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  1943. if (__pyx_t_7) {
  1944. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  1945. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1946. __Pyx_GOTREF(__pyx_t_4);
  1947. __Pyx_GOTREF(__pyx_t_5);
  1948. __Pyx_GOTREF(__pyx_t_6);
  1949. __Pyx_INCREF(__pyx_t_5);
  1950. __pyx_v_e = __pyx_t_5;
  1951. /* "lib/Naked/toolshed/c/casts.pyx":66
  1952. * raise TypeError("Attempted to cast to a XQueue with an incompatible type")
  1953. * except Exception as e:
  1954. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  1955. * print("Naked Framework Error: unable to cast object to a XQueue with the xq() function (Naked.toolshed.casts.py).")
  1956. * raise e
  1957. */
  1958. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1959. __Pyx_GOTREF(__pyx_t_8);
  1960. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1961. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  1962. if (__pyx_t_9) {
  1963. /* "lib/Naked/toolshed/c/casts.pyx":67
  1964. * except Exception as e:
  1965. * if DEBUG_FLAG:
  1966. * print("Naked Framework Error: unable to cast object to a XQueue with the xq() function (Naked.toolshed.casts.py).") # <<<<<<<<<<<<<<
  1967. * raise e
  1968. *
  1969. */
  1970. if (__Pyx_PrintOne(0, __pyx_kp_s_Naked_Framework_Error_unable_to_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1971. goto __pyx_L15;
  1972. }
  1973. __pyx_L15:;
  1974. /* "lib/Naked/toolshed/c/casts.pyx":68
  1975. * if DEBUG_FLAG:
  1976. * print("Naked Framework Error: unable to cast object to a XQueue with the xq() function (Naked.toolshed.casts.py).")
  1977. * raise e # <<<<<<<<<<<<<<
  1978. *
  1979. * #------------------------------------------------------------------------------
  1980. */
  1981. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  1982. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  1983. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  1984. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  1985. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  1986. goto __pyx_L4_exception_handled;
  1987. }
  1988. goto __pyx_L5_except_error;
  1989. __pyx_L5_except_error:;
  1990. __Pyx_XGIVEREF(__pyx_t_1);
  1991. __Pyx_XGIVEREF(__pyx_t_2);
  1992. __Pyx_XGIVEREF(__pyx_t_3);
  1993. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  1994. goto __pyx_L1_error;
  1995. __pyx_L7_try_return:;
  1996. __Pyx_XGIVEREF(__pyx_t_1);
  1997. __Pyx_XGIVEREF(__pyx_t_2);
  1998. __Pyx_XGIVEREF(__pyx_t_3);
  1999. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2000. goto __pyx_L0;
  2001. __pyx_L4_exception_handled:;
  2002. __Pyx_XGIVEREF(__pyx_t_1);
  2003. __Pyx_XGIVEREF(__pyx_t_2);
  2004. __Pyx_XGIVEREF(__pyx_t_3);
  2005. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2006. __pyx_L10_try_end:;
  2007. }
  2008. /* "lib/Naked/toolshed/c/casts.pyx":60
  2009. * # Cast a Python list, set, tuple to a XQueue
  2010. * #------------------------------------------------------------------------------
  2011. * def xq(queue_arg, attributes={}): # <<<<<<<<<<<<<<
  2012. * try:
  2013. * return XQueue(queue_arg, attributes)
  2014. */
  2015. /* function exit code */
  2016. __pyx_L1_error:;
  2017. __Pyx_XDECREF(__pyx_t_4);
  2018. __Pyx_XDECREF(__pyx_t_5);
  2019. __Pyx_XDECREF(__pyx_t_6);
  2020. __Pyx_XDECREF(__pyx_t_8);
  2021. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xq", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2022. __pyx_r = NULL;
  2023. __pyx_L0:;
  2024. __Pyx_XDECREF(__pyx_v_e);
  2025. __Pyx_XGIVEREF(__pyx_r);
  2026. __Pyx_TraceReturn(__pyx_r);
  2027. __Pyx_RefNannyFinishContext();
  2028. return __pyx_r;
  2029. }
  2030. /* "lib/Naked/toolshed/c/casts.pyx":74
  2031. * # Cast a Python set to a XSet
  2032. * #------------------------------------------------------------------------------
  2033. * def xset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  2034. * try:
  2035. * return XSet(set_arg, attributes)
  2036. */
  2037. /* Python wrapper */
  2038. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_9xset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2039. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_9xset = {__Pyx_NAMESTR("xset"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_9xset, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  2040. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_9xset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2041. PyObject *__pyx_v_set_arg = 0;
  2042. PyObject *__pyx_v_attributes = 0;
  2043. int __pyx_lineno = 0;
  2044. const char *__pyx_filename = NULL;
  2045. int __pyx_clineno = 0;
  2046. PyObject *__pyx_r = 0;
  2047. __Pyx_RefNannyDeclarations
  2048. __Pyx_RefNannySetupContext("xset (wrapper)", 0);
  2049. {
  2050. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_set_arg,&__pyx_n_s_attributes,0};
  2051. PyObject* values[2] = {0,0};
  2052. values[1] = __pyx_k__8;
  2053. if (unlikely(__pyx_kwds)) {
  2054. Py_ssize_t kw_args;
  2055. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2056. switch (pos_args) {
  2057. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2058. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2059. case 0: break;
  2060. default: goto __pyx_L5_argtuple_error;
  2061. }
  2062. kw_args = PyDict_Size(__pyx_kwds);
  2063. switch (pos_args) {
  2064. case 0:
  2065. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_set_arg)) != 0)) kw_args--;
  2066. else goto __pyx_L5_argtuple_error;
  2067. case 1:
  2068. if (kw_args > 0) {
  2069. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attributes);
  2070. if (value) { values[1] = value; kw_args--; }
  2071. }
  2072. }
  2073. if (unlikely(kw_args > 0)) {
  2074. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xset") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2075. }
  2076. } else {
  2077. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2078. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2079. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2080. break;
  2081. default: goto __pyx_L5_argtuple_error;
  2082. }
  2083. }
  2084. __pyx_v_set_arg = values[0];
  2085. __pyx_v_attributes = values[1];
  2086. }
  2087. goto __pyx_L4_argument_unpacking_done;
  2088. __pyx_L5_argtuple_error:;
  2089. __Pyx_RaiseArgtupleInvalid("xset", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2090. __pyx_L3_error:;
  2091. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2092. __Pyx_RefNannyFinishContext();
  2093. return NULL;
  2094. __pyx_L4_argument_unpacking_done:;
  2095. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_5casts_8xset(__pyx_self, __pyx_v_set_arg, __pyx_v_attributes);
  2096. /* function exit code */
  2097. __Pyx_RefNannyFinishContext();
  2098. return __pyx_r;
  2099. }
  2100. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_8xset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_set_arg, PyObject *__pyx_v_attributes) {
  2101. PyObject *__pyx_v_e = NULL;
  2102. PyObject *__pyx_r = NULL;
  2103. __Pyx_RefNannyDeclarations
  2104. PyObject *__pyx_t_1 = NULL;
  2105. PyObject *__pyx_t_2 = NULL;
  2106. PyObject *__pyx_t_3 = NULL;
  2107. PyObject *__pyx_t_4 = NULL;
  2108. PyObject *__pyx_t_5 = NULL;
  2109. PyObject *__pyx_t_6 = NULL;
  2110. int __pyx_t_7;
  2111. PyObject *__pyx_t_8 = NULL;
  2112. int __pyx_t_9;
  2113. int __pyx_lineno = 0;
  2114. const char *__pyx_filename = NULL;
  2115. int __pyx_clineno = 0;
  2116. __Pyx_TraceDeclarations
  2117. __Pyx_RefNannySetupContext("xset", 0);
  2118. __Pyx_TraceCall("xset", __pyx_f[0], 74);
  2119. /* "lib/Naked/toolshed/c/casts.pyx":75
  2120. * #------------------------------------------------------------------------------
  2121. * def xset(set_arg, attributes={}):
  2122. * try: # <<<<<<<<<<<<<<
  2123. * return XSet(set_arg, attributes)
  2124. * except TypeError:
  2125. */
  2126. {
  2127. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  2128. __Pyx_XGOTREF(__pyx_t_1);
  2129. __Pyx_XGOTREF(__pyx_t_2);
  2130. __Pyx_XGOTREF(__pyx_t_3);
  2131. /*try:*/ {
  2132. /* "lib/Naked/toolshed/c/casts.pyx":76
  2133. * def xset(set_arg, attributes={}):
  2134. * try:
  2135. * return XSet(set_arg, attributes) # <<<<<<<<<<<<<<
  2136. * except TypeError:
  2137. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2138. */
  2139. __Pyx_XDECREF(__pyx_r);
  2140. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_XSet); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2141. __Pyx_GOTREF(__pyx_t_4);
  2142. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2143. __Pyx_GOTREF(__pyx_t_5);
  2144. __Pyx_INCREF(__pyx_v_set_arg);
  2145. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_set_arg);
  2146. __Pyx_GIVEREF(__pyx_v_set_arg);
  2147. __Pyx_INCREF(__pyx_v_attributes);
  2148. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_attributes);
  2149. __Pyx_GIVEREF(__pyx_v_attributes);
  2150. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2151. __Pyx_GOTREF(__pyx_t_6);
  2152. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2153. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2154. __pyx_r = __pyx_t_6;
  2155. __pyx_t_6 = 0;
  2156. goto __pyx_L7_try_return;
  2157. }
  2158. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2159. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2160. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2161. goto __pyx_L10_try_end;
  2162. __pyx_L3_error:;
  2163. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2164. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2165. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2166. /* "lib/Naked/toolshed/c/casts.pyx":77
  2167. * try:
  2168. * return XSet(set_arg, attributes)
  2169. * except TypeError: # <<<<<<<<<<<<<<
  2170. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2171. * except Exception as e:
  2172. */
  2173. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
  2174. if (__pyx_t_7) {
  2175. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2176. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2177. __Pyx_GOTREF(__pyx_t_6);
  2178. __Pyx_GOTREF(__pyx_t_5);
  2179. __Pyx_GOTREF(__pyx_t_4);
  2180. /* "lib/Naked/toolshed/c/casts.pyx":78
  2181. * return XSet(set_arg, attributes)
  2182. * except TypeError:
  2183. * raise TypeError("Attempted to cast to a XSet with an incompatible type") # <<<<<<<<<<<<<<
  2184. * except Exception as e:
  2185. * if DEBUG_FLAG:
  2186. */
  2187. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2188. __Pyx_GOTREF(__pyx_t_8);
  2189. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  2190. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2191. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2192. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2193. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2194. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2195. goto __pyx_L4_exception_handled;
  2196. }
  2197. /* "lib/Naked/toolshed/c/casts.pyx":79
  2198. * except TypeError:
  2199. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2200. * except Exception as e: # <<<<<<<<<<<<<<
  2201. * if DEBUG_FLAG:
  2202. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).")
  2203. */
  2204. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  2205. if (__pyx_t_7) {
  2206. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2207. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2208. __Pyx_GOTREF(__pyx_t_4);
  2209. __Pyx_GOTREF(__pyx_t_5);
  2210. __Pyx_GOTREF(__pyx_t_6);
  2211. __Pyx_INCREF(__pyx_t_5);
  2212. __pyx_v_e = __pyx_t_5;
  2213. /* "lib/Naked/toolshed/c/casts.pyx":80
  2214. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2215. * except Exception as e:
  2216. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  2217. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).")
  2218. * raise e
  2219. */
  2220. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2221. __Pyx_GOTREF(__pyx_t_8);
  2222. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2223. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2224. if (__pyx_t_9) {
  2225. /* "lib/Naked/toolshed/c/casts.pyx":81
  2226. * except Exception as e:
  2227. * if DEBUG_FLAG:
  2228. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).") # <<<<<<<<<<<<<<
  2229. * raise e
  2230. *
  2231. */
  2232. if (__Pyx_PrintOne(0, __pyx_kp_s_Naked_Framework_Error_unable_to_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2233. goto __pyx_L15;
  2234. }
  2235. __pyx_L15:;
  2236. /* "lib/Naked/toolshed/c/casts.pyx":82
  2237. * if DEBUG_FLAG:
  2238. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).")
  2239. * raise e # <<<<<<<<<<<<<<
  2240. *
  2241. * #------------------------------------------------------------------------------
  2242. */
  2243. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  2244. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2245. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2246. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2247. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2248. goto __pyx_L4_exception_handled;
  2249. }
  2250. goto __pyx_L5_except_error;
  2251. __pyx_L5_except_error:;
  2252. __Pyx_XGIVEREF(__pyx_t_1);
  2253. __Pyx_XGIVEREF(__pyx_t_2);
  2254. __Pyx_XGIVEREF(__pyx_t_3);
  2255. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2256. goto __pyx_L1_error;
  2257. __pyx_L7_try_return:;
  2258. __Pyx_XGIVEREF(__pyx_t_1);
  2259. __Pyx_XGIVEREF(__pyx_t_2);
  2260. __Pyx_XGIVEREF(__pyx_t_3);
  2261. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2262. goto __pyx_L0;
  2263. __pyx_L4_exception_handled:;
  2264. __Pyx_XGIVEREF(__pyx_t_1);
  2265. __Pyx_XGIVEREF(__pyx_t_2);
  2266. __Pyx_XGIVEREF(__pyx_t_3);
  2267. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2268. __pyx_L10_try_end:;
  2269. }
  2270. /* "lib/Naked/toolshed/c/casts.pyx":74
  2271. * # Cast a Python set to a XSet
  2272. * #------------------------------------------------------------------------------
  2273. * def xset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  2274. * try:
  2275. * return XSet(set_arg, attributes)
  2276. */
  2277. /* function exit code */
  2278. __pyx_L1_error:;
  2279. __Pyx_XDECREF(__pyx_t_4);
  2280. __Pyx_XDECREF(__pyx_t_5);
  2281. __Pyx_XDECREF(__pyx_t_6);
  2282. __Pyx_XDECREF(__pyx_t_8);
  2283. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2284. __pyx_r = NULL;
  2285. __pyx_L0:;
  2286. __Pyx_XDECREF(__pyx_v_e);
  2287. __Pyx_XGIVEREF(__pyx_r);
  2288. __Pyx_TraceReturn(__pyx_r);
  2289. __Pyx_RefNannyFinishContext();
  2290. return __pyx_r;
  2291. }
  2292. /* "lib/Naked/toolshed/c/casts.pyx":88
  2293. * # Cast a Python set to a XFSet
  2294. * #------------------------------------------------------------------------------
  2295. * def xfset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  2296. * try:
  2297. * return XFSet(set_arg, attributes)
  2298. */
  2299. /* Python wrapper */
  2300. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_11xfset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2301. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_11xfset = {__Pyx_NAMESTR("xfset"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_11xfset, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  2302. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_11xfset(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2303. PyObject *__pyx_v_set_arg = 0;
  2304. PyObject *__pyx_v_attributes = 0;
  2305. int __pyx_lineno = 0;
  2306. const char *__pyx_filename = NULL;
  2307. int __pyx_clineno = 0;
  2308. PyObject *__pyx_r = 0;
  2309. __Pyx_RefNannyDeclarations
  2310. __Pyx_RefNannySetupContext("xfset (wrapper)", 0);
  2311. {
  2312. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_set_arg,&__pyx_n_s_attributes,0};
  2313. PyObject* values[2] = {0,0};
  2314. values[1] = __pyx_k__10;
  2315. if (unlikely(__pyx_kwds)) {
  2316. Py_ssize_t kw_args;
  2317. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2318. switch (pos_args) {
  2319. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2320. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2321. case 0: break;
  2322. default: goto __pyx_L5_argtuple_error;
  2323. }
  2324. kw_args = PyDict_Size(__pyx_kwds);
  2325. switch (pos_args) {
  2326. case 0:
  2327. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_set_arg)) != 0)) kw_args--;
  2328. else goto __pyx_L5_argtuple_error;
  2329. case 1:
  2330. if (kw_args > 0) {
  2331. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attributes);
  2332. if (value) { values[1] = value; kw_args--; }
  2333. }
  2334. }
  2335. if (unlikely(kw_args > 0)) {
  2336. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xfset") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2337. }
  2338. } else {
  2339. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2340. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2341. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2342. break;
  2343. default: goto __pyx_L5_argtuple_error;
  2344. }
  2345. }
  2346. __pyx_v_set_arg = values[0];
  2347. __pyx_v_attributes = values[1];
  2348. }
  2349. goto __pyx_L4_argument_unpacking_done;
  2350. __pyx_L5_argtuple_error:;
  2351. __Pyx_RaiseArgtupleInvalid("xfset", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2352. __pyx_L3_error:;
  2353. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xfset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2354. __Pyx_RefNannyFinishContext();
  2355. return NULL;
  2356. __pyx_L4_argument_unpacking_done:;
  2357. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_5casts_10xfset(__pyx_self, __pyx_v_set_arg, __pyx_v_attributes);
  2358. /* function exit code */
  2359. __Pyx_RefNannyFinishContext();
  2360. return __pyx_r;
  2361. }
  2362. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_10xfset(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_set_arg, PyObject *__pyx_v_attributes) {
  2363. PyObject *__pyx_v_e = NULL;
  2364. PyObject *__pyx_r = NULL;
  2365. __Pyx_RefNannyDeclarations
  2366. PyObject *__pyx_t_1 = NULL;
  2367. PyObject *__pyx_t_2 = NULL;
  2368. PyObject *__pyx_t_3 = NULL;
  2369. PyObject *__pyx_t_4 = NULL;
  2370. PyObject *__pyx_t_5 = NULL;
  2371. PyObject *__pyx_t_6 = NULL;
  2372. int __pyx_t_7;
  2373. PyObject *__pyx_t_8 = NULL;
  2374. int __pyx_t_9;
  2375. int __pyx_lineno = 0;
  2376. const char *__pyx_filename = NULL;
  2377. int __pyx_clineno = 0;
  2378. __Pyx_TraceDeclarations
  2379. __Pyx_RefNannySetupContext("xfset", 0);
  2380. __Pyx_TraceCall("xfset", __pyx_f[0], 88);
  2381. /* "lib/Naked/toolshed/c/casts.pyx":89
  2382. * #------------------------------------------------------------------------------
  2383. * def xfset(set_arg, attributes={}):
  2384. * try: # <<<<<<<<<<<<<<
  2385. * return XFSet(set_arg, attributes)
  2386. * except TypeError:
  2387. */
  2388. {
  2389. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  2390. __Pyx_XGOTREF(__pyx_t_1);
  2391. __Pyx_XGOTREF(__pyx_t_2);
  2392. __Pyx_XGOTREF(__pyx_t_3);
  2393. /*try:*/ {
  2394. /* "lib/Naked/toolshed/c/casts.pyx":90
  2395. * def xfset(set_arg, attributes={}):
  2396. * try:
  2397. * return XFSet(set_arg, attributes) # <<<<<<<<<<<<<<
  2398. * except TypeError:
  2399. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2400. */
  2401. __Pyx_XDECREF(__pyx_r);
  2402. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_XFSet); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2403. __Pyx_GOTREF(__pyx_t_4);
  2404. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2405. __Pyx_GOTREF(__pyx_t_5);
  2406. __Pyx_INCREF(__pyx_v_set_arg);
  2407. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_set_arg);
  2408. __Pyx_GIVEREF(__pyx_v_set_arg);
  2409. __Pyx_INCREF(__pyx_v_attributes);
  2410. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_attributes);
  2411. __Pyx_GIVEREF(__pyx_v_attributes);
  2412. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2413. __Pyx_GOTREF(__pyx_t_6);
  2414. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2415. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2416. __pyx_r = __pyx_t_6;
  2417. __pyx_t_6 = 0;
  2418. goto __pyx_L7_try_return;
  2419. }
  2420. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2421. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2422. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2423. goto __pyx_L10_try_end;
  2424. __pyx_L3_error:;
  2425. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2426. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2427. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2428. /* "lib/Naked/toolshed/c/casts.pyx":91
  2429. * try:
  2430. * return XFSet(set_arg, attributes)
  2431. * except TypeError: # <<<<<<<<<<<<<<
  2432. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2433. * except Exception as e:
  2434. */
  2435. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
  2436. if (__pyx_t_7) {
  2437. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xfset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2438. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2439. __Pyx_GOTREF(__pyx_t_6);
  2440. __Pyx_GOTREF(__pyx_t_5);
  2441. __Pyx_GOTREF(__pyx_t_4);
  2442. /* "lib/Naked/toolshed/c/casts.pyx":92
  2443. * return XFSet(set_arg, attributes)
  2444. * except TypeError:
  2445. * raise TypeError("Attempted to cast to a XSet with an incompatible type") # <<<<<<<<<<<<<<
  2446. * except Exception as e:
  2447. * if DEBUG_FLAG:
  2448. */
  2449. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2450. __Pyx_GOTREF(__pyx_t_8);
  2451. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  2452. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2453. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2454. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2455. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2456. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2457. goto __pyx_L4_exception_handled;
  2458. }
  2459. /* "lib/Naked/toolshed/c/casts.pyx":93
  2460. * except TypeError:
  2461. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2462. * except Exception as e: # <<<<<<<<<<<<<<
  2463. * if DEBUG_FLAG:
  2464. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).")
  2465. */
  2466. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  2467. if (__pyx_t_7) {
  2468. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xfset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2469. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2470. __Pyx_GOTREF(__pyx_t_4);
  2471. __Pyx_GOTREF(__pyx_t_5);
  2472. __Pyx_GOTREF(__pyx_t_6);
  2473. __Pyx_INCREF(__pyx_t_5);
  2474. __pyx_v_e = __pyx_t_5;
  2475. /* "lib/Naked/toolshed/c/casts.pyx":94
  2476. * raise TypeError("Attempted to cast to a XSet with an incompatible type")
  2477. * except Exception as e:
  2478. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  2479. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).")
  2480. * raise e
  2481. */
  2482. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2483. __Pyx_GOTREF(__pyx_t_8);
  2484. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2485. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2486. if (__pyx_t_9) {
  2487. /* "lib/Naked/toolshed/c/casts.pyx":95
  2488. * except Exception as e:
  2489. * if DEBUG_FLAG:
  2490. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).") # <<<<<<<<<<<<<<
  2491. * raise e
  2492. *
  2493. */
  2494. if (__Pyx_PrintOne(0, __pyx_kp_s_Naked_Framework_Error_unable_to_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2495. goto __pyx_L15;
  2496. }
  2497. __pyx_L15:;
  2498. /* "lib/Naked/toolshed/c/casts.pyx":96
  2499. * if DEBUG_FLAG:
  2500. * print("Naked Framework Error: unable to cast object to a XSet with the xset() function (Naked.toolshed.casts.py).")
  2501. * raise e # <<<<<<<<<<<<<<
  2502. *
  2503. * #------------------------------------------------------------------------------
  2504. */
  2505. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  2506. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2507. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2508. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2509. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2510. goto __pyx_L4_exception_handled;
  2511. }
  2512. goto __pyx_L5_except_error;
  2513. __pyx_L5_except_error:;
  2514. __Pyx_XGIVEREF(__pyx_t_1);
  2515. __Pyx_XGIVEREF(__pyx_t_2);
  2516. __Pyx_XGIVEREF(__pyx_t_3);
  2517. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2518. goto __pyx_L1_error;
  2519. __pyx_L7_try_return:;
  2520. __Pyx_XGIVEREF(__pyx_t_1);
  2521. __Pyx_XGIVEREF(__pyx_t_2);
  2522. __Pyx_XGIVEREF(__pyx_t_3);
  2523. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2524. goto __pyx_L0;
  2525. __pyx_L4_exception_handled:;
  2526. __Pyx_XGIVEREF(__pyx_t_1);
  2527. __Pyx_XGIVEREF(__pyx_t_2);
  2528. __Pyx_XGIVEREF(__pyx_t_3);
  2529. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2530. __pyx_L10_try_end:;
  2531. }
  2532. /* "lib/Naked/toolshed/c/casts.pyx":88
  2533. * # Cast a Python set to a XFSet
  2534. * #------------------------------------------------------------------------------
  2535. * def xfset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  2536. * try:
  2537. * return XFSet(set_arg, attributes)
  2538. */
  2539. /* function exit code */
  2540. __pyx_L1_error:;
  2541. __Pyx_XDECREF(__pyx_t_4);
  2542. __Pyx_XDECREF(__pyx_t_5);
  2543. __Pyx_XDECREF(__pyx_t_6);
  2544. __Pyx_XDECREF(__pyx_t_8);
  2545. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xfset", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2546. __pyx_r = NULL;
  2547. __pyx_L0:;
  2548. __Pyx_XDECREF(__pyx_v_e);
  2549. __Pyx_XGIVEREF(__pyx_r);
  2550. __Pyx_TraceReturn(__pyx_r);
  2551. __Pyx_RefNannyFinishContext();
  2552. return __pyx_r;
  2553. }
  2554. /* "lib/Naked/toolshed/c/casts.pyx":102
  2555. * # Cast a Python string to a XString
  2556. * #------------------------------------------------------------------------------
  2557. * def xstr(string_arg, attributes={}): # <<<<<<<<<<<<<<
  2558. * try:
  2559. * return XString(string_arg, attributes)
  2560. */
  2561. /* Python wrapper */
  2562. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_13xstr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  2563. static PyMethodDef __pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_13xstr = {__Pyx_NAMESTR("xstr"), (PyCFunction)__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_13xstr, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)};
  2564. static PyObject *__pyx_pw_3lib_5Naked_8toolshed_1c_5casts_13xstr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  2565. PyObject *__pyx_v_string_arg = 0;
  2566. PyObject *__pyx_v_attributes = 0;
  2567. int __pyx_lineno = 0;
  2568. const char *__pyx_filename = NULL;
  2569. int __pyx_clineno = 0;
  2570. PyObject *__pyx_r = 0;
  2571. __Pyx_RefNannyDeclarations
  2572. __Pyx_RefNannySetupContext("xstr (wrapper)", 0);
  2573. {
  2574. static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_string_arg,&__pyx_n_s_attributes,0};
  2575. PyObject* values[2] = {0,0};
  2576. values[1] = __pyx_k__12;
  2577. if (unlikely(__pyx_kwds)) {
  2578. Py_ssize_t kw_args;
  2579. const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
  2580. switch (pos_args) {
  2581. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2582. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2583. case 0: break;
  2584. default: goto __pyx_L5_argtuple_error;
  2585. }
  2586. kw_args = PyDict_Size(__pyx_kwds);
  2587. switch (pos_args) {
  2588. case 0:
  2589. if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_string_arg)) != 0)) kw_args--;
  2590. else goto __pyx_L5_argtuple_error;
  2591. case 1:
  2592. if (kw_args > 0) {
  2593. PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_attributes);
  2594. if (value) { values[1] = value; kw_args--; }
  2595. }
  2596. }
  2597. if (unlikely(kw_args > 0)) {
  2598. if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "xstr") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2599. }
  2600. } else {
  2601. switch (PyTuple_GET_SIZE(__pyx_args)) {
  2602. case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
  2603. case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
  2604. break;
  2605. default: goto __pyx_L5_argtuple_error;
  2606. }
  2607. }
  2608. __pyx_v_string_arg = values[0];
  2609. __pyx_v_attributes = values[1];
  2610. }
  2611. goto __pyx_L4_argument_unpacking_done;
  2612. __pyx_L5_argtuple_error:;
  2613. __Pyx_RaiseArgtupleInvalid("xstr", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2614. __pyx_L3_error:;
  2615. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xstr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2616. __Pyx_RefNannyFinishContext();
  2617. return NULL;
  2618. __pyx_L4_argument_unpacking_done:;
  2619. __pyx_r = __pyx_pf_3lib_5Naked_8toolshed_1c_5casts_12xstr(__pyx_self, __pyx_v_string_arg, __pyx_v_attributes);
  2620. /* function exit code */
  2621. __Pyx_RefNannyFinishContext();
  2622. return __pyx_r;
  2623. }
  2624. static PyObject *__pyx_pf_3lib_5Naked_8toolshed_1c_5casts_12xstr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_string_arg, PyObject *__pyx_v_attributes) {
  2625. CYTHON_UNUSED PyObject *__pyx_v_te = NULL;
  2626. PyObject *__pyx_v_e = NULL;
  2627. PyObject *__pyx_r = NULL;
  2628. __Pyx_RefNannyDeclarations
  2629. PyObject *__pyx_t_1 = NULL;
  2630. PyObject *__pyx_t_2 = NULL;
  2631. PyObject *__pyx_t_3 = NULL;
  2632. PyObject *__pyx_t_4 = NULL;
  2633. PyObject *__pyx_t_5 = NULL;
  2634. PyObject *__pyx_t_6 = NULL;
  2635. int __pyx_t_7;
  2636. PyObject *__pyx_t_8 = NULL;
  2637. int __pyx_t_9;
  2638. int __pyx_lineno = 0;
  2639. const char *__pyx_filename = NULL;
  2640. int __pyx_clineno = 0;
  2641. __Pyx_TraceDeclarations
  2642. __Pyx_RefNannySetupContext("xstr", 0);
  2643. __Pyx_TraceCall("xstr", __pyx_f[0], 102);
  2644. /* "lib/Naked/toolshed/c/casts.pyx":103
  2645. * #------------------------------------------------------------------------------
  2646. * def xstr(string_arg, attributes={}):
  2647. * try: # <<<<<<<<<<<<<<
  2648. * return XString(string_arg, attributes)
  2649. * except TypeError as te:
  2650. */
  2651. {
  2652. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  2653. __Pyx_XGOTREF(__pyx_t_1);
  2654. __Pyx_XGOTREF(__pyx_t_2);
  2655. __Pyx_XGOTREF(__pyx_t_3);
  2656. /*try:*/ {
  2657. /* "lib/Naked/toolshed/c/casts.pyx":104
  2658. * def xstr(string_arg, attributes={}):
  2659. * try:
  2660. * return XString(string_arg, attributes) # <<<<<<<<<<<<<<
  2661. * except TypeError as te:
  2662. * raise TypeError("Attempted to cast to a XString with an incompatible type")
  2663. */
  2664. __Pyx_XDECREF(__pyx_r);
  2665. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_XString); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2666. __Pyx_GOTREF(__pyx_t_4);
  2667. __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2668. __Pyx_GOTREF(__pyx_t_5);
  2669. __Pyx_INCREF(__pyx_v_string_arg);
  2670. PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_string_arg);
  2671. __Pyx_GIVEREF(__pyx_v_string_arg);
  2672. __Pyx_INCREF(__pyx_v_attributes);
  2673. PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_attributes);
  2674. __Pyx_GIVEREF(__pyx_v_attributes);
  2675. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  2676. __Pyx_GOTREF(__pyx_t_6);
  2677. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2678. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2679. __pyx_r = __pyx_t_6;
  2680. __pyx_t_6 = 0;
  2681. goto __pyx_L7_try_return;
  2682. }
  2683. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  2684. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  2685. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  2686. goto __pyx_L10_try_end;
  2687. __pyx_L3_error:;
  2688. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  2689. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  2690. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  2691. /* "lib/Naked/toolshed/c/casts.pyx":105
  2692. * try:
  2693. * return XString(string_arg, attributes)
  2694. * except TypeError as te: # <<<<<<<<<<<<<<
  2695. * raise TypeError("Attempted to cast to a XString with an incompatible type")
  2696. * except Exception as e:
  2697. */
  2698. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_TypeError);
  2699. if (__pyx_t_7) {
  2700. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xstr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2701. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2702. __Pyx_GOTREF(__pyx_t_6);
  2703. __Pyx_GOTREF(__pyx_t_5);
  2704. __Pyx_GOTREF(__pyx_t_4);
  2705. __Pyx_INCREF(__pyx_t_5);
  2706. __pyx_v_te = __pyx_t_5;
  2707. /* "lib/Naked/toolshed/c/casts.pyx":106
  2708. * return XString(string_arg, attributes)
  2709. * except TypeError as te:
  2710. * raise TypeError("Attempted to cast to a XString with an incompatible type") # <<<<<<<<<<<<<<
  2711. * except Exception as e:
  2712. * if DEBUG_FLAG:
  2713. */
  2714. __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2715. __Pyx_GOTREF(__pyx_t_8);
  2716. __Pyx_Raise(__pyx_t_8, 0, 0, 0);
  2717. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2718. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2719. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2720. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2721. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2722. goto __pyx_L4_exception_handled;
  2723. }
  2724. /* "lib/Naked/toolshed/c/casts.pyx":107
  2725. * except TypeError as te:
  2726. * raise TypeError("Attempted to cast to a XString with an incompatible type")
  2727. * except Exception as e: # <<<<<<<<<<<<<<
  2728. * if DEBUG_FLAG:
  2729. * print("Naked Framework Error: unable to cast object to a XString with the xstr() function (Naked.toolshed.casts.py).")
  2730. */
  2731. __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_Exception);
  2732. if (__pyx_t_7) {
  2733. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xstr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2734. if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2735. __Pyx_GOTREF(__pyx_t_4);
  2736. __Pyx_GOTREF(__pyx_t_5);
  2737. __Pyx_GOTREF(__pyx_t_6);
  2738. __Pyx_INCREF(__pyx_t_5);
  2739. __pyx_v_e = __pyx_t_5;
  2740. /* "lib/Naked/toolshed/c/casts.pyx":108
  2741. * raise TypeError("Attempted to cast to a XString with an incompatible type")
  2742. * except Exception as e:
  2743. * if DEBUG_FLAG: # <<<<<<<<<<<<<<
  2744. * print("Naked Framework Error: unable to cast object to a XString with the xstr() function (Naked.toolshed.casts.py).")
  2745. * raise e
  2746. */
  2747. __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_DEBUG_FLAG); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2748. __Pyx_GOTREF(__pyx_t_8);
  2749. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2750. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  2751. if (__pyx_t_9) {
  2752. /* "lib/Naked/toolshed/c/casts.pyx":109
  2753. * except Exception as e:
  2754. * if DEBUG_FLAG:
  2755. * print("Naked Framework Error: unable to cast object to a XString with the xstr() function (Naked.toolshed.casts.py).") # <<<<<<<<<<<<<<
  2756. * raise e
  2757. *
  2758. */
  2759. if (__Pyx_PrintOne(0, __pyx_kp_s_Naked_Framework_Error_unable_to_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2760. goto __pyx_L15;
  2761. }
  2762. __pyx_L15:;
  2763. /* "lib/Naked/toolshed/c/casts.pyx":110
  2764. * if DEBUG_FLAG:
  2765. * print("Naked Framework Error: unable to cast object to a XString with the xstr() function (Naked.toolshed.casts.py).")
  2766. * raise e # <<<<<<<<<<<<<<
  2767. *
  2768. * if __name__ == '__main__':
  2769. */
  2770. __Pyx_Raise(__pyx_v_e, 0, 0, 0);
  2771. {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
  2772. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  2773. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  2774. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  2775. goto __pyx_L4_exception_handled;
  2776. }
  2777. goto __pyx_L5_except_error;
  2778. __pyx_L5_except_error:;
  2779. __Pyx_XGIVEREF(__pyx_t_1);
  2780. __Pyx_XGIVEREF(__pyx_t_2);
  2781. __Pyx_XGIVEREF(__pyx_t_3);
  2782. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2783. goto __pyx_L1_error;
  2784. __pyx_L7_try_return:;
  2785. __Pyx_XGIVEREF(__pyx_t_1);
  2786. __Pyx_XGIVEREF(__pyx_t_2);
  2787. __Pyx_XGIVEREF(__pyx_t_3);
  2788. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2789. goto __pyx_L0;
  2790. __pyx_L4_exception_handled:;
  2791. __Pyx_XGIVEREF(__pyx_t_1);
  2792. __Pyx_XGIVEREF(__pyx_t_2);
  2793. __Pyx_XGIVEREF(__pyx_t_3);
  2794. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  2795. __pyx_L10_try_end:;
  2796. }
  2797. /* "lib/Naked/toolshed/c/casts.pyx":102
  2798. * # Cast a Python string to a XString
  2799. * #------------------------------------------------------------------------------
  2800. * def xstr(string_arg, attributes={}): # <<<<<<<<<<<<<<
  2801. * try:
  2802. * return XString(string_arg, attributes)
  2803. */
  2804. /* function exit code */
  2805. __pyx_L1_error:;
  2806. __Pyx_XDECREF(__pyx_t_4);
  2807. __Pyx_XDECREF(__pyx_t_5);
  2808. __Pyx_XDECREF(__pyx_t_6);
  2809. __Pyx_XDECREF(__pyx_t_8);
  2810. __Pyx_AddTraceback("lib.Naked.toolshed.c.casts.xstr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  2811. __pyx_r = NULL;
  2812. __pyx_L0:;
  2813. __Pyx_XDECREF(__pyx_v_te);
  2814. __Pyx_XDECREF(__pyx_v_e);
  2815. __Pyx_XGIVEREF(__pyx_r);
  2816. __Pyx_TraceReturn(__pyx_r);
  2817. __Pyx_RefNannyFinishContext();
  2818. return __pyx_r;
  2819. }
  2820. static PyMethodDef __pyx_methods[] = {
  2821. {0, 0, 0, 0}
  2822. };
  2823. #if PY_MAJOR_VERSION >= 3
  2824. static struct PyModuleDef __pyx_moduledef = {
  2825. #if PY_VERSION_HEX < 0x03020000
  2826. { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
  2827. #else
  2828. PyModuleDef_HEAD_INIT,
  2829. #endif
  2830. __Pyx_NAMESTR("casts"),
  2831. 0, /* m_doc */
  2832. -1, /* m_size */
  2833. __pyx_methods /* m_methods */,
  2834. NULL, /* m_reload */
  2835. NULL, /* m_traverse */
  2836. NULL, /* m_clear */
  2837. NULL /* m_free */
  2838. };
  2839. #endif
  2840. static __Pyx_StringTabEntry __pyx_string_tab[] = {
  2841. {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
  2842. {&__pyx_kp_s_A_test, __pyx_k_A_test, sizeof(__pyx_k_A_test), 0, 0, 1, 0},
  2843. {&__pyx_kp_s_Attempted_to_cast_to_a_XDict_wit, __pyx_k_Attempted_to_cast_to_a_XDict_wit, sizeof(__pyx_k_Attempted_to_cast_to_a_XDict_wit), 0, 0, 1, 0},
  2844. {&__pyx_kp_s_Attempted_to_cast_to_a_XList_wit, __pyx_k_Attempted_to_cast_to_a_XList_wit, sizeof(__pyx_k_Attempted_to_cast_to_a_XList_wit), 0, 0, 1, 0},
  2845. {&__pyx_kp_s_Attempted_to_cast_to_a_XQueue_wi, __pyx_k_Attempted_to_cast_to_a_XQueue_wi, sizeof(__pyx_k_Attempted_to_cast_to_a_XQueue_wi), 0, 0, 1, 0},
  2846. {&__pyx_kp_s_Attempted_to_cast_to_a_XSet_with, __pyx_k_Attempted_to_cast_to_a_XSet_with, sizeof(__pyx_k_Attempted_to_cast_to_a_XSet_with), 0, 0, 1, 0},
  2847. {&__pyx_kp_s_Attempted_to_cast_to_a_XString_w, __pyx_k_Attempted_to_cast_to_a_XString_w, sizeof(__pyx_k_Attempted_to_cast_to_a_XString_w), 0, 0, 1, 0},
  2848. {&__pyx_n_s_DEBUG_FLAG, __pyx_k_DEBUG_FLAG, sizeof(__pyx_k_DEBUG_FLAG), 0, 0, 1, 1},
  2849. {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
  2850. {&__pyx_n_s_NakedObject, __pyx_k_NakedObject, sizeof(__pyx_k_NakedObject), 0, 0, 1, 1},
  2851. {&__pyx_kp_s_Naked_Framework_Error_unable_to, __pyx_k_Naked_Framework_Error_unable_to, sizeof(__pyx_k_Naked_Framework_Error_unable_to), 0, 0, 1, 0},
  2852. {&__pyx_kp_s_Naked_Framework_Error_unable_to_2, __pyx_k_Naked_Framework_Error_unable_to_2, sizeof(__pyx_k_Naked_Framework_Error_unable_to_2), 0, 0, 1, 0},
  2853. {&__pyx_kp_s_Naked_Framework_Error_unable_to_3, __pyx_k_Naked_Framework_Error_unable_to_3, sizeof(__pyx_k_Naked_Framework_Error_unable_to_3), 0, 0, 1, 0},
  2854. {&__pyx_kp_s_Naked_Framework_Error_unable_to_4, __pyx_k_Naked_Framework_Error_unable_to_4, sizeof(__pyx_k_Naked_Framework_Error_unable_to_4), 0, 0, 1, 0},
  2855. {&__pyx_kp_s_Naked_Framework_Error_unable_to_5, __pyx_k_Naked_Framework_Error_unable_to_5, sizeof(__pyx_k_Naked_Framework_Error_unable_to_5), 0, 0, 1, 0},
  2856. {&__pyx_kp_s_Naked_Framework_Error_unable_to_6, __pyx_k_Naked_Framework_Error_unable_to_6, sizeof(__pyx_k_Naked_Framework_Error_unable_to_6), 0, 0, 1, 0},
  2857. {&__pyx_n_s_Naked_settings, __pyx_k_Naked_settings, sizeof(__pyx_k_Naked_settings), 0, 0, 1, 1},
  2858. {&__pyx_n_s_Naked_toolshed_c_types, __pyx_k_Naked_toolshed_c_types, sizeof(__pyx_k_Naked_toolshed_c_types), 0, 0, 1, 1},
  2859. {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
  2860. {&__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},
  2861. {&__pyx_n_s_XDict, __pyx_k_XDict, sizeof(__pyx_k_XDict), 0, 0, 1, 1},
  2862. {&__pyx_n_s_XFSet, __pyx_k_XFSet, sizeof(__pyx_k_XFSet), 0, 0, 1, 1},
  2863. {&__pyx_n_s_XList, __pyx_k_XList, sizeof(__pyx_k_XList), 0, 0, 1, 1},
  2864. {&__pyx_n_s_XQueue, __pyx_k_XQueue, sizeof(__pyx_k_XQueue), 0, 0, 1, 1},
  2865. {&__pyx_n_s_XSet, __pyx_k_XSet, sizeof(__pyx_k_XSet), 0, 0, 1, 1},
  2866. {&__pyx_n_s_XString, __pyx_k_XString, sizeof(__pyx_k_XString), 0, 0, 1, 1},
  2867. {&__pyx_n_s_arg1, __pyx_k_arg1, sizeof(__pyx_k_arg1), 0, 0, 1, 1},
  2868. {&__pyx_n_s_attributes, __pyx_k_attributes, sizeof(__pyx_k_attributes), 0, 0, 1, 1},
  2869. {&__pyx_n_s_debug, __pyx_k_debug, sizeof(__pyx_k_debug), 0, 0, 1, 1},
  2870. {&__pyx_n_s_dictionary_arg, __pyx_k_dictionary_arg, sizeof(__pyx_k_dictionary_arg), 0, 0, 1, 1},
  2871. {&__pyx_n_s_e, __pyx_k_e, sizeof(__pyx_k_e), 0, 0, 1, 1},
  2872. {&__pyx_n_s_end, __pyx_k_end, sizeof(__pyx_k_end), 0, 0, 1, 1},
  2873. {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
  2874. {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
  2875. {&__pyx_n_s_lib_Naked_toolshed_c_casts, __pyx_k_lib_Naked_toolshed_c_casts, sizeof(__pyx_k_lib_Naked_toolshed_c_casts), 0, 0, 1, 1},
  2876. {&__pyx_n_s_list_arg, __pyx_k_list_arg, sizeof(__pyx_k_list_arg), 0, 0, 1, 1},
  2877. {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
  2878. {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
  2879. {&__pyx_n_s_nob, __pyx_k_nob, sizeof(__pyx_k_nob), 0, 0, 1, 1},
  2880. {&__pyx_n_s_print, __pyx_k_print, sizeof(__pyx_k_print), 0, 0, 1, 1},
  2881. {&__pyx_n_s_queue_arg, __pyx_k_queue_arg, sizeof(__pyx_k_queue_arg), 0, 0, 1, 1},
  2882. {&__pyx_n_s_set_arg, __pyx_k_set_arg, sizeof(__pyx_k_set_arg), 0, 0, 1, 1},
  2883. {&__pyx_n_s_string_arg, __pyx_k_string_arg, sizeof(__pyx_k_string_arg), 0, 0, 1, 1},
  2884. {&__pyx_n_s_te, __pyx_k_te, sizeof(__pyx_k_te), 0, 0, 1, 1},
  2885. {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
  2886. {&__pyx_n_s_test_2, __pyx_k_test_2, sizeof(__pyx_k_test_2), 0, 0, 1, 1},
  2887. {&__pyx_n_s_xd, __pyx_k_xd, sizeof(__pyx_k_xd), 0, 0, 1, 1},
  2888. {&__pyx_n_s_xfset, __pyx_k_xfset, sizeof(__pyx_k_xfset), 0, 0, 1, 1},
  2889. {&__pyx_n_s_xl, __pyx_k_xl, sizeof(__pyx_k_xl), 0, 0, 1, 1},
  2890. {&__pyx_n_s_xq, __pyx_k_xq, sizeof(__pyx_k_xq), 0, 0, 1, 1},
  2891. {&__pyx_n_s_xset, __pyx_k_xset, sizeof(__pyx_k_xset), 0, 0, 1, 1},
  2892. {&__pyx_n_s_xstr, __pyx_k_xstr, sizeof(__pyx_k_xstr), 0, 0, 1, 1},
  2893. {0, 0, 0, 0, 0, 0, 0}
  2894. };
  2895. static int __Pyx_InitCachedBuiltins(void) {
  2896. __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2897. __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2898. return 0;
  2899. __pyx_L1_error:;
  2900. return -1;
  2901. }
  2902. static int __Pyx_InitCachedConstants(void) {
  2903. __Pyx_RefNannyDeclarations
  2904. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  2905. /* "lib/Naked/toolshed/c/casts.pyx":36
  2906. * return XDict(dictionary_arg, attributes)
  2907. * except TypeError:
  2908. * raise TypeError("Attempted to cast to a XDict with an incompatible type") # <<<<<<<<<<<<<<
  2909. * except Exception as e:
  2910. * if DEBUG_FLAG:
  2911. */
  2912. __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_Attempted_to_cast_to_a_XDict_wit); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2913. __Pyx_GOTREF(__pyx_tuple__3);
  2914. __Pyx_GIVEREF(__pyx_tuple__3);
  2915. /* "lib/Naked/toolshed/c/casts.pyx":50
  2916. * return XList(list_arg, attributes)
  2917. * except TypeError:
  2918. * raise TypeError("Attempted to cast to a XList with an incompatible type") # <<<<<<<<<<<<<<
  2919. * except Exception as e:
  2920. * if DEBUG_FLAG:
  2921. */
  2922. __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_Attempted_to_cast_to_a_XList_wit); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2923. __Pyx_GOTREF(__pyx_tuple__5);
  2924. __Pyx_GIVEREF(__pyx_tuple__5);
  2925. /* "lib/Naked/toolshed/c/casts.pyx":64
  2926. * return XQueue(queue_arg, attributes)
  2927. * except TypeError:
  2928. * raise TypeError("Attempted to cast to a XQueue with an incompatible type") # <<<<<<<<<<<<<<
  2929. * except Exception as e:
  2930. * if DEBUG_FLAG:
  2931. */
  2932. __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Attempted_to_cast_to_a_XQueue_wi); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2933. __Pyx_GOTREF(__pyx_tuple__7);
  2934. __Pyx_GIVEREF(__pyx_tuple__7);
  2935. /* "lib/Naked/toolshed/c/casts.pyx":78
  2936. * return XSet(set_arg, attributes)
  2937. * except TypeError:
  2938. * raise TypeError("Attempted to cast to a XSet with an incompatible type") # <<<<<<<<<<<<<<
  2939. * except Exception as e:
  2940. * if DEBUG_FLAG:
  2941. */
  2942. __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_Attempted_to_cast_to_a_XSet_with); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2943. __Pyx_GOTREF(__pyx_tuple__9);
  2944. __Pyx_GIVEREF(__pyx_tuple__9);
  2945. /* "lib/Naked/toolshed/c/casts.pyx":92
  2946. * return XFSet(set_arg, attributes)
  2947. * except TypeError:
  2948. * raise TypeError("Attempted to cast to a XSet with an incompatible type") # <<<<<<<<<<<<<<
  2949. * except Exception as e:
  2950. * if DEBUG_FLAG:
  2951. */
  2952. __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_Attempted_to_cast_to_a_XSet_with); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2953. __Pyx_GOTREF(__pyx_tuple__11);
  2954. __Pyx_GIVEREF(__pyx_tuple__11);
  2955. /* "lib/Naked/toolshed/c/casts.pyx":106
  2956. * return XString(string_arg, attributes)
  2957. * except TypeError as te:
  2958. * raise TypeError("Attempted to cast to a XString with an incompatible type") # <<<<<<<<<<<<<<
  2959. * except Exception as e:
  2960. * if DEBUG_FLAG:
  2961. */
  2962. __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Attempted_to_cast_to_a_XString_w); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2963. __Pyx_GOTREF(__pyx_tuple__13);
  2964. __Pyx_GIVEREF(__pyx_tuple__13);
  2965. /* "lib/Naked/toolshed/c/casts.pyx":20
  2966. * # Cast a dictionary of attributes to a NakedObject with key>attribute mapping
  2967. * #------------------------------------------------------------------------------
  2968. * def nob(attributes={}): # <<<<<<<<<<<<<<
  2969. * try:
  2970. * return NakedObject(attributes)
  2971. */
  2972. __pyx_tuple__14 = PyTuple_Pack(2, __pyx_n_s_attributes, __pyx_n_s_e); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2973. __Pyx_GOTREF(__pyx_tuple__14);
  2974. __Pyx_GIVEREF(__pyx_tuple__14);
  2975. __pyx_codeobj__15 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_nob, 20, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2976. /* "lib/Naked/toolshed/c/casts.pyx":32
  2977. * # Cast a Python dictionary to a XDict
  2978. * #------------------------------------------------------------------------------
  2979. * def xd(dictionary_arg, attributes={}): # <<<<<<<<<<<<<<
  2980. * try:
  2981. * return XDict(dictionary_arg, attributes)
  2982. */
  2983. __pyx_tuple__16 = PyTuple_Pack(3, __pyx_n_s_dictionary_arg, __pyx_n_s_attributes, __pyx_n_s_e); if (unlikely(!__pyx_tuple__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2984. __Pyx_GOTREF(__pyx_tuple__16);
  2985. __Pyx_GIVEREF(__pyx_tuple__16);
  2986. __pyx_codeobj__17 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__16, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_xd, 32, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2987. /* "lib/Naked/toolshed/c/casts.pyx":46
  2988. * # Cast a Python list, set, or tuple to a XList
  2989. * #------------------------------------------------------------------------------
  2990. * def xl(list_arg, attributes={}): # <<<<<<<<<<<<<<
  2991. * try:
  2992. * return XList(list_arg, attributes)
  2993. */
  2994. __pyx_tuple__18 = PyTuple_Pack(3, __pyx_n_s_list_arg, __pyx_n_s_attributes, __pyx_n_s_e); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2995. __Pyx_GOTREF(__pyx_tuple__18);
  2996. __Pyx_GIVEREF(__pyx_tuple__18);
  2997. __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_xl, 46, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  2998. /* "lib/Naked/toolshed/c/casts.pyx":60
  2999. * # Cast a Python list, set, tuple to a XQueue
  3000. * #------------------------------------------------------------------------------
  3001. * def xq(queue_arg, attributes={}): # <<<<<<<<<<<<<<
  3002. * try:
  3003. * return XQueue(queue_arg, attributes)
  3004. */
  3005. __pyx_tuple__20 = PyTuple_Pack(3, __pyx_n_s_queue_arg, __pyx_n_s_attributes, __pyx_n_s_e); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3006. __Pyx_GOTREF(__pyx_tuple__20);
  3007. __Pyx_GIVEREF(__pyx_tuple__20);
  3008. __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_xq, 60, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3009. /* "lib/Naked/toolshed/c/casts.pyx":74
  3010. * # Cast a Python set to a XSet
  3011. * #------------------------------------------------------------------------------
  3012. * def xset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  3013. * try:
  3014. * return XSet(set_arg, attributes)
  3015. */
  3016. __pyx_tuple__22 = PyTuple_Pack(3, __pyx_n_s_set_arg, __pyx_n_s_attributes, __pyx_n_s_e); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3017. __Pyx_GOTREF(__pyx_tuple__22);
  3018. __Pyx_GIVEREF(__pyx_tuple__22);
  3019. __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_xset, 74, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3020. /* "lib/Naked/toolshed/c/casts.pyx":88
  3021. * # Cast a Python set to a XFSet
  3022. * #------------------------------------------------------------------------------
  3023. * def xfset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  3024. * try:
  3025. * return XFSet(set_arg, attributes)
  3026. */
  3027. __pyx_tuple__24 = PyTuple_Pack(3, __pyx_n_s_set_arg, __pyx_n_s_attributes, __pyx_n_s_e); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3028. __Pyx_GOTREF(__pyx_tuple__24);
  3029. __Pyx_GIVEREF(__pyx_tuple__24);
  3030. __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_xfset, 88, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3031. /* "lib/Naked/toolshed/c/casts.pyx":102
  3032. * # Cast a Python string to a XString
  3033. * #------------------------------------------------------------------------------
  3034. * def xstr(string_arg, attributes={}): # <<<<<<<<<<<<<<
  3035. * try:
  3036. * return XString(string_arg, attributes)
  3037. */
  3038. __pyx_tuple__26 = PyTuple_Pack(4, __pyx_n_s_string_arg, __pyx_n_s_attributes, __pyx_n_s_te, __pyx_n_s_e); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3039. __Pyx_GOTREF(__pyx_tuple__26);
  3040. __Pyx_GIVEREF(__pyx_tuple__26);
  3041. __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_ces_Desktop_code_naked_li, __pyx_n_s_xstr, 102, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3042. __Pyx_RefNannyFinishContext();
  3043. return 0;
  3044. __pyx_L1_error:;
  3045. __Pyx_RefNannyFinishContext();
  3046. return -1;
  3047. }
  3048. static int __Pyx_InitGlobals(void) {
  3049. if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  3050. return 0;
  3051. __pyx_L1_error:;
  3052. return -1;
  3053. }
  3054. #if PY_MAJOR_VERSION < 3
  3055. PyMODINIT_FUNC initcasts(void); /*proto*/
  3056. PyMODINIT_FUNC initcasts(void)
  3057. #else
  3058. PyMODINIT_FUNC PyInit_casts(void); /*proto*/
  3059. PyMODINIT_FUNC PyInit_casts(void)
  3060. #endif
  3061. {
  3062. PyObject *__pyx_t_1 = NULL;
  3063. PyObject *__pyx_t_2 = NULL;
  3064. int __pyx_t_3;
  3065. PyObject *__pyx_t_4 = NULL;
  3066. int __pyx_lineno = 0;
  3067. const char *__pyx_filename = NULL;
  3068. int __pyx_clineno = 0;
  3069. __Pyx_RefNannyDeclarations
  3070. #if CYTHON_REFNANNY
  3071. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  3072. if (!__Pyx_RefNanny) {
  3073. PyErr_Clear();
  3074. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  3075. if (!__Pyx_RefNanny)
  3076. Py_FatalError("failed to import 'refnanny' module");
  3077. }
  3078. #endif
  3079. __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_casts(void)", 0);
  3080. if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3081. __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;}
  3082. __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;}
  3083. #ifdef __Pyx_CyFunction_USED
  3084. if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3085. #endif
  3086. #ifdef __Pyx_FusedFunction_USED
  3087. if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3088. #endif
  3089. #ifdef __Pyx_Generator_USED
  3090. if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3091. #endif
  3092. /*--- Library function declarations ---*/
  3093. /*--- Threads initialization code ---*/
  3094. #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  3095. #ifdef WITH_THREAD /* Python build with threading support? */
  3096. PyEval_InitThreads();
  3097. #endif
  3098. #endif
  3099. /*--- Module creation code ---*/
  3100. #if PY_MAJOR_VERSION < 3
  3101. __pyx_m = Py_InitModule4(__Pyx_NAMESTR("casts"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
  3102. #else
  3103. __pyx_m = PyModule_Create(&__pyx_moduledef);
  3104. #endif
  3105. if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3106. __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;}
  3107. Py_INCREF(__pyx_d);
  3108. __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;}
  3109. #if CYTHON_COMPILING_IN_PYPY
  3110. Py_INCREF(__pyx_b);
  3111. #endif
  3112. if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  3113. /*--- Initialize various global constants etc. ---*/
  3114. if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3115. #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
  3116. if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3117. #endif
  3118. if (__pyx_module_is_main_lib__Naked__toolshed__c__casts) {
  3119. 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;};
  3120. }
  3121. #if PY_MAJOR_VERSION >= 3
  3122. {
  3123. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3124. if (!PyDict_GetItemString(modules, "lib.Naked.toolshed.c.casts")) {
  3125. if (unlikely(PyDict_SetItemString(modules, "lib.Naked.toolshed.c.casts", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3126. }
  3127. }
  3128. #endif
  3129. /*--- Builtin init code ---*/
  3130. if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3131. /*--- Constants init code ---*/
  3132. if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3133. /*--- Global init code ---*/
  3134. /*--- Variable export code ---*/
  3135. /*--- Function export code ---*/
  3136. /*--- Type init code ---*/
  3137. /*--- Type import code ---*/
  3138. /*--- Variable import code ---*/
  3139. /*--- Function import code ---*/
  3140. /*--- Execution code ---*/
  3141. /* "lib/Naked/toolshed/c/casts.pyx":13
  3142. * return count
  3143. *
  3144. * from Naked.toolshed.c.types import NakedObject, XFSet, XDict, XList, XQueue, XSet, XString # <<<<<<<<<<<<<<
  3145. * from Naked.settings import debug as DEBUG_FLAG
  3146. *
  3147. */
  3148. __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3149. __Pyx_GOTREF(__pyx_t_1);
  3150. __Pyx_INCREF(__pyx_n_s_NakedObject);
  3151. PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_NakedObject);
  3152. __Pyx_GIVEREF(__pyx_n_s_NakedObject);
  3153. __Pyx_INCREF(__pyx_n_s_XFSet);
  3154. PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_XFSet);
  3155. __Pyx_GIVEREF(__pyx_n_s_XFSet);
  3156. __Pyx_INCREF(__pyx_n_s_XDict);
  3157. PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_XDict);
  3158. __Pyx_GIVEREF(__pyx_n_s_XDict);
  3159. __Pyx_INCREF(__pyx_n_s_XList);
  3160. PyList_SET_ITEM(__pyx_t_1, 3, __pyx_n_s_XList);
  3161. __Pyx_GIVEREF(__pyx_n_s_XList);
  3162. __Pyx_INCREF(__pyx_n_s_XQueue);
  3163. PyList_SET_ITEM(__pyx_t_1, 4, __pyx_n_s_XQueue);
  3164. __Pyx_GIVEREF(__pyx_n_s_XQueue);
  3165. __Pyx_INCREF(__pyx_n_s_XSet);
  3166. PyList_SET_ITEM(__pyx_t_1, 5, __pyx_n_s_XSet);
  3167. __Pyx_GIVEREF(__pyx_n_s_XSet);
  3168. __Pyx_INCREF(__pyx_n_s_XString);
  3169. PyList_SET_ITEM(__pyx_t_1, 6, __pyx_n_s_XString);
  3170. __Pyx_GIVEREF(__pyx_n_s_XString);
  3171. __pyx_t_2 = __Pyx_Import(__pyx_n_s_Naked_toolshed_c_types, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3172. __Pyx_GOTREF(__pyx_t_2);
  3173. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3174. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_NakedObject); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3175. __Pyx_GOTREF(__pyx_t_1);
  3176. if (PyDict_SetItem(__pyx_d, __pyx_n_s_NakedObject, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3177. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3178. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_XFSet); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3179. __Pyx_GOTREF(__pyx_t_1);
  3180. if (PyDict_SetItem(__pyx_d, __pyx_n_s_XFSet, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3181. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3182. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_XDict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3183. __Pyx_GOTREF(__pyx_t_1);
  3184. if (PyDict_SetItem(__pyx_d, __pyx_n_s_XDict, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3185. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3186. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_XList); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3187. __Pyx_GOTREF(__pyx_t_1);
  3188. if (PyDict_SetItem(__pyx_d, __pyx_n_s_XList, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3189. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3190. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_XQueue); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3191. __Pyx_GOTREF(__pyx_t_1);
  3192. if (PyDict_SetItem(__pyx_d, __pyx_n_s_XQueue, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3193. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3194. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_XSet); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3195. __Pyx_GOTREF(__pyx_t_1);
  3196. if (PyDict_SetItem(__pyx_d, __pyx_n_s_XSet, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3197. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3198. __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_XString); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3199. __Pyx_GOTREF(__pyx_t_1);
  3200. if (PyDict_SetItem(__pyx_d, __pyx_n_s_XString, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3201. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3202. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3203. /* "lib/Naked/toolshed/c/casts.pyx":14
  3204. *
  3205. * from Naked.toolshed.c.types import NakedObject, XFSet, XDict, XList, XQueue, XSet, XString
  3206. * from Naked.settings import debug as DEBUG_FLAG # <<<<<<<<<<<<<<
  3207. *
  3208. * #------------------------------------------------------------------------------
  3209. */
  3210. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3211. __Pyx_GOTREF(__pyx_t_2);
  3212. __Pyx_INCREF(__pyx_n_s_debug);
  3213. PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_debug);
  3214. __Pyx_GIVEREF(__pyx_n_s_debug);
  3215. __pyx_t_1 = __Pyx_Import(__pyx_n_s_Naked_settings, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3216. __Pyx_GOTREF(__pyx_t_1);
  3217. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3218. __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_debug); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3219. __Pyx_GOTREF(__pyx_t_2);
  3220. if (PyDict_SetItem(__pyx_d, __pyx_n_s_DEBUG_FLAG, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3221. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3222. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3223. /* "lib/Naked/toolshed/c/casts.pyx":20
  3224. * # Cast a dictionary of attributes to a NakedObject with key>attribute mapping
  3225. * #------------------------------------------------------------------------------
  3226. * def nob(attributes={}): # <<<<<<<<<<<<<<
  3227. * try:
  3228. * return NakedObject(attributes)
  3229. */
  3230. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3231. __Pyx_GOTREF(__pyx_t_1);
  3232. __pyx_k_ = __pyx_t_1;
  3233. __Pyx_GIVEREF(__pyx_t_1);
  3234. __pyx_t_1 = 0;
  3235. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_1nob, NULL, __pyx_n_s_lib_Naked_toolshed_c_casts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3236. __Pyx_GOTREF(__pyx_t_1);
  3237. if (PyDict_SetItem(__pyx_d, __pyx_n_s_nob, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3238. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3239. /* "lib/Naked/toolshed/c/casts.pyx":32
  3240. * # Cast a Python dictionary to a XDict
  3241. * #------------------------------------------------------------------------------
  3242. * def xd(dictionary_arg, attributes={}): # <<<<<<<<<<<<<<
  3243. * try:
  3244. * return XDict(dictionary_arg, attributes)
  3245. */
  3246. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3247. __Pyx_GOTREF(__pyx_t_1);
  3248. __pyx_k__2 = __pyx_t_1;
  3249. __Pyx_GIVEREF(__pyx_t_1);
  3250. __pyx_t_1 = 0;
  3251. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_3xd, NULL, __pyx_n_s_lib_Naked_toolshed_c_casts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3252. __Pyx_GOTREF(__pyx_t_1);
  3253. if (PyDict_SetItem(__pyx_d, __pyx_n_s_xd, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3254. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3255. /* "lib/Naked/toolshed/c/casts.pyx":46
  3256. * # Cast a Python list, set, or tuple to a XList
  3257. * #------------------------------------------------------------------------------
  3258. * def xl(list_arg, attributes={}): # <<<<<<<<<<<<<<
  3259. * try:
  3260. * return XList(list_arg, attributes)
  3261. */
  3262. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3263. __Pyx_GOTREF(__pyx_t_1);
  3264. __pyx_k__4 = __pyx_t_1;
  3265. __Pyx_GIVEREF(__pyx_t_1);
  3266. __pyx_t_1 = 0;
  3267. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_5xl, NULL, __pyx_n_s_lib_Naked_toolshed_c_casts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3268. __Pyx_GOTREF(__pyx_t_1);
  3269. if (PyDict_SetItem(__pyx_d, __pyx_n_s_xl, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3270. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3271. /* "lib/Naked/toolshed/c/casts.pyx":60
  3272. * # Cast a Python list, set, tuple to a XQueue
  3273. * #------------------------------------------------------------------------------
  3274. * def xq(queue_arg, attributes={}): # <<<<<<<<<<<<<<
  3275. * try:
  3276. * return XQueue(queue_arg, attributes)
  3277. */
  3278. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3279. __Pyx_GOTREF(__pyx_t_1);
  3280. __pyx_k__6 = __pyx_t_1;
  3281. __Pyx_GIVEREF(__pyx_t_1);
  3282. __pyx_t_1 = 0;
  3283. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_7xq, NULL, __pyx_n_s_lib_Naked_toolshed_c_casts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3284. __Pyx_GOTREF(__pyx_t_1);
  3285. if (PyDict_SetItem(__pyx_d, __pyx_n_s_xq, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3286. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3287. /* "lib/Naked/toolshed/c/casts.pyx":74
  3288. * # Cast a Python set to a XSet
  3289. * #------------------------------------------------------------------------------
  3290. * def xset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  3291. * try:
  3292. * return XSet(set_arg, attributes)
  3293. */
  3294. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3295. __Pyx_GOTREF(__pyx_t_1);
  3296. __pyx_k__8 = __pyx_t_1;
  3297. __Pyx_GIVEREF(__pyx_t_1);
  3298. __pyx_t_1 = 0;
  3299. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_9xset, NULL, __pyx_n_s_lib_Naked_toolshed_c_casts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3300. __Pyx_GOTREF(__pyx_t_1);
  3301. if (PyDict_SetItem(__pyx_d, __pyx_n_s_xset, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3302. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3303. /* "lib/Naked/toolshed/c/casts.pyx":88
  3304. * # Cast a Python set to a XFSet
  3305. * #------------------------------------------------------------------------------
  3306. * def xfset(set_arg, attributes={}): # <<<<<<<<<<<<<<
  3307. * try:
  3308. * return XFSet(set_arg, attributes)
  3309. */
  3310. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3311. __Pyx_GOTREF(__pyx_t_1);
  3312. __pyx_k__10 = __pyx_t_1;
  3313. __Pyx_GIVEREF(__pyx_t_1);
  3314. __pyx_t_1 = 0;
  3315. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_11xfset, NULL, __pyx_n_s_lib_Naked_toolshed_c_casts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3316. __Pyx_GOTREF(__pyx_t_1);
  3317. if (PyDict_SetItem(__pyx_d, __pyx_n_s_xfset, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3318. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3319. /* "lib/Naked/toolshed/c/casts.pyx":102
  3320. * # Cast a Python string to a XString
  3321. * #------------------------------------------------------------------------------
  3322. * def xstr(string_arg, attributes={}): # <<<<<<<<<<<<<<
  3323. * try:
  3324. * return XString(string_arg, attributes)
  3325. */
  3326. __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3327. __Pyx_GOTREF(__pyx_t_1);
  3328. __pyx_k__12 = __pyx_t_1;
  3329. __Pyx_GIVEREF(__pyx_t_1);
  3330. __pyx_t_1 = 0;
  3331. __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3lib_5Naked_8toolshed_1c_5casts_13xstr, NULL, __pyx_n_s_lib_Naked_toolshed_c_casts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3332. __Pyx_GOTREF(__pyx_t_1);
  3333. if (PyDict_SetItem(__pyx_d, __pyx_n_s_xstr, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3334. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3335. /* "lib/Naked/toolshed/c/casts.pyx":112
  3336. * raise e
  3337. *
  3338. * if __name__ == '__main__': # <<<<<<<<<<<<<<
  3339. * test = xstr("A test", {'arg1': '2'})
  3340. * print(test)
  3341. */
  3342. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3343. __Pyx_GOTREF(__pyx_t_1);
  3344. __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_n_s_main, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3345. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3346. if (__pyx_t_3) {
  3347. /* "lib/Naked/toolshed/c/casts.pyx":113
  3348. *
  3349. * if __name__ == '__main__':
  3350. * test = xstr("A test", {'arg1': '2'}) # <<<<<<<<<<<<<<
  3351. * print(test)
  3352. * print(test[0])
  3353. */
  3354. __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_xstr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3355. __Pyx_GOTREF(__pyx_t_1);
  3356. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3357. __Pyx_GOTREF(__pyx_t_2);
  3358. if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_arg1, __pyx_kp_s_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3359. __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3360. __Pyx_GOTREF(__pyx_t_4);
  3361. __Pyx_INCREF(__pyx_kp_s_A_test);
  3362. PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_kp_s_A_test);
  3363. __Pyx_GIVEREF(__pyx_kp_s_A_test);
  3364. PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  3365. __Pyx_GIVEREF(__pyx_t_2);
  3366. __pyx_t_2 = 0;
  3367. __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3368. __Pyx_GOTREF(__pyx_t_2);
  3369. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3370. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3371. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3372. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3373. /* "lib/Naked/toolshed/c/casts.pyx":114
  3374. * if __name__ == '__main__':
  3375. * test = xstr("A test", {'arg1': '2'})
  3376. * print(test) # <<<<<<<<<<<<<<
  3377. * print(test[0])
  3378. * print(test.arg1)
  3379. */
  3380. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_test); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3381. __Pyx_GOTREF(__pyx_t_2);
  3382. if (__Pyx_PrintOne(0, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3383. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3384. /* "lib/Naked/toolshed/c/casts.pyx":115
  3385. * test = xstr("A test", {'arg1': '2'})
  3386. * print(test)
  3387. * print(test[0]) # <<<<<<<<<<<<<<
  3388. * print(test.arg1)
  3389. * print(type(test))
  3390. */
  3391. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_test); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3392. __Pyx_GOTREF(__pyx_t_2);
  3393. __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  3394. __Pyx_GOTREF(__pyx_t_4);
  3395. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3396. if (__Pyx_PrintOne(0, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3397. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3398. /* "lib/Naked/toolshed/c/casts.pyx":116
  3399. * print(test)
  3400. * print(test[0])
  3401. * print(test.arg1) # <<<<<<<<<<<<<<
  3402. * print(type(test))
  3403. */
  3404. __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_test); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3405. __Pyx_GOTREF(__pyx_t_4);
  3406. __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_arg1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3407. __Pyx_GOTREF(__pyx_t_2);
  3408. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3409. if (__Pyx_PrintOne(0, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3410. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3411. /* "lib/Naked/toolshed/c/casts.pyx":117
  3412. * print(test[0])
  3413. * print(test.arg1)
  3414. * print(type(test)) # <<<<<<<<<<<<<<
  3415. */
  3416. __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_test); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3417. __Pyx_GOTREF(__pyx_t_2);
  3418. if (__Pyx_PrintOne(0, ((PyObject *)Py_TYPE(__pyx_t_2))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3419. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3420. goto __pyx_L2;
  3421. }
  3422. __pyx_L2:;
  3423. /* "lib/Naked/toolshed/c/casts.pyx":1
  3424. * #!/usr/bin/env python # <<<<<<<<<<<<<<
  3425. * # encoding: utf-8
  3426. * # cython: profile=True
  3427. */
  3428. __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3429. __Pyx_GOTREF(__pyx_t_2);
  3430. if (PyDict_SetItem(__pyx_d, __pyx_n_s_test_2, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  3431. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3432. goto __pyx_L0;
  3433. __pyx_L1_error:;
  3434. __Pyx_XDECREF(__pyx_t_1);
  3435. __Pyx_XDECREF(__pyx_t_2);
  3436. __Pyx_XDECREF(__pyx_t_4);
  3437. if (__pyx_m) {
  3438. __Pyx_AddTraceback("init lib.Naked.toolshed.c.casts", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3439. Py_DECREF(__pyx_m); __pyx_m = 0;
  3440. } else if (!PyErr_Occurred()) {
  3441. PyErr_SetString(PyExc_ImportError, "init lib.Naked.toolshed.c.casts");
  3442. }
  3443. __pyx_L0:;
  3444. __Pyx_RefNannyFinishContext();
  3445. #if PY_MAJOR_VERSION < 3
  3446. return;
  3447. #else
  3448. return __pyx_m;
  3449. #endif
  3450. }
  3451. /* Runtime support code */
  3452. #if CYTHON_REFNANNY
  3453. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  3454. PyObject *m = NULL, *p = NULL;
  3455. void *r = NULL;
  3456. m = PyImport_ImportModule((char *)modname);
  3457. if (!m) goto end;
  3458. p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
  3459. if (!p) goto end;
  3460. r = PyLong_AsVoidPtr(p);
  3461. end:
  3462. Py_XDECREF(p);
  3463. Py_XDECREF(m);
  3464. return (__Pyx_RefNannyAPIStruct *)r;
  3465. }
  3466. #endif /* CYTHON_REFNANNY */
  3467. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  3468. PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
  3469. if (unlikely(!result)) {
  3470. PyErr_Format(PyExc_NameError,
  3471. #if PY_MAJOR_VERSION >= 3
  3472. "name '%U' is not defined", name);
  3473. #else
  3474. "name '%.200s' is not defined", PyString_AS_STRING(name));
  3475. #endif
  3476. }
  3477. return result;
  3478. }
  3479. #if CYTHON_PROFILE
  3480. static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
  3481. PyFrameObject** frame,
  3482. const char *funcname,
  3483. const char *srcfile,
  3484. int firstlineno) {
  3485. int retval;
  3486. PyThreadState* tstate = PyThreadState_GET();
  3487. if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
  3488. if (*code == NULL) {
  3489. *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
  3490. if (*code == NULL) return 0;
  3491. }
  3492. *frame = PyFrame_New(
  3493. tstate, /*PyThreadState *tstate*/
  3494. *code, /*PyCodeObject *code*/
  3495. __pyx_d, /*PyObject *globals*/
  3496. 0 /*PyObject *locals*/
  3497. );
  3498. if (*frame == NULL) return 0;
  3499. if (CYTHON_TRACE && (*frame)->f_trace == NULL) {
  3500. Py_INCREF(Py_None);
  3501. (*frame)->f_trace = Py_None;
  3502. }
  3503. #if PY_VERSION_HEX < 0x030400B1
  3504. } else {
  3505. (*frame)->f_tstate = tstate;
  3506. #endif
  3507. }
  3508. (*frame)->f_lineno = firstlineno;
  3509. tstate->use_tracing = 0;
  3510. #if CYTHON_TRACE
  3511. if (tstate->c_tracefunc)
  3512. tstate->c_tracefunc(tstate->c_traceobj, *frame, PyTrace_CALL, NULL);
  3513. if (!tstate->c_profilefunc)
  3514. retval = 1;
  3515. else
  3516. #endif
  3517. retval = tstate->c_profilefunc(tstate->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
  3518. tstate->use_tracing = (tstate->c_profilefunc ||
  3519. (CYTHON_TRACE && tstate->c_tracefunc));
  3520. return tstate->use_tracing && retval;
  3521. }
  3522. static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
  3523. PyObject *py_srcfile = 0;
  3524. PyObject *py_funcname = 0;
  3525. PyCodeObject *py_code = 0;
  3526. #if PY_MAJOR_VERSION < 3
  3527. py_funcname = PyString_FromString(funcname);
  3528. py_srcfile = PyString_FromString(srcfile);
  3529. #else
  3530. py_funcname = PyUnicode_FromString(funcname);
  3531. py_srcfile = PyUnicode_FromString(srcfile);
  3532. #endif
  3533. if (!py_funcname | !py_srcfile) goto bad;
  3534. py_code = PyCode_New(
  3535. 0, /*int argcount,*/
  3536. #if PY_MAJOR_VERSION >= 3
  3537. 0, /*int kwonlyargcount,*/
  3538. #endif
  3539. 0, /*int nlocals,*/
  3540. 0, /*int stacksize,*/
  3541. 0, /*int flags,*/
  3542. __pyx_empty_bytes, /*PyObject *code,*/
  3543. __pyx_empty_tuple, /*PyObject *consts,*/
  3544. __pyx_empty_tuple, /*PyObject *names,*/
  3545. __pyx_empty_tuple, /*PyObject *varnames,*/
  3546. __pyx_empty_tuple, /*PyObject *freevars,*/
  3547. __pyx_empty_tuple, /*PyObject *cellvars,*/
  3548. py_srcfile, /*PyObject *filename,*/
  3549. py_funcname, /*PyObject *name,*/
  3550. firstlineno, /*int firstlineno,*/
  3551. __pyx_empty_bytes /*PyObject *lnotab*/
  3552. );
  3553. bad:
  3554. Py_XDECREF(py_srcfile);
  3555. Py_XDECREF(py_funcname);
  3556. return py_code;
  3557. }
  3558. #endif /* CYTHON_PROFILE */
  3559. static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
  3560. #if CYTHON_COMPILING_IN_CPYTHON
  3561. PyObject *tmp_type, *tmp_value, *tmp_tb;
  3562. PyThreadState *tstate = PyThreadState_GET();
  3563. tmp_type = tstate->curexc_type;
  3564. tmp_value = tstate->curexc_value;
  3565. tmp_tb = tstate->curexc_traceback;
  3566. tstate->curexc_type = type;
  3567. tstate->curexc_value = value;
  3568. tstate->curexc_traceback = tb;
  3569. Py_XDECREF(tmp_type);
  3570. Py_XDECREF(tmp_value);
  3571. Py_XDECREF(tmp_tb);
  3572. #else
  3573. PyErr_Restore(type, value, tb);
  3574. #endif
  3575. }
  3576. static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
  3577. #if CYTHON_COMPILING_IN_CPYTHON
  3578. PyThreadState *tstate = PyThreadState_GET();
  3579. *type = tstate->curexc_type;
  3580. *value = tstate->curexc_value;
  3581. *tb = tstate->curexc_traceback;
  3582. tstate->curexc_type = 0;
  3583. tstate->curexc_value = 0;
  3584. tstate->curexc_traceback = 0;
  3585. #else
  3586. PyErr_Fetch(type, value, tb);
  3587. #endif
  3588. }
  3589. static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
  3590. CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
  3591. int full_traceback) {
  3592. PyObject *old_exc, *old_val, *old_tb;
  3593. PyObject *ctx;
  3594. __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
  3595. if (full_traceback) {
  3596. Py_XINCREF(old_exc);
  3597. Py_XINCREF(old_val);
  3598. Py_XINCREF(old_tb);
  3599. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  3600. PyErr_PrintEx(1);
  3601. }
  3602. #if PY_MAJOR_VERSION < 3
  3603. ctx = PyString_FromString(name);
  3604. #else
  3605. ctx = PyUnicode_FromString(name);
  3606. #endif
  3607. __Pyx_ErrRestore(old_exc, old_val, old_tb);
  3608. if (!ctx) {
  3609. PyErr_WriteUnraisable(Py_None);
  3610. } else {
  3611. PyErr_WriteUnraisable(ctx);
  3612. Py_DECREF(ctx);
  3613. }
  3614. }
  3615. static void __Pyx_RaiseDoubleKeywordsError(
  3616. const char* func_name,
  3617. PyObject* kw_name)
  3618. {
  3619. PyErr_Format(PyExc_TypeError,
  3620. #if PY_MAJOR_VERSION >= 3
  3621. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  3622. #else
  3623. "%s() got multiple values for keyword argument '%s'", func_name,
  3624. PyString_AsString(kw_name));
  3625. #endif
  3626. }
  3627. static int __Pyx_ParseOptionalKeywords(
  3628. PyObject *kwds,
  3629. PyObject **argnames[],
  3630. PyObject *kwds2,
  3631. PyObject *values[],
  3632. Py_ssize_t num_pos_args,
  3633. const char* function_name)
  3634. {
  3635. PyObject *key = 0, *value = 0;
  3636. Py_ssize_t pos = 0;
  3637. PyObject*** name;
  3638. PyObject*** first_kw_arg = argnames + num_pos_args;
  3639. while (PyDict_Next(kwds, &pos, &key, &value)) {
  3640. name = first_kw_arg;
  3641. while (*name && (**name != key)) name++;
  3642. if (*name) {
  3643. values[name-argnames] = value;
  3644. continue;
  3645. }
  3646. name = first_kw_arg;
  3647. #if PY_MAJOR_VERSION < 3
  3648. if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
  3649. while (*name) {
  3650. if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
  3651. && _PyString_Eq(**name, key)) {
  3652. values[name-argnames] = value;
  3653. break;
  3654. }
  3655. name++;
  3656. }
  3657. if (*name) continue;
  3658. else {
  3659. PyObject*** argname = argnames;
  3660. while (argname != first_kw_arg) {
  3661. if ((**argname == key) || (
  3662. (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
  3663. && _PyString_Eq(**argname, key))) {
  3664. goto arg_passed_twice;
  3665. }
  3666. argname++;
  3667. }
  3668. }
  3669. } else
  3670. #endif
  3671. if (likely(PyUnicode_Check(key))) {
  3672. while (*name) {
  3673. int cmp = (**name == key) ? 0 :
  3674. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  3675. (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
  3676. #endif
  3677. PyUnicode_Compare(**name, key);
  3678. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  3679. if (cmp == 0) {
  3680. values[name-argnames] = value;
  3681. break;
  3682. }
  3683. name++;
  3684. }
  3685. if (*name) continue;
  3686. else {
  3687. PyObject*** argname = argnames;
  3688. while (argname != first_kw_arg) {
  3689. int cmp = (**argname == key) ? 0 :
  3690. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
  3691. (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
  3692. #endif
  3693. PyUnicode_Compare(**argname, key);
  3694. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  3695. if (cmp == 0) goto arg_passed_twice;
  3696. argname++;
  3697. }
  3698. }
  3699. } else
  3700. goto invalid_keyword_type;
  3701. if (kwds2) {
  3702. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  3703. } else {
  3704. goto invalid_keyword;
  3705. }
  3706. }
  3707. return 0;
  3708. arg_passed_twice:
  3709. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  3710. goto bad;
  3711. invalid_keyword_type:
  3712. PyErr_Format(PyExc_TypeError,
  3713. "%.200s() keywords must be strings", function_name);
  3714. goto bad;
  3715. invalid_keyword:
  3716. PyErr_Format(PyExc_TypeError,
  3717. #if PY_MAJOR_VERSION < 3
  3718. "%.200s() got an unexpected keyword argument '%.200s'",
  3719. function_name, PyString_AsString(key));
  3720. #else
  3721. "%s() got an unexpected keyword argument '%U'",
  3722. function_name, key);
  3723. #endif
  3724. bad:
  3725. return -1;
  3726. }
  3727. static void __Pyx_RaiseArgtupleInvalid(
  3728. const char* func_name,
  3729. int exact,
  3730. Py_ssize_t num_min,
  3731. Py_ssize_t num_max,
  3732. Py_ssize_t num_found)
  3733. {
  3734. Py_ssize_t num_expected;
  3735. const char *more_or_less;
  3736. if (num_found < num_min) {
  3737. num_expected = num_min;
  3738. more_or_less = "at least";
  3739. } else {
  3740. num_expected = num_max;
  3741. more_or_less = "at most";
  3742. }
  3743. if (exact) {
  3744. more_or_less = "exactly";
  3745. }
  3746. PyErr_Format(PyExc_TypeError,
  3747. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  3748. func_name, more_or_less, num_expected,
  3749. (num_expected == 1) ? "" : "s", num_found);
  3750. }
  3751. static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
  3752. PyObject *result;
  3753. #if CYTHON_COMPILING_IN_CPYTHON
  3754. result = PyDict_GetItem(__pyx_d, name);
  3755. if (result) {
  3756. Py_INCREF(result);
  3757. } else {
  3758. #else
  3759. result = PyObject_GetItem(__pyx_d, name);
  3760. if (!result) {
  3761. PyErr_Clear();
  3762. #endif
  3763. result = __Pyx_GetBuiltinName(name);
  3764. }
  3765. return result;
  3766. }
  3767. #if CYTHON_COMPILING_IN_CPYTHON
  3768. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  3769. PyObject *result;
  3770. ternaryfunc call = func->ob_type->tp_call;
  3771. if (unlikely(!call))
  3772. return PyObject_Call(func, arg, kw);
  3773. #if PY_VERSION_HEX >= 0x02060000
  3774. if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
  3775. return NULL;
  3776. #endif
  3777. result = (*call)(func, arg, kw);
  3778. #if PY_VERSION_HEX >= 0x02060000
  3779. Py_LeaveRecursiveCall();
  3780. #endif
  3781. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  3782. PyErr_SetString(
  3783. PyExc_SystemError,
  3784. "NULL result without error in PyObject_Call");
  3785. }
  3786. return result;
  3787. }
  3788. #endif
  3789. static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
  3790. #if CYTHON_COMPILING_IN_CPYTHON
  3791. PyThreadState *tstate = PyThreadState_GET();
  3792. *type = tstate->exc_type;
  3793. *value = tstate->exc_value;
  3794. *tb = tstate->exc_traceback;
  3795. Py_XINCREF(*type);
  3796. Py_XINCREF(*value);
  3797. Py_XINCREF(*tb);
  3798. #else
  3799. PyErr_GetExcInfo(type, value, tb);
  3800. #endif
  3801. }
  3802. static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
  3803. #if CYTHON_COMPILING_IN_CPYTHON
  3804. PyObject *tmp_type, *tmp_value, *tmp_tb;
  3805. PyThreadState *tstate = PyThreadState_GET();
  3806. tmp_type = tstate->exc_type;
  3807. tmp_value = tstate->exc_value;
  3808. tmp_tb = tstate->exc_traceback;
  3809. tstate->exc_type = type;
  3810. tstate->exc_value = value;
  3811. tstate->exc_traceback = tb;
  3812. Py_XDECREF(tmp_type);
  3813. Py_XDECREF(tmp_value);
  3814. Py_XDECREF(tmp_tb);
  3815. #else
  3816. PyErr_SetExcInfo(type, value, tb);
  3817. #endif
  3818. }
  3819. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
  3820. PyObject *local_type, *local_value, *local_tb;
  3821. #if CYTHON_COMPILING_IN_CPYTHON
  3822. PyObject *tmp_type, *tmp_value, *tmp_tb;
  3823. PyThreadState *tstate = PyThreadState_GET();
  3824. local_type = tstate->curexc_type;
  3825. local_value = tstate->curexc_value;
  3826. local_tb = tstate->curexc_traceback;
  3827. tstate->curexc_type = 0;
  3828. tstate->curexc_value = 0;
  3829. tstate->curexc_traceback = 0;
  3830. #else
  3831. PyErr_Fetch(&local_type, &local_value, &local_tb);
  3832. #endif
  3833. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  3834. #if CYTHON_COMPILING_IN_CPYTHON
  3835. if (unlikely(tstate->curexc_type))
  3836. #else
  3837. if (unlikely(PyErr_Occurred()))
  3838. #endif
  3839. goto bad;
  3840. #if PY_MAJOR_VERSION >= 3
  3841. if (local_tb) {
  3842. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  3843. goto bad;
  3844. }
  3845. #endif
  3846. Py_XINCREF(local_tb);
  3847. Py_XINCREF(local_type);
  3848. Py_XINCREF(local_value);
  3849. *type = local_type;
  3850. *value = local_value;
  3851. *tb = local_tb;
  3852. #if CYTHON_COMPILING_IN_CPYTHON
  3853. tmp_type = tstate->exc_type;
  3854. tmp_value = tstate->exc_value;
  3855. tmp_tb = tstate->exc_traceback;
  3856. tstate->exc_type = local_type;
  3857. tstate->exc_value = local_value;
  3858. tstate->exc_traceback = local_tb;
  3859. Py_XDECREF(tmp_type);
  3860. Py_XDECREF(tmp_value);
  3861. Py_XDECREF(tmp_tb);
  3862. #else
  3863. PyErr_SetExcInfo(local_type, local_value, local_tb);
  3864. #endif
  3865. return 0;
  3866. bad:
  3867. *type = 0;
  3868. *value = 0;
  3869. *tb = 0;
  3870. Py_XDECREF(local_type);
  3871. Py_XDECREF(local_value);
  3872. Py_XDECREF(local_tb);
  3873. return -1;
  3874. }
  3875. #if PY_MAJOR_VERSION < 3
  3876. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
  3877. CYTHON_UNUSED PyObject *cause) {
  3878. Py_XINCREF(type);
  3879. if (!value || value == Py_None)
  3880. value = NULL;
  3881. else
  3882. Py_INCREF(value);
  3883. if (!tb || tb == Py_None)
  3884. tb = NULL;
  3885. else {
  3886. Py_INCREF(tb);
  3887. if (!PyTraceBack_Check(tb)) {
  3888. PyErr_SetString(PyExc_TypeError,
  3889. "raise: arg 3 must be a traceback or None");
  3890. goto raise_error;
  3891. }
  3892. }
  3893. #if PY_VERSION_HEX < 0x02050000
  3894. if (PyClass_Check(type)) {
  3895. #else
  3896. if (PyType_Check(type)) {
  3897. #endif
  3898. #if CYTHON_COMPILING_IN_PYPY
  3899. if (!value) {
  3900. Py_INCREF(Py_None);
  3901. value = Py_None;
  3902. }
  3903. #endif
  3904. PyErr_NormalizeException(&type, &value, &tb);
  3905. } else {
  3906. if (value) {
  3907. PyErr_SetString(PyExc_TypeError,
  3908. "instance exception may not have a separate value");
  3909. goto raise_error;
  3910. }
  3911. value = type;
  3912. #if PY_VERSION_HEX < 0x02050000
  3913. if (PyInstance_Check(type)) {
  3914. type = (PyObject*) ((PyInstanceObject*)type)->in_class;
  3915. Py_INCREF(type);
  3916. } else {
  3917. type = 0;
  3918. PyErr_SetString(PyExc_TypeError,
  3919. "raise: exception must be an old-style class or instance");
  3920. goto raise_error;
  3921. }
  3922. #else
  3923. type = (PyObject*) Py_TYPE(type);
  3924. Py_INCREF(type);
  3925. if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
  3926. PyErr_SetString(PyExc_TypeError,
  3927. "raise: exception class must be a subclass of BaseException");
  3928. goto raise_error;
  3929. }
  3930. #endif
  3931. }
  3932. __Pyx_ErrRestore(type, value, tb);
  3933. return;
  3934. raise_error:
  3935. Py_XDECREF(value);
  3936. Py_XDECREF(type);
  3937. Py_XDECREF(tb);
  3938. return;
  3939. }
  3940. #else /* Python 3+ */
  3941. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  3942. PyObject* owned_instance = NULL;
  3943. if (tb == Py_None) {
  3944. tb = 0;
  3945. } else if (tb && !PyTraceBack_Check(tb)) {
  3946. PyErr_SetString(PyExc_TypeError,
  3947. "raise: arg 3 must be a traceback or None");
  3948. goto bad;
  3949. }
  3950. if (value == Py_None)
  3951. value = 0;
  3952. if (PyExceptionInstance_Check(type)) {
  3953. if (value) {
  3954. PyErr_SetString(PyExc_TypeError,
  3955. "instance exception may not have a separate value");
  3956. goto bad;
  3957. }
  3958. value = type;
  3959. type = (PyObject*) Py_TYPE(value);
  3960. } else if (PyExceptionClass_Check(type)) {
  3961. PyObject *instance_class = NULL;
  3962. if (value && PyExceptionInstance_Check(value)) {
  3963. instance_class = (PyObject*) Py_TYPE(value);
  3964. if (instance_class != type) {
  3965. if (PyObject_IsSubclass(instance_class, type)) {
  3966. type = instance_class;
  3967. } else {
  3968. instance_class = NULL;
  3969. }
  3970. }
  3971. }
  3972. if (!instance_class) {
  3973. PyObject *args;
  3974. if (!value)
  3975. args = PyTuple_New(0);
  3976. else if (PyTuple_Check(value)) {
  3977. Py_INCREF(value);
  3978. args = value;
  3979. } else
  3980. args = PyTuple_Pack(1, value);
  3981. if (!args)
  3982. goto bad;
  3983. owned_instance = PyObject_Call(type, args, NULL);
  3984. Py_DECREF(args);
  3985. if (!owned_instance)
  3986. goto bad;
  3987. value = owned_instance;
  3988. if (!PyExceptionInstance_Check(value)) {
  3989. PyErr_Format(PyExc_TypeError,
  3990. "calling %R should have returned an instance of "
  3991. "BaseException, not %R",
  3992. type, Py_TYPE(value));
  3993. goto bad;
  3994. }
  3995. }
  3996. } else {
  3997. PyErr_SetString(PyExc_TypeError,
  3998. "raise: exception class must be a subclass of BaseException");
  3999. goto bad;
  4000. }
  4001. #if PY_VERSION_HEX >= 0x03030000
  4002. if (cause) {
  4003. #else
  4004. if (cause && cause != Py_None) {
  4005. #endif
  4006. PyObject *fixed_cause;
  4007. if (cause == Py_None) {
  4008. fixed_cause = NULL;
  4009. } else if (PyExceptionClass_Check(cause)) {
  4010. fixed_cause = PyObject_CallObject(cause, NULL);
  4011. if (fixed_cause == NULL)
  4012. goto bad;
  4013. } else if (PyExceptionInstance_Check(cause)) {
  4014. fixed_cause = cause;
  4015. Py_INCREF(fixed_cause);
  4016. } else {
  4017. PyErr_SetString(PyExc_TypeError,
  4018. "exception causes must derive from "
  4019. "BaseException");
  4020. goto bad;
  4021. }
  4022. PyException_SetCause(value, fixed_cause);
  4023. }
  4024. PyErr_SetObject(type, value);
  4025. if (tb) {
  4026. PyThreadState *tstate = PyThreadState_GET();
  4027. PyObject* tmp_tb = tstate->curexc_traceback;
  4028. if (tb != tmp_tb) {
  4029. Py_INCREF(tb);
  4030. tstate->curexc_traceback = tb;
  4031. Py_XDECREF(tmp_tb);
  4032. }
  4033. }
  4034. bad:
  4035. Py_XDECREF(owned_instance);
  4036. return;
  4037. }
  4038. #endif
  4039. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  4040. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  4041. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  4042. PyErr_Format(PyExc_ImportError,
  4043. #if PY_MAJOR_VERSION < 3
  4044. "cannot import name %.230s", PyString_AS_STRING(name));
  4045. #else
  4046. "cannot import name %S", name);
  4047. #endif
  4048. }
  4049. return value;
  4050. }
  4051. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  4052. #if CYTHON_COMPILING_IN_PYPY
  4053. return PyObject_RichCompareBool(s1, s2, equals);
  4054. #else
  4055. if (s1 == s2) {
  4056. return (equals == Py_EQ);
  4057. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  4058. const char *ps1, *ps2;
  4059. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  4060. if (length != PyBytes_GET_SIZE(s2))
  4061. return (equals == Py_NE);
  4062. ps1 = PyBytes_AS_STRING(s1);
  4063. ps2 = PyBytes_AS_STRING(s2);
  4064. if (ps1[0] != ps2[0]) {
  4065. return (equals == Py_NE);
  4066. } else if (length == 1) {
  4067. return (equals == Py_EQ);
  4068. } else {
  4069. int result = memcmp(ps1, ps2, (size_t)length);
  4070. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  4071. }
  4072. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  4073. return (equals == Py_NE);
  4074. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  4075. return (equals == Py_NE);
  4076. } else {
  4077. int result;
  4078. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  4079. if (!py_result)
  4080. return -1;
  4081. result = __Pyx_PyObject_IsTrue(py_result);
  4082. Py_DECREF(py_result);
  4083. return result;
  4084. }
  4085. #endif
  4086. }
  4087. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  4088. #if CYTHON_COMPILING_IN_PYPY
  4089. return PyObject_RichCompareBool(s1, s2, equals);
  4090. #else
  4091. #if PY_MAJOR_VERSION < 3
  4092. PyObject* owned_ref = NULL;
  4093. #endif
  4094. int s1_is_unicode, s2_is_unicode;
  4095. if (s1 == s2) {
  4096. goto return_eq;
  4097. }
  4098. s1_is_unicode = PyUnicode_CheckExact(s1);
  4099. s2_is_unicode = PyUnicode_CheckExact(s2);
  4100. #if PY_MAJOR_VERSION < 3
  4101. if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
  4102. owned_ref = PyUnicode_FromObject(s2);
  4103. if (unlikely(!owned_ref))
  4104. return -1;
  4105. s2 = owned_ref;
  4106. s2_is_unicode = 1;
  4107. } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
  4108. owned_ref = PyUnicode_FromObject(s1);
  4109. if (unlikely(!owned_ref))
  4110. return -1;
  4111. s1 = owned_ref;
  4112. s1_is_unicode = 1;
  4113. } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
  4114. return __Pyx_PyBytes_Equals(s1, s2, equals);
  4115. }
  4116. #endif
  4117. if (s1_is_unicode & s2_is_unicode) {
  4118. Py_ssize_t length;
  4119. int kind;
  4120. void *data1, *data2;
  4121. #if CYTHON_PEP393_ENABLED
  4122. if (unlikely(PyUnicode_READY(s1) < 0) || unlikely(PyUnicode_READY(s2) < 0))
  4123. return -1;
  4124. #endif
  4125. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  4126. if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
  4127. goto return_ne;
  4128. }
  4129. kind = __Pyx_PyUnicode_KIND(s1);
  4130. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  4131. goto return_ne;
  4132. }
  4133. data1 = __Pyx_PyUnicode_DATA(s1);
  4134. data2 = __Pyx_PyUnicode_DATA(s2);
  4135. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  4136. goto return_ne;
  4137. } else if (length == 1) {
  4138. goto return_eq;
  4139. } else {
  4140. int result = memcmp(data1, data2, length * kind);
  4141. #if PY_MAJOR_VERSION < 3
  4142. Py_XDECREF(owned_ref);
  4143. #endif
  4144. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  4145. }
  4146. } else if ((s1 == Py_None) & s2_is_unicode) {
  4147. goto return_ne;
  4148. } else if ((s2 == Py_None) & s1_is_unicode) {
  4149. goto return_ne;
  4150. } else {
  4151. int result;
  4152. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  4153. if (!py_result)
  4154. return -1;
  4155. result = __Pyx_PyObject_IsTrue(py_result);
  4156. Py_DECREF(py_result);
  4157. return result;
  4158. }
  4159. return_eq:
  4160. #if PY_MAJOR_VERSION < 3
  4161. Py_XDECREF(owned_ref);
  4162. #endif
  4163. return (equals == Py_EQ);
  4164. return_ne:
  4165. #if PY_MAJOR_VERSION < 3
  4166. Py_XDECREF(owned_ref);
  4167. #endif
  4168. return (equals == Py_NE);
  4169. #endif
  4170. }
  4171. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  4172. PyObject *r;
  4173. if (!j) return NULL;
  4174. r = PyObject_GetItem(o, j);
  4175. Py_DECREF(j);
  4176. return r;
  4177. }
  4178. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  4179. int wraparound, int boundscheck) {
  4180. #if CYTHON_COMPILING_IN_CPYTHON
  4181. if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
  4182. if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
  4183. PyObject *r = PyList_GET_ITEM(o, i);
  4184. Py_INCREF(r);
  4185. return r;
  4186. }
  4187. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  4188. #else
  4189. return PySequence_GetItem(o, i);
  4190. #endif
  4191. }
  4192. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  4193. int wraparound, int boundscheck) {
  4194. #if CYTHON_COMPILING_IN_CPYTHON
  4195. if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
  4196. if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
  4197. PyObject *r = PyTuple_GET_ITEM(o, i);
  4198. Py_INCREF(r);
  4199. return r;
  4200. }
  4201. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  4202. #else
  4203. return PySequence_GetItem(o, i);
  4204. #endif
  4205. }
  4206. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  4207. int is_list, int wraparound, int boundscheck) {
  4208. #if CYTHON_COMPILING_IN_CPYTHON
  4209. if (is_list || PyList_CheckExact(o)) {
  4210. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  4211. if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
  4212. PyObject *r = PyList_GET_ITEM(o, n);
  4213. Py_INCREF(r);
  4214. return r;
  4215. }
  4216. }
  4217. else if (PyTuple_CheckExact(o)) {
  4218. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  4219. if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
  4220. PyObject *r = PyTuple_GET_ITEM(o, n);
  4221. Py_INCREF(r);
  4222. return r;
  4223. }
  4224. } else {
  4225. PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
  4226. if (likely(m && m->sq_item)) {
  4227. if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
  4228. Py_ssize_t l = m->sq_length(o);
  4229. if (likely(l >= 0)) {
  4230. i += l;
  4231. } else {
  4232. if (PyErr_ExceptionMatches(PyExc_OverflowError))
  4233. PyErr_Clear();
  4234. else
  4235. return NULL;
  4236. }
  4237. }
  4238. return m->sq_item(o, i);
  4239. }
  4240. }
  4241. #else
  4242. if (is_list || PySequence_Check(o)) {
  4243. return PySequence_GetItem(o, i);
  4244. }
  4245. #endif
  4246. return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
  4247. }
  4248. static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
  4249. PyObject *empty_list = 0;
  4250. PyObject *module = 0;
  4251. PyObject *global_dict = 0;
  4252. PyObject *empty_dict = 0;
  4253. PyObject *list;
  4254. #if PY_VERSION_HEX < 0x03030000
  4255. PyObject *py_import;
  4256. py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
  4257. if (!py_import)
  4258. goto bad;
  4259. #endif
  4260. if (from_list)
  4261. list = from_list;
  4262. else {
  4263. empty_list = PyList_New(0);
  4264. if (!empty_list)
  4265. goto bad;
  4266. list = empty_list;
  4267. }
  4268. global_dict = PyModule_GetDict(__pyx_m);
  4269. if (!global_dict)
  4270. goto bad;
  4271. empty_dict = PyDict_New();
  4272. if (!empty_dict)
  4273. goto bad;
  4274. #if PY_VERSION_HEX >= 0x02050000
  4275. {
  4276. #if PY_MAJOR_VERSION >= 3
  4277. if (level == -1) {
  4278. if (strchr(__Pyx_MODULE_NAME, '.')) {
  4279. #if PY_VERSION_HEX < 0x03030000
  4280. PyObject *py_level = PyInt_FromLong(1);
  4281. if (!py_level)
  4282. goto bad;
  4283. module = PyObject_CallFunctionObjArgs(py_import,
  4284. name, global_dict, empty_dict, list, py_level, NULL);
  4285. Py_DECREF(py_level);
  4286. #else
  4287. module = PyImport_ImportModuleLevelObject(
  4288. name, global_dict, empty_dict, list, 1);
  4289. #endif
  4290. if (!module) {
  4291. if (!PyErr_ExceptionMatches(PyExc_ImportError))
  4292. goto bad;
  4293. PyErr_Clear();
  4294. }
  4295. }
  4296. level = 0; /* try absolute import on failure */
  4297. }
  4298. #endif
  4299. if (!module) {
  4300. #if PY_VERSION_HEX < 0x03030000
  4301. PyObject *py_level = PyInt_FromLong(level);
  4302. if (!py_level)
  4303. goto bad;
  4304. module = PyObject_CallFunctionObjArgs(py_import,
  4305. name, global_dict, empty_dict, list, py_level, NULL);
  4306. Py_DECREF(py_level);
  4307. #else
  4308. module = PyImport_ImportModuleLevelObject(
  4309. name, global_dict, empty_dict, list, level);
  4310. #endif
  4311. }
  4312. }
  4313. #else
  4314. if (level>0) {
  4315. PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
  4316. goto bad;
  4317. }
  4318. module = PyObject_CallFunctionObjArgs(py_import,
  4319. name, global_dict, empty_dict, list, NULL);
  4320. #endif
  4321. bad:
  4322. #if PY_VERSION_HEX < 0x03030000
  4323. Py_XDECREF(py_import);
  4324. #endif
  4325. Py_XDECREF(empty_list);
  4326. Py_XDECREF(empty_dict);
  4327. return module;
  4328. }
  4329. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
  4330. static PyObject *__Pyx_GetStdout(void) {
  4331. PyObject *f = PySys_GetObject((char *)"stdout");
  4332. if (!f) {
  4333. PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
  4334. }
  4335. return f;
  4336. }
  4337. static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
  4338. int i;
  4339. if (!f) {
  4340. if (!(f = __Pyx_GetStdout()))
  4341. return -1;
  4342. }
  4343. Py_INCREF(f);
  4344. for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
  4345. PyObject* v;
  4346. if (PyFile_SoftSpace(f, 1)) {
  4347. if (PyFile_WriteString(" ", f) < 0)
  4348. goto error;
  4349. }
  4350. v = PyTuple_GET_ITEM(arg_tuple, i);
  4351. if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
  4352. goto error;
  4353. if (PyString_Check(v)) {
  4354. char *s = PyString_AsString(v);
  4355. Py_ssize_t len = PyString_Size(v);
  4356. if (len > 0) {
  4357. switch (s[len-1]) {
  4358. case ' ': break;
  4359. case '\f': case '\r': case '\n': case '\t': case '\v':
  4360. PyFile_SoftSpace(f, 0);
  4361. break;
  4362. default: break;
  4363. }
  4364. }
  4365. }
  4366. }
  4367. if (newline) {
  4368. if (PyFile_WriteString("\n", f) < 0)
  4369. goto error;
  4370. PyFile_SoftSpace(f, 0);
  4371. }
  4372. Py_DECREF(f);
  4373. return 0;
  4374. error:
  4375. Py_DECREF(f);
  4376. return -1;
  4377. }
  4378. #else /* Python 3 has a print function */
  4379. static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
  4380. PyObject* kwargs = 0;
  4381. PyObject* result = 0;
  4382. PyObject* end_string;
  4383. if (unlikely(!__pyx_print)) {
  4384. __pyx_print = PyObject_GetAttr(__pyx_b, __pyx_n_s_print);
  4385. if (!__pyx_print)
  4386. return -1;
  4387. }
  4388. if (stream) {
  4389. kwargs = PyDict_New();
  4390. if (unlikely(!kwargs))
  4391. return -1;
  4392. if (unlikely(PyDict_SetItem(kwargs, __pyx_n_s_file, stream) < 0))
  4393. goto bad;
  4394. if (!newline) {
  4395. end_string = PyUnicode_FromStringAndSize(" ", 1);
  4396. if (unlikely(!end_string))
  4397. goto bad;
  4398. if (PyDict_SetItem(kwargs, __pyx_n_s_end, end_string) < 0) {
  4399. Py_DECREF(end_string);
  4400. goto bad;
  4401. }
  4402. Py_DECREF(end_string);
  4403. }
  4404. } else if (!newline) {
  4405. if (unlikely(!__pyx_print_kwargs)) {
  4406. __pyx_print_kwargs = PyDict_New();
  4407. if (unlikely(!__pyx_print_kwargs))
  4408. return -1;
  4409. end_string = PyUnicode_FromStringAndSize(" ", 1);
  4410. if (unlikely(!end_string))
  4411. return -1;
  4412. if (PyDict_SetItem(__pyx_print_kwargs, __pyx_n_s_end, end_string) < 0) {
  4413. Py_DECREF(end_string);
  4414. return -1;
  4415. }
  4416. Py_DECREF(end_string);
  4417. }
  4418. kwargs = __pyx_print_kwargs;
  4419. }
  4420. result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
  4421. if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
  4422. Py_DECREF(kwargs);
  4423. if (!result)
  4424. return -1;
  4425. Py_DECREF(result);
  4426. return 0;
  4427. bad:
  4428. if (kwargs != __pyx_print_kwargs)
  4429. Py_XDECREF(kwargs);
  4430. return -1;
  4431. }
  4432. #endif
  4433. #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION < 3
  4434. static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
  4435. if (!f) {
  4436. if (!(f = __Pyx_GetStdout()))
  4437. return -1;
  4438. }
  4439. Py_INCREF(f);
  4440. if (PyFile_SoftSpace(f, 0)) {
  4441. if (PyFile_WriteString(" ", f) < 0)
  4442. goto error;
  4443. }
  4444. if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
  4445. goto error;
  4446. if (PyFile_WriteString("\n", f) < 0)
  4447. goto error;
  4448. Py_DECREF(f);
  4449. return 0;
  4450. error:
  4451. Py_DECREF(f);
  4452. return -1;
  4453. /* the line below is just to avoid C compiler
  4454. * warnings about unused functions */
  4455. return __Pyx_Print(f, NULL, 0);
  4456. }
  4457. #else /* Python 3 has a print function */
  4458. static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
  4459. int res;
  4460. PyObject* arg_tuple = PyTuple_Pack(1, o);
  4461. if (unlikely(!arg_tuple))
  4462. return -1;
  4463. res = __Pyx_Print(stream, arg_tuple, 1);
  4464. Py_DECREF(arg_tuple);
  4465. return res;
  4466. }
  4467. #endif
  4468. static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
  4469. const long neg_one = (long) -1, const_zero = 0;
  4470. const int is_unsigned = neg_one > const_zero;
  4471. if (is_unsigned) {
  4472. if (sizeof(long) < sizeof(long)) {
  4473. return PyInt_FromLong((long) value);
  4474. } else if (sizeof(long) <= sizeof(unsigned long)) {
  4475. return PyLong_FromUnsignedLong((unsigned long) value);
  4476. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  4477. return PyLong_FromUnsignedLongLong((unsigned long long) value);
  4478. }
  4479. } else {
  4480. if (sizeof(long) <= sizeof(long)) {
  4481. return PyInt_FromLong((long) value);
  4482. } else if (sizeof(long) <= sizeof(long long)) {
  4483. return PyLong_FromLongLong((long long) value);
  4484. }
  4485. }
  4486. {
  4487. int one = 1; int little = (int)*(unsigned char *)&one;
  4488. unsigned char *bytes = (unsigned char *)&value;
  4489. return _PyLong_FromByteArray(bytes, sizeof(long),
  4490. little, !is_unsigned);
  4491. }
  4492. }
  4493. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func) \
  4494. { \
  4495. func_type value = func(x); \
  4496. if (sizeof(target_type) < sizeof(func_type)) { \
  4497. if (unlikely(value != (func_type) (target_type) value)) { \
  4498. func_type zero = 0; \
  4499. PyErr_SetString(PyExc_OverflowError, \
  4500. (is_unsigned && unlikely(value < zero)) ? \
  4501. "can't convert negative value to " #target_type : \
  4502. "value too large to convert to " #target_type); \
  4503. return (target_type) -1; \
  4504. } \
  4505. } \
  4506. return (target_type) value; \
  4507. }
  4508. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4509. #if CYTHON_USE_PYLONG_INTERNALS
  4510. #include "longintrepr.h"
  4511. #endif
  4512. #endif
  4513. static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
  4514. const long neg_one = (long) -1, const_zero = 0;
  4515. const int is_unsigned = neg_one > const_zero;
  4516. #if PY_MAJOR_VERSION < 3
  4517. if (likely(PyInt_Check(x))) {
  4518. if (sizeof(long) < sizeof(long)) {
  4519. __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG)
  4520. } else {
  4521. long val = PyInt_AS_LONG(x);
  4522. if (is_unsigned && unlikely(val < 0)) {
  4523. PyErr_SetString(PyExc_OverflowError,
  4524. "can't convert negative value to long");
  4525. return (long) -1;
  4526. }
  4527. return (long) val;
  4528. }
  4529. } else
  4530. #endif
  4531. if (likely(PyLong_Check(x))) {
  4532. if (is_unsigned) {
  4533. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4534. #if CYTHON_USE_PYLONG_INTERNALS
  4535. if (sizeof(digit) <= sizeof(long)) {
  4536. switch (Py_SIZE(x)) {
  4537. case 0: return 0;
  4538. case 1: return (long) ((PyLongObject*)x)->ob_digit[0];
  4539. }
  4540. }
  4541. #endif
  4542. #endif
  4543. if (unlikely(Py_SIZE(x) < 0)) {
  4544. PyErr_SetString(PyExc_OverflowError,
  4545. "can't convert negative value to long");
  4546. return (long) -1;
  4547. }
  4548. if (sizeof(long) <= sizeof(unsigned long)) {
  4549. __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong)
  4550. } else if (sizeof(long) <= sizeof(unsigned long long)) {
  4551. __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong)
  4552. }
  4553. } else {
  4554. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4555. #if CYTHON_USE_PYLONG_INTERNALS
  4556. if (sizeof(digit) <= sizeof(long)) {
  4557. switch (Py_SIZE(x)) {
  4558. case 0: return 0;
  4559. case 1: return +(long) ((PyLongObject*)x)->ob_digit[0];
  4560. case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
  4561. }
  4562. }
  4563. #endif
  4564. #endif
  4565. if (sizeof(long) <= sizeof(long)) {
  4566. __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong)
  4567. } else if (sizeof(long) <= sizeof(long long)) {
  4568. __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong)
  4569. }
  4570. }
  4571. {
  4572. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  4573. PyErr_SetString(PyExc_RuntimeError,
  4574. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  4575. #else
  4576. long val;
  4577. PyObject *v = __Pyx_PyNumber_Int(x);
  4578. #if PY_MAJOR_VERSION < 3
  4579. if (likely(v) && !PyLong_Check(v)) {
  4580. PyObject *tmp = v;
  4581. v = PyNumber_Long(tmp);
  4582. Py_DECREF(tmp);
  4583. }
  4584. #endif
  4585. if (likely(v)) {
  4586. int one = 1; int is_little = (int)*(unsigned char *)&one;
  4587. unsigned char *bytes = (unsigned char *)&val;
  4588. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  4589. bytes, sizeof(val),
  4590. is_little, !is_unsigned);
  4591. Py_DECREF(v);
  4592. if (likely(!ret))
  4593. return val;
  4594. }
  4595. #endif
  4596. return (long) -1;
  4597. }
  4598. } else {
  4599. long val;
  4600. PyObject *tmp = __Pyx_PyNumber_Int(x);
  4601. if (!tmp) return (long) -1;
  4602. val = __Pyx_PyInt_As_long(tmp);
  4603. Py_DECREF(tmp);
  4604. return val;
  4605. }
  4606. }
  4607. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4608. #if CYTHON_USE_PYLONG_INTERNALS
  4609. #include "longintrepr.h"
  4610. #endif
  4611. #endif
  4612. static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
  4613. const int neg_one = (int) -1, const_zero = 0;
  4614. const int is_unsigned = neg_one > const_zero;
  4615. #if PY_MAJOR_VERSION < 3
  4616. if (likely(PyInt_Check(x))) {
  4617. if (sizeof(int) < sizeof(long)) {
  4618. __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG)
  4619. } else {
  4620. long val = PyInt_AS_LONG(x);
  4621. if (is_unsigned && unlikely(val < 0)) {
  4622. PyErr_SetString(PyExc_OverflowError,
  4623. "can't convert negative value to int");
  4624. return (int) -1;
  4625. }
  4626. return (int) val;
  4627. }
  4628. } else
  4629. #endif
  4630. if (likely(PyLong_Check(x))) {
  4631. if (is_unsigned) {
  4632. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4633. #if CYTHON_USE_PYLONG_INTERNALS
  4634. if (sizeof(digit) <= sizeof(int)) {
  4635. switch (Py_SIZE(x)) {
  4636. case 0: return 0;
  4637. case 1: return (int) ((PyLongObject*)x)->ob_digit[0];
  4638. }
  4639. }
  4640. #endif
  4641. #endif
  4642. if (unlikely(Py_SIZE(x) < 0)) {
  4643. PyErr_SetString(PyExc_OverflowError,
  4644. "can't convert negative value to int");
  4645. return (int) -1;
  4646. }
  4647. if (sizeof(int) <= sizeof(unsigned long)) {
  4648. __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong)
  4649. } else if (sizeof(int) <= sizeof(unsigned long long)) {
  4650. __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong)
  4651. }
  4652. } else {
  4653. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  4654. #if CYTHON_USE_PYLONG_INTERNALS
  4655. if (sizeof(digit) <= sizeof(int)) {
  4656. switch (Py_SIZE(x)) {
  4657. case 0: return 0;
  4658. case 1: return +(int) ((PyLongObject*)x)->ob_digit[0];
  4659. case -1: return -(int) ((PyLongObject*)x)->ob_digit[0];
  4660. }
  4661. }
  4662. #endif
  4663. #endif
  4664. if (sizeof(int) <= sizeof(long)) {
  4665. __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong)
  4666. } else if (sizeof(int) <= sizeof(long long)) {
  4667. __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong)
  4668. }
  4669. }
  4670. {
  4671. #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
  4672. PyErr_SetString(PyExc_RuntimeError,
  4673. "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
  4674. #else
  4675. int val;
  4676. PyObject *v = __Pyx_PyNumber_Int(x);
  4677. #if PY_MAJOR_VERSION < 3
  4678. if (likely(v) && !PyLong_Check(v)) {
  4679. PyObject *tmp = v;
  4680. v = PyNumber_Long(tmp);
  4681. Py_DECREF(tmp);
  4682. }
  4683. #endif
  4684. if (likely(v)) {
  4685. int one = 1; int is_little = (int)*(unsigned char *)&one;
  4686. unsigned char *bytes = (unsigned char *)&val;
  4687. int ret = _PyLong_AsByteArray((PyLongObject *)v,
  4688. bytes, sizeof(val),
  4689. is_little, !is_unsigned);
  4690. Py_DECREF(v);
  4691. if (likely(!ret))
  4692. return val;
  4693. }
  4694. #endif
  4695. return (int) -1;
  4696. }
  4697. } else {
  4698. int val;
  4699. PyObject *tmp = __Pyx_PyNumber_Int(x);
  4700. if (!tmp) return (int) -1;
  4701. val = __Pyx_PyInt_As_int(tmp);
  4702. Py_DECREF(tmp);
  4703. return val;
  4704. }
  4705. }
  4706. static int __Pyx_check_binary_version(void) {
  4707. char ctversion[4], rtversion[4];
  4708. PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
  4709. PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
  4710. if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
  4711. char message[200];
  4712. PyOS_snprintf(message, sizeof(message),
  4713. "compiletime version %s of module '%.100s' "
  4714. "does not match runtime version %s",
  4715. ctversion, __Pyx_MODULE_NAME, rtversion);
  4716. #if PY_VERSION_HEX < 0x02050000
  4717. return PyErr_Warn(NULL, message);
  4718. #else
  4719. return PyErr_WarnEx(NULL, message, 1);
  4720. #endif
  4721. }
  4722. return 0;
  4723. }
  4724. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  4725. int start = 0, mid = 0, end = count - 1;
  4726. if (end >= 0 && code_line > entries[end].code_line) {
  4727. return count;
  4728. }
  4729. while (start < end) {
  4730. mid = (start + end) / 2;
  4731. if (code_line < entries[mid].code_line) {
  4732. end = mid;
  4733. } else if (code_line > entries[mid].code_line) {
  4734. start = mid + 1;
  4735. } else {
  4736. return mid;
  4737. }
  4738. }
  4739. if (code_line <= entries[mid].code_line) {
  4740. return mid;
  4741. } else {
  4742. return mid + 1;
  4743. }
  4744. }
  4745. static PyCodeObject *__pyx_find_code_object(int code_line) {
  4746. PyCodeObject* code_object;
  4747. int pos;
  4748. if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
  4749. return NULL;
  4750. }
  4751. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  4752. if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
  4753. return NULL;
  4754. }
  4755. code_object = __pyx_code_cache.entries[pos].code_object;
  4756. Py_INCREF(code_object);
  4757. return code_object;
  4758. }
  4759. static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
  4760. int pos, i;
  4761. __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
  4762. if (unlikely(!code_line)) {
  4763. return;
  4764. }
  4765. if (unlikely(!entries)) {
  4766. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  4767. if (likely(entries)) {
  4768. __pyx_code_cache.entries = entries;
  4769. __pyx_code_cache.max_count = 64;
  4770. __pyx_code_cache.count = 1;
  4771. entries[0].code_line = code_line;
  4772. entries[0].code_object = code_object;
  4773. Py_INCREF(code_object);
  4774. }
  4775. return;
  4776. }
  4777. pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
  4778. if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
  4779. PyCodeObject* tmp = entries[pos].code_object;
  4780. entries[pos].code_object = code_object;
  4781. Py_DECREF(tmp);
  4782. return;
  4783. }
  4784. if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
  4785. int new_max = __pyx_code_cache.max_count + 64;
  4786. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  4787. __pyx_code_cache.entries, new_max*sizeof(__Pyx_CodeObjectCacheEntry));
  4788. if (unlikely(!entries)) {
  4789. return;
  4790. }
  4791. __pyx_code_cache.entries = entries;
  4792. __pyx_code_cache.max_count = new_max;
  4793. }
  4794. for (i=__pyx_code_cache.count; i>pos; i--) {
  4795. entries[i] = entries[i-1];
  4796. }
  4797. entries[pos].code_line = code_line;
  4798. entries[pos].code_object = code_object;
  4799. __pyx_code_cache.count++;
  4800. Py_INCREF(code_object);
  4801. }
  4802. #include "compile.h"
  4803. #include "frameobject.h"
  4804. #include "traceback.h"
  4805. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  4806. const char *funcname, int c_line,
  4807. int py_line, const char *filename) {
  4808. PyCodeObject *py_code = 0;
  4809. PyObject *py_srcfile = 0;
  4810. PyObject *py_funcname = 0;
  4811. #if PY_MAJOR_VERSION < 3
  4812. py_srcfile = PyString_FromString(filename);
  4813. #else
  4814. py_srcfile = PyUnicode_FromString(filename);
  4815. #endif
  4816. if (!py_srcfile) goto bad;
  4817. if (c_line) {
  4818. #if PY_MAJOR_VERSION < 3
  4819. py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  4820. #else
  4821. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  4822. #endif
  4823. }
  4824. else {
  4825. #if PY_MAJOR_VERSION < 3
  4826. py_funcname = PyString_FromString(funcname);
  4827. #else
  4828. py_funcname = PyUnicode_FromString(funcname);
  4829. #endif
  4830. }
  4831. if (!py_funcname) goto bad;
  4832. py_code = __Pyx_PyCode_New(
  4833. 0, /*int argcount,*/
  4834. 0, /*int kwonlyargcount,*/
  4835. 0, /*int nlocals,*/
  4836. 0, /*int stacksize,*/
  4837. 0, /*int flags,*/
  4838. __pyx_empty_bytes, /*PyObject *code,*/
  4839. __pyx_empty_tuple, /*PyObject *consts,*/
  4840. __pyx_empty_tuple, /*PyObject *names,*/
  4841. __pyx_empty_tuple, /*PyObject *varnames,*/
  4842. __pyx_empty_tuple, /*PyObject *freevars,*/
  4843. __pyx_empty_tuple, /*PyObject *cellvars,*/
  4844. py_srcfile, /*PyObject *filename,*/
  4845. py_funcname, /*PyObject *name,*/
  4846. py_line, /*int firstlineno,*/
  4847. __pyx_empty_bytes /*PyObject *lnotab*/
  4848. );
  4849. Py_DECREF(py_srcfile);
  4850. Py_DECREF(py_funcname);
  4851. return py_code;
  4852. bad:
  4853. Py_XDECREF(py_srcfile);
  4854. Py_XDECREF(py_funcname);
  4855. return NULL;
  4856. }
  4857. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  4858. int py_line, const char *filename) {
  4859. PyCodeObject *py_code = 0;
  4860. PyObject *py_globals = 0;
  4861. PyFrameObject *py_frame = 0;
  4862. py_code = __pyx_find_code_object(c_line ? c_line : py_line);
  4863. if (!py_code) {
  4864. py_code = __Pyx_CreateCodeObjectForTraceback(
  4865. funcname, c_line, py_line, filename);
  4866. if (!py_code) goto bad;
  4867. __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
  4868. }
  4869. py_globals = PyModule_GetDict(__pyx_m);
  4870. if (!py_globals) goto bad;
  4871. py_frame = PyFrame_New(
  4872. PyThreadState_GET(), /*PyThreadState *tstate,*/
  4873. py_code, /*PyCodeObject *code,*/
  4874. py_globals, /*PyObject *globals,*/
  4875. 0 /*PyObject *locals*/
  4876. );
  4877. if (!py_frame) goto bad;
  4878. py_frame->f_lineno = py_line;
  4879. PyTraceBack_Here(py_frame);
  4880. bad:
  4881. Py_XDECREF(py_code);
  4882. Py_XDECREF(py_frame);
  4883. }
  4884. static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
  4885. while (t->p) {
  4886. #if PY_MAJOR_VERSION < 3
  4887. if (t->is_unicode) {
  4888. *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
  4889. } else if (t->intern) {
  4890. *t->p = PyString_InternFromString(t->s);
  4891. } else {
  4892. *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
  4893. }
  4894. #else /* Python 3+ has unicode identifiers */
  4895. if (t->is_unicode | t->is_str) {
  4896. if (t->intern) {
  4897. *t->p = PyUnicode_InternFromString(t->s);
  4898. } else if (t->encoding) {
  4899. *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
  4900. } else {
  4901. *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
  4902. }
  4903. } else {
  4904. *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
  4905. }
  4906. #endif
  4907. if (!*t->p)
  4908. return -1;
  4909. ++t;
  4910. }
  4911. return 0;
  4912. }
  4913. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(char* c_str) {
  4914. return __Pyx_PyUnicode_FromStringAndSize(c_str, strlen(c_str));
  4915. }
  4916. static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
  4917. Py_ssize_t ignore;
  4918. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  4919. }
  4920. static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  4921. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
  4922. if (
  4923. #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  4924. __Pyx_sys_getdefaultencoding_not_ascii &&
  4925. #endif
  4926. PyUnicode_Check(o)) {
  4927. #if PY_VERSION_HEX < 0x03030000
  4928. char* defenc_c;
  4929. PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
  4930. if (!defenc) return NULL;
  4931. defenc_c = PyBytes_AS_STRING(defenc);
  4932. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  4933. {
  4934. char* end = defenc_c + PyBytes_GET_SIZE(defenc);
  4935. char* c;
  4936. for (c = defenc_c; c < end; c++) {
  4937. if ((unsigned char) (*c) >= 128) {
  4938. PyUnicode_AsASCIIString(o);
  4939. return NULL;
  4940. }
  4941. }
  4942. }
  4943. #endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
  4944. *length = PyBytes_GET_SIZE(defenc);
  4945. return defenc_c;
  4946. #else /* PY_VERSION_HEX < 0x03030000 */
  4947. if (PyUnicode_READY(o) == -1) return NULL;
  4948. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  4949. if (PyUnicode_IS_ASCII(o)) {
  4950. *length = PyUnicode_GET_DATA_SIZE(o);
  4951. return PyUnicode_AsUTF8(o);
  4952. } else {
  4953. PyUnicode_AsASCIIString(o);
  4954. return NULL;
  4955. }
  4956. #else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  4957. return PyUnicode_AsUTF8AndSize(o, length);
  4958. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
  4959. #endif /* PY_VERSION_HEX < 0x03030000 */
  4960. } else
  4961. #endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
  4962. #if !CYTHON_COMPILING_IN_PYPY
  4963. #if PY_VERSION_HEX >= 0x02060000
  4964. if (PyByteArray_Check(o)) {
  4965. *length = PyByteArray_GET_SIZE(o);
  4966. return PyByteArray_AS_STRING(o);
  4967. } else
  4968. #endif
  4969. #endif
  4970. {
  4971. char* result;
  4972. int r = PyBytes_AsStringAndSize(o, &result, length);
  4973. if (unlikely(r < 0)) {
  4974. return NULL;
  4975. } else {
  4976. return result;
  4977. }
  4978. }
  4979. }
  4980. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  4981. int is_true = x == Py_True;
  4982. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  4983. else return PyObject_IsTrue(x);
  4984. }
  4985. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  4986. PyNumberMethods *m;
  4987. const char *name = NULL;
  4988. PyObject *res = NULL;
  4989. #if PY_MAJOR_VERSION < 3
  4990. if (PyInt_Check(x) || PyLong_Check(x))
  4991. #else
  4992. if (PyLong_Check(x))
  4993. #endif
  4994. return Py_INCREF(x), x;
  4995. m = Py_TYPE(x)->tp_as_number;
  4996. #if PY_MAJOR_VERSION < 3
  4997. if (m && m->nb_int) {
  4998. name = "int";
  4999. res = PyNumber_Int(x);
  5000. }
  5001. else if (m && m->nb_long) {
  5002. name = "long";
  5003. res = PyNumber_Long(x);
  5004. }
  5005. #else
  5006. if (m && m->nb_int) {
  5007. name = "int";
  5008. res = PyNumber_Long(x);
  5009. }
  5010. #endif
  5011. if (res) {
  5012. #if PY_MAJOR_VERSION < 3
  5013. if (!PyInt_Check(res) && !PyLong_Check(res)) {
  5014. #else
  5015. if (!PyLong_Check(res)) {
  5016. #endif
  5017. PyErr_Format(PyExc_TypeError,
  5018. "__%.4s__ returned non-%.4s (type %.200s)",
  5019. name, name, Py_TYPE(res)->tp_name);
  5020. Py_DECREF(res);
  5021. return NULL;
  5022. }
  5023. }
  5024. else if (!PyErr_Occurred()) {
  5025. PyErr_SetString(PyExc_TypeError,
  5026. "an integer is required");
  5027. }
  5028. return res;
  5029. }
  5030. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  5031. #if CYTHON_USE_PYLONG_INTERNALS
  5032. #include "longintrepr.h"
  5033. #endif
  5034. #endif
  5035. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  5036. Py_ssize_t ival;
  5037. PyObject *x;
  5038. #if PY_MAJOR_VERSION < 3
  5039. if (likely(PyInt_CheckExact(b)))
  5040. return PyInt_AS_LONG(b);
  5041. #endif
  5042. if (likely(PyLong_CheckExact(b))) {
  5043. #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
  5044. #if CYTHON_USE_PYLONG_INTERNALS
  5045. switch (Py_SIZE(b)) {
  5046. case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
  5047. case 0: return 0;
  5048. case 1: return ((PyLongObject*)b)->ob_digit[0];
  5049. }
  5050. #endif
  5051. #endif
  5052. #if PY_VERSION_HEX < 0x02060000
  5053. return PyInt_AsSsize_t(b);
  5054. #else
  5055. return PyLong_AsSsize_t(b);
  5056. #endif
  5057. }
  5058. x = PyNumber_Index(b);
  5059. if (!x) return -1;
  5060. ival = PyInt_AsSsize_t(x);
  5061. Py_DECREF(x);
  5062. return ival;
  5063. }
  5064. static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
  5065. #if PY_VERSION_HEX < 0x02050000
  5066. if (ival <= LONG_MAX)
  5067. return PyInt_FromLong((long)ival);
  5068. else {
  5069. unsigned char *bytes = (unsigned char *) &ival;
  5070. int one = 1; int little = (int)*(unsigned char*)&one;
  5071. return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
  5072. }
  5073. #else
  5074. return PyInt_FromSize_t(ival);
  5075. #endif
  5076. }
  5077. #endif /* Py_PYTHON_H */