qu2cu.c 677 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682
  1. /* Generated by Cython 3.2.2 */
  2. /* BEGIN: Cython Metadata
  3. {
  4. "distutils": {
  5. "define_macros": [
  6. [
  7. "CYTHON_TRACE_NOGIL",
  8. "1"
  9. ]
  10. ],
  11. "name": "fontTools.qu2cu.qu2cu",
  12. "sources": [
  13. "Lib/fontTools/qu2cu/qu2cu.py"
  14. ]
  15. },
  16. "module_name": "fontTools.qu2cu.qu2cu"
  17. }
  18. END: Cython Metadata */
  19. #ifndef PY_SSIZE_T_CLEAN
  20. #define PY_SSIZE_T_CLEAN
  21. #endif /* PY_SSIZE_T_CLEAN */
  22. /* InitLimitedAPI */
  23. #if defined(Py_LIMITED_API)
  24. #if !defined(CYTHON_LIMITED_API)
  25. #define CYTHON_LIMITED_API 1
  26. #endif
  27. #elif defined(CYTHON_LIMITED_API)
  28. #ifdef _MSC_VER
  29. #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.")
  30. #else
  31. #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.
  32. #endif
  33. #endif
  34. #include "Python.h"
  35. #ifndef Py_PYTHON_H
  36. #error Python headers needed to compile C extensions, please install development version of Python.
  37. #elif PY_VERSION_HEX < 0x03080000
  38. #error Cython requires Python 3.8+.
  39. #else
  40. #define __PYX_ABI_VERSION "3_2_2"
  41. #define CYTHON_HEX_VERSION 0x030202F0
  42. #define CYTHON_FUTURE_DIVISION 1
  43. /* CModulePreamble */
  44. #include <stddef.h>
  45. #ifndef offsetof
  46. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  47. #endif
  48. #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS)
  49. #ifndef __stdcall
  50. #define __stdcall
  51. #endif
  52. #ifndef __cdecl
  53. #define __cdecl
  54. #endif
  55. #ifndef __fastcall
  56. #define __fastcall
  57. #endif
  58. #endif
  59. #ifndef DL_IMPORT
  60. #define DL_IMPORT(t) t
  61. #endif
  62. #ifndef DL_EXPORT
  63. #define DL_EXPORT(t) t
  64. #endif
  65. #define __PYX_COMMA ,
  66. #ifndef PY_LONG_LONG
  67. #define PY_LONG_LONG LONG_LONG
  68. #endif
  69. #ifndef Py_HUGE_VAL
  70. #define Py_HUGE_VAL HUGE_VAL
  71. #endif
  72. #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX
  73. #if defined(GRAALVM_PYTHON)
  74. /* For very preliminary testing purposes. Most variables are set the same as PyPy.
  75. The existence of this section does not imply that anything works or is even tested */
  76. #define CYTHON_COMPILING_IN_PYPY 0
  77. #define CYTHON_COMPILING_IN_CPYTHON 0
  78. #define CYTHON_COMPILING_IN_LIMITED_API 0
  79. #define CYTHON_COMPILING_IN_GRAAL 1
  80. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  81. #undef CYTHON_USE_TYPE_SLOTS
  82. #define CYTHON_USE_TYPE_SLOTS 0
  83. #undef CYTHON_USE_TYPE_SPECS
  84. #define CYTHON_USE_TYPE_SPECS 0
  85. #undef CYTHON_USE_PYTYPE_LOOKUP
  86. #define CYTHON_USE_PYTYPE_LOOKUP 0
  87. #undef CYTHON_USE_PYLIST_INTERNALS
  88. #define CYTHON_USE_PYLIST_INTERNALS 0
  89. #undef CYTHON_USE_UNICODE_INTERNALS
  90. #define CYTHON_USE_UNICODE_INTERNALS 0
  91. #undef CYTHON_USE_UNICODE_WRITER
  92. #define CYTHON_USE_UNICODE_WRITER 0
  93. #undef CYTHON_USE_PYLONG_INTERNALS
  94. #define CYTHON_USE_PYLONG_INTERNALS 0
  95. #undef CYTHON_AVOID_BORROWED_REFS
  96. #define CYTHON_AVOID_BORROWED_REFS 1
  97. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  98. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  99. #undef CYTHON_ASSUME_SAFE_MACROS
  100. #define CYTHON_ASSUME_SAFE_MACROS 0
  101. #undef CYTHON_ASSUME_SAFE_SIZE
  102. #define CYTHON_ASSUME_SAFE_SIZE 0
  103. #undef CYTHON_UNPACK_METHODS
  104. #define CYTHON_UNPACK_METHODS 0
  105. #undef CYTHON_FAST_THREAD_STATE
  106. #define CYTHON_FAST_THREAD_STATE 0
  107. #undef CYTHON_FAST_GIL
  108. #define CYTHON_FAST_GIL 0
  109. #undef CYTHON_METH_FASTCALL
  110. #define CYTHON_METH_FASTCALL 0
  111. #undef CYTHON_FAST_PYCALL
  112. #define CYTHON_FAST_PYCALL 0
  113. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  114. #define CYTHON_PEP487_INIT_SUBCLASS 1
  115. #endif
  116. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  117. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  118. #undef CYTHON_USE_MODULE_STATE
  119. #define CYTHON_USE_MODULE_STATE 0
  120. #undef CYTHON_USE_SYS_MONITORING
  121. #define CYTHON_USE_SYS_MONITORING 0
  122. #undef CYTHON_USE_TP_FINALIZE
  123. #define CYTHON_USE_TP_FINALIZE 0
  124. #undef CYTHON_USE_AM_SEND
  125. #define CYTHON_USE_AM_SEND 0
  126. #undef CYTHON_USE_DICT_VERSIONS
  127. #define CYTHON_USE_DICT_VERSIONS 0
  128. #undef CYTHON_USE_EXC_INFO_STACK
  129. #define CYTHON_USE_EXC_INFO_STACK 1
  130. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  131. #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  132. #endif
  133. #undef CYTHON_USE_FREELISTS
  134. #define CYTHON_USE_FREELISTS 0
  135. #undef CYTHON_IMMORTAL_CONSTANTS
  136. #define CYTHON_IMMORTAL_CONSTANTS 0
  137. #elif defined(PYPY_VERSION)
  138. #define CYTHON_COMPILING_IN_PYPY 1
  139. #define CYTHON_COMPILING_IN_CPYTHON 0
  140. #define CYTHON_COMPILING_IN_LIMITED_API 0
  141. #define CYTHON_COMPILING_IN_GRAAL 0
  142. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  143. #undef CYTHON_USE_TYPE_SLOTS
  144. #define CYTHON_USE_TYPE_SLOTS 1
  145. #ifndef CYTHON_USE_TYPE_SPECS
  146. #define CYTHON_USE_TYPE_SPECS 0
  147. #endif
  148. #undef CYTHON_USE_PYTYPE_LOOKUP
  149. #define CYTHON_USE_PYTYPE_LOOKUP 0
  150. #undef CYTHON_USE_PYLIST_INTERNALS
  151. #define CYTHON_USE_PYLIST_INTERNALS 0
  152. #undef CYTHON_USE_UNICODE_INTERNALS
  153. #define CYTHON_USE_UNICODE_INTERNALS 0
  154. #undef CYTHON_USE_UNICODE_WRITER
  155. #define CYTHON_USE_UNICODE_WRITER 0
  156. #undef CYTHON_USE_PYLONG_INTERNALS
  157. #define CYTHON_USE_PYLONG_INTERNALS 0
  158. #undef CYTHON_AVOID_BORROWED_REFS
  159. #define CYTHON_AVOID_BORROWED_REFS 1
  160. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  161. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  162. #undef CYTHON_ASSUME_SAFE_MACROS
  163. #define CYTHON_ASSUME_SAFE_MACROS 0
  164. #ifndef CYTHON_ASSUME_SAFE_SIZE
  165. #define CYTHON_ASSUME_SAFE_SIZE 1
  166. #endif
  167. #undef CYTHON_UNPACK_METHODS
  168. #define CYTHON_UNPACK_METHODS 0
  169. #undef CYTHON_FAST_THREAD_STATE
  170. #define CYTHON_FAST_THREAD_STATE 0
  171. #undef CYTHON_FAST_GIL
  172. #define CYTHON_FAST_GIL 0
  173. #undef CYTHON_METH_FASTCALL
  174. #define CYTHON_METH_FASTCALL 0
  175. #undef CYTHON_FAST_PYCALL
  176. #define CYTHON_FAST_PYCALL 0
  177. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  178. #define CYTHON_PEP487_INIT_SUBCLASS 1
  179. #endif
  180. #if PY_VERSION_HEX < 0x03090000
  181. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  182. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  183. #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
  184. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  185. #endif
  186. #undef CYTHON_USE_MODULE_STATE
  187. #define CYTHON_USE_MODULE_STATE 0
  188. #undef CYTHON_USE_SYS_MONITORING
  189. #define CYTHON_USE_SYS_MONITORING 0
  190. #ifndef CYTHON_USE_TP_FINALIZE
  191. #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00)
  192. #endif
  193. #undef CYTHON_USE_AM_SEND
  194. #define CYTHON_USE_AM_SEND 0
  195. #undef CYTHON_USE_DICT_VERSIONS
  196. #define CYTHON_USE_DICT_VERSIONS 0
  197. #undef CYTHON_USE_EXC_INFO_STACK
  198. #define CYTHON_USE_EXC_INFO_STACK 0
  199. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  200. #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100)
  201. #endif
  202. #undef CYTHON_USE_FREELISTS
  203. #define CYTHON_USE_FREELISTS 0
  204. #undef CYTHON_IMMORTAL_CONSTANTS
  205. #define CYTHON_IMMORTAL_CONSTANTS 0
  206. #elif defined(CYTHON_LIMITED_API)
  207. #ifdef Py_LIMITED_API
  208. #undef __PYX_LIMITED_VERSION_HEX
  209. #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API
  210. #endif
  211. #define CYTHON_COMPILING_IN_PYPY 0
  212. #define CYTHON_COMPILING_IN_CPYTHON 0
  213. #define CYTHON_COMPILING_IN_LIMITED_API 1
  214. #define CYTHON_COMPILING_IN_GRAAL 0
  215. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  216. #undef CYTHON_USE_TYPE_SLOTS
  217. #define CYTHON_USE_TYPE_SLOTS 0
  218. #undef CYTHON_USE_TYPE_SPECS
  219. #define CYTHON_USE_TYPE_SPECS 1
  220. #undef CYTHON_USE_PYTYPE_LOOKUP
  221. #define CYTHON_USE_PYTYPE_LOOKUP 0
  222. #undef CYTHON_USE_PYLIST_INTERNALS
  223. #define CYTHON_USE_PYLIST_INTERNALS 0
  224. #undef CYTHON_USE_UNICODE_INTERNALS
  225. #define CYTHON_USE_UNICODE_INTERNALS 0
  226. #ifndef CYTHON_USE_UNICODE_WRITER
  227. #define CYTHON_USE_UNICODE_WRITER 0
  228. #endif
  229. #undef CYTHON_USE_PYLONG_INTERNALS
  230. #define CYTHON_USE_PYLONG_INTERNALS 0
  231. #ifndef CYTHON_AVOID_BORROWED_REFS
  232. #define CYTHON_AVOID_BORROWED_REFS 0
  233. #endif
  234. #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  235. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  236. #endif
  237. #undef CYTHON_ASSUME_SAFE_MACROS
  238. #define CYTHON_ASSUME_SAFE_MACROS 0
  239. #undef CYTHON_ASSUME_SAFE_SIZE
  240. #define CYTHON_ASSUME_SAFE_SIZE 0
  241. #undef CYTHON_UNPACK_METHODS
  242. #define CYTHON_UNPACK_METHODS 0
  243. #undef CYTHON_FAST_THREAD_STATE
  244. #define CYTHON_FAST_THREAD_STATE 0
  245. #undef CYTHON_FAST_GIL
  246. #define CYTHON_FAST_GIL 0
  247. #undef CYTHON_METH_FASTCALL
  248. #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
  249. #undef CYTHON_FAST_PYCALL
  250. #define CYTHON_FAST_PYCALL 0
  251. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  252. #define CYTHON_PEP487_INIT_SUBCLASS 1
  253. #endif
  254. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  255. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  256. #endif
  257. #ifndef CYTHON_USE_MODULE_STATE
  258. #define CYTHON_USE_MODULE_STATE 0
  259. #endif
  260. #undef CYTHON_USE_SYS_MONITORING
  261. #define CYTHON_USE_SYS_MONITORING 0
  262. #ifndef CYTHON_USE_TP_FINALIZE
  263. #define CYTHON_USE_TP_FINALIZE 0
  264. #endif
  265. #ifndef CYTHON_USE_AM_SEND
  266. #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
  267. #endif
  268. #undef CYTHON_USE_DICT_VERSIONS
  269. #define CYTHON_USE_DICT_VERSIONS 0
  270. #undef CYTHON_USE_EXC_INFO_STACK
  271. #define CYTHON_USE_EXC_INFO_STACK 0
  272. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  273. #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  274. #endif
  275. #ifndef CYTHON_USE_FREELISTS
  276. #define CYTHON_USE_FREELISTS 1
  277. #endif
  278. #undef CYTHON_IMMORTAL_CONSTANTS
  279. #define CYTHON_IMMORTAL_CONSTANTS 0
  280. #else
  281. #define CYTHON_COMPILING_IN_PYPY 0
  282. #define CYTHON_COMPILING_IN_CPYTHON 1
  283. #define CYTHON_COMPILING_IN_LIMITED_API 0
  284. #define CYTHON_COMPILING_IN_GRAAL 0
  285. #ifdef Py_GIL_DISABLED
  286. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1
  287. #else
  288. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  289. #endif
  290. #if PY_VERSION_HEX < 0x030A0000
  291. #undef CYTHON_USE_TYPE_SLOTS
  292. #define CYTHON_USE_TYPE_SLOTS 1
  293. #elif !defined(CYTHON_USE_TYPE_SLOTS)
  294. #define CYTHON_USE_TYPE_SLOTS 1
  295. #endif
  296. #ifndef CYTHON_USE_TYPE_SPECS
  297. #define CYTHON_USE_TYPE_SPECS 0
  298. #endif
  299. #ifndef CYTHON_USE_PYTYPE_LOOKUP
  300. #define CYTHON_USE_PYTYPE_LOOKUP 1
  301. #endif
  302. #ifndef CYTHON_USE_PYLONG_INTERNALS
  303. #define CYTHON_USE_PYLONG_INTERNALS 1
  304. #endif
  305. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  306. #undef CYTHON_USE_PYLIST_INTERNALS
  307. #define CYTHON_USE_PYLIST_INTERNALS 0
  308. #elif !defined(CYTHON_USE_PYLIST_INTERNALS)
  309. #define CYTHON_USE_PYLIST_INTERNALS 1
  310. #endif
  311. #ifndef CYTHON_USE_UNICODE_INTERNALS
  312. #define CYTHON_USE_UNICODE_INTERNALS 1
  313. #endif
  314. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2
  315. #undef CYTHON_USE_UNICODE_WRITER
  316. #define CYTHON_USE_UNICODE_WRITER 0
  317. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  318. #define CYTHON_USE_UNICODE_WRITER 1
  319. #endif
  320. #ifndef CYTHON_AVOID_BORROWED_REFS
  321. #define CYTHON_AVOID_BORROWED_REFS 0
  322. #endif
  323. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  324. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  325. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  326. #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
  327. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  328. #endif
  329. #ifndef CYTHON_ASSUME_SAFE_MACROS
  330. #define CYTHON_ASSUME_SAFE_MACROS 1
  331. #endif
  332. #ifndef CYTHON_ASSUME_SAFE_SIZE
  333. #define CYTHON_ASSUME_SAFE_SIZE 1
  334. #endif
  335. #ifndef CYTHON_UNPACK_METHODS
  336. #define CYTHON_UNPACK_METHODS 1
  337. #endif
  338. #ifndef CYTHON_FAST_THREAD_STATE
  339. #define CYTHON_FAST_THREAD_STATE 1
  340. #endif
  341. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  342. #undef CYTHON_FAST_GIL
  343. #define CYTHON_FAST_GIL 0
  344. #elif !defined(CYTHON_FAST_GIL)
  345. #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6)
  346. #endif
  347. #ifndef CYTHON_METH_FASTCALL
  348. #define CYTHON_METH_FASTCALL 1
  349. #endif
  350. #ifndef CYTHON_FAST_PYCALL
  351. #define CYTHON_FAST_PYCALL 1
  352. #endif
  353. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  354. #define CYTHON_PEP487_INIT_SUBCLASS 1
  355. #endif
  356. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  357. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  358. #endif
  359. #ifndef CYTHON_USE_MODULE_STATE
  360. #define CYTHON_USE_MODULE_STATE 0
  361. #endif
  362. #ifndef CYTHON_USE_SYS_MONITORING
  363. #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1)
  364. #endif
  365. #ifndef CYTHON_USE_TP_FINALIZE
  366. #define CYTHON_USE_TP_FINALIZE 1
  367. #endif
  368. #ifndef CYTHON_USE_AM_SEND
  369. #define CYTHON_USE_AM_SEND 1
  370. #endif
  371. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  372. #undef CYTHON_USE_DICT_VERSIONS
  373. #define CYTHON_USE_DICT_VERSIONS 0
  374. #elif !defined(CYTHON_USE_DICT_VERSIONS)
  375. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE)
  376. #endif
  377. #ifndef CYTHON_USE_EXC_INFO_STACK
  378. #define CYTHON_USE_EXC_INFO_STACK 1
  379. #endif
  380. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  381. #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  382. #endif
  383. #ifndef CYTHON_USE_FREELISTS
  384. #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  385. #endif
  386. #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000
  387. #undef CYTHON_IMMORTAL_CONSTANTS
  388. #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work
  389. #elif !defined(CYTHON_IMMORTAL_CONSTANTS)
  390. #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  391. #endif
  392. #endif
  393. #ifndef CYTHON_COMPRESS_STRINGS
  394. #define CYTHON_COMPRESS_STRINGS 1
  395. #endif
  396. #ifndef CYTHON_FAST_PYCCALL
  397. #define CYTHON_FAST_PYCCALL CYTHON_FAST_PYCALL
  398. #endif
  399. #ifndef CYTHON_VECTORCALL
  400. #if CYTHON_COMPILING_IN_LIMITED_API
  401. #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
  402. #else
  403. #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL)
  404. #endif
  405. #endif
  406. #if CYTHON_USE_PYLONG_INTERNALS
  407. #undef SHIFT
  408. #undef BASE
  409. #undef MASK
  410. #ifdef SIZEOF_VOID_P
  411. enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  412. #endif
  413. #endif
  414. #ifndef __has_attribute
  415. #define __has_attribute(x) 0
  416. #endif
  417. #ifndef __has_cpp_attribute
  418. #define __has_cpp_attribute(x) 0
  419. #endif
  420. #ifndef CYTHON_RESTRICT
  421. #if defined(__GNUC__)
  422. #define CYTHON_RESTRICT __restrict__
  423. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  424. #define CYTHON_RESTRICT __restrict
  425. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  426. #define CYTHON_RESTRICT restrict
  427. #else
  428. #define CYTHON_RESTRICT
  429. #endif
  430. #endif
  431. #ifndef CYTHON_UNUSED
  432. #if defined(__cplusplus)
  433. /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17
  434. * but leads to warnings with -pedantic, since it is a C++17 feature */
  435. #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
  436. #if __has_cpp_attribute(maybe_unused)
  437. #define CYTHON_UNUSED [[maybe_unused]]
  438. #endif
  439. #endif
  440. #endif
  441. #endif
  442. #ifndef CYTHON_UNUSED
  443. # if defined(__GNUC__)
  444. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  445. # define CYTHON_UNUSED __attribute__ ((__unused__))
  446. # else
  447. # define CYTHON_UNUSED
  448. # endif
  449. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  450. # define CYTHON_UNUSED __attribute__ ((__unused__))
  451. # else
  452. # define CYTHON_UNUSED
  453. # endif
  454. #endif
  455. #ifndef CYTHON_UNUSED_VAR
  456. # if defined(__cplusplus)
  457. template<class T> void CYTHON_UNUSED_VAR( const T& ) { }
  458. # else
  459. # define CYTHON_UNUSED_VAR(x) (void)(x)
  460. # endif
  461. #endif
  462. #ifndef CYTHON_MAYBE_UNUSED_VAR
  463. #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x)
  464. #endif
  465. #ifndef CYTHON_NCP_UNUSED
  466. # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  467. # define CYTHON_NCP_UNUSED
  468. # else
  469. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  470. # endif
  471. #endif
  472. #ifndef CYTHON_USE_CPP_STD_MOVE
  473. #if defined(__cplusplus) && (\
  474. __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
  475. #define CYTHON_USE_CPP_STD_MOVE 1
  476. #else
  477. #define CYTHON_USE_CPP_STD_MOVE 0
  478. #endif
  479. #endif
  480. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  481. #include <stdint.h>
  482. typedef uintptr_t __pyx_uintptr_t;
  483. #ifndef CYTHON_FALLTHROUGH
  484. #if defined(__cplusplus)
  485. /* for clang __has_cpp_attribute(fallthrough) is true even before C++17
  486. * but leads to warnings with -pedantic, since it is a C++17 feature */
  487. #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
  488. #if __has_cpp_attribute(fallthrough)
  489. #define CYTHON_FALLTHROUGH [[fallthrough]]
  490. #endif
  491. #endif
  492. #ifndef CYTHON_FALLTHROUGH
  493. #if __has_cpp_attribute(clang::fallthrough)
  494. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  495. #elif __has_cpp_attribute(gnu::fallthrough)
  496. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  497. #endif
  498. #endif
  499. #endif
  500. #ifndef CYTHON_FALLTHROUGH
  501. #if __has_attribute(fallthrough)
  502. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  503. #else
  504. #define CYTHON_FALLTHROUGH
  505. #endif
  506. #endif
  507. #if defined(__clang__) && defined(__apple_build_version__)
  508. #if __apple_build_version__ < 7000000
  509. #undef CYTHON_FALLTHROUGH
  510. #define CYTHON_FALLTHROUGH
  511. #endif
  512. #endif
  513. #endif
  514. #ifndef Py_UNREACHABLE
  515. #define Py_UNREACHABLE() assert(0); abort()
  516. #endif
  517. #ifdef __cplusplus
  518. template <typename T>
  519. struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);};
  520. #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL<type>::value)
  521. #else
  522. #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0)
  523. #endif
  524. #if CYTHON_COMPILING_IN_PYPY == 1
  525. #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000)
  526. #else
  527. #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x03090000)
  528. #endif
  529. #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer))
  530. /* CInitCode */
  531. #ifndef CYTHON_INLINE
  532. #if defined(__clang__)
  533. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  534. #elif defined(__GNUC__)
  535. #define CYTHON_INLINE __inline__
  536. #elif defined(_MSC_VER)
  537. #define CYTHON_INLINE __inline
  538. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  539. #define CYTHON_INLINE inline
  540. #else
  541. #define CYTHON_INLINE
  542. #endif
  543. #endif
  544. /* PythonCompatibility */
  545. #define __PYX_BUILD_PY_SSIZE_T "n"
  546. #define CYTHON_FORMAT_SSIZE_T "z"
  547. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  548. #define __Pyx_DefaultClassType PyType_Type
  549. #if CYTHON_COMPILING_IN_LIMITED_API
  550. #ifndef CO_OPTIMIZED
  551. static int CO_OPTIMIZED;
  552. #endif
  553. #ifndef CO_NEWLOCALS
  554. static int CO_NEWLOCALS;
  555. #endif
  556. #ifndef CO_VARARGS
  557. static int CO_VARARGS;
  558. #endif
  559. #ifndef CO_VARKEYWORDS
  560. static int CO_VARKEYWORDS;
  561. #endif
  562. #ifndef CO_ASYNC_GENERATOR
  563. static int CO_ASYNC_GENERATOR;
  564. #endif
  565. #ifndef CO_GENERATOR
  566. static int CO_GENERATOR;
  567. #endif
  568. #ifndef CO_COROUTINE
  569. static int CO_COROUTINE;
  570. #endif
  571. #else
  572. #ifndef CO_COROUTINE
  573. #define CO_COROUTINE 0x80
  574. #endif
  575. #ifndef CO_ASYNC_GENERATOR
  576. #define CO_ASYNC_GENERATOR 0x200
  577. #endif
  578. #endif
  579. static int __Pyx_init_co_variables(void);
  580. #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE)
  581. #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type)
  582. #else
  583. #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type))
  584. #endif
  585. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is)
  586. #define __Pyx_Py_Is(x, y) Py_Is(x, y)
  587. #else
  588. #define __Pyx_Py_Is(x, y) ((x) == (y))
  589. #endif
  590. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone)
  591. #define __Pyx_Py_IsNone(ob) Py_IsNone(ob)
  592. #else
  593. #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None)
  594. #endif
  595. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue)
  596. #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob)
  597. #else
  598. #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True)
  599. #endif
  600. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse)
  601. #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob)
  602. #else
  603. #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False)
  604. #endif
  605. #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj))
  606. #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY
  607. #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
  608. #else
  609. #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
  610. #endif
  611. #ifndef Py_TPFLAGS_CHECKTYPES
  612. #define Py_TPFLAGS_CHECKTYPES 0
  613. #endif
  614. #ifndef Py_TPFLAGS_HAVE_INDEX
  615. #define Py_TPFLAGS_HAVE_INDEX 0
  616. #endif
  617. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  618. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  619. #endif
  620. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  621. #define Py_TPFLAGS_HAVE_FINALIZE 0
  622. #endif
  623. #ifndef Py_TPFLAGS_SEQUENCE
  624. #define Py_TPFLAGS_SEQUENCE 0
  625. #endif
  626. #ifndef Py_TPFLAGS_MAPPING
  627. #define Py_TPFLAGS_MAPPING 0
  628. #endif
  629. #ifndef Py_TPFLAGS_IMMUTABLETYPE
  630. #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
  631. #endif
  632. #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION
  633. #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
  634. #endif
  635. #ifndef METH_STACKLESS
  636. #define METH_STACKLESS 0
  637. #endif
  638. #ifndef METH_FASTCALL
  639. #ifndef METH_FASTCALL
  640. #define METH_FASTCALL 0x80
  641. #endif
  642. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  643. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  644. Py_ssize_t nargs, PyObject *kwnames);
  645. #else
  646. #if PY_VERSION_HEX >= 0x030d00A4
  647. # define __Pyx_PyCFunctionFast PyCFunctionFast
  648. # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords
  649. #else
  650. # define __Pyx_PyCFunctionFast _PyCFunctionFast
  651. # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  652. #endif
  653. #endif
  654. #if CYTHON_METH_FASTCALL
  655. #define __Pyx_METH_FASTCALL METH_FASTCALL
  656. #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast
  657. #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords
  658. #else
  659. #define __Pyx_METH_FASTCALL METH_VARARGS
  660. #define __Pyx_PyCFunction_FastCall PyCFunction
  661. #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords
  662. #endif
  663. #if CYTHON_VECTORCALL
  664. #define __pyx_vectorcallfunc vectorcallfunc
  665. #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET
  666. #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n))
  667. #else
  668. #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0
  669. #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n))
  670. #endif
  671. #if PY_VERSION_HEX >= 0x030900B1
  672. #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func)
  673. #else
  674. #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func)
  675. #endif
  676. #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func)
  677. #if CYTHON_COMPILING_IN_CPYTHON
  678. #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth)
  679. #elif !CYTHON_COMPILING_IN_LIMITED_API
  680. #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func)
  681. #endif
  682. #if CYTHON_COMPILING_IN_CPYTHON
  683. #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags)
  684. static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) {
  685. return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self;
  686. }
  687. #endif
  688. static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) {
  689. #if CYTHON_COMPILING_IN_LIMITED_API
  690. return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
  691. #else
  692. return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  693. #endif
  694. }
  695. #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc)
  696. #if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000)
  697. #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b))
  698. typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *);
  699. #else
  700. #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b)
  701. #define __Pyx_PyCMethod PyCMethod
  702. #endif
  703. #ifndef METH_METHOD
  704. #define METH_METHOD 0x200
  705. #endif
  706. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  707. #define PyObject_Malloc(s) PyMem_Malloc(s)
  708. #define PyObject_Free(p) PyMem_Free(p)
  709. #define PyObject_Realloc(p) PyMem_Realloc(p)
  710. #endif
  711. #if CYTHON_COMPILING_IN_LIMITED_API
  712. #define __Pyx_PyFrame_SetLineNumber(frame, lineno)
  713. #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  714. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  715. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno))
  716. #elif CYTHON_COMPILING_IN_GRAAL
  717. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  718. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno))
  719. #else
  720. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  721. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  722. #endif
  723. #if CYTHON_COMPILING_IN_LIMITED_API
  724. #define __Pyx_PyThreadState_Current PyThreadState_Get()
  725. #elif !CYTHON_FAST_THREAD_STATE
  726. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  727. #elif PY_VERSION_HEX >= 0x030d00A1
  728. #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
  729. #else
  730. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  731. #endif
  732. #if CYTHON_USE_MODULE_STATE
  733. static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op)
  734. {
  735. void *result;
  736. result = PyModule_GetState(op);
  737. if (!result)
  738. Py_FatalError("Couldn't find the module state");
  739. return result;
  740. }
  741. #define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o)
  742. #else
  743. #define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global)
  744. #endif
  745. #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype)
  746. #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype)
  747. #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
  748. #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
  749. #if CYTHON_USE_TYPE_SLOTS
  750. #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name)
  751. #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype)
  752. #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL)
  753. #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype)
  754. #else
  755. #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name))
  756. #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\
  757. ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\
  758. (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\
  759. __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL)
  760. #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype)
  761. #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype)
  762. #endif
  763. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  764. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  765. #else
  766. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  767. #endif
  768. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  769. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  770. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS
  771. #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  772. static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) {
  773. PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name);
  774. if (res == NULL) PyErr_Clear();
  775. return res;
  776. }
  777. #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000
  778. #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError
  779. #define __Pyx_PyDict_GetItemStr PyDict_GetItem
  780. #else
  781. static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) {
  782. #if CYTHON_COMPILING_IN_PYPY
  783. return PyDict_GetItem(dict, name);
  784. #else
  785. PyDictEntry *ep;
  786. PyDictObject *mp = (PyDictObject*) dict;
  787. long hash = ((PyStringObject *) name)->ob_shash;
  788. assert(hash != -1);
  789. ep = (mp->ma_lookup)(mp, name, hash);
  790. if (ep == NULL) {
  791. return NULL;
  792. }
  793. return ep->me_value;
  794. #endif
  795. }
  796. #define __Pyx_PyDict_GetItemStr PyDict_GetItem
  797. #endif
  798. #if CYTHON_USE_TYPE_SLOTS
  799. #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags)
  800. #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
  801. #else
  802. #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp))
  803. #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature)
  804. #endif
  805. #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc)
  806. #if CYTHON_USE_TYPE_SPECS
  807. #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\
  808. PyTypeObject *type = Py_TYPE((PyObject*)obj);\
  809. assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\
  810. PyObject_GC_Del(obj);\
  811. Py_DECREF(type);\
  812. }
  813. #else
  814. #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj)
  815. #endif
  816. #if CYTHON_COMPILING_IN_LIMITED_API
  817. #define __Pyx_PyUnicode_READY(op) (0)
  818. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
  819. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U)
  820. #define __Pyx_PyUnicode_KIND(u) ((void)u, (0))
  821. #define __Pyx_PyUnicode_DATA(u) ((void*)u)
  822. #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i))
  823. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u))
  824. #else
  825. #if PY_VERSION_HEX >= 0x030C0000
  826. #define __Pyx_PyUnicode_READY(op) (0)
  827. #else
  828. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  829. 0 : _PyUnicode_Ready((PyObject *)(op)))
  830. #endif
  831. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  832. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  833. #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u))
  834. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  835. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  836. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch)
  837. #if PY_VERSION_HEX >= 0x030C0000
  838. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
  839. #else
  840. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  841. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  842. #else
  843. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  844. #endif
  845. #endif
  846. #endif
  847. #if CYTHON_COMPILING_IN_PYPY
  848. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  849. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  850. #else
  851. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  852. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  853. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  854. #endif
  855. #if CYTHON_COMPILING_IN_PYPY
  856. #if !defined(PyUnicode_DecodeUnicodeEscape)
  857. #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors)
  858. #endif
  859. #if !defined(PyUnicode_Contains)
  860. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  861. #endif
  862. #if !defined(PyByteArray_Check)
  863. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  864. #endif
  865. #if !defined(PyObject_Format)
  866. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  867. #endif
  868. #endif
  869. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  870. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  871. #define __Pyx_PySequence_ListKeepNew(obj)\
  872. (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj))
  873. #elif CYTHON_COMPILING_IN_CPYTHON
  874. #define __Pyx_PySequence_ListKeepNew(obj)\
  875. (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj))
  876. #else
  877. #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj)
  878. #endif
  879. #ifndef PySet_CheckExact
  880. #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type)
  881. #endif
  882. #if PY_VERSION_HEX >= 0x030900A4
  883. #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  884. #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
  885. #else
  886. #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  887. #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
  888. #endif
  889. enum __Pyx_ReferenceSharing {
  890. __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check
  891. __Pyx_ReferenceSharing_OwnStrongReference,
  892. __Pyx_ReferenceSharing_FunctionArgument,
  893. __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar
  894. };
  895. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000
  896. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\
  897. (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\
  898. (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\
  899. (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0)))
  900. #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API
  901. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1)
  902. #else
  903. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0)
  904. #endif
  905. #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  906. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  907. #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
  908. #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
  909. #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  910. #else
  911. #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i)
  912. #endif
  913. #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
  914. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  915. #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
  916. #else
  917. #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i))
  918. #endif
  919. #else
  920. #define __Pyx_PyList_GetItemRef(o, i) __Pyx_NewRef(PyList_GET_ITEM(o, i))
  921. #endif
  922. #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !CYTHON_COMPILING_IN_LIMITED_API && CYTHON_ASSUME_SAFE_MACROS
  923. #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) (__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\
  924. __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i))
  925. #else
  926. #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) __Pyx_PyList_GetItemRef(o, i)
  927. #endif
  928. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  929. #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result)
  930. #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  931. static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  932. *result = PyObject_GetItem(dict, key);
  933. if (*result == NULL) {
  934. if (PyErr_ExceptionMatches(PyExc_KeyError)) {
  935. PyErr_Clear();
  936. return 0;
  937. }
  938. return -1;
  939. }
  940. return 1;
  941. }
  942. #else
  943. static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  944. *result = PyDict_GetItemWithError(dict, key);
  945. if (*result == NULL) {
  946. return PyErr_Occurred() ? -1 : 0;
  947. }
  948. Py_INCREF(*result);
  949. return 1;
  950. }
  951. #endif
  952. #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST
  953. #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj)
  954. #else
  955. #define __Pyx_VISIT_CONST(obj)
  956. #endif
  957. #if CYTHON_ASSUME_SAFE_MACROS
  958. #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i)
  959. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  960. #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0))
  961. #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i)
  962. #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0))
  963. #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i)
  964. #else
  965. #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i)
  966. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  967. #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v)
  968. #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i)
  969. #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v)
  970. #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i)
  971. #endif
  972. #if CYTHON_ASSUME_SAFE_SIZE
  973. #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o)
  974. #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o)
  975. #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o)
  976. #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
  977. #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o)
  978. #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o)
  979. #else
  980. #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o)
  981. #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o)
  982. #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o)
  983. #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o)
  984. #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o)
  985. #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o)
  986. #endif
  987. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString)
  988. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  989. #endif
  990. #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t
  991. #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t
  992. #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
  993. #define __Pyx_PySendResult PySendResult
  994. #else
  995. typedef enum {
  996. PYGEN_RETURN = 0,
  997. PYGEN_ERROR = -1,
  998. PYGEN_NEXT = 1,
  999. } __Pyx_PySendResult;
  1000. #endif
  1001. #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3
  1002. typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
  1003. #else
  1004. #define __Pyx_pyiter_sendfunc sendfunc
  1005. #endif
  1006. #if !CYTHON_USE_AM_SEND
  1007. #define __PYX_HAS_PY_AM_SEND 0
  1008. #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000
  1009. #define __PYX_HAS_PY_AM_SEND 1
  1010. #else
  1011. #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation
  1012. #endif
  1013. #if __PYX_HAS_PY_AM_SEND < 2
  1014. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  1015. #else
  1016. typedef struct {
  1017. unaryfunc am_await;
  1018. unaryfunc am_aiter;
  1019. unaryfunc am_anext;
  1020. __Pyx_pyiter_sendfunc am_send;
  1021. } __Pyx_PyAsyncMethodsStruct;
  1022. #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s))
  1023. #endif
  1024. #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0
  1025. #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21)
  1026. #else
  1027. #define __Pyx_TPFLAGS_HAVE_AM_SEND (0)
  1028. #endif
  1029. #if PY_VERSION_HEX >= 0x03090000
  1030. #define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get()
  1031. #else
  1032. #define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp
  1033. #endif
  1034. #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000
  1035. #ifdef __cplusplus
  1036. extern "C"
  1037. #endif
  1038. PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
  1039. #endif
  1040. #if CYTHON_COMPILING_IN_LIMITED_API
  1041. static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) {
  1042. int value;
  1043. PyObject *py_value = PyObject_GetAttrString(inspect, name);
  1044. if (!py_value) return 0;
  1045. value = (int) PyLong_AsLong(py_value);
  1046. Py_DECREF(py_value);
  1047. *write_to = value;
  1048. return value != -1 || !PyErr_Occurred();
  1049. }
  1050. static int __Pyx_init_co_variables(void) {
  1051. PyObject *inspect;
  1052. int result;
  1053. inspect = PyImport_ImportModule("inspect");
  1054. result =
  1055. #if !defined(CO_OPTIMIZED)
  1056. __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) &&
  1057. #endif
  1058. #if !defined(CO_NEWLOCALS)
  1059. __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) &&
  1060. #endif
  1061. #if !defined(CO_VARARGS)
  1062. __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) &&
  1063. #endif
  1064. #if !defined(CO_VARKEYWORDS)
  1065. __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) &&
  1066. #endif
  1067. #if !defined(CO_ASYNC_GENERATOR)
  1068. __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) &&
  1069. #endif
  1070. #if !defined(CO_GENERATOR)
  1071. __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) &&
  1072. #endif
  1073. #if !defined(CO_COROUTINE)
  1074. __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) &&
  1075. #endif
  1076. 1;
  1077. Py_DECREF(inspect);
  1078. return result ? 0 : -1;
  1079. }
  1080. #else
  1081. static int __Pyx_init_co_variables(void) {
  1082. return 0; // It's a limited API-only feature
  1083. }
  1084. #endif
  1085. /* MathInitCode */
  1086. #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  1087. #ifndef _USE_MATH_DEFINES
  1088. #define _USE_MATH_DEFINES
  1089. #endif
  1090. #endif
  1091. #include <math.h>
  1092. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  1093. #define __Pyx_truncl trunc
  1094. #else
  1095. #define __Pyx_truncl truncl
  1096. #endif
  1097. #ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  1098. #define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0
  1099. #endif
  1100. #ifndef CYTHON_CLINE_IN_TRACEBACK
  1101. #define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  1102. #endif
  1103. #if CYTHON_CLINE_IN_TRACEBACK
  1104. #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; }
  1105. #else
  1106. #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; }
  1107. #endif
  1108. #define __PYX_ERR(f_index, lineno, Ln_error) \
  1109. { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
  1110. #ifdef CYTHON_EXTERN_C
  1111. #undef __PYX_EXTERN_C
  1112. #define __PYX_EXTERN_C CYTHON_EXTERN_C
  1113. #elif defined(__PYX_EXTERN_C)
  1114. #ifdef _MSC_VER
  1115. #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
  1116. #else
  1117. #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
  1118. #endif
  1119. #else
  1120. #ifdef __cplusplus
  1121. #define __PYX_EXTERN_C extern "C"
  1122. #else
  1123. #define __PYX_EXTERN_C extern
  1124. #endif
  1125. #endif
  1126. #define __PYX_HAVE__fontTools__qu2cu__qu2cu
  1127. #define __PYX_HAVE_API__fontTools__qu2cu__qu2cu
  1128. /* Early includes */
  1129. #ifdef _OPENMP
  1130. #include <omp.h>
  1131. #endif /* _OPENMP */
  1132. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  1133. #define CYTHON_WITHOUT_ASSERTIONS
  1134. #endif
  1135. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  1136. #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
  1137. #define __PYX_DEFAULT_STRING_ENCODING ""
  1138. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  1139. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  1140. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  1141. #define __Pyx_long_cast(x) ((long)x)
  1142. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  1143. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  1144. (sizeof(type) > sizeof(Py_ssize_t) &&\
  1145. likely(v < (type)PY_SSIZE_T_MAX ||\
  1146. v == (type)PY_SSIZE_T_MAX) &&\
  1147. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  1148. v == (type)PY_SSIZE_T_MIN))) ||\
  1149. (sizeof(type) == sizeof(Py_ssize_t) &&\
  1150. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  1151. v == (type)PY_SSIZE_T_MAX))) )
  1152. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  1153. return (size_t) i < (size_t) limit;
  1154. }
  1155. #if defined (__cplusplus) && __cplusplus >= 201103L
  1156. #include <cstdlib>
  1157. #define __Pyx_sst_abs(value) std::abs(value)
  1158. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  1159. #define __Pyx_sst_abs(value) abs(value)
  1160. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  1161. #define __Pyx_sst_abs(value) labs(value)
  1162. #elif defined (_MSC_VER)
  1163. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  1164. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  1165. #define __Pyx_sst_abs(value) llabs(value)
  1166. #elif defined (__GNUC__)
  1167. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  1168. #else
  1169. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  1170. #endif
  1171. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s);
  1172. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  1173. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  1174. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*);
  1175. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  1176. #define __Pyx_PyBytes_FromString PyBytes_FromString
  1177. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  1178. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  1179. #if CYTHON_ASSUME_SAFE_MACROS
  1180. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  1181. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  1182. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  1183. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  1184. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  1185. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  1186. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s)
  1187. #else
  1188. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s))
  1189. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s))
  1190. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s))
  1191. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s))
  1192. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s))
  1193. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s))
  1194. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s)
  1195. #endif
  1196. #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1197. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1198. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1199. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  1200. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  1201. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  1202. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  1203. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  1204. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  1205. #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o)
  1206. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  1207. static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) {
  1208. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef)
  1209. return Py_NewRef(obj);
  1210. #else
  1211. Py_INCREF(obj);
  1212. return obj;
  1213. #endif
  1214. }
  1215. static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) {
  1216. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef)
  1217. return Py_XNewRef(obj);
  1218. #else
  1219. Py_XINCREF(obj);
  1220. return obj;
  1221. #endif
  1222. }
  1223. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b);
  1224. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  1225. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  1226. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  1227. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x);
  1228. #define __Pyx_PySequence_Tuple(obj)\
  1229. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  1230. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  1231. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t);
  1232. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
  1233. #if CYTHON_ASSUME_SAFE_MACROS
  1234. #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  1235. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x)
  1236. #else
  1237. #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  1238. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x)
  1239. #endif
  1240. #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x))
  1241. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  1242. #if CYTHON_USE_PYLONG_INTERNALS
  1243. #if PY_VERSION_HEX >= 0x030C00A7
  1244. #ifndef _PyLong_SIGN_MASK
  1245. #define _PyLong_SIGN_MASK 3
  1246. #endif
  1247. #ifndef _PyLong_NON_SIZE_BITS
  1248. #define _PyLong_NON_SIZE_BITS 3
  1249. #endif
  1250. #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK)
  1251. #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0)
  1252. #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x))
  1253. #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1)
  1254. #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0)
  1255. #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0])
  1256. #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS))
  1257. #define __Pyx_PyLong_SignedDigitCount(x)\
  1258. ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x))
  1259. #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue)
  1260. #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x)
  1261. #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x)
  1262. #else
  1263. #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS))
  1264. #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
  1265. #endif
  1266. typedef Py_ssize_t __Pyx_compact_pylong;
  1267. typedef size_t __Pyx_compact_upylong;
  1268. #else
  1269. #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0)
  1270. #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0)
  1271. #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0)
  1272. #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0)
  1273. #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
  1274. #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x))
  1275. #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x)
  1276. #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
  1277. #define __Pyx_PyLong_CompactValue(x)\
  1278. ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
  1279. typedef sdigit __Pyx_compact_pylong;
  1280. typedef digit __Pyx_compact_upylong;
  1281. #endif
  1282. #if PY_VERSION_HEX >= 0x030C00A5
  1283. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit)
  1284. #else
  1285. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit)
  1286. #endif
  1287. #endif
  1288. #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  1289. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  1290. #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  1291. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL)
  1292. #else
  1293. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  1294. #endif
  1295. /* Test for GCC > 2.95 */
  1296. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  1297. #define likely(x) __builtin_expect(!!(x), 1)
  1298. #define unlikely(x) __builtin_expect(!!(x), 0)
  1299. #else /* !__GNUC__ or GCC < 2.95 */
  1300. #define likely(x) (x)
  1301. #define unlikely(x) (x)
  1302. #endif /* __GNUC__ */
  1303. /* PretendToInitialize */
  1304. #ifdef __cplusplus
  1305. #if __cplusplus > 201103L
  1306. #include <type_traits>
  1307. #endif
  1308. template <typename T>
  1309. static void __Pyx_pretend_to_initialize(T* ptr) {
  1310. #if __cplusplus > 201103L
  1311. if ((std::is_trivially_default_constructible<T>::value))
  1312. #endif
  1313. *ptr = T();
  1314. (void)ptr;
  1315. }
  1316. #else
  1317. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  1318. #endif
  1319. #if !CYTHON_USE_MODULE_STATE
  1320. static PyObject *__pyx_m = NULL;
  1321. #endif
  1322. static int __pyx_lineno;
  1323. static int __pyx_clineno = 0;
  1324. static const char * const __pyx_cfilenm = __FILE__;
  1325. static const char *__pyx_filename;
  1326. /* Header.proto */
  1327. #if !defined(CYTHON_CCOMPLEX)
  1328. #if defined(__cplusplus)
  1329. #define CYTHON_CCOMPLEX 1
  1330. #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__) && !defined(_MSC_VER))
  1331. #define CYTHON_CCOMPLEX 1
  1332. #else
  1333. #define CYTHON_CCOMPLEX 0
  1334. #endif
  1335. #endif
  1336. #if CYTHON_CCOMPLEX
  1337. #ifdef __cplusplus
  1338. #include <complex>
  1339. #else
  1340. #include <complex.h>
  1341. #endif
  1342. #endif
  1343. #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  1344. #undef _Complex_I
  1345. #define _Complex_I 1.0fj
  1346. #endif
  1347. /* #### Code section: filename_table ### */
  1348. static const char* const __pyx_f[] = {
  1349. "Lib/fontTools/qu2cu/qu2cu.py",
  1350. };
  1351. /* #### Code section: utility_code_proto_before_types ### */
  1352. /* Atomics.proto (used by UnpackUnboundCMethod) */
  1353. #include <pythread.h>
  1354. #ifndef CYTHON_ATOMICS
  1355. #define CYTHON_ATOMICS 1
  1356. #endif
  1357. #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS
  1358. #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1359. #define __pyx_atomic_int_type int
  1360. #define __pyx_nonatomic_int_type int
  1361. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1362. (__STDC_VERSION__ >= 201112L) &&\
  1363. !defined(__STDC_NO_ATOMICS__))
  1364. #include <stdatomic.h>
  1365. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1366. (__cplusplus >= 201103L) ||\
  1367. (defined(_MSC_VER) && _MSC_VER >= 1700)))
  1368. #include <atomic>
  1369. #endif
  1370. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1371. (__STDC_VERSION__ >= 201112L) &&\
  1372. !defined(__STDC_NO_ATOMICS__) &&\
  1373. ATOMIC_INT_LOCK_FREE == 2)
  1374. #undef __pyx_atomic_int_type
  1375. #define __pyx_atomic_int_type atomic_int
  1376. #define __pyx_atomic_ptr_type atomic_uintptr_t
  1377. #define __pyx_nonatomic_ptr_type uintptr_t
  1378. #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed)
  1379. #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel)
  1380. #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel)
  1381. #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg)
  1382. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1383. #define __pyx_atomic_load(value) atomic_load(value)
  1384. #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value)
  1385. #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed)
  1386. #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire)
  1387. #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1388. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1389. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1390. #pragma message ("Using standard C atomics")
  1391. #elif defined(__PYX_DEBUG_ATOMICS)
  1392. #warning "Using standard C atomics"
  1393. #endif
  1394. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1395. (__cplusplus >= 201103L) ||\
  1396. \
  1397. (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\
  1398. ATOMIC_INT_LOCK_FREE == 2)
  1399. #undef __pyx_atomic_int_type
  1400. #define __pyx_atomic_int_type std::atomic_int
  1401. #define __pyx_atomic_ptr_type std::atomic_uintptr_t
  1402. #define __pyx_nonatomic_ptr_type uintptr_t
  1403. #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed)
  1404. #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel)
  1405. #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel)
  1406. #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg)
  1407. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1408. #define __pyx_atomic_load(value) std::atomic_load(value)
  1409. #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value)
  1410. #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed)
  1411. #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire)
  1412. #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1413. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1414. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1415. #pragma message ("Using standard C++ atomics")
  1416. #elif defined(__PYX_DEBUG_ATOMICS)
  1417. #warning "Using standard C++ atomics"
  1418. #endif
  1419. #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\
  1420. (__GNUC_MINOR__ > 1 ||\
  1421. (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2))))
  1422. #define __pyx_atomic_ptr_type void*
  1423. #define __pyx_nonatomic_ptr_type void*
  1424. #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1)
  1425. #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1)
  1426. #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1)
  1427. #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg)
  1428. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1429. __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1430. int result = old == *expected;
  1431. *expected = old;
  1432. return result;
  1433. }
  1434. #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0)
  1435. #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value)
  1436. #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0)
  1437. #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0)
  1438. #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value)
  1439. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1440. __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1441. int result = old == *expected;
  1442. *expected = old;
  1443. return result;
  1444. }
  1445. #ifdef __PYX_DEBUG_ATOMICS
  1446. #warning "Using GNU atomics"
  1447. #endif
  1448. #elif CYTHON_ATOMICS && defined(_MSC_VER)
  1449. #include <intrin.h>
  1450. #undef __pyx_atomic_int_type
  1451. #define __pyx_atomic_int_type long
  1452. #define __pyx_atomic_ptr_type void*
  1453. #undef __pyx_nonatomic_int_type
  1454. #define __pyx_nonatomic_int_type long
  1455. #define __pyx_nonatomic_ptr_type void*
  1456. #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer)
  1457. #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1)
  1458. #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1)
  1459. #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1)
  1460. #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg)
  1461. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1462. __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected);
  1463. int result = old == *expected;
  1464. *expected = old;
  1465. return result;
  1466. }
  1467. #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0)
  1468. #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value)
  1469. #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value
  1470. #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0)
  1471. #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value)
  1472. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1473. __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected);
  1474. int result = old == *expected;
  1475. *expected = old;
  1476. return result;
  1477. }
  1478. #ifdef __PYX_DEBUG_ATOMICS
  1479. #pragma message ("Using MSVC atomics")
  1480. #endif
  1481. #else
  1482. #undef CYTHON_ATOMICS
  1483. #define CYTHON_ATOMICS 0
  1484. #ifdef __PYX_DEBUG_ATOMICS
  1485. #warning "Not using atomics"
  1486. #endif
  1487. #endif
  1488. /* CriticalSectionsDefinition.proto (used by CriticalSections) */
  1489. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1490. #define __Pyx_PyCriticalSection void*
  1491. #define __Pyx_PyCriticalSection2 void*
  1492. #define __Pyx_PyCriticalSection_End(cs)
  1493. #define __Pyx_PyCriticalSection2_End(cs)
  1494. #else
  1495. #define __Pyx_PyCriticalSection PyCriticalSection
  1496. #define __Pyx_PyCriticalSection2 PyCriticalSection2
  1497. #define __Pyx_PyCriticalSection_End PyCriticalSection_End
  1498. #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End
  1499. #endif
  1500. /* CriticalSections.proto (used by ParseKeywordsImpl) */
  1501. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1502. #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs)
  1503. #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs)
  1504. #else
  1505. #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin
  1506. #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin
  1507. #endif
  1508. #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1509. #define __Pyx_BEGIN_CRITICAL_SECTION(o) {
  1510. #define __Pyx_END_CRITICAL_SECTION() }
  1511. #else
  1512. #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION
  1513. #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION
  1514. #endif
  1515. /* IncludeStructmemberH.proto (used by FixUpExtensionType) */
  1516. #include <structmember.h>
  1517. /* #### Code section: numeric_typedefs ### */
  1518. /* #### Code section: complex_type_declarations ### */
  1519. /* Declarations.proto */
  1520. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  1521. #ifdef __cplusplus
  1522. typedef ::std::complex< double > __pyx_t_double_complex;
  1523. #else
  1524. typedef double _Complex __pyx_t_double_complex;
  1525. #endif
  1526. #else
  1527. typedef struct { double real, imag; } __pyx_t_double_complex;
  1528. #endif
  1529. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
  1530. /* #### Code section: type_declarations ### */
  1531. /*--- Type declarations ---*/
  1532. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  1533. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  1534. /* "fontTools/qu2cu/qu2cu.py":235
  1535. *
  1536. * if not is_complex:
  1537. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves] # <<<<<<<<<<<<<<
  1538. * return curves
  1539. *
  1540. */
  1541. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr {
  1542. PyObject_HEAD
  1543. PyObject *__pyx_genexpr_arg_0;
  1544. PyObject *__pyx_v_c;
  1545. int __pyx_v_cost;
  1546. int __pyx_v_is_complex;
  1547. PyObject *__pyx_t_0;
  1548. Py_ssize_t __pyx_t_1;
  1549. PyObject *(*__pyx_t_2)(PyObject *);
  1550. };
  1551. /* "fontTools/qu2cu/qu2cu.py":340
  1552. * for k, reconst in enumerate(reconstructed):
  1553. * orig = elevated_quadratics[j + k]
  1554. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig)) # <<<<<<<<<<<<<<
  1555. *
  1556. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  1557. */
  1558. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr {
  1559. PyObject_HEAD
  1560. PyObject *__pyx_genexpr_arg_0;
  1561. int __pyx_v_all_cubic;
  1562. int __pyx_v_count;
  1563. double __pyx_v_err;
  1564. double __pyx_v_error;
  1565. int __pyx_v_i;
  1566. int __pyx_v_i_sol_count;
  1567. double __pyx_v_i_sol_error;
  1568. int __pyx_v_is_cubic;
  1569. int __pyx_v_j;
  1570. int __pyx_v_j_sol_count;
  1571. double __pyx_v_j_sol_error;
  1572. int __pyx_v_k;
  1573. __pyx_t_double_complex __pyx_v_p0;
  1574. __pyx_t_double_complex __pyx_v_p1;
  1575. __pyx_t_double_complex __pyx_v_p2;
  1576. __pyx_t_double_complex __pyx_v_p3;
  1577. int __pyx_v_start;
  1578. int __pyx_v_this_sol_count;
  1579. double __pyx_v_tolerance;
  1580. __pyx_t_double_complex __pyx_v_u;
  1581. __pyx_t_double_complex __pyx_v_v;
  1582. PyObject *__pyx_t_0;
  1583. Py_ssize_t __pyx_t_1;
  1584. PyObject *(*__pyx_t_2)(PyObject *);
  1585. };
  1586. /* #### Code section: utility_code_proto ### */
  1587. /* --- Runtime support code (head) --- */
  1588. /* Refnanny.proto */
  1589. #ifndef CYTHON_REFNANNY
  1590. #define CYTHON_REFNANNY 0
  1591. #endif
  1592. #if CYTHON_REFNANNY
  1593. typedef struct {
  1594. void (*INCREF)(void*, PyObject*, Py_ssize_t);
  1595. void (*DECREF)(void*, PyObject*, Py_ssize_t);
  1596. void (*GOTREF)(void*, PyObject*, Py_ssize_t);
  1597. void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
  1598. void* (*SetupContext)(const char*, Py_ssize_t, const char*);
  1599. void (*FinishContext)(void**);
  1600. } __Pyx_RefNannyAPIStruct;
  1601. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1602. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1603. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1604. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1605. if (acquire_gil) {\
  1606. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1607. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1608. PyGILState_Release(__pyx_gilstate_save);\
  1609. } else {\
  1610. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1611. }
  1612. #define __Pyx_RefNannyFinishContextNogil() {\
  1613. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1614. __Pyx_RefNannyFinishContext();\
  1615. PyGILState_Release(__pyx_gilstate_save);\
  1616. }
  1617. #define __Pyx_RefNannyFinishContextNogil() {\
  1618. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1619. __Pyx_RefNannyFinishContext();\
  1620. PyGILState_Release(__pyx_gilstate_save);\
  1621. }
  1622. #define __Pyx_RefNannyFinishContext()\
  1623. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1624. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1625. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1626. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1627. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1628. #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
  1629. #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
  1630. #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
  1631. #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
  1632. #else
  1633. #define __Pyx_RefNannyDeclarations
  1634. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1635. #define __Pyx_RefNannyFinishContextNogil()
  1636. #define __Pyx_RefNannyFinishContext()
  1637. #define __Pyx_INCREF(r) Py_INCREF(r)
  1638. #define __Pyx_DECREF(r) Py_DECREF(r)
  1639. #define __Pyx_GOTREF(r)
  1640. #define __Pyx_GIVEREF(r)
  1641. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1642. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1643. #define __Pyx_XGOTREF(r)
  1644. #define __Pyx_XGIVEREF(r)
  1645. #endif
  1646. #define __Pyx_Py_XDECREF_SET(r, v) do {\
  1647. PyObject *tmp = (PyObject *) r;\
  1648. r = v; Py_XDECREF(tmp);\
  1649. } while (0)
  1650. #define __Pyx_XDECREF_SET(r, v) do {\
  1651. PyObject *tmp = (PyObject *) r;\
  1652. r = v; __Pyx_XDECREF(tmp);\
  1653. } while (0)
  1654. #define __Pyx_DECREF_SET(r, v) do {\
  1655. PyObject *tmp = (PyObject *) r;\
  1656. r = v; __Pyx_DECREF(tmp);\
  1657. } while (0)
  1658. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1659. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1660. /* PyErrExceptionMatches.proto (used by PyObjectGetAttrStrNoError) */
  1661. #if CYTHON_FAST_THREAD_STATE
  1662. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1663. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1664. #else
  1665. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1666. #endif
  1667. /* PyThreadStateGet.proto (used by PyErrFetchRestore) */
  1668. #if CYTHON_FAST_THREAD_STATE
  1669. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1670. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1671. #if PY_VERSION_HEX >= 0x030C00A6
  1672. #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL)
  1673. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL)
  1674. #else
  1675. #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL)
  1676. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type)
  1677. #endif
  1678. #else
  1679. #define __Pyx_PyThreadState_declare
  1680. #define __Pyx_PyThreadState_assign
  1681. #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
  1682. #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
  1683. #endif
  1684. /* PyErrFetchRestore.proto (used by PyObjectGetAttrStrNoError) */
  1685. #if CYTHON_FAST_THREAD_STATE
  1686. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1687. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1688. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1689. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1690. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1691. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1692. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1693. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
  1694. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1695. #else
  1696. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1697. #endif
  1698. #else
  1699. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1700. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1701. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1702. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1703. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1704. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1705. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1706. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1707. #endif
  1708. /* PyObjectGetAttrStr.proto (used by PyObjectGetAttrStrNoError) */
  1709. #if CYTHON_USE_TYPE_SLOTS
  1710. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1711. #else
  1712. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1713. #endif
  1714. /* PyObjectGetAttrStrNoError.proto (used by GetBuiltinName) */
  1715. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
  1716. /* GetBuiltinName.proto */
  1717. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1718. /* TupleAndListFromArray.proto (used by fastcall) */
  1719. #if CYTHON_COMPILING_IN_CPYTHON
  1720. static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
  1721. #endif
  1722. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL
  1723. static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
  1724. #endif
  1725. /* IncludeStringH.proto (used by BytesEquals) */
  1726. #include <string.h>
  1727. /* BytesEquals.proto (used by UnicodeEquals) */
  1728. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
  1729. /* UnicodeEquals.proto (used by fastcall) */
  1730. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
  1731. /* fastcall.proto */
  1732. #if CYTHON_AVOID_BORROWED_REFS
  1733. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i)
  1734. #elif CYTHON_ASSUME_SAFE_MACROS
  1735. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i))
  1736. #else
  1737. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i))
  1738. #endif
  1739. #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
  1740. #define __Pyx_KwValues_VARARGS(args, nargs) NULL
  1741. #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
  1742. #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
  1743. #if CYTHON_METH_FASTCALL
  1744. #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i])
  1745. #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds)
  1746. #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
  1747. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
  1748. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1749. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);
  1750. #else
  1751. #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
  1752. #endif
  1753. #else
  1754. #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS
  1755. #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
  1756. #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
  1757. #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
  1758. #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
  1759. #endif
  1760. #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1761. #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  1762. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start)
  1763. #else
  1764. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1765. #endif
  1766. /* py_dict_items.proto (used by OwnedDictNext) */
  1767. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
  1768. /* CallCFunction.proto (used by CallUnboundCMethod0) */
  1769. #define __Pyx_CallCFunction(cfunc, self, args)\
  1770. ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args)
  1771. #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\
  1772. ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs)
  1773. #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\
  1774. ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs)
  1775. #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\
  1776. ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames)
  1777. /* PyObjectCall.proto (used by PyObjectFastCall) */
  1778. #if CYTHON_COMPILING_IN_CPYTHON
  1779. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1780. #else
  1781. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1782. #endif
  1783. /* PyObjectCallMethO.proto (used by PyObjectFastCall) */
  1784. #if CYTHON_COMPILING_IN_CPYTHON
  1785. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1786. #endif
  1787. /* PyObjectFastCall.proto (used by PyObjectCallOneArg) */
  1788. #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
  1789. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs);
  1790. /* PyObjectCallOneArg.proto (used by CallUnboundCMethod0) */
  1791. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1792. /* UnpackUnboundCMethod.proto (used by CallUnboundCMethod0) */
  1793. typedef struct {
  1794. PyObject *type;
  1795. PyObject **method_name;
  1796. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
  1797. __pyx_atomic_int_type initialized;
  1798. #endif
  1799. PyCFunction func;
  1800. PyObject *method;
  1801. int flag;
  1802. } __Pyx_CachedCFunction;
  1803. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1804. static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) {
  1805. #if !CYTHON_ATOMICS
  1806. return 1;
  1807. #else
  1808. __pyx_nonatomic_int_type expected = 0;
  1809. if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) {
  1810. return 0;
  1811. }
  1812. return expected;
  1813. #endif
  1814. }
  1815. static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) {
  1816. #if CYTHON_ATOMICS
  1817. __pyx_atomic_store(&cfunc->initialized, 2);
  1818. #endif
  1819. }
  1820. #else
  1821. #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2
  1822. #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc)
  1823. #endif
  1824. /* CallUnboundCMethod0.proto */
  1825. CYTHON_UNUSED
  1826. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1827. #if CYTHON_COMPILING_IN_CPYTHON
  1828. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1829. #else
  1830. #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
  1831. #endif
  1832. /* py_dict_values.proto (used by OwnedDictNext) */
  1833. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d);
  1834. /* OwnedDictNext.proto (used by ParseKeywordsImpl) */
  1835. #if CYTHON_AVOID_BORROWED_REFS
  1836. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue);
  1837. #else
  1838. CYTHON_INLINE
  1839. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue);
  1840. #endif
  1841. /* RaiseDoubleKeywords.proto (used by ParseKeywordsImpl) */
  1842. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1843. /* ParseKeywordsImpl.export */
  1844. static int __Pyx_ParseKeywordsTuple(
  1845. PyObject *kwds,
  1846. PyObject * const *kwvalues,
  1847. PyObject ** const argnames[],
  1848. PyObject *kwds2,
  1849. PyObject *values[],
  1850. Py_ssize_t num_pos_args,
  1851. Py_ssize_t num_kwargs,
  1852. const char* function_name,
  1853. int ignore_unknown_kwargs
  1854. );
  1855. static int __Pyx_ParseKeywordDictToDict(
  1856. PyObject *kwds,
  1857. PyObject ** const argnames[],
  1858. PyObject *kwds2,
  1859. PyObject *values[],
  1860. Py_ssize_t num_pos_args,
  1861. const char* function_name
  1862. );
  1863. static int __Pyx_ParseKeywordDict(
  1864. PyObject *kwds,
  1865. PyObject ** const argnames[],
  1866. PyObject *values[],
  1867. Py_ssize_t num_pos_args,
  1868. Py_ssize_t num_kwargs,
  1869. const char* function_name,
  1870. int ignore_unknown_kwargs
  1871. );
  1872. /* CallUnboundCMethod2.proto */
  1873. CYTHON_UNUSED
  1874. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
  1875. #if CYTHON_COMPILING_IN_CPYTHON
  1876. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
  1877. #else
  1878. #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
  1879. #endif
  1880. /* ParseKeywords.proto */
  1881. static CYTHON_INLINE int __Pyx_ParseKeywords(
  1882. PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[],
  1883. PyObject *kwds2, PyObject *values[],
  1884. Py_ssize_t num_pos_args, Py_ssize_t num_kwargs,
  1885. const char* function_name,
  1886. int ignore_unknown_kwargs
  1887. );
  1888. /* RaiseArgTupleInvalid.proto */
  1889. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1890. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1891. /* GetItemInt.proto */
  1892. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1893. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1894. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\
  1895. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
  1896. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  1897. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1898. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1899. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1900. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  1901. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  1902. int wraparound, int boundscheck, int unsafe_shared);
  1903. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1904. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1905. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1906. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  1907. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  1908. int wraparound, int boundscheck, int unsafe_shared);
  1909. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  1910. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  1911. int is_list, int wraparound, int boundscheck, int unsafe_shared);
  1912. /* AssertionsEnabled.proto */
  1913. #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000
  1914. static int __pyx_assertions_enabled_flag;
  1915. #define __pyx_assertions_enabled() (__pyx_assertions_enabled_flag)
  1916. #if __clang__ || __GNUC__
  1917. __attribute__((no_sanitize("thread")))
  1918. #endif
  1919. static int __Pyx_init_assertions_enabled(void) {
  1920. PyObject *builtins, *debug, *debug_str;
  1921. int flag;
  1922. builtins = PyEval_GetBuiltins();
  1923. if (!builtins) goto bad;
  1924. debug_str = PyUnicode_FromStringAndSize("__debug__", 9);
  1925. if (!debug_str) goto bad;
  1926. debug = PyObject_GetItem(builtins, debug_str);
  1927. Py_DECREF(debug_str);
  1928. if (!debug) goto bad;
  1929. flag = PyObject_IsTrue(debug);
  1930. Py_DECREF(debug);
  1931. if (flag == -1) goto bad;
  1932. __pyx_assertions_enabled_flag = flag;
  1933. return 0;
  1934. bad:
  1935. __pyx_assertions_enabled_flag = 1;
  1936. return -1;
  1937. }
  1938. #else
  1939. #define __Pyx_init_assertions_enabled() (0)
  1940. #define __pyx_assertions_enabled() (!Py_OptimizeFlag)
  1941. #endif
  1942. /* PyAssertionError_Check.proto */
  1943. #define __Pyx_PyExc_AssertionError_Check(obj) __Pyx_TypeCheck(obj, PyExc_AssertionError)
  1944. /* RaiseException.export */
  1945. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1946. /* py_abs.proto */
  1947. #if CYTHON_USE_PYLONG_INTERNALS
  1948. static PyObject *__Pyx_PyLong_AbsNeg(PyObject *num);
  1949. #define __Pyx_PyNumber_Absolute(x)\
  1950. ((likely(PyLong_CheckExact(x))) ?\
  1951. (likely(__Pyx_PyLong_IsNonNeg(x)) ? __Pyx_NewRef(x) : __Pyx_PyLong_AbsNeg(x)) :\
  1952. PyNumber_Absolute(x))
  1953. #else
  1954. #define __Pyx_PyNumber_Absolute(x) PyNumber_Absolute(x)
  1955. #endif
  1956. /* ListAppend.proto */
  1957. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1958. static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
  1959. PyListObject* L = (PyListObject*) list;
  1960. Py_ssize_t len = Py_SIZE(list);
  1961. if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
  1962. Py_INCREF(x);
  1963. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  1964. L->ob_item[len] = x;
  1965. #else
  1966. PyList_SET_ITEM(list, len, x);
  1967. #endif
  1968. __Pyx_SET_SIZE(list, len + 1);
  1969. return 0;
  1970. }
  1971. return PyList_Append(list, x);
  1972. }
  1973. #else
  1974. #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
  1975. #endif
  1976. /* SliceTupleAndList.proto */
  1977. #if CYTHON_COMPILING_IN_CPYTHON
  1978. static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
  1979. static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
  1980. #else
  1981. #define __Pyx_PyList_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
  1982. #define __Pyx_PyTuple_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
  1983. #endif
  1984. /* ListCompAppend.proto */
  1985. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1986. static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
  1987. PyListObject* L = (PyListObject*) list;
  1988. Py_ssize_t len = Py_SIZE(list);
  1989. if (likely(L->allocated > len)) {
  1990. Py_INCREF(x);
  1991. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  1992. L->ob_item[len] = x;
  1993. #else
  1994. PyList_SET_ITEM(list, len, x);
  1995. #endif
  1996. __Pyx_SET_SIZE(list, len + 1);
  1997. return 0;
  1998. }
  1999. return PyList_Append(list, x);
  2000. }
  2001. #else
  2002. #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
  2003. #endif
  2004. /* PyLongBinop.proto */
  2005. #if !CYTHON_COMPILING_IN_PYPY
  2006. static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
  2007. #else
  2008. #define __Pyx_PyLong_SubtractCObj(op1, op2, intval, inplace, zerodivision_check)\
  2009. (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
  2010. #endif
  2011. /* ArgTypeTestFunc.export */
  2012. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
  2013. /* ArgTypeTest.proto */
  2014. #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
  2015. ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\
  2016. __Pyx__ArgTypeTest(obj, type, name, exact))
  2017. /* RaiseUnboundLocalError.proto */
  2018. static void __Pyx_RaiseUnboundLocalError(const char *varname);
  2019. /* GetException.proto (used by pep479) */
  2020. #if CYTHON_FAST_THREAD_STATE
  2021. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  2022. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2023. #else
  2024. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  2025. #endif
  2026. /* pep479.proto */
  2027. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen);
  2028. /* RaiseTooManyValuesToUnpack.proto */
  2029. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  2030. /* RaiseNeedMoreValuesToUnpack.proto */
  2031. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  2032. /* IterFinish.proto */
  2033. static CYTHON_INLINE int __Pyx_IterFinish(void);
  2034. /* UnpackItemEndCheck.proto */
  2035. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
  2036. /* PyDictVersioning.proto (used by GetModuleGlobalName) */
  2037. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  2038. #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
  2039. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  2040. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  2041. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  2042. (cache_var) = (value);
  2043. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  2044. static PY_UINT64_T __pyx_dict_version = 0;\
  2045. static PyObject *__pyx_dict_cached_value = NULL;\
  2046. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  2047. (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\
  2048. } else {\
  2049. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  2050. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  2051. }\
  2052. }
  2053. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
  2054. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
  2055. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
  2056. #else
  2057. #define __PYX_GET_DICT_VERSION(dict) (0)
  2058. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  2059. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  2060. #endif
  2061. /* GetModuleGlobalName.proto */
  2062. #if CYTHON_USE_DICT_VERSIONS
  2063. #define __Pyx_GetModuleGlobalName(var, name) do {\
  2064. static PY_UINT64_T __pyx_dict_version = 0;\
  2065. static PyObject *__pyx_dict_cached_value = NULL;\
  2066. (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\
  2067. (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
  2068. __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  2069. } while(0)
  2070. #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\
  2071. PY_UINT64_T __pyx_dict_version;\
  2072. PyObject *__pyx_dict_cached_value;\
  2073. (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  2074. } while(0)
  2075. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
  2076. #else
  2077. #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  2078. #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  2079. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
  2080. #endif
  2081. /* SliceObject.proto */
  2082. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
  2083. PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
  2084. PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
  2085. int has_cstart, int has_cstop, int wraparound);
  2086. /* PyObjectCallNoArg.proto (used by PyObjectCallMethod0) */
  2087. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  2088. /* PyObjectGetMethod.proto (used by PyObjectCallMethod0) */
  2089. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  2090. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
  2091. #endif
  2092. /* PyObjectCallMethod0.proto (used by pop) */
  2093. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
  2094. /* pop.proto */
  2095. static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
  2096. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  2097. static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
  2098. #define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
  2099. __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
  2100. #else
  2101. #define __Pyx_PyList_Pop(L) __Pyx__PyObject_Pop(L)
  2102. #define __Pyx_PyObject_Pop(L) __Pyx__PyObject_Pop(L)
  2103. #endif
  2104. /* ListExtend.proto */
  2105. static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
  2106. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00a2
  2107. return PyList_Extend(L, v);
  2108. #elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
  2109. PyObject* none = _PyList_Extend((PyListObject*)L, v);
  2110. if (unlikely(!none))
  2111. return -1;
  2112. Py_DECREF(none);
  2113. return 0;
  2114. #else
  2115. return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
  2116. #endif
  2117. }
  2118. /* RaiseUnexpectedTypeError.proto */
  2119. static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj);
  2120. /* PyLongBinop.proto */
  2121. #if !CYTHON_COMPILING_IN_PYPY
  2122. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
  2123. #else
  2124. #define __Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
  2125. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  2126. #endif
  2127. /* GetTopmostException.proto (used by SaveResetException) */
  2128. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  2129. static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
  2130. #endif
  2131. /* SaveResetException.proto */
  2132. #if CYTHON_FAST_THREAD_STATE
  2133. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  2134. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2135. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  2136. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  2137. #else
  2138. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  2139. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  2140. #endif
  2141. /* PyZeroDivisionError_Check.proto */
  2142. #define __Pyx_PyExc_ZeroDivisionError_Check(obj) __Pyx_TypeCheck(obj, PyExc_ZeroDivisionError)
  2143. /* pyfrozenset_new.proto (used by PySetContains) */
  2144. static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);
  2145. /* PySetContains.proto */
  2146. static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);
  2147. /* HasAttr.proto (used by ImportImpl) */
  2148. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2149. #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n)
  2150. #else
  2151. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
  2152. #endif
  2153. /* ImportImpl.export */
  2154. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level);
  2155. /* Import.proto */
  2156. static CYTHON_INLINE PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level);
  2157. /* ImportFrom.proto */
  2158. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  2159. /* CheckTypeForFreelists.proto */
  2160. #if CYTHON_USE_FREELISTS
  2161. #if CYTHON_USE_TYPE_SPECS
  2162. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t) == (expected_tp)))
  2163. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS Py_TPFLAGS_IS_ABSTRACT
  2164. #else
  2165. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t)->tp_basicsize == (expected_size)))
  2166. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)
  2167. #endif
  2168. #define __PYX_CHECK_TYPE_FOR_FREELISTS(t, expected_tp, expected_size)\
  2169. (__PYX_CHECK_FINAL_TYPE_FOR_FREELISTS((t), (expected_tp), (expected_size)) &\
  2170. (int) (!__Pyx_PyType_HasFeature((t), __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS)))
  2171. #endif
  2172. /* AllocateExtensionType.proto */
  2173. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final);
  2174. /* CallTypeTraverse.proto */
  2175. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  2176. #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0
  2177. #else
  2178. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg);
  2179. #endif
  2180. /* LimitedApiGetTypeDict.proto (used by SetItemOnTypeDict) */
  2181. #if CYTHON_COMPILING_IN_LIMITED_API
  2182. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp);
  2183. #endif
  2184. /* SetItemOnTypeDict.proto (used by FixUpExtensionType) */
  2185. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v);
  2186. #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v)
  2187. /* FixUpExtensionType.proto */
  2188. static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type);
  2189. /* ValidateBasesTuple.proto (used by PyType_Ready) */
  2190. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  2191. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases);
  2192. #endif
  2193. /* PyType_Ready.proto */
  2194. CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t);
  2195. /* ListPack.proto */
  2196. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...);
  2197. /* dict_setdefault.proto (used by FetchCommonType) */
  2198. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value);
  2199. /* AddModuleRef.proto (used by FetchSharedCythonModule) */
  2200. #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\
  2201. __PYX_LIMITED_VERSION_HEX < 0x030d0000)
  2202. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name);
  2203. #else
  2204. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  2205. #endif
  2206. /* FetchSharedCythonModule.proto (used by FetchCommonType) */
  2207. static PyObject *__Pyx_FetchSharedCythonABIModule(void);
  2208. /* FetchCommonType.proto (used by CommonTypesMetaclass) */
  2209. static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases);
  2210. /* CommonTypesMetaclass.proto (used by CythonFunctionShared) */
  2211. static int __pyx_CommonTypesMetaclass_init(PyObject *module);
  2212. #define __Pyx_CommonTypesMetaclass_USED
  2213. /* PyMethodNew.proto (used by CythonFunctionShared) */
  2214. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ);
  2215. /* PyVectorcallFastCallDict.proto (used by CythonFunctionShared) */
  2216. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  2217. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
  2218. #endif
  2219. /* CythonFunctionShared.proto (used by CythonFunction) */
  2220. #define __Pyx_CyFunction_USED
  2221. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  2222. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  2223. #define __Pyx_CYFUNCTION_CCLASS 0x04
  2224. #define __Pyx_CYFUNCTION_COROUTINE 0x08
  2225. #define __Pyx_CyFunction_GetClosure(f)\
  2226. (((__pyx_CyFunctionObject *) (f))->func_closure)
  2227. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2228. #define __Pyx_CyFunction_GetClassObj(f)\
  2229. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  2230. #else
  2231. #define __Pyx_CyFunction_GetClassObj(f)\
  2232. ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
  2233. #endif
  2234. #define __Pyx_CyFunction_SetClassObj(f, classobj)\
  2235. __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
  2236. #define __Pyx_CyFunction_Defaults(type, f)\
  2237. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  2238. #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
  2239. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  2240. typedef struct {
  2241. #if CYTHON_COMPILING_IN_LIMITED_API
  2242. PyObject_HEAD
  2243. PyObject *func;
  2244. #elif PY_VERSION_HEX < 0x030900B1
  2245. PyCFunctionObject func;
  2246. #else
  2247. PyCMethodObject func;
  2248. #endif
  2249. #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL
  2250. __pyx_vectorcallfunc func_vectorcall;
  2251. #endif
  2252. #if CYTHON_COMPILING_IN_LIMITED_API
  2253. PyObject *func_weakreflist;
  2254. #endif
  2255. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2256. PyObject *func_dict;
  2257. #endif
  2258. PyObject *func_name;
  2259. PyObject *func_qualname;
  2260. PyObject *func_doc;
  2261. PyObject *func_globals;
  2262. PyObject *func_code;
  2263. PyObject *func_closure;
  2264. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2265. PyObject *func_classobj;
  2266. #endif
  2267. PyObject *defaults;
  2268. int flags;
  2269. PyObject *defaults_tuple;
  2270. PyObject *defaults_kwdict;
  2271. PyObject *(*defaults_getter)(PyObject *);
  2272. PyObject *func_annotations;
  2273. PyObject *func_is_coroutine;
  2274. } __pyx_CyFunctionObject;
  2275. #undef __Pyx_CyOrPyCFunction_Check
  2276. #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2277. #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type)
  2278. #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2279. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));
  2280. #undef __Pyx_IsSameCFunction
  2281. #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
  2282. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
  2283. int flags, PyObject* qualname,
  2284. PyObject *closure,
  2285. PyObject *module, PyObject *globals,
  2286. PyObject* code);
  2287. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
  2288. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
  2289. PyTypeObject *defaults_type);
  2290. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  2291. PyObject *tuple);
  2292. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  2293. PyObject *dict);
  2294. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  2295. PyObject *dict);
  2296. static int __pyx_CyFunction_init(PyObject *module);
  2297. #if CYTHON_METH_FASTCALL
  2298. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2299. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2300. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2301. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2302. #if CYTHON_COMPILING_IN_LIMITED_API
  2303. #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
  2304. #else
  2305. #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
  2306. #endif
  2307. #endif
  2308. /* CythonFunction.proto */
  2309. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
  2310. int flags, PyObject* qualname,
  2311. PyObject *closure,
  2312. PyObject *module, PyObject *globals,
  2313. PyObject* code);
  2314. /* ObjectGetItem.proto */
  2315. #if CYTHON_USE_TYPE_SLOTS
  2316. static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key);
  2317. #else
  2318. #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
  2319. #endif
  2320. /* CLineInTraceback.proto (used by AddTraceback) */
  2321. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  2322. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  2323. #else
  2324. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  2325. #endif
  2326. /* CodeObjectCache.proto (used by AddTraceback) */
  2327. #if CYTHON_COMPILING_IN_LIMITED_API
  2328. typedef PyObject __Pyx_CachedCodeObjectType;
  2329. #else
  2330. typedef PyCodeObject __Pyx_CachedCodeObjectType;
  2331. #endif
  2332. typedef struct {
  2333. __Pyx_CachedCodeObjectType* code_object;
  2334. int code_line;
  2335. } __Pyx_CodeObjectCacheEntry;
  2336. struct __Pyx_CodeObjectCache {
  2337. int count;
  2338. int max_count;
  2339. __Pyx_CodeObjectCacheEntry* entries;
  2340. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  2341. __pyx_atomic_int_type accessor_count;
  2342. #endif
  2343. };
  2344. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  2345. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line);
  2346. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object);
  2347. /* AddTraceback.proto */
  2348. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  2349. int py_line, const char *filename);
  2350. /* RealImag.proto */
  2351. #if CYTHON_CCOMPLEX
  2352. #ifdef __cplusplus
  2353. #define __Pyx_CREAL(z) ((z).real())
  2354. #define __Pyx_CIMAG(z) ((z).imag())
  2355. #else
  2356. #define __Pyx_CREAL(z) (__real__(z))
  2357. #define __Pyx_CIMAG(z) (__imag__(z))
  2358. #endif
  2359. #else
  2360. #define __Pyx_CREAL(z) ((z).real)
  2361. #define __Pyx_CIMAG(z) ((z).imag)
  2362. #endif
  2363. #if defined(__cplusplus) && CYTHON_CCOMPLEX\
  2364. && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
  2365. #define __Pyx_SET_CREAL(z,x) ((z).real(x))
  2366. #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
  2367. #else
  2368. #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
  2369. #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
  2370. #endif
  2371. /* Arithmetic.proto */
  2372. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  2373. #define __Pyx_c_eq_double(a, b) ((a)==(b))
  2374. #define __Pyx_c_sum_double(a, b) ((a)+(b))
  2375. #define __Pyx_c_diff_double(a, b) ((a)-(b))
  2376. #define __Pyx_c_prod_double(a, b) ((a)*(b))
  2377. #define __Pyx_c_quot_double(a, b) ((a)/(b))
  2378. #define __Pyx_c_neg_double(a) (-(a))
  2379. #ifdef __cplusplus
  2380. #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
  2381. #define __Pyx_c_conj_double(z) (::std::conj(z))
  2382. #if 1
  2383. #define __Pyx_c_abs_double(z) (::std::abs(z))
  2384. #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
  2385. #endif
  2386. #else
  2387. #define __Pyx_c_is_zero_double(z) ((z)==0)
  2388. #define __Pyx_c_conj_double(z) (conj(z))
  2389. #if 1
  2390. #define __Pyx_c_abs_double(z) (cabs(z))
  2391. #define __Pyx_c_pow_double(a, b) (cpow(a, b))
  2392. #endif
  2393. #endif
  2394. #else
  2395. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2396. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2397. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2398. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2399. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2400. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
  2401. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
  2402. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
  2403. #if 1
  2404. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
  2405. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2406. #endif
  2407. #endif
  2408. /* FromPy.proto */
  2409. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
  2410. /* GCCDiagnostics.proto */
  2411. #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  2412. #define __Pyx_HAS_GCC_DIAGNOSTIC
  2413. #endif
  2414. /* ToPy.proto */
  2415. #define __pyx_PyComplex_FromComplex(z)\
  2416. PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
  2417. (double)__Pyx_CIMAG(z))
  2418. /* CIntFromPy.proto */
  2419. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *);
  2420. /* PyObjectVectorCallKwBuilder.proto (used by CIntToPy) */
  2421. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2422. #if CYTHON_VECTORCALL
  2423. #if PY_VERSION_HEX >= 0x03090000
  2424. #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall
  2425. #else
  2426. #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall
  2427. #endif
  2428. #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n)
  2429. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2430. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2431. #else
  2432. #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict
  2433. #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n)
  2434. #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value)
  2435. #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value)
  2436. #endif
  2437. /* CIntToPy.proto */
  2438. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value);
  2439. /* CIntToPy.proto */
  2440. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value);
  2441. /* FormatTypeName.proto */
  2442. #if CYTHON_COMPILING_IN_LIMITED_API
  2443. typedef PyObject *__Pyx_TypeName;
  2444. #define __Pyx_FMT_TYPENAME "%U"
  2445. #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
  2446. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2447. #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName
  2448. #else
  2449. static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp);
  2450. #endif
  2451. #else // !LIMITED_API
  2452. typedef const char *__Pyx_TypeName;
  2453. #define __Pyx_FMT_TYPENAME "%.200s"
  2454. #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name)
  2455. #define __Pyx_DECREF_TypeName(obj)
  2456. #endif
  2457. /* CIntFromPy.proto */
  2458. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *);
  2459. /* FastTypeChecks.proto */
  2460. #if CYTHON_COMPILING_IN_CPYTHON
  2461. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  2462. #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
  2463. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  2464. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);
  2465. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  2466. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  2467. #else
  2468. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  2469. #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
  2470. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  2471. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) {
  2472. return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2);
  2473. }
  2474. #endif
  2475. #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2)
  2476. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  2477. #ifdef PyExceptionInstance_Check
  2478. #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj)
  2479. #else
  2480. #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException)
  2481. #endif
  2482. /* GetRuntimeVersion.proto */
  2483. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  2484. static unsigned long __Pyx_cached_runtime_version = 0;
  2485. static void __Pyx_init_runtime_version(void);
  2486. #else
  2487. #define __Pyx_init_runtime_version()
  2488. #endif
  2489. static unsigned long __Pyx_get_runtime_version(void);
  2490. /* SwapException.proto (used by CoroutineBase) */
  2491. #if CYTHON_FAST_THREAD_STATE
  2492. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  2493. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2494. #else
  2495. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  2496. #endif
  2497. /* IterNextPlain.proto (used by CoroutineBase) */
  2498. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator);
  2499. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  2500. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void);
  2501. #endif
  2502. /* PyObjectCall2Args.proto (used by PyObjectCallMethod1) */
  2503. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
  2504. /* PyObjectCallMethod1.proto (used by CoroutineBase) */
  2505. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  2506. /* ReturnWithStopIteration.proto (used by CoroutineBase) */
  2507. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext);
  2508. /* CoroutineBase.proto (used by Generator) */
  2509. struct __pyx_CoroutineObject;
  2510. typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *);
  2511. #if CYTHON_USE_EXC_INFO_STACK
  2512. #define __Pyx_ExcInfoStruct _PyErr_StackItem
  2513. #else
  2514. typedef struct {
  2515. PyObject *exc_type;
  2516. PyObject *exc_value;
  2517. PyObject *exc_traceback;
  2518. } __Pyx_ExcInfoStruct;
  2519. #endif
  2520. typedef struct __pyx_CoroutineObject {
  2521. PyObject_HEAD
  2522. __pyx_coroutine_body_t body;
  2523. PyObject *closure;
  2524. __Pyx_ExcInfoStruct gi_exc_state;
  2525. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2526. PyObject *gi_weakreflist;
  2527. #endif
  2528. PyObject *classobj;
  2529. PyObject *yieldfrom;
  2530. __Pyx_pyiter_sendfunc yieldfrom_am_send;
  2531. PyObject *gi_name;
  2532. PyObject *gi_qualname;
  2533. PyObject *gi_modulename;
  2534. PyObject *gi_code;
  2535. PyObject *gi_frame;
  2536. #if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
  2537. PyMonitoringState __pyx_pymonitoring_state[__Pyx_MonitoringEventTypes_CyGen_count];
  2538. uint64_t __pyx_pymonitoring_version;
  2539. #endif
  2540. int resume_label;
  2541. char is_running;
  2542. } __pyx_CoroutineObject;
  2543. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  2544. PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2545. PyObject *name, PyObject *qualname, PyObject *module_name);
  2546. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  2547. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2548. PyObject *name, PyObject *qualname, PyObject *module_name);
  2549. static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
  2550. static int __Pyx_Coroutine_clear(PyObject *self);
  2551. static __Pyx_PySendResult __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval);
  2552. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
  2553. static __Pyx_PySendResult __Pyx_Coroutine_Close(PyObject *self, PyObject **retval);
  2554. static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
  2555. #if CYTHON_USE_EXC_INFO_STACK
  2556. #define __Pyx_Coroutine_SwapException(self)
  2557. #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
  2558. #else
  2559. #define __Pyx_Coroutine_SwapException(self) {\
  2560. __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
  2561. __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
  2562. }
  2563. #define __Pyx_Coroutine_ResetAndClearException(self) {\
  2564. __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
  2565. (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
  2566. }
  2567. #endif
  2568. #if CYTHON_FAST_THREAD_STATE
  2569. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2570. __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
  2571. #else
  2572. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2573. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
  2574. #endif
  2575. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
  2576. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
  2577. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen);
  2578. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen);
  2579. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen);
  2580. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure);
  2581. #if __PYX_HAS_PY_AM_SEND == 2
  2582. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send);
  2583. #endif
  2584. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg);
  2585. /* Generator.proto */
  2586. #define __Pyx_Generator_USED
  2587. #define __Pyx_Generator_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_GeneratorType)
  2588. #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
  2589. __Pyx__Coroutine_New(__pyx_mstate_global->__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
  2590. static PyObject *__Pyx_Generator_Next(PyObject *self);
  2591. static int __pyx_Generator_init(PyObject *module);
  2592. static CYTHON_INLINE PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self);
  2593. /* CheckBinaryVersion.proto */
  2594. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);
  2595. /* DecompressString.proto */
  2596. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo);
  2597. /* MultiPhaseInitModuleState.proto */
  2598. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  2599. static PyObject *__Pyx_State_FindModule(void*);
  2600. static int __Pyx_State_AddModule(PyObject* module, void*);
  2601. static int __Pyx_State_RemoveModule(void*);
  2602. #elif CYTHON_USE_MODULE_STATE
  2603. #define __Pyx_State_FindModule PyState_FindModule
  2604. #define __Pyx_State_AddModule PyState_AddModule
  2605. #define __Pyx_State_RemoveModule PyState_RemoveModule
  2606. #endif
  2607. /* #### Code section: module_declarations ### */
  2608. /* CythonABIVersion.proto */
  2609. #if CYTHON_COMPILING_IN_LIMITED_API
  2610. #if CYTHON_METH_FASTCALL
  2611. #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall"
  2612. #else
  2613. #define __PYX_FASTCALL_ABI_SUFFIX
  2614. #endif
  2615. #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
  2616. #else
  2617. #define __PYX_LIMITED_ABI_SUFFIX
  2618. #endif
  2619. #if __PYX_HAS_PY_AM_SEND == 1
  2620. #define __PYX_AM_SEND_ABI_SUFFIX
  2621. #elif __PYX_HAS_PY_AM_SEND == 2
  2622. #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport"
  2623. #else
  2624. #define __PYX_AM_SEND_ABI_SUFFIX "noamsend"
  2625. #endif
  2626. #ifndef __PYX_MONITORING_ABI_SUFFIX
  2627. #define __PYX_MONITORING_ABI_SUFFIX
  2628. #endif
  2629. #if CYTHON_USE_TP_FINALIZE
  2630. #define __PYX_TP_FINALIZE_ABI_SUFFIX
  2631. #else
  2632. #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize"
  2633. #endif
  2634. #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED)
  2635. #define __PYX_FREELISTS_ABI_SUFFIX
  2636. #else
  2637. #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists"
  2638. #endif
  2639. #define CYTHON_ABI __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
  2640. #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
  2641. #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
  2642. /* Module declarations from "cython" */
  2643. /* Module declarations from "fontTools.qu2cu.qu2cu" */
  2644. static int __pyx_f_9fontTools_5qu2cu_5qu2cu_cubic_farthest_fit_inside(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, double); /*proto*/
  2645. static PyObject *__pyx_f_9fontTools_5qu2cu_5qu2cu_merge_curves(PyObject *, int, int); /*proto*/
  2646. /* #### Code section: typeinfo ### */
  2647. /* #### Code section: before_global_var ### */
  2648. #define __Pyx_MODULE_NAME "fontTools.qu2cu.qu2cu"
  2649. extern int __pyx_module_is_main_fontTools__qu2cu__qu2cu;
  2650. int __pyx_module_is_main_fontTools__qu2cu__qu2cu = 0;
  2651. /* Implementation of "fontTools.qu2cu.qu2cu" */
  2652. /* #### Code section: global_var ### */
  2653. static PyObject *__pyx_builtin_enumerate;
  2654. static PyObject *__pyx_builtin_reversed;
  2655. static PyObject *__pyx_builtin_zip;
  2656. static PyObject *__pyx_builtin_print;
  2657. /* #### Code section: string_decls ### */
  2658. /* #### Code section: decls ### */
  2659. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_elevate_quadratic(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2); /* proto */
  2660. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_p); /* proto */
  2661. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
  2662. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_4quadratic_to_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_quads, double __pyx_v_max_err, int __pyx_v_all_cubic); /* proto */
  2663. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
  2664. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_6spline_to_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_q, PyObject *__pyx_v_costs, double __pyx_v_tolerance, int __pyx_v_all_cubic); /* proto */
  2665. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_8main(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  2666. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2667. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2668. /* #### Code section: late_includes ### */
  2669. /* #### Code section: module_state ### */
  2670. /* SmallCodeConfig */
  2671. #ifndef CYTHON_SMALL_CODE
  2672. #if defined(__clang__)
  2673. #define CYTHON_SMALL_CODE
  2674. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  2675. #define CYTHON_SMALL_CODE __attribute__((cold))
  2676. #else
  2677. #define CYTHON_SMALL_CODE
  2678. #endif
  2679. #endif
  2680. typedef struct {
  2681. PyObject *__pyx_d;
  2682. PyObject *__pyx_b;
  2683. PyObject *__pyx_cython_runtime;
  2684. PyObject *__pyx_empty_tuple;
  2685. PyObject *__pyx_empty_bytes;
  2686. PyObject *__pyx_empty_unicode;
  2687. PyObject *__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  2688. PyObject *__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  2689. PyTypeObject *__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  2690. PyTypeObject *__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  2691. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items;
  2692. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop;
  2693. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values;
  2694. __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop;
  2695. PyObject *__pyx_slice[1];
  2696. PyObject *__pyx_tuple[1];
  2697. PyObject *__pyx_codeobj_tab[7];
  2698. PyObject *__pyx_string_tab[137];
  2699. PyObject *__pyx_number_tab[3];
  2700. /* #### Code section: module_state_contents ### */
  2701. #if CYTHON_USE_FREELISTS
  2702. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr[8];
  2703. int __pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  2704. #endif
  2705. #if CYTHON_USE_FREELISTS
  2706. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr[8];
  2707. int __pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  2708. #endif
  2709. /* CommonTypesMetaclass.module_state_decls */
  2710. PyTypeObject *__pyx_CommonTypesMetaclassType;
  2711. /* CachedMethodType.module_state_decls */
  2712. #if CYTHON_COMPILING_IN_LIMITED_API
  2713. PyObject *__Pyx_CachedMethodType;
  2714. #endif
  2715. /* CythonFunctionShared.module_state_decls */
  2716. PyTypeObject *__pyx_CyFunctionType;
  2717. /* CodeObjectCache.module_state_decls */
  2718. struct __Pyx_CodeObjectCache __pyx_code_cache;
  2719. /* IterNextPlain.module_state_decls */
  2720. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  2721. PyObject *__Pyx_GetBuiltinNext_LimitedAPI_cache;
  2722. #endif
  2723. /* Generator.module_state_decls */
  2724. PyTypeObject *__pyx_GeneratorType;
  2725. /* #### Code section: module_state_end ### */
  2726. } __pyx_mstatetype;
  2727. #if CYTHON_USE_MODULE_STATE
  2728. #ifdef __cplusplus
  2729. namespace {
  2730. extern struct PyModuleDef __pyx_moduledef;
  2731. } /* anonymous namespace */
  2732. #else
  2733. static struct PyModuleDef __pyx_moduledef;
  2734. #endif
  2735. #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef)))
  2736. #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef))
  2737. #else
  2738. static __pyx_mstatetype __pyx_mstate_global_static =
  2739. #ifdef __cplusplus
  2740. {};
  2741. #else
  2742. {0};
  2743. #endif
  2744. static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static;
  2745. #endif
  2746. /* #### Code section: constant_name_defines ### */
  2747. #define __pyx_kp_u_ __pyx_string_tab[0]
  2748. #define __pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py __pyx_string_tab[1]
  2749. #define __pyx_kp_u_List_List_Point __pyx_string_tab[2]
  2750. #define __pyx_kp_u_List_Tuple_Point __pyx_string_tab[3]
  2751. #define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[4]
  2752. #define __pyx_kp_u_One_random_cubic_turned_into_d_q __pyx_string_tab[5]
  2753. #define __pyx_kp_u_Original_curve __pyx_string_tab[6]
  2754. #define __pyx_kp_u_Reconstructed_curve_s __pyx_string_tab[7]
  2755. #define __pyx_kp_u_Those_quadratics_turned_back_int __pyx_string_tab[8]
  2756. #define __pyx_kp_u__2 __pyx_string_tab[9]
  2757. #define __pyx_kp_u_add_note __pyx_string_tab[10]
  2758. #define __pyx_kp_u_cu2qu_tolerance_g_qu2cu_toleranc __pyx_string_tab[11]
  2759. #define __pyx_kp_u_disable __pyx_string_tab[12]
  2760. #define __pyx_kp_u_enable __pyx_string_tab[13]
  2761. #define __pyx_kp_u_gc __pyx_string_tab[14]
  2762. #define __pyx_kp_u_isenabled __pyx_string_tab[15]
  2763. #define __pyx_kp_u_quadratic_spline_requires_at_lea __pyx_string_tab[16]
  2764. #define __pyx_n_u_COMPILED __pyx_string_tab[17]
  2765. #define __pyx_n_u_List __pyx_string_tab[18]
  2766. #define __pyx_n_u_Point __pyx_string_tab[19]
  2767. #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[20]
  2768. #define __pyx_n_u_Solution __pyx_string_tab[21]
  2769. #define __pyx_n_u_Tuple __pyx_string_tab[22]
  2770. #define __pyx_n_u_Union __pyx_string_tab[23]
  2771. #define __pyx_n_u_add_implicit_on_curves __pyx_string_tab[24]
  2772. #define __pyx_n_u_all __pyx_string_tab[25]
  2773. #define __pyx_n_u_all_cubic __pyx_string_tab[26]
  2774. #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[27]
  2775. #define __pyx_n_u_best_sol __pyx_string_tab[28]
  2776. #define __pyx_n_u_bool __pyx_string_tab[29]
  2777. #define __pyx_n_u_c __pyx_string_tab[30]
  2778. #define __pyx_n_u_class_getitem __pyx_string_tab[31]
  2779. #define __pyx_n_u_cline_in_traceback __pyx_string_tab[32]
  2780. #define __pyx_n_u_close __pyx_string_tab[33]
  2781. #define __pyx_n_u_collections __pyx_string_tab[34]
  2782. #define __pyx_n_u_cost __pyx_string_tab[35]
  2783. #define __pyx_n_u_costs __pyx_string_tab[36]
  2784. #define __pyx_n_u_count __pyx_string_tab[37]
  2785. #define __pyx_n_u_cubic __pyx_string_tab[38]
  2786. #define __pyx_n_u_curve __pyx_string_tab[39]
  2787. #define __pyx_n_u_curve_to_quadratic __pyx_string_tab[40]
  2788. #define __pyx_n_u_curves __pyx_string_tab[41]
  2789. #define __pyx_n_u_elevate_quadratic __pyx_string_tab[42]
  2790. #define __pyx_n_u_elevated_quadratics __pyx_string_tab[43]
  2791. #define __pyx_n_u_enumerate __pyx_string_tab[44]
  2792. #define __pyx_n_u_err __pyx_string_tab[45]
  2793. #define __pyx_n_u_error __pyx_string_tab[46]
  2794. #define __pyx_n_u_float __pyx_string_tab[47]
  2795. #define __pyx_n_u_fontTools_cu2qu __pyx_string_tab[48]
  2796. #define __pyx_n_u_fontTools_cu2qu_benchmark __pyx_string_tab[49]
  2797. #define __pyx_n_u_fontTools_misc_bezierTools __pyx_string_tab[50]
  2798. #define __pyx_n_u_fontTools_qu2cu_qu2cu __pyx_string_tab[51]
  2799. #define __pyx_n_u_forced __pyx_string_tab[52]
  2800. #define __pyx_n_u_func __pyx_string_tab[53]
  2801. #define __pyx_n_u_generate_curve __pyx_string_tab[54]
  2802. #define __pyx_n_u_genexpr __pyx_string_tab[55]
  2803. #define __pyx_n_u_i __pyx_string_tab[56]
  2804. #define __pyx_n_u_i_sol __pyx_string_tab[57]
  2805. #define __pyx_n_u_i_sol_count __pyx_string_tab[58]
  2806. #define __pyx_n_u_i_sol_error __pyx_string_tab[59]
  2807. #define __pyx_n_u_imag __pyx_string_tab[60]
  2808. #define __pyx_n_u_impossible __pyx_string_tab[61]
  2809. #define __pyx_n_u_is_complex __pyx_string_tab[62]
  2810. #define __pyx_n_u_is_coroutine __pyx_string_tab[63]
  2811. #define __pyx_n_u_is_cubic __pyx_string_tab[64]
  2812. #define __pyx_n_u_items __pyx_string_tab[65]
  2813. #define __pyx_n_u_j __pyx_string_tab[66]
  2814. #define __pyx_n_u_j_sol_count __pyx_string_tab[67]
  2815. #define __pyx_n_u_j_sol_error __pyx_string_tab[68]
  2816. #define __pyx_n_u_k __pyx_string_tab[69]
  2817. #define __pyx_n_u_main __pyx_string_tab[70]
  2818. #define __pyx_n_u_main_2 __pyx_string_tab[71]
  2819. #define __pyx_n_u_math __pyx_string_tab[72]
  2820. #define __pyx_n_u_max_err __pyx_string_tab[73]
  2821. #define __pyx_n_u_module __pyx_string_tab[74]
  2822. #define __pyx_n_u_name __pyx_string_tab[75]
  2823. #define __pyx_n_u_namedtuple __pyx_string_tab[76]
  2824. #define __pyx_n_u_next __pyx_string_tab[77]
  2825. #define __pyx_n_u_num_offcurves __pyx_string_tab[78]
  2826. #define __pyx_n_u_num_points __pyx_string_tab[79]
  2827. #define __pyx_n_u_off1 __pyx_string_tab[80]
  2828. #define __pyx_n_u_off2 __pyx_string_tab[81]
  2829. #define __pyx_n_u_on __pyx_string_tab[82]
  2830. #define __pyx_n_u_orig __pyx_string_tab[83]
  2831. #define __pyx_n_u_p __pyx_string_tab[84]
  2832. #define __pyx_n_u_p0 __pyx_string_tab[85]
  2833. #define __pyx_n_u_p1 __pyx_string_tab[86]
  2834. #define __pyx_n_u_p1_2_3 __pyx_string_tab[87]
  2835. #define __pyx_n_u_p2 __pyx_string_tab[88]
  2836. #define __pyx_n_u_p3 __pyx_string_tab[89]
  2837. #define __pyx_n_u_pop __pyx_string_tab[90]
  2838. #define __pyx_n_u_print __pyx_string_tab[91]
  2839. #define __pyx_n_u_q __pyx_string_tab[92]
  2840. #define __pyx_n_u_qq __pyx_string_tab[93]
  2841. #define __pyx_n_u_quadratic_to_curves __pyx_string_tab[94]
  2842. #define __pyx_n_u_quadratic_to_curves_locals_genex __pyx_string_tab[95]
  2843. #define __pyx_n_u_quadratics __pyx_string_tab[96]
  2844. #define __pyx_n_u_quads __pyx_string_tab[97]
  2845. #define __pyx_n_u_qualname __pyx_string_tab[98]
  2846. #define __pyx_n_u_real __pyx_string_tab[99]
  2847. #define __pyx_n_u_reconst __pyx_string_tab[100]
  2848. #define __pyx_n_u_reconstruct_tolerance __pyx_string_tab[101]
  2849. #define __pyx_n_u_reconstructed __pyx_string_tab[102]
  2850. #define __pyx_n_u_reconstructed_iter __pyx_string_tab[103]
  2851. #define __pyx_n_u_return __pyx_string_tab[104]
  2852. #define __pyx_n_u_reversed __pyx_string_tab[105]
  2853. #define __pyx_n_u_send __pyx_string_tab[106]
  2854. #define __pyx_n_u_set_name __pyx_string_tab[107]
  2855. #define __pyx_n_u_setdefault __pyx_string_tab[108]
  2856. #define __pyx_n_u_sols __pyx_string_tab[109]
  2857. #define __pyx_n_u_spline_to_curves __pyx_string_tab[110]
  2858. #define __pyx_n_u_spline_to_curves_locals_genexpr __pyx_string_tab[111]
  2859. #define __pyx_n_u_splitCubicAtTC __pyx_string_tab[112]
  2860. #define __pyx_n_u_splits __pyx_string_tab[113]
  2861. #define __pyx_n_u_start __pyx_string_tab[114]
  2862. #define __pyx_n_u_start_index __pyx_string_tab[115]
  2863. #define __pyx_n_u_test __pyx_string_tab[116]
  2864. #define __pyx_n_u_this_count __pyx_string_tab[117]
  2865. #define __pyx_n_u_this_sol_count __pyx_string_tab[118]
  2866. #define __pyx_n_u_throw __pyx_string_tab[119]
  2867. #define __pyx_n_u_tolerance __pyx_string_tab[120]
  2868. #define __pyx_n_u_ts __pyx_string_tab[121]
  2869. #define __pyx_n_u_typing __pyx_string_tab[122]
  2870. #define __pyx_n_u_u __pyx_string_tab[123]
  2871. #define __pyx_n_u_v __pyx_string_tab[124]
  2872. #define __pyx_n_u_value __pyx_string_tab[125]
  2873. #define __pyx_n_u_values __pyx_string_tab[126]
  2874. #define __pyx_n_u_x __pyx_string_tab[127]
  2875. #define __pyx_n_u_y __pyx_string_tab[128]
  2876. #define __pyx_n_u_zip __pyx_string_tab[129]
  2877. #define __pyx_kp_b_iso88591_AQ_A_Cq_2Q_U_3a_q_q_2Q_U_U_F_A __pyx_string_tab[130]
  2878. #define __pyx_kp_b_iso88591_Jb_N_1G1_2_8_Qa_q_Cq_Q_Q __pyx_string_tab[131]
  2879. #define __pyx_kp_b_iso88591_Q_q_6_Qe1Bat3a_t1_S_S_c_U_ar_AQ __pyx_string_tab[132]
  2880. #define __pyx_kp_b_iso88591_S_2Rq_Cr_3b_Cr_3b __pyx_string_tab[133]
  2881. #define __pyx_kp_b_iso88591__3 __pyx_string_tab[134]
  2882. #define __pyx_kp_b_iso88591__4 __pyx_string_tab[135]
  2883. #define __pyx_kp_b_iso88591_a_3as_S_1AT_2T_U_q_3as_Cq_U_3c __pyx_string_tab[136]
  2884. #define __pyx_int_0 __pyx_number_tab[0]
  2885. #define __pyx_int_1 __pyx_number_tab[1]
  2886. #define __pyx_int_3 __pyx_number_tab[2]
  2887. /* #### Code section: module_state_clear ### */
  2888. #if CYTHON_USE_MODULE_STATE
  2889. static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) {
  2890. __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m);
  2891. if (!clear_module_state) return 0;
  2892. Py_CLEAR(clear_module_state->__pyx_d);
  2893. Py_CLEAR(clear_module_state->__pyx_b);
  2894. Py_CLEAR(clear_module_state->__pyx_cython_runtime);
  2895. Py_CLEAR(clear_module_state->__pyx_empty_tuple);
  2896. Py_CLEAR(clear_module_state->__pyx_empty_bytes);
  2897. Py_CLEAR(clear_module_state->__pyx_empty_unicode);
  2898. #if CYTHON_PEP489_MULTI_PHASE_INIT
  2899. __Pyx_State_RemoveModule(NULL);
  2900. #endif
  2901. Py_CLEAR(clear_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2902. Py_CLEAR(clear_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2903. Py_CLEAR(clear_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2904. Py_CLEAR(clear_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2905. for (int i=0; i<1; ++i) { Py_CLEAR(clear_module_state->__pyx_slice[i]); }
  2906. for (int i=0; i<1; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); }
  2907. for (int i=0; i<7; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); }
  2908. for (int i=0; i<137; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); }
  2909. for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); }
  2910. /* #### Code section: module_state_clear_contents ### */
  2911. /* CommonTypesMetaclass.module_state_clear */
  2912. Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType);
  2913. /* CythonFunctionShared.module_state_clear */
  2914. Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
  2915. /* Generator.module_state_clear */
  2916. Py_CLEAR(clear_module_state->__pyx_GeneratorType);
  2917. /* #### Code section: module_state_clear_end ### */
  2918. return 0;
  2919. }
  2920. #endif
  2921. /* #### Code section: module_state_traverse ### */
  2922. #if CYTHON_USE_MODULE_STATE
  2923. static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
  2924. __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m);
  2925. if (!traverse_module_state) return 0;
  2926. Py_VISIT(traverse_module_state->__pyx_d);
  2927. Py_VISIT(traverse_module_state->__pyx_b);
  2928. Py_VISIT(traverse_module_state->__pyx_cython_runtime);
  2929. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple);
  2930. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes);
  2931. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode);
  2932. Py_VISIT(traverse_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2933. Py_VISIT(traverse_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2934. Py_VISIT(traverse_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2935. Py_VISIT(traverse_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2936. for (int i=0; i<1; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_slice[i]); }
  2937. for (int i=0; i<1; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); }
  2938. for (int i=0; i<7; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); }
  2939. for (int i=0; i<137; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); }
  2940. for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); }
  2941. /* #### Code section: module_state_traverse_contents ### */
  2942. /* CommonTypesMetaclass.module_state_traverse */
  2943. Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType);
  2944. /* CythonFunctionShared.module_state_traverse */
  2945. Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
  2946. /* Generator.module_state_traverse */
  2947. Py_VISIT(traverse_module_state->__pyx_GeneratorType);
  2948. /* #### Code section: module_state_traverse_end ### */
  2949. return 0;
  2950. }
  2951. #endif
  2952. /* #### Code section: module_code ### */
  2953. /* "fontTools/qu2cu/qu2cu.py":40
  2954. *
  2955. * # Copied from cu2qu
  2956. * @cython.cfunc # <<<<<<<<<<<<<<
  2957. * @cython.returns(cython.int)
  2958. * @cython.locals(
  2959. */
  2960. static int __pyx_f_9fontTools_5qu2cu_5qu2cu_cubic_farthest_fit_inside(__pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2, __pyx_t_double_complex __pyx_v_p3, double __pyx_v_tolerance) {
  2961. __pyx_t_double_complex __pyx_v_mid;
  2962. __pyx_t_double_complex __pyx_v_deriv3;
  2963. int __pyx_r;
  2964. int __pyx_t_1;
  2965. int __pyx_t_2;
  2966. int __pyx_t_3;
  2967. int __pyx_t_4;
  2968. int __pyx_lineno = 0;
  2969. const char *__pyx_filename = NULL;
  2970. int __pyx_clineno = 0;
  2971. /* "fontTools/qu2cu/qu2cu.py":69
  2972. * """
  2973. * # First check p2 then p1, as p2 has higher error early on.
  2974. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  2975. * return True
  2976. *
  2977. */
  2978. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p2) <= __pyx_v_tolerance);
  2979. if (__pyx_t_2) {
  2980. } else {
  2981. __pyx_t_1 = __pyx_t_2;
  2982. goto __pyx_L4_bool_binop_done;
  2983. }
  2984. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p1) <= __pyx_v_tolerance);
  2985. __pyx_t_1 = __pyx_t_2;
  2986. __pyx_L4_bool_binop_done:;
  2987. if (__pyx_t_1) {
  2988. /* "fontTools/qu2cu/qu2cu.py":70
  2989. * # First check p2 then p1, as p2 has higher error early on.
  2990. * if abs(p2) <= tolerance and abs(p1) <= tolerance:
  2991. * return True # <<<<<<<<<<<<<<
  2992. *
  2993. * # Split.
  2994. */
  2995. __pyx_r = 1;
  2996. goto __pyx_L0;
  2997. /* "fontTools/qu2cu/qu2cu.py":69
  2998. * """
  2999. * # First check p2 then p1, as p2 has higher error early on.
  3000. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  3001. * return True
  3002. *
  3003. */
  3004. }
  3005. /* "fontTools/qu2cu/qu2cu.py":73
  3006. *
  3007. * # Split.
  3008. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<<
  3009. * if abs(mid) > tolerance:
  3010. * return False
  3011. */
  3012. __pyx_v_mid = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __Pyx_c_sum_double(__pyx_v_p1, __pyx_v_p2))), __pyx_v_p3), __pyx_t_double_complex_from_parts(0.125, 0));
  3013. /* "fontTools/qu2cu/qu2cu.py":74
  3014. * # Split.
  3015. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  3016. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  3017. * return False
  3018. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3019. */
  3020. __pyx_t_1 = (__Pyx_c_abs_double(__pyx_v_mid) > __pyx_v_tolerance);
  3021. if (__pyx_t_1) {
  3022. /* "fontTools/qu2cu/qu2cu.py":75
  3023. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  3024. * if abs(mid) > tolerance:
  3025. * return False # <<<<<<<<<<<<<<
  3026. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3027. * return cubic_farthest_fit_inside(
  3028. */
  3029. __pyx_r = 0;
  3030. goto __pyx_L0;
  3031. /* "fontTools/qu2cu/qu2cu.py":74
  3032. * # Split.
  3033. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  3034. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  3035. * return False
  3036. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3037. */
  3038. }
  3039. /* "fontTools/qu2cu/qu2cu.py":76
  3040. * if abs(mid) > tolerance:
  3041. * return False
  3042. * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<<
  3043. * return cubic_farthest_fit_inside(
  3044. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  3045. */
  3046. __pyx_v_deriv3 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __pyx_v_p2), __pyx_v_p1), __pyx_v_p0), __pyx_t_double_complex_from_parts(0.125, 0));
  3047. /* "fontTools/qu2cu/qu2cu.py":77
  3048. * return False
  3049. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3050. * return cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  3051. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  3052. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance)
  3053. */
  3054. __pyx_t_4 = __pyx_f_9fontTools_5qu2cu_5qu2cu_cubic_farthest_fit_inside(__pyx_v_p0, __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p0, __pyx_v_p1), __pyx_t_double_complex_from_parts(0.5, 0)), __Pyx_c_diff_double(__pyx_v_mid, __pyx_v_deriv3), __pyx_v_mid, __pyx_v_tolerance); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 77, __pyx_L1_error)
  3055. if (__pyx_t_4) {
  3056. } else {
  3057. __pyx_t_3 = __pyx_t_4;
  3058. goto __pyx_L7_bool_binop_done;
  3059. }
  3060. /* "fontTools/qu2cu/qu2cu.py":79
  3061. * return cubic_farthest_fit_inside(
  3062. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  3063. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) # <<<<<<<<<<<<<<
  3064. *
  3065. *
  3066. */
  3067. __pyx_t_4 = __pyx_f_9fontTools_5qu2cu_5qu2cu_cubic_farthest_fit_inside(__pyx_v_mid, __Pyx_c_sum_double(__pyx_v_mid, __pyx_v_deriv3), __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(0.5, 0)), __pyx_v_p3, __pyx_v_tolerance); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 79, __pyx_L1_error)
  3068. __pyx_t_3 = __pyx_t_4;
  3069. __pyx_L7_bool_binop_done:;
  3070. __pyx_r = __pyx_t_3;
  3071. goto __pyx_L0;
  3072. /* "fontTools/qu2cu/qu2cu.py":40
  3073. *
  3074. * # Copied from cu2qu
  3075. * @cython.cfunc # <<<<<<<<<<<<<<
  3076. * @cython.returns(cython.int)
  3077. * @cython.locals(
  3078. */
  3079. /* function exit code */
  3080. __pyx_L1_error:;
  3081. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.cubic_farthest_fit_inside", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3082. __pyx_r = -1;
  3083. __pyx_L0:;
  3084. return __pyx_r;
  3085. }
  3086. /* "fontTools/qu2cu/qu2cu.py":82
  3087. *
  3088. *
  3089. * @cython.locals( # <<<<<<<<<<<<<<
  3090. * p0=cython.complex,
  3091. * p1=cython.complex,
  3092. */
  3093. /* Python wrapper */
  3094. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_1elevate_quadratic(PyObject *__pyx_self,
  3095. #if CYTHON_METH_FASTCALL
  3096. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3097. #else
  3098. PyObject *__pyx_args, PyObject *__pyx_kwds
  3099. #endif
  3100. ); /*proto*/
  3101. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_elevate_quadratic, "elevate_quadratic(double complex p0, double complex p1, double complex p2)\n\nGiven a quadratic bezier curve, return its degree-elevated cubic.");
  3102. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_1elevate_quadratic = {"elevate_quadratic", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_1elevate_quadratic, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_elevate_quadratic};
  3103. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_1elevate_quadratic(PyObject *__pyx_self,
  3104. #if CYTHON_METH_FASTCALL
  3105. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3106. #else
  3107. PyObject *__pyx_args, PyObject *__pyx_kwds
  3108. #endif
  3109. ) {
  3110. __pyx_t_double_complex __pyx_v_p0;
  3111. __pyx_t_double_complex __pyx_v_p1;
  3112. __pyx_t_double_complex __pyx_v_p2;
  3113. #if !CYTHON_METH_FASTCALL
  3114. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  3115. #endif
  3116. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  3117. PyObject* values[3] = {0,0,0};
  3118. int __pyx_lineno = 0;
  3119. const char *__pyx_filename = NULL;
  3120. int __pyx_clineno = 0;
  3121. PyObject *__pyx_r = 0;
  3122. __Pyx_RefNannyDeclarations
  3123. __Pyx_RefNannySetupContext("elevate_quadratic (wrapper)", 0);
  3124. #if !CYTHON_METH_FASTCALL
  3125. #if CYTHON_ASSUME_SAFE_SIZE
  3126. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  3127. #else
  3128. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  3129. #endif
  3130. #endif
  3131. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  3132. {
  3133. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_p0,&__pyx_mstate_global->__pyx_n_u_p1,&__pyx_mstate_global->__pyx_n_u_p2,0};
  3134. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  3135. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 82, __pyx_L3_error)
  3136. if (__pyx_kwds_len > 0) {
  3137. switch (__pyx_nargs) {
  3138. case 3:
  3139. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3140. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 82, __pyx_L3_error)
  3141. CYTHON_FALLTHROUGH;
  3142. case 2:
  3143. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  3144. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 82, __pyx_L3_error)
  3145. CYTHON_FALLTHROUGH;
  3146. case 1:
  3147. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3148. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 82, __pyx_L3_error)
  3149. CYTHON_FALLTHROUGH;
  3150. case 0: break;
  3151. default: goto __pyx_L5_argtuple_error;
  3152. }
  3153. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  3154. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "elevate_quadratic", 0) < (0)) __PYX_ERR(0, 82, __pyx_L3_error)
  3155. for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
  3156. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("elevate_quadratic", 1, 3, 3, i); __PYX_ERR(0, 82, __pyx_L3_error) }
  3157. }
  3158. } else if (unlikely(__pyx_nargs != 3)) {
  3159. goto __pyx_L5_argtuple_error;
  3160. } else {
  3161. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3162. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 82, __pyx_L3_error)
  3163. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  3164. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 82, __pyx_L3_error)
  3165. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3166. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 82, __pyx_L3_error)
  3167. }
  3168. __pyx_v_p0 = __Pyx_PyComplex_As___pyx_t_double_complex(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L3_error)
  3169. __pyx_v_p1 = __Pyx_PyComplex_As___pyx_t_double_complex(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L3_error)
  3170. __pyx_v_p2 = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L3_error)
  3171. }
  3172. goto __pyx_L6_skip;
  3173. __pyx_L5_argtuple_error:;
  3174. __Pyx_RaiseArgtupleInvalid("elevate_quadratic", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 82, __pyx_L3_error)
  3175. __pyx_L6_skip:;
  3176. goto __pyx_L4_argument_unpacking_done;
  3177. __pyx_L3_error:;
  3178. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3179. Py_XDECREF(values[__pyx_temp]);
  3180. }
  3181. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.elevate_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3182. __Pyx_RefNannyFinishContext();
  3183. return NULL;
  3184. __pyx_L4_argument_unpacking_done:;
  3185. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_elevate_quadratic(__pyx_self, __pyx_v_p0, __pyx_v_p1, __pyx_v_p2);
  3186. /* function exit code */
  3187. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3188. Py_XDECREF(values[__pyx_temp]);
  3189. }
  3190. __Pyx_RefNannyFinishContext();
  3191. return __pyx_r;
  3192. }
  3193. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_elevate_quadratic(CYTHON_UNUSED PyObject *__pyx_self, __pyx_t_double_complex __pyx_v_p0, __pyx_t_double_complex __pyx_v_p1, __pyx_t_double_complex __pyx_v_p2) {
  3194. __pyx_t_double_complex __pyx_v_p1_2_3;
  3195. PyObject *__pyx_r = NULL;
  3196. __Pyx_RefNannyDeclarations
  3197. PyObject *__pyx_t_1 = NULL;
  3198. __pyx_t_double_complex __pyx_t_2;
  3199. PyObject *__pyx_t_3 = NULL;
  3200. PyObject *__pyx_t_4 = NULL;
  3201. PyObject *__pyx_t_5 = NULL;
  3202. PyObject *__pyx_t_6 = NULL;
  3203. int __pyx_lineno = 0;
  3204. const char *__pyx_filename = NULL;
  3205. int __pyx_clineno = 0;
  3206. __Pyx_RefNannySetupContext("elevate_quadratic", 0);
  3207. /* "fontTools/qu2cu/qu2cu.py":92
  3208. *
  3209. * # https://pomax.github.io/bezierinfo/#reordering
  3210. * p1_2_3 = p1 * (2 / 3) # <<<<<<<<<<<<<<
  3211. * return (
  3212. * p0,
  3213. */
  3214. __pyx_v_p1_2_3 = __Pyx_c_prod_double(__pyx_v_p1, __pyx_t_double_complex_from_parts((2.0 / 3.0), 0));
  3215. /* "fontTools/qu2cu/qu2cu.py":93
  3216. * # https://pomax.github.io/bezierinfo/#reordering
  3217. * p1_2_3 = p1 * (2 / 3)
  3218. * return ( # <<<<<<<<<<<<<<
  3219. * p0,
  3220. * (p0 * (1 / 3) + p1_2_3),
  3221. */
  3222. __Pyx_XDECREF(__pyx_r);
  3223. /* "fontTools/qu2cu/qu2cu.py":94
  3224. * p1_2_3 = p1 * (2 / 3)
  3225. * return (
  3226. * p0, # <<<<<<<<<<<<<<
  3227. * (p0 * (1 / 3) + p1_2_3),
  3228. * (p2 * (1 / 3) + p1_2_3),
  3229. */
  3230. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
  3231. __Pyx_GOTREF(__pyx_t_1);
  3232. /* "fontTools/qu2cu/qu2cu.py":95
  3233. * return (
  3234. * p0,
  3235. * (p0 * (1 / 3) + p1_2_3), # <<<<<<<<<<<<<<
  3236. * (p2 * (1 / 3) + p1_2_3),
  3237. * p2,
  3238. */
  3239. __pyx_t_2 = __Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_v_p0, __pyx_t_double_complex_from_parts((1.0 / 3.0), 0)), __pyx_v_p1_2_3);
  3240. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
  3241. __Pyx_GOTREF(__pyx_t_3);
  3242. /* "fontTools/qu2cu/qu2cu.py":96
  3243. * p0,
  3244. * (p0 * (1 / 3) + p1_2_3),
  3245. * (p2 * (1 / 3) + p1_2_3), # <<<<<<<<<<<<<<
  3246. * p2,
  3247. * )
  3248. */
  3249. __pyx_t_2 = __Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_v_p2, __pyx_t_double_complex_from_parts((1.0 / 3.0), 0)), __pyx_v_p1_2_3);
  3250. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error)
  3251. __Pyx_GOTREF(__pyx_t_4);
  3252. /* "fontTools/qu2cu/qu2cu.py":97
  3253. * (p0 * (1 / 3) + p1_2_3),
  3254. * (p2 * (1 / 3) + p1_2_3),
  3255. * p2, # <<<<<<<<<<<<<<
  3256. * )
  3257. *
  3258. */
  3259. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error)
  3260. __Pyx_GOTREF(__pyx_t_5);
  3261. /* "fontTools/qu2cu/qu2cu.py":94
  3262. * p1_2_3 = p1 * (2 / 3)
  3263. * return (
  3264. * p0, # <<<<<<<<<<<<<<
  3265. * (p0 * (1 / 3) + p1_2_3),
  3266. * (p2 * (1 / 3) + p1_2_3),
  3267. */
  3268. __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 94, __pyx_L1_error)
  3269. __Pyx_GOTREF(__pyx_t_6);
  3270. __Pyx_GIVEREF(__pyx_t_1);
  3271. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3272. __Pyx_GIVEREF(__pyx_t_3);
  3273. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3274. __Pyx_GIVEREF(__pyx_t_4);
  3275. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3276. __Pyx_GIVEREF(__pyx_t_5);
  3277. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3278. __pyx_t_1 = 0;
  3279. __pyx_t_3 = 0;
  3280. __pyx_t_4 = 0;
  3281. __pyx_t_5 = 0;
  3282. __pyx_r = __pyx_t_6;
  3283. __pyx_t_6 = 0;
  3284. goto __pyx_L0;
  3285. /* "fontTools/qu2cu/qu2cu.py":82
  3286. *
  3287. *
  3288. * @cython.locals( # <<<<<<<<<<<<<<
  3289. * p0=cython.complex,
  3290. * p1=cython.complex,
  3291. */
  3292. /* function exit code */
  3293. __pyx_L1_error:;
  3294. __Pyx_XDECREF(__pyx_t_1);
  3295. __Pyx_XDECREF(__pyx_t_3);
  3296. __Pyx_XDECREF(__pyx_t_4);
  3297. __Pyx_XDECREF(__pyx_t_5);
  3298. __Pyx_XDECREF(__pyx_t_6);
  3299. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.elevate_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3300. __pyx_r = NULL;
  3301. __pyx_L0:;
  3302. __Pyx_XGIVEREF(__pyx_r);
  3303. __Pyx_RefNannyFinishContext();
  3304. return __pyx_r;
  3305. }
  3306. /* "fontTools/qu2cu/qu2cu.py":101
  3307. *
  3308. *
  3309. * @cython.cfunc # <<<<<<<<<<<<<<
  3310. * @cython.locals(
  3311. * start=cython.int,
  3312. */
  3313. static PyObject *__pyx_f_9fontTools_5qu2cu_5qu2cu_merge_curves(PyObject *__pyx_v_curves, int __pyx_v_start, int __pyx_v_n) {
  3314. int __pyx_v_k;
  3315. double __pyx_v_prod_ratio;
  3316. double __pyx_v_sum_ratio;
  3317. double __pyx_v_ratio;
  3318. __pyx_t_double_complex __pyx_v_p0;
  3319. __pyx_t_double_complex __pyx_v_p1;
  3320. __pyx_t_double_complex __pyx_v_p2;
  3321. __pyx_t_double_complex __pyx_v_p3;
  3322. PyObject *__pyx_v_ts = NULL;
  3323. PyObject *__pyx_v_ck = NULL;
  3324. PyObject *__pyx_v_c_before = NULL;
  3325. PyObject *__pyx_v_curve = NULL;
  3326. double __pyx_7genexpr__pyx_v_t;
  3327. PyObject *__pyx_r = NULL;
  3328. __Pyx_RefNannyDeclarations
  3329. PyObject *__pyx_t_1 = NULL;
  3330. int __pyx_t_2;
  3331. int __pyx_t_3;
  3332. int __pyx_t_4;
  3333. int __pyx_t_5;
  3334. long __pyx_t_6;
  3335. PyObject *__pyx_t_7 = NULL;
  3336. PyObject *__pyx_t_8 = NULL;
  3337. int __pyx_t_9;
  3338. PyObject *__pyx_t_10 = NULL;
  3339. double __pyx_t_11;
  3340. int __pyx_t_12;
  3341. Py_ssize_t __pyx_t_13;
  3342. __pyx_t_double_complex __pyx_t_14;
  3343. PyObject *__pyx_t_15 = NULL;
  3344. int __pyx_lineno = 0;
  3345. const char *__pyx_filename = NULL;
  3346. int __pyx_clineno = 0;
  3347. __Pyx_RefNannySetupContext("merge_curves", 0);
  3348. /* "fontTools/qu2cu/qu2cu.py":121
  3349. *
  3350. * # Reconstruct the t values of the cut segments
  3351. * prod_ratio = 1.0 # <<<<<<<<<<<<<<
  3352. * sum_ratio = 1.0
  3353. * ts = [1]
  3354. */
  3355. __pyx_v_prod_ratio = 1.0;
  3356. /* "fontTools/qu2cu/qu2cu.py":122
  3357. * # Reconstruct the t values of the cut segments
  3358. * prod_ratio = 1.0
  3359. * sum_ratio = 1.0 # <<<<<<<<<<<<<<
  3360. * ts = [1]
  3361. * for k in range(1, n):
  3362. */
  3363. __pyx_v_sum_ratio = 1.0;
  3364. /* "fontTools/qu2cu/qu2cu.py":123
  3365. * prod_ratio = 1.0
  3366. * sum_ratio = 1.0
  3367. * ts = [1] # <<<<<<<<<<<<<<
  3368. * for k in range(1, n):
  3369. * ck = curves[start + k]
  3370. */
  3371. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
  3372. __Pyx_GOTREF(__pyx_t_1);
  3373. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  3374. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
  3375. if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 123, __pyx_L1_error);
  3376. __pyx_v_ts = ((PyObject*)__pyx_t_1);
  3377. __pyx_t_1 = 0;
  3378. /* "fontTools/qu2cu/qu2cu.py":124
  3379. * sum_ratio = 1.0
  3380. * ts = [1]
  3381. * for k in range(1, n): # <<<<<<<<<<<<<<
  3382. * ck = curves[start + k]
  3383. * c_before = curves[start + k - 1]
  3384. */
  3385. __pyx_t_2 = __pyx_v_n;
  3386. __pyx_t_3 = __pyx_t_2;
  3387. for (__pyx_t_4 = 1; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
  3388. __pyx_v_k = __pyx_t_4;
  3389. /* "fontTools/qu2cu/qu2cu.py":125
  3390. * ts = [1]
  3391. * for k in range(1, n):
  3392. * ck = curves[start + k] # <<<<<<<<<<<<<<
  3393. * c_before = curves[start + k - 1]
  3394. *
  3395. */
  3396. __pyx_t_5 = (__pyx_v_start + __pyx_v_k);
  3397. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_t_5, int, 1, __Pyx_PyLong_From_int, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
  3398. __Pyx_GOTREF(__pyx_t_1);
  3399. __Pyx_XDECREF_SET(__pyx_v_ck, __pyx_t_1);
  3400. __pyx_t_1 = 0;
  3401. /* "fontTools/qu2cu/qu2cu.py":126
  3402. * for k in range(1, n):
  3403. * ck = curves[start + k]
  3404. * c_before = curves[start + k - 1] # <<<<<<<<<<<<<<
  3405. *
  3406. * # |t_(k+1) - t_k| / |t_k - t_(k - 1)| = ratio
  3407. */
  3408. __pyx_t_6 = ((__pyx_v_start + __pyx_v_k) - 1);
  3409. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_t_6, long, 1, __Pyx_PyLong_From_long, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
  3410. __Pyx_GOTREF(__pyx_t_1);
  3411. __Pyx_XDECREF_SET(__pyx_v_c_before, __pyx_t_1);
  3412. __pyx_t_1 = 0;
  3413. /* "fontTools/qu2cu/qu2cu.py":129
  3414. *
  3415. * # |t_(k+1) - t_k| / |t_k - t_(k - 1)| = ratio
  3416. * assert ck[0] == c_before[3] # <<<<<<<<<<<<<<
  3417. * ratio = abs(ck[1] - ck[0]) / abs(c_before[3] - c_before[2])
  3418. *
  3419. */
  3420. #ifndef CYTHON_WITHOUT_ASSERTIONS
  3421. if (unlikely(__pyx_assertions_enabled())) {
  3422. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_ck, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
  3423. __Pyx_GOTREF(__pyx_t_1);
  3424. __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_c_before, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 129, __pyx_L1_error)
  3425. __Pyx_GOTREF(__pyx_t_7);
  3426. __pyx_t_8 = PyObject_RichCompare(__pyx_t_1, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 129, __pyx_L1_error)
  3427. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3428. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3429. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 129, __pyx_L1_error)
  3430. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3431. if (unlikely(!__pyx_t_9)) {
  3432. __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_AssertionError))), 0, 0, 0);
  3433. __PYX_ERR(0, 129, __pyx_L1_error)
  3434. }
  3435. }
  3436. #else
  3437. if ((1)); else __PYX_ERR(0, 129, __pyx_L1_error)
  3438. #endif
  3439. /* "fontTools/qu2cu/qu2cu.py":130
  3440. * # |t_(k+1) - t_k| / |t_k - t_(k - 1)| = ratio
  3441. * assert ck[0] == c_before[3]
  3442. * ratio = abs(ck[1] - ck[0]) / abs(c_before[3] - c_before[2]) # <<<<<<<<<<<<<<
  3443. *
  3444. * prod_ratio *= ratio
  3445. */
  3446. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_ck, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 130, __pyx_L1_error)
  3447. __Pyx_GOTREF(__pyx_t_8);
  3448. __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_ck, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 130, __pyx_L1_error)
  3449. __Pyx_GOTREF(__pyx_t_7);
  3450. __pyx_t_1 = PyNumber_Subtract(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
  3451. __Pyx_GOTREF(__pyx_t_1);
  3452. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3453. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3454. __pyx_t_7 = __Pyx_PyNumber_Absolute(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 130, __pyx_L1_error)
  3455. __Pyx_GOTREF(__pyx_t_7);
  3456. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3457. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_c_before, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
  3458. __Pyx_GOTREF(__pyx_t_1);
  3459. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_c_before, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 130, __pyx_L1_error)
  3460. __Pyx_GOTREF(__pyx_t_8);
  3461. __pyx_t_10 = PyNumber_Subtract(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 130, __pyx_L1_error)
  3462. __Pyx_GOTREF(__pyx_t_10);
  3463. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3464. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3465. __pyx_t_8 = __Pyx_PyNumber_Absolute(__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 130, __pyx_L1_error)
  3466. __Pyx_GOTREF(__pyx_t_8);
  3467. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3468. __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 130, __pyx_L1_error)
  3469. __Pyx_GOTREF(__pyx_t_10);
  3470. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3471. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3472. __pyx_t_11 = __Pyx_PyFloat_AsDouble(__pyx_t_10); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L1_error)
  3473. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3474. __pyx_v_ratio = __pyx_t_11;
  3475. /* "fontTools/qu2cu/qu2cu.py":132
  3476. * ratio = abs(ck[1] - ck[0]) / abs(c_before[3] - c_before[2])
  3477. *
  3478. * prod_ratio *= ratio # <<<<<<<<<<<<<<
  3479. * sum_ratio += prod_ratio
  3480. * ts.append(sum_ratio)
  3481. */
  3482. __pyx_v_prod_ratio = (__pyx_v_prod_ratio * __pyx_v_ratio);
  3483. /* "fontTools/qu2cu/qu2cu.py":133
  3484. *
  3485. * prod_ratio *= ratio
  3486. * sum_ratio += prod_ratio # <<<<<<<<<<<<<<
  3487. * ts.append(sum_ratio)
  3488. *
  3489. */
  3490. __pyx_v_sum_ratio = (__pyx_v_sum_ratio + __pyx_v_prod_ratio);
  3491. /* "fontTools/qu2cu/qu2cu.py":134
  3492. * prod_ratio *= ratio
  3493. * sum_ratio += prod_ratio
  3494. * ts.append(sum_ratio) # <<<<<<<<<<<<<<
  3495. *
  3496. * # (t(n) - t(n - 1)) / (t_(1) - t(0)) = prod_ratio
  3497. */
  3498. __pyx_t_10 = PyFloat_FromDouble(__pyx_v_sum_ratio); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 134, __pyx_L1_error)
  3499. __Pyx_GOTREF(__pyx_t_10);
  3500. __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_ts, __pyx_t_10); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 134, __pyx_L1_error)
  3501. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3502. }
  3503. /* "fontTools/qu2cu/qu2cu.py":138
  3504. * # (t(n) - t(n - 1)) / (t_(1) - t(0)) = prod_ratio
  3505. *
  3506. * ts = [t / sum_ratio for t in ts[:-1]] # <<<<<<<<<<<<<<
  3507. *
  3508. * p0 = curves[start][0]
  3509. */
  3510. { /* enter inner scope */
  3511. __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 138, __pyx_L1_error)
  3512. __Pyx_GOTREF(__pyx_t_10);
  3513. __pyx_t_8 = __Pyx_PyList_GetSlice(__pyx_v_ts, 0, -1L); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 138, __pyx_L1_error)
  3514. __Pyx_GOTREF(__pyx_t_8);
  3515. __pyx_t_7 = __pyx_t_8; __Pyx_INCREF(__pyx_t_7);
  3516. __pyx_t_13 = 0;
  3517. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3518. for (;;) {
  3519. {
  3520. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7);
  3521. #if !CYTHON_ASSUME_SAFE_SIZE
  3522. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 138, __pyx_L1_error)
  3523. #endif
  3524. if (__pyx_t_13 >= __pyx_temp) break;
  3525. }
  3526. __pyx_t_8 = __Pyx_PyList_GetItemRefFast(__pyx_t_7, __pyx_t_13, __Pyx_ReferenceSharing_OwnStrongReference);
  3527. ++__pyx_t_13;
  3528. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 138, __pyx_L1_error)
  3529. __Pyx_GOTREF(__pyx_t_8);
  3530. __pyx_t_11 = __Pyx_PyFloat_AsDouble(__pyx_t_8); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3531. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3532. __pyx_7genexpr__pyx_v_t = __pyx_t_11;
  3533. if (unlikely(__pyx_v_sum_ratio == 0)) {
  3534. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  3535. __PYX_ERR(0, 138, __pyx_L1_error)
  3536. }
  3537. __pyx_t_8 = PyFloat_FromDouble((__pyx_7genexpr__pyx_v_t / __pyx_v_sum_ratio)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 138, __pyx_L1_error)
  3538. __Pyx_GOTREF(__pyx_t_8);
  3539. if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 138, __pyx_L1_error)
  3540. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3541. }
  3542. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3543. } /* exit inner scope */
  3544. __Pyx_DECREF_SET(__pyx_v_ts, ((PyObject*)__pyx_t_10));
  3545. __pyx_t_10 = 0;
  3546. /* "fontTools/qu2cu/qu2cu.py":140
  3547. * ts = [t / sum_ratio for t in ts[:-1]]
  3548. *
  3549. * p0 = curves[start][0] # <<<<<<<<<<<<<<
  3550. * p1 = curves[start][1]
  3551. * p2 = curves[start + n - 1][2]
  3552. */
  3553. __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_v_start, int, 1, __Pyx_PyLong_From_int, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 140, __pyx_L1_error)
  3554. __Pyx_GOTREF(__pyx_t_10);
  3555. __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_10, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error)
  3556. __Pyx_GOTREF(__pyx_t_7);
  3557. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3558. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L1_error)
  3559. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3560. __pyx_v_p0 = __pyx_t_14;
  3561. /* "fontTools/qu2cu/qu2cu.py":141
  3562. *
  3563. * p0 = curves[start][0]
  3564. * p1 = curves[start][1] # <<<<<<<<<<<<<<
  3565. * p2 = curves[start + n - 1][2]
  3566. * p3 = curves[start + n - 1][3]
  3567. */
  3568. __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_v_start, int, 1, __Pyx_PyLong_From_int, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 141, __pyx_L1_error)
  3569. __Pyx_GOTREF(__pyx_t_7);
  3570. __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_7, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 141, __pyx_L1_error)
  3571. __Pyx_GOTREF(__pyx_t_10);
  3572. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3573. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
  3574. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3575. __pyx_v_p1 = __pyx_t_14;
  3576. /* "fontTools/qu2cu/qu2cu.py":142
  3577. * p0 = curves[start][0]
  3578. * p1 = curves[start][1]
  3579. * p2 = curves[start + n - 1][2] # <<<<<<<<<<<<<<
  3580. * p3 = curves[start + n - 1][3]
  3581. *
  3582. */
  3583. __pyx_t_6 = ((__pyx_v_start + __pyx_v_n) - 1);
  3584. __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_t_6, long, 1, __Pyx_PyLong_From_long, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 142, __pyx_L1_error)
  3585. __Pyx_GOTREF(__pyx_t_10);
  3586. __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_10, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 142, __pyx_L1_error)
  3587. __Pyx_GOTREF(__pyx_t_7);
  3588. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3589. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error)
  3590. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3591. __pyx_v_p2 = __pyx_t_14;
  3592. /* "fontTools/qu2cu/qu2cu.py":143
  3593. * p1 = curves[start][1]
  3594. * p2 = curves[start + n - 1][2]
  3595. * p3 = curves[start + n - 1][3] # <<<<<<<<<<<<<<
  3596. *
  3597. * # Build the curve by scaling the control-points.
  3598. */
  3599. __pyx_t_6 = ((__pyx_v_start + __pyx_v_n) - 1);
  3600. __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_t_6, long, 1, __Pyx_PyLong_From_long, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 143, __pyx_L1_error)
  3601. __Pyx_GOTREF(__pyx_t_7);
  3602. __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_7, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 143, __pyx_L1_error)
  3603. __Pyx_GOTREF(__pyx_t_10);
  3604. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3605. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3606. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3607. __pyx_v_p3 = __pyx_t_14;
  3608. /* "fontTools/qu2cu/qu2cu.py":146
  3609. *
  3610. * # Build the curve by scaling the control-points.
  3611. * p1 = p0 + (p1 - p0) / (ts[0] if ts else 1) # <<<<<<<<<<<<<<
  3612. * p2 = p3 + (p2 - p3) / ((1 - ts[-1]) if ts else 1)
  3613. *
  3614. */
  3615. __pyx_t_10 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 146, __pyx_L1_error)
  3616. __Pyx_GOTREF(__pyx_t_10);
  3617. __pyx_t_14 = __Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0);
  3618. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error)
  3619. __Pyx_GOTREF(__pyx_t_7);
  3620. {
  3621. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_ts);
  3622. if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 146, __pyx_L1_error)
  3623. __pyx_t_9 = (__pyx_temp != 0);
  3624. }
  3625. if (__pyx_t_9) {
  3626. __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_ts, 0, long, 1, __Pyx_PyLong_From_long, 1, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
  3627. __Pyx_GOTREF(__pyx_t_1);
  3628. __pyx_t_8 = __pyx_t_1;
  3629. __pyx_t_1 = 0;
  3630. } else {
  3631. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  3632. __pyx_t_8 = __pyx_mstate_global->__pyx_int_1;
  3633. }
  3634. __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
  3635. __Pyx_GOTREF(__pyx_t_1);
  3636. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3637. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3638. __pyx_t_8 = PyNumber_Add(__pyx_t_10, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 146, __pyx_L1_error)
  3639. __Pyx_GOTREF(__pyx_t_8);
  3640. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3641. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3642. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L1_error)
  3643. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3644. __pyx_v_p1 = __pyx_t_14;
  3645. /* "fontTools/qu2cu/qu2cu.py":147
  3646. * # Build the curve by scaling the control-points.
  3647. * p1 = p0 + (p1 - p0) / (ts[0] if ts else 1)
  3648. * p2 = p3 + (p2 - p3) / ((1 - ts[-1]) if ts else 1) # <<<<<<<<<<<<<<
  3649. *
  3650. * curve = (p0, p1, p2, p3)
  3651. */
  3652. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 147, __pyx_L1_error)
  3653. __Pyx_GOTREF(__pyx_t_8);
  3654. __pyx_t_14 = __Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p3);
  3655. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
  3656. __Pyx_GOTREF(__pyx_t_1);
  3657. {
  3658. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_ts);
  3659. if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 147, __pyx_L1_error)
  3660. __pyx_t_9 = (__pyx_temp != 0);
  3661. }
  3662. if (__pyx_t_9) {
  3663. __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_ts, -1L, long, 1, __Pyx_PyLong_From_long, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 147, __pyx_L1_error)
  3664. __Pyx_GOTREF(__pyx_t_7);
  3665. __pyx_t_15 = __Pyx_PyLong_SubtractCObj(__pyx_mstate_global->__pyx_int_1, __pyx_t_7, 1, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 147, __pyx_L1_error)
  3666. __Pyx_GOTREF(__pyx_t_15);
  3667. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3668. __pyx_t_10 = __pyx_t_15;
  3669. __pyx_t_15 = 0;
  3670. } else {
  3671. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  3672. __pyx_t_10 = __pyx_mstate_global->__pyx_int_1;
  3673. }
  3674. __pyx_t_15 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 147, __pyx_L1_error)
  3675. __Pyx_GOTREF(__pyx_t_15);
  3676. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3677. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3678. __pyx_t_10 = PyNumber_Add(__pyx_t_8, __pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 147, __pyx_L1_error)
  3679. __Pyx_GOTREF(__pyx_t_10);
  3680. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3681. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3682. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 147, __pyx_L1_error)
  3683. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3684. __pyx_v_p2 = __pyx_t_14;
  3685. /* "fontTools/qu2cu/qu2cu.py":149
  3686. * p2 = p3 + (p2 - p3) / ((1 - ts[-1]) if ts else 1)
  3687. *
  3688. * curve = (p0, p1, p2, p3) # <<<<<<<<<<<<<<
  3689. *
  3690. * return curve, ts
  3691. */
  3692. __pyx_t_10 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 149, __pyx_L1_error)
  3693. __Pyx_GOTREF(__pyx_t_10);
  3694. __pyx_t_15 = __pyx_PyComplex_FromComplex(__pyx_v_p1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 149, __pyx_L1_error)
  3695. __Pyx_GOTREF(__pyx_t_15);
  3696. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error)
  3697. __Pyx_GOTREF(__pyx_t_8);
  3698. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
  3699. __Pyx_GOTREF(__pyx_t_1);
  3700. __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 149, __pyx_L1_error)
  3701. __Pyx_GOTREF(__pyx_t_7);
  3702. __Pyx_GIVEREF(__pyx_t_10);
  3703. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3704. __Pyx_GIVEREF(__pyx_t_15);
  3705. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_15) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3706. __Pyx_GIVEREF(__pyx_t_8);
  3707. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_8) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3708. __Pyx_GIVEREF(__pyx_t_1);
  3709. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3710. __pyx_t_10 = 0;
  3711. __pyx_t_15 = 0;
  3712. __pyx_t_8 = 0;
  3713. __pyx_t_1 = 0;
  3714. __pyx_v_curve = __pyx_t_7;
  3715. __pyx_t_7 = 0;
  3716. /* "fontTools/qu2cu/qu2cu.py":151
  3717. * curve = (p0, p1, p2, p3)
  3718. *
  3719. * return curve, ts # <<<<<<<<<<<<<<
  3720. *
  3721. *
  3722. */
  3723. __Pyx_XDECREF(__pyx_r);
  3724. __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error)
  3725. __Pyx_GOTREF(__pyx_t_7);
  3726. __Pyx_INCREF(__pyx_v_curve);
  3727. __Pyx_GIVEREF(__pyx_v_curve);
  3728. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_curve) != (0)) __PYX_ERR(0, 151, __pyx_L1_error);
  3729. __Pyx_INCREF(__pyx_v_ts);
  3730. __Pyx_GIVEREF(__pyx_v_ts);
  3731. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ts) != (0)) __PYX_ERR(0, 151, __pyx_L1_error);
  3732. __pyx_r = __pyx_t_7;
  3733. __pyx_t_7 = 0;
  3734. goto __pyx_L0;
  3735. /* "fontTools/qu2cu/qu2cu.py":101
  3736. *
  3737. *
  3738. * @cython.cfunc # <<<<<<<<<<<<<<
  3739. * @cython.locals(
  3740. * start=cython.int,
  3741. */
  3742. /* function exit code */
  3743. __pyx_L1_error:;
  3744. __Pyx_XDECREF(__pyx_t_1);
  3745. __Pyx_XDECREF(__pyx_t_7);
  3746. __Pyx_XDECREF(__pyx_t_8);
  3747. __Pyx_XDECREF(__pyx_t_10);
  3748. __Pyx_XDECREF(__pyx_t_15);
  3749. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.merge_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3750. __pyx_r = 0;
  3751. __pyx_L0:;
  3752. __Pyx_XDECREF(__pyx_v_ts);
  3753. __Pyx_XDECREF(__pyx_v_ck);
  3754. __Pyx_XDECREF(__pyx_v_c_before);
  3755. __Pyx_XDECREF(__pyx_v_curve);
  3756. __Pyx_XGIVEREF(__pyx_r);
  3757. __Pyx_RefNannyFinishContext();
  3758. return __pyx_r;
  3759. }
  3760. /* "fontTools/qu2cu/qu2cu.py":154
  3761. *
  3762. *
  3763. * @cython.locals( # <<<<<<<<<<<<<<
  3764. * count=cython.int,
  3765. * num_offcurves=cython.int,
  3766. */
  3767. /* Python wrapper */
  3768. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_3add_implicit_on_curves(PyObject *__pyx_self,
  3769. #if CYTHON_METH_FASTCALL
  3770. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3771. #else
  3772. PyObject *__pyx_args, PyObject *__pyx_kwds
  3773. #endif
  3774. ); /*proto*/
  3775. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves, "add_implicit_on_curves(p)");
  3776. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_3add_implicit_on_curves = {"add_implicit_on_curves", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_3add_implicit_on_curves, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves};
  3777. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_3add_implicit_on_curves(PyObject *__pyx_self,
  3778. #if CYTHON_METH_FASTCALL
  3779. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3780. #else
  3781. PyObject *__pyx_args, PyObject *__pyx_kwds
  3782. #endif
  3783. ) {
  3784. PyObject *__pyx_v_p = 0;
  3785. #if !CYTHON_METH_FASTCALL
  3786. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  3787. #endif
  3788. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  3789. PyObject* values[1] = {0};
  3790. int __pyx_lineno = 0;
  3791. const char *__pyx_filename = NULL;
  3792. int __pyx_clineno = 0;
  3793. PyObject *__pyx_r = 0;
  3794. __Pyx_RefNannyDeclarations
  3795. __Pyx_RefNannySetupContext("add_implicit_on_curves (wrapper)", 0);
  3796. #if !CYTHON_METH_FASTCALL
  3797. #if CYTHON_ASSUME_SAFE_SIZE
  3798. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  3799. #else
  3800. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  3801. #endif
  3802. #endif
  3803. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  3804. {
  3805. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_p,0};
  3806. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  3807. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 154, __pyx_L3_error)
  3808. if (__pyx_kwds_len > 0) {
  3809. switch (__pyx_nargs) {
  3810. case 1:
  3811. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3812. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 154, __pyx_L3_error)
  3813. CYTHON_FALLTHROUGH;
  3814. case 0: break;
  3815. default: goto __pyx_L5_argtuple_error;
  3816. }
  3817. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  3818. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "add_implicit_on_curves", 0) < (0)) __PYX_ERR(0, 154, __pyx_L3_error)
  3819. for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
  3820. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("add_implicit_on_curves", 1, 1, 1, i); __PYX_ERR(0, 154, __pyx_L3_error) }
  3821. }
  3822. } else if (unlikely(__pyx_nargs != 1)) {
  3823. goto __pyx_L5_argtuple_error;
  3824. } else {
  3825. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3826. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 154, __pyx_L3_error)
  3827. }
  3828. __pyx_v_p = values[0];
  3829. }
  3830. goto __pyx_L6_skip;
  3831. __pyx_L5_argtuple_error:;
  3832. __Pyx_RaiseArgtupleInvalid("add_implicit_on_curves", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 154, __pyx_L3_error)
  3833. __pyx_L6_skip:;
  3834. goto __pyx_L4_argument_unpacking_done;
  3835. __pyx_L3_error:;
  3836. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3837. Py_XDECREF(values[__pyx_temp]);
  3838. }
  3839. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.add_implicit_on_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3840. __Pyx_RefNannyFinishContext();
  3841. return NULL;
  3842. __pyx_L4_argument_unpacking_done:;
  3843. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves(__pyx_self, __pyx_v_p);
  3844. /* function exit code */
  3845. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3846. Py_XDECREF(values[__pyx_temp]);
  3847. }
  3848. __Pyx_RefNannyFinishContext();
  3849. return __pyx_r;
  3850. }
  3851. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_p) {
  3852. int __pyx_v_count;
  3853. int __pyx_v_num_offcurves;
  3854. int __pyx_v_i;
  3855. __pyx_t_double_complex __pyx_v_off1;
  3856. __pyx_t_double_complex __pyx_v_off2;
  3857. __pyx_t_double_complex __pyx_v_on;
  3858. PyObject *__pyx_v_q = NULL;
  3859. PyObject *__pyx_r = NULL;
  3860. __Pyx_RefNannyDeclarations
  3861. PyObject *__pyx_t_1 = NULL;
  3862. Py_ssize_t __pyx_t_2;
  3863. int __pyx_t_3;
  3864. int __pyx_t_4;
  3865. int __pyx_t_5;
  3866. __pyx_t_double_complex __pyx_t_6;
  3867. long __pyx_t_7;
  3868. int __pyx_t_8;
  3869. int __pyx_lineno = 0;
  3870. const char *__pyx_filename = NULL;
  3871. int __pyx_clineno = 0;
  3872. __Pyx_RefNannySetupContext("add_implicit_on_curves", 0);
  3873. /* "fontTools/qu2cu/qu2cu.py":163
  3874. * )
  3875. * def add_implicit_on_curves(p):
  3876. * q = list(p) # <<<<<<<<<<<<<<
  3877. * count = 0
  3878. * num_offcurves = len(p) - 2
  3879. */
  3880. __pyx_t_1 = PySequence_List(__pyx_v_p); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
  3881. __Pyx_GOTREF(__pyx_t_1);
  3882. __pyx_v_q = ((PyObject*)__pyx_t_1);
  3883. __pyx_t_1 = 0;
  3884. /* "fontTools/qu2cu/qu2cu.py":164
  3885. * def add_implicit_on_curves(p):
  3886. * q = list(p)
  3887. * count = 0 # <<<<<<<<<<<<<<
  3888. * num_offcurves = len(p) - 2
  3889. * for i in range(1, num_offcurves):
  3890. */
  3891. __pyx_v_count = 0;
  3892. /* "fontTools/qu2cu/qu2cu.py":165
  3893. * q = list(p)
  3894. * count = 0
  3895. * num_offcurves = len(p) - 2 # <<<<<<<<<<<<<<
  3896. * for i in range(1, num_offcurves):
  3897. * off1 = p[i]
  3898. */
  3899. __pyx_t_2 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 165, __pyx_L1_error)
  3900. __pyx_v_num_offcurves = (__pyx_t_2 - 2);
  3901. /* "fontTools/qu2cu/qu2cu.py":166
  3902. * count = 0
  3903. * num_offcurves = len(p) - 2
  3904. * for i in range(1, num_offcurves): # <<<<<<<<<<<<<<
  3905. * off1 = p[i]
  3906. * off2 = p[i + 1]
  3907. */
  3908. __pyx_t_3 = __pyx_v_num_offcurves;
  3909. __pyx_t_4 = __pyx_t_3;
  3910. for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
  3911. __pyx_v_i = __pyx_t_5;
  3912. /* "fontTools/qu2cu/qu2cu.py":167
  3913. * num_offcurves = len(p) - 2
  3914. * for i in range(1, num_offcurves):
  3915. * off1 = p[i] # <<<<<<<<<<<<<<
  3916. * off2 = p[i + 1]
  3917. * on = off1 + (off2 - off1) * 0.5
  3918. */
  3919. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_p, __pyx_v_i, int, 1, __Pyx_PyLong_From_int, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
  3920. __Pyx_GOTREF(__pyx_t_1);
  3921. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 167, __pyx_L1_error)
  3922. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3923. __pyx_v_off1 = __pyx_t_6;
  3924. /* "fontTools/qu2cu/qu2cu.py":168
  3925. * for i in range(1, num_offcurves):
  3926. * off1 = p[i]
  3927. * off2 = p[i + 1] # <<<<<<<<<<<<<<
  3928. * on = off1 + (off2 - off1) * 0.5
  3929. * q.insert(i + 1 + count, on)
  3930. */
  3931. __pyx_t_7 = (__pyx_v_i + 1);
  3932. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_p, __pyx_t_7, long, 1, __Pyx_PyLong_From_long, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 168, __pyx_L1_error)
  3933. __Pyx_GOTREF(__pyx_t_1);
  3934. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 168, __pyx_L1_error)
  3935. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3936. __pyx_v_off2 = __pyx_t_6;
  3937. /* "fontTools/qu2cu/qu2cu.py":169
  3938. * off1 = p[i]
  3939. * off2 = p[i + 1]
  3940. * on = off1 + (off2 - off1) * 0.5 # <<<<<<<<<<<<<<
  3941. * q.insert(i + 1 + count, on)
  3942. * count += 1
  3943. */
  3944. __pyx_v_on = __Pyx_c_sum_double(__pyx_v_off1, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_off2, __pyx_v_off1), __pyx_t_double_complex_from_parts(0.5, 0)));
  3945. /* "fontTools/qu2cu/qu2cu.py":170
  3946. * off2 = p[i + 1]
  3947. * on = off1 + (off2 - off1) * 0.5
  3948. * q.insert(i + 1 + count, on) # <<<<<<<<<<<<<<
  3949. * count += 1
  3950. * return q
  3951. */
  3952. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_on); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
  3953. __Pyx_GOTREF(__pyx_t_1);
  3954. __pyx_t_8 = PyList_Insert(__pyx_v_q, ((__pyx_v_i + 1) + __pyx_v_count), __pyx_t_1); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 170, __pyx_L1_error)
  3955. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3956. /* "fontTools/qu2cu/qu2cu.py":171
  3957. * on = off1 + (off2 - off1) * 0.5
  3958. * q.insert(i + 1 + count, on)
  3959. * count += 1 # <<<<<<<<<<<<<<
  3960. * return q
  3961. *
  3962. */
  3963. __pyx_v_count = (__pyx_v_count + 1);
  3964. }
  3965. /* "fontTools/qu2cu/qu2cu.py":172
  3966. * q.insert(i + 1 + count, on)
  3967. * count += 1
  3968. * return q # <<<<<<<<<<<<<<
  3969. *
  3970. *
  3971. */
  3972. __Pyx_XDECREF(__pyx_r);
  3973. __Pyx_INCREF(__pyx_v_q);
  3974. __pyx_r = __pyx_v_q;
  3975. goto __pyx_L0;
  3976. /* "fontTools/qu2cu/qu2cu.py":154
  3977. *
  3978. *
  3979. * @cython.locals( # <<<<<<<<<<<<<<
  3980. * count=cython.int,
  3981. * num_offcurves=cython.int,
  3982. */
  3983. /* function exit code */
  3984. __pyx_L1_error:;
  3985. __Pyx_XDECREF(__pyx_t_1);
  3986. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.add_implicit_on_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3987. __pyx_r = NULL;
  3988. __pyx_L0:;
  3989. __Pyx_XDECREF(__pyx_v_q);
  3990. __Pyx_XGIVEREF(__pyx_r);
  3991. __Pyx_RefNannyFinishContext();
  3992. return __pyx_r;
  3993. }
  3994. /* "fontTools/qu2cu/qu2cu.py":178
  3995. *
  3996. *
  3997. * @cython.locals( # <<<<<<<<<<<<<<
  3998. * cost=cython.int,
  3999. * is_complex=cython.int,
  4000. */
  4001. /* Python wrapper */
  4002. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_5quadratic_to_curves(PyObject *__pyx_self,
  4003. #if CYTHON_METH_FASTCALL
  4004. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4005. #else
  4006. PyObject *__pyx_args, PyObject *__pyx_kwds
  4007. #endif
  4008. ); /*proto*/
  4009. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_4quadratic_to_curves, "quadratic_to_curves(list quads: List[List[Point]], double max_err: float = 0.5, bool all_cubic: bool = False) -> List[Tuple[Point, ...]]\n\nConverts a connecting list of quadratic splines to a list of quadratic\nand cubic curves.\n\nA quadratic spline is specified as a list of points. Either each point is\na 2-tuple of X,Y coordinates, or each point is a complex number with\nreal/imaginary components representing X,Y coordinates.\n\nThe first and last points are on-curve points and the rest are off-curve\npoints, with an implied on-curve point in the middle between every two\nconsequtive off-curve points.\n\nReturns:\n The output is a list of tuples of points. Points are represented\n in the same format as the input, either as 2-tuples or complex numbers.\n\n Each tuple is either of length three, for a quadratic curve, or four,\n for a cubic curve. Each curve's last point is the same as the next\n curve's first point.\n\nArgs:\n quads: quadratic splines\n\n max_err: absolute error tolerance; defaults to 0.5\n\n all_cubic: if True, only cubic curves are generated; defaults to False");
  4010. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_5quadratic_to_curves = {"quadratic_to_curves", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_5quadratic_to_curves, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_4quadratic_to_curves};
  4011. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_5quadratic_to_curves(PyObject *__pyx_self,
  4012. #if CYTHON_METH_FASTCALL
  4013. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4014. #else
  4015. PyObject *__pyx_args, PyObject *__pyx_kwds
  4016. #endif
  4017. ) {
  4018. PyObject *__pyx_v_quads = 0;
  4019. double __pyx_v_max_err;
  4020. int __pyx_v_all_cubic;
  4021. #if !CYTHON_METH_FASTCALL
  4022. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  4023. #endif
  4024. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  4025. PyObject* values[3] = {0,0,0};
  4026. int __pyx_lineno = 0;
  4027. const char *__pyx_filename = NULL;
  4028. int __pyx_clineno = 0;
  4029. PyObject *__pyx_r = 0;
  4030. __Pyx_RefNannyDeclarations
  4031. __Pyx_RefNannySetupContext("quadratic_to_curves (wrapper)", 0);
  4032. #if !CYTHON_METH_FASTCALL
  4033. #if CYTHON_ASSUME_SAFE_SIZE
  4034. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  4035. #else
  4036. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  4037. #endif
  4038. #endif
  4039. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  4040. {
  4041. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_quads,&__pyx_mstate_global->__pyx_n_u_max_err,&__pyx_mstate_global->__pyx_n_u_all_cubic,0};
  4042. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  4043. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 178, __pyx_L3_error)
  4044. if (__pyx_kwds_len > 0) {
  4045. switch (__pyx_nargs) {
  4046. case 3:
  4047. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  4048. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 178, __pyx_L3_error)
  4049. CYTHON_FALLTHROUGH;
  4050. case 2:
  4051. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  4052. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 178, __pyx_L3_error)
  4053. CYTHON_FALLTHROUGH;
  4054. case 1:
  4055. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4056. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 178, __pyx_L3_error)
  4057. CYTHON_FALLTHROUGH;
  4058. case 0: break;
  4059. default: goto __pyx_L5_argtuple_error;
  4060. }
  4061. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  4062. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "quadratic_to_curves", 0) < (0)) __PYX_ERR(0, 178, __pyx_L3_error)
  4063. for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
  4064. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("quadratic_to_curves", 0, 1, 3, i); __PYX_ERR(0, 178, __pyx_L3_error) }
  4065. }
  4066. } else {
  4067. switch (__pyx_nargs) {
  4068. case 3:
  4069. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  4070. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 178, __pyx_L3_error)
  4071. CYTHON_FALLTHROUGH;
  4072. case 2:
  4073. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  4074. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 178, __pyx_L3_error)
  4075. CYTHON_FALLTHROUGH;
  4076. case 1:
  4077. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4078. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 178, __pyx_L3_error)
  4079. break;
  4080. default: goto __pyx_L5_argtuple_error;
  4081. }
  4082. }
  4083. __pyx_v_quads = ((PyObject*)values[0]);
  4084. if (values[1]) {
  4085. __pyx_v_max_err = __Pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_max_err == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L3_error)
  4086. } else {
  4087. __pyx_v_max_err = ((double)((double)0.5));
  4088. }
  4089. if (values[2]) {
  4090. __pyx_v_all_cubic = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_all_cubic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 185, __pyx_L3_error)
  4091. } else {
  4092. /* "fontTools/qu2cu/qu2cu.py":185
  4093. * quads: List[List[Point]],
  4094. * max_err: float = 0.5,
  4095. * all_cubic: bool = False, # <<<<<<<<<<<<<<
  4096. * ) -> List[Tuple[Point, ...]]:
  4097. * """Converts a connecting list of quadratic splines to a list of quadratic
  4098. */
  4099. __pyx_v_all_cubic = ((int)((int)0));
  4100. }
  4101. }
  4102. goto __pyx_L6_skip;
  4103. __pyx_L5_argtuple_error:;
  4104. __Pyx_RaiseArgtupleInvalid("quadratic_to_curves", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 178, __pyx_L3_error)
  4105. __pyx_L6_skip:;
  4106. goto __pyx_L4_argument_unpacking_done;
  4107. __pyx_L3_error:;
  4108. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4109. Py_XDECREF(values[__pyx_temp]);
  4110. }
  4111. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.quadratic_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4112. __Pyx_RefNannyFinishContext();
  4113. return NULL;
  4114. __pyx_L4_argument_unpacking_done:;
  4115. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_quads), (&PyList_Type), 0, "quads", 2))) __PYX_ERR(0, 183, __pyx_L1_error)
  4116. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_4quadratic_to_curves(__pyx_self, __pyx_v_quads, __pyx_v_max_err, __pyx_v_all_cubic);
  4117. /* "fontTools/qu2cu/qu2cu.py":178
  4118. *
  4119. *
  4120. * @cython.locals( # <<<<<<<<<<<<<<
  4121. * cost=cython.int,
  4122. * is_complex=cython.int,
  4123. */
  4124. /* function exit code */
  4125. goto __pyx_L0;
  4126. __pyx_L1_error:;
  4127. __pyx_r = NULL;
  4128. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4129. Py_XDECREF(values[__pyx_temp]);
  4130. }
  4131. goto __pyx_L7_cleaned_up;
  4132. __pyx_L0:;
  4133. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4134. Py_XDECREF(values[__pyx_temp]);
  4135. }
  4136. __pyx_L7_cleaned_up:;
  4137. __Pyx_RefNannyFinishContext();
  4138. return __pyx_r;
  4139. }
  4140. static PyObject *__pyx_gb_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
  4141. /* "fontTools/qu2cu/qu2cu.py":235
  4142. *
  4143. * if not is_complex:
  4144. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves] # <<<<<<<<<<<<<<
  4145. * return curves
  4146. *
  4147. */
  4148. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  4149. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *__pyx_cur_scope;
  4150. PyObject *__pyx_r = NULL;
  4151. __Pyx_RefNannyDeclarations
  4152. int __pyx_lineno = 0;
  4153. const char *__pyx_filename = NULL;
  4154. int __pyx_clineno = 0;
  4155. __Pyx_RefNannySetupContext("genexpr", 0);
  4156. __pyx_cur_scope = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(__pyx_mstate_global->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  4157. if (unlikely(!__pyx_cur_scope)) {
  4158. __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)Py_None);
  4159. __Pyx_INCREF(Py_None);
  4160. __PYX_ERR(0, 235, __pyx_L1_error)
  4161. } else {
  4162. __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  4163. }
  4164. __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  4165. __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  4166. __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  4167. {
  4168. __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_2generator, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_quadratic_to_curves_locals_genex, __pyx_mstate_global->__pyx_n_u_fontTools_qu2cu_qu2cu); if (unlikely(!gen)) __PYX_ERR(0, 235, __pyx_L1_error)
  4169. __Pyx_DECREF(__pyx_cur_scope);
  4170. __Pyx_RefNannyFinishContext();
  4171. return (PyObject *) gen;
  4172. }
  4173. /* function exit code */
  4174. __pyx_L1_error:;
  4175. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.quadratic_to_curves.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4176. __pyx_r = NULL;
  4177. __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  4178. __Pyx_XGIVEREF(__pyx_r);
  4179. __Pyx_RefNannyFinishContext();
  4180. return __pyx_r;
  4181. }
  4182. static PyObject *__pyx_gb_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
  4183. {
  4184. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *__pyx_cur_scope = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)__pyx_generator->closure);
  4185. PyObject *__pyx_r = NULL;
  4186. PyObject *__pyx_t_1 = NULL;
  4187. Py_ssize_t __pyx_t_2;
  4188. PyObject *(*__pyx_t_3)(PyObject *);
  4189. PyObject *__pyx_t_4 = NULL;
  4190. PyObject *__pyx_t_5 = NULL;
  4191. PyObject *__pyx_t_6 = NULL;
  4192. int __pyx_lineno = 0;
  4193. const char *__pyx_filename = NULL;
  4194. int __pyx_clineno = 0;
  4195. __Pyx_RefNannyDeclarations
  4196. __Pyx_RefNannySetupContext("genexpr", 0);
  4197. switch (__pyx_generator->resume_label) {
  4198. case 0: goto __pyx_L3_first_run;
  4199. case 1: goto __pyx_L6_resume_from_yield;
  4200. default: /* CPython raises the right error here */
  4201. __Pyx_RefNannyFinishContext();
  4202. return NULL;
  4203. }
  4204. __pyx_L3_first_run:;
  4205. if (unlikely(__pyx_sent_value != Py_None)) {
  4206. if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started generator");
  4207. __PYX_ERR(0, 235, __pyx_L1_error)
  4208. }
  4209. if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 235, __pyx_L1_error) }
  4210. if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
  4211. __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
  4212. __pyx_t_2 = 0;
  4213. __pyx_t_3 = NULL;
  4214. } else {
  4215. __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
  4216. __Pyx_GOTREF(__pyx_t_1);
  4217. __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __pyx_L1_error)
  4218. }
  4219. for (;;) {
  4220. if (likely(!__pyx_t_3)) {
  4221. if (likely(PyList_CheckExact(__pyx_t_1))) {
  4222. {
  4223. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
  4224. #if !CYTHON_ASSUME_SAFE_SIZE
  4225. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 235, __pyx_L1_error)
  4226. #endif
  4227. if (__pyx_t_2 >= __pyx_temp) break;
  4228. }
  4229. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
  4230. ++__pyx_t_2;
  4231. } else {
  4232. {
  4233. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
  4234. #if !CYTHON_ASSUME_SAFE_SIZE
  4235. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 235, __pyx_L1_error)
  4236. #endif
  4237. if (__pyx_t_2 >= __pyx_temp) break;
  4238. }
  4239. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4240. __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
  4241. #else
  4242. __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
  4243. #endif
  4244. ++__pyx_t_2;
  4245. }
  4246. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L1_error)
  4247. } else {
  4248. __pyx_t_4 = __pyx_t_3(__pyx_t_1);
  4249. if (unlikely(!__pyx_t_4)) {
  4250. PyObject* exc_type = PyErr_Occurred();
  4251. if (exc_type) {
  4252. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 235, __pyx_L1_error)
  4253. PyErr_Clear();
  4254. }
  4255. break;
  4256. }
  4257. }
  4258. __Pyx_GOTREF(__pyx_t_4);
  4259. __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_c);
  4260. __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_c, __pyx_t_4);
  4261. __Pyx_GIVEREF(__pyx_t_4);
  4262. __pyx_t_4 = 0;
  4263. __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_c, __pyx_mstate_global->__pyx_n_u_real); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 235, __pyx_L1_error)
  4264. __Pyx_GOTREF(__pyx_t_4);
  4265. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_c, __pyx_mstate_global->__pyx_n_u_imag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L1_error)
  4266. __Pyx_GOTREF(__pyx_t_5);
  4267. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 235, __pyx_L1_error)
  4268. __Pyx_GOTREF(__pyx_t_6);
  4269. __Pyx_GIVEREF(__pyx_t_4);
  4270. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 235, __pyx_L1_error);
  4271. __Pyx_GIVEREF(__pyx_t_5);
  4272. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 235, __pyx_L1_error);
  4273. __pyx_t_4 = 0;
  4274. __pyx_t_5 = 0;
  4275. __pyx_r = __pyx_t_6;
  4276. __pyx_t_6 = 0;
  4277. __Pyx_XGIVEREF(__pyx_t_1);
  4278. __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
  4279. __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
  4280. __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
  4281. __Pyx_XGIVEREF(__pyx_r);
  4282. __Pyx_RefNannyFinishContext();
  4283. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4284. /* return from generator, yielding value */
  4285. __pyx_generator->resume_label = 1;
  4286. return __pyx_r;
  4287. __pyx_L6_resume_from_yield:;
  4288. __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
  4289. __pyx_cur_scope->__pyx_t_0 = 0;
  4290. __Pyx_XGOTREF(__pyx_t_1);
  4291. __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
  4292. __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
  4293. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 235, __pyx_L1_error)
  4294. }
  4295. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4296. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  4297. /* function exit code */
  4298. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4299. goto __pyx_L0;
  4300. __pyx_L1_error:;
  4301. __Pyx_XDECREF(__pyx_t_1);
  4302. __Pyx_XDECREF(__pyx_t_4);
  4303. __Pyx_XDECREF(__pyx_t_5);
  4304. __Pyx_XDECREF(__pyx_t_6);
  4305. if (__Pyx_PyErr_Occurred()) {
  4306. __Pyx_Generator_Replace_StopIteration(0);
  4307. __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4308. }
  4309. __pyx_L0:;
  4310. __Pyx_XGIVEREF(__pyx_r);
  4311. #if !CYTHON_USE_EXC_INFO_STACK
  4312. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4313. #endif
  4314. __pyx_generator->resume_label = -1;
  4315. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  4316. __Pyx_RefNannyFinishContext();
  4317. return __pyx_r;
  4318. }
  4319. /* "fontTools/qu2cu/qu2cu.py":178
  4320. *
  4321. *
  4322. * @cython.locals( # <<<<<<<<<<<<<<
  4323. * cost=cython.int,
  4324. * is_complex=cython.int,
  4325. */
  4326. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_4quadratic_to_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_quads, double __pyx_v_max_err, int __pyx_v_all_cubic) {
  4327. int __pyx_v_cost;
  4328. int __pyx_v_is_complex;
  4329. PyObject *__pyx_v_q = NULL;
  4330. PyObject *__pyx_v_costs = NULL;
  4331. PyObject *__pyx_v_p = NULL;
  4332. CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  4333. PyObject *__pyx_v_qq = NULL;
  4334. PyObject *__pyx_v_curves = NULL;
  4335. PyObject *__pyx_8genexpr1__pyx_v_p = NULL;
  4336. PyObject *__pyx_8genexpr2__pyx_v_x = NULL;
  4337. PyObject *__pyx_8genexpr2__pyx_v_y = NULL;
  4338. PyObject *__pyx_8genexpr3__pyx_v_curve = NULL;
  4339. PyObject *__pyx_8genexpr3__pyx_v_0 = NULL;
  4340. PyObject *__pyx_r = NULL;
  4341. __Pyx_RefNannyDeclarations
  4342. PyObject *__pyx_t_1 = NULL;
  4343. PyObject *__pyx_t_2 = NULL;
  4344. int __pyx_t_3;
  4345. Py_ssize_t __pyx_t_4;
  4346. PyObject *__pyx_t_5 = NULL;
  4347. PyObject *__pyx_t_6 = NULL;
  4348. Py_ssize_t __pyx_t_7;
  4349. PyObject *(*__pyx_t_8)(PyObject *);
  4350. PyObject *__pyx_t_9 = NULL;
  4351. PyObject *__pyx_t_10 = NULL;
  4352. PyObject *__pyx_t_11 = NULL;
  4353. PyObject *__pyx_t_12 = NULL;
  4354. PyObject *(*__pyx_t_13)(PyObject *);
  4355. size_t __pyx_t_14;
  4356. Py_ssize_t __pyx_t_15;
  4357. Py_ssize_t __pyx_t_16;
  4358. int __pyx_t_17;
  4359. int __pyx_lineno = 0;
  4360. const char *__pyx_filename = NULL;
  4361. int __pyx_clineno = 0;
  4362. __Pyx_RefNannySetupContext("quadratic_to_curves", 0);
  4363. __Pyx_INCREF(__pyx_v_quads);
  4364. /* "fontTools/qu2cu/qu2cu.py":213
  4365. * all_cubic: if True, only cubic curves are generated; defaults to False
  4366. * """
  4367. * is_complex = type(quads[0][0]) is complex # <<<<<<<<<<<<<<
  4368. * if not is_complex:
  4369. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  4370. */
  4371. __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_quads, 0, long, 1, __Pyx_PyLong_From_long, 1, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error)
  4372. __Pyx_GOTREF(__pyx_t_1);
  4373. __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  4374. __Pyx_GOTREF(__pyx_t_2);
  4375. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4376. __pyx_t_3 = (((PyObject *)Py_TYPE(__pyx_t_2)) == ((PyObject *)(&PyComplex_Type)));
  4377. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4378. __pyx_v_is_complex = __pyx_t_3;
  4379. /* "fontTools/qu2cu/qu2cu.py":214
  4380. * """
  4381. * is_complex = type(quads[0][0]) is complex
  4382. * if not is_complex: # <<<<<<<<<<<<<<
  4383. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  4384. *
  4385. */
  4386. __pyx_t_3 = (!(__pyx_v_is_complex != 0));
  4387. if (__pyx_t_3) {
  4388. /* "fontTools/qu2cu/qu2cu.py":215
  4389. * is_complex = type(quads[0][0]) is complex
  4390. * if not is_complex:
  4391. * quads = [[complex(x, y) for (x, y) in p] for p in quads] # <<<<<<<<<<<<<<
  4392. *
  4393. * q = [quads[0][0]]
  4394. */
  4395. { /* enter inner scope */
  4396. __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L6_error)
  4397. __Pyx_GOTREF(__pyx_t_2);
  4398. __pyx_t_1 = __pyx_v_quads; __Pyx_INCREF(__pyx_t_1);
  4399. __pyx_t_4 = 0;
  4400. for (;;) {
  4401. {
  4402. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
  4403. #if !CYTHON_ASSUME_SAFE_SIZE
  4404. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 215, __pyx_L6_error)
  4405. #endif
  4406. if (__pyx_t_4 >= __pyx_temp) break;
  4407. }
  4408. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_1, __pyx_t_4, __Pyx_ReferenceSharing_OwnStrongReference);
  4409. ++__pyx_t_4;
  4410. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 215, __pyx_L6_error)
  4411. __Pyx_GOTREF(__pyx_t_5);
  4412. __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_p, __pyx_t_5);
  4413. __pyx_t_5 = 0;
  4414. { /* enter inner scope */
  4415. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 215, __pyx_L11_error)
  4416. __Pyx_GOTREF(__pyx_t_5);
  4417. if (likely(PyList_CheckExact(__pyx_8genexpr1__pyx_v_p)) || PyTuple_CheckExact(__pyx_8genexpr1__pyx_v_p)) {
  4418. __pyx_t_6 = __pyx_8genexpr1__pyx_v_p; __Pyx_INCREF(__pyx_t_6);
  4419. __pyx_t_7 = 0;
  4420. __pyx_t_8 = NULL;
  4421. } else {
  4422. __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr1__pyx_v_p); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 215, __pyx_L11_error)
  4423. __Pyx_GOTREF(__pyx_t_6);
  4424. __pyx_t_8 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 215, __pyx_L11_error)
  4425. }
  4426. for (;;) {
  4427. if (likely(!__pyx_t_8)) {
  4428. if (likely(PyList_CheckExact(__pyx_t_6))) {
  4429. {
  4430. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  4431. #if !CYTHON_ASSUME_SAFE_SIZE
  4432. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 215, __pyx_L11_error)
  4433. #endif
  4434. if (__pyx_t_7 >= __pyx_temp) break;
  4435. }
  4436. __pyx_t_9 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_7, __Pyx_ReferenceSharing_OwnStrongReference);
  4437. ++__pyx_t_7;
  4438. } else {
  4439. {
  4440. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  4441. #if !CYTHON_ASSUME_SAFE_SIZE
  4442. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 215, __pyx_L11_error)
  4443. #endif
  4444. if (__pyx_t_7 >= __pyx_temp) break;
  4445. }
  4446. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4447. __pyx_t_9 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7));
  4448. #else
  4449. __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7);
  4450. #endif
  4451. ++__pyx_t_7;
  4452. }
  4453. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 215, __pyx_L11_error)
  4454. } else {
  4455. __pyx_t_9 = __pyx_t_8(__pyx_t_6);
  4456. if (unlikely(!__pyx_t_9)) {
  4457. PyObject* exc_type = PyErr_Occurred();
  4458. if (exc_type) {
  4459. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 215, __pyx_L11_error)
  4460. PyErr_Clear();
  4461. }
  4462. break;
  4463. }
  4464. }
  4465. __Pyx_GOTREF(__pyx_t_9);
  4466. if ((likely(PyTuple_CheckExact(__pyx_t_9))) || (PyList_CheckExact(__pyx_t_9))) {
  4467. PyObject* sequence = __pyx_t_9;
  4468. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  4469. if (unlikely(size != 2)) {
  4470. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  4471. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  4472. __PYX_ERR(0, 215, __pyx_L11_error)
  4473. }
  4474. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4475. if (likely(PyTuple_CheckExact(sequence))) {
  4476. __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0);
  4477. __Pyx_INCREF(__pyx_t_10);
  4478. __pyx_t_11 = PyTuple_GET_ITEM(sequence, 1);
  4479. __Pyx_INCREF(__pyx_t_11);
  4480. } else {
  4481. __pyx_t_10 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  4482. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 215, __pyx_L11_error)
  4483. __Pyx_XGOTREF(__pyx_t_10);
  4484. __pyx_t_11 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  4485. if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 215, __pyx_L11_error)
  4486. __Pyx_XGOTREF(__pyx_t_11);
  4487. }
  4488. #else
  4489. __pyx_t_10 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 215, __pyx_L11_error)
  4490. __Pyx_GOTREF(__pyx_t_10);
  4491. __pyx_t_11 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 215, __pyx_L11_error)
  4492. __Pyx_GOTREF(__pyx_t_11);
  4493. #endif
  4494. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4495. } else {
  4496. Py_ssize_t index = -1;
  4497. __pyx_t_12 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 215, __pyx_L11_error)
  4498. __Pyx_GOTREF(__pyx_t_12);
  4499. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4500. __pyx_t_13 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_12);
  4501. index = 0; __pyx_t_10 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_10)) goto __pyx_L14_unpacking_failed;
  4502. __Pyx_GOTREF(__pyx_t_10);
  4503. index = 1; __pyx_t_11 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_11)) goto __pyx_L14_unpacking_failed;
  4504. __Pyx_GOTREF(__pyx_t_11);
  4505. if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < (0)) __PYX_ERR(0, 215, __pyx_L11_error)
  4506. __pyx_t_13 = NULL;
  4507. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4508. goto __pyx_L15_unpacking_done;
  4509. __pyx_L14_unpacking_failed:;
  4510. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4511. __pyx_t_13 = NULL;
  4512. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  4513. __PYX_ERR(0, 215, __pyx_L11_error)
  4514. __pyx_L15_unpacking_done:;
  4515. }
  4516. __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_x, __pyx_t_10);
  4517. __pyx_t_10 = 0;
  4518. __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_y, __pyx_t_11);
  4519. __pyx_t_11 = 0;
  4520. __pyx_t_11 = NULL;
  4521. __pyx_t_14 = 1;
  4522. {
  4523. PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_8genexpr2__pyx_v_x, __pyx_8genexpr2__pyx_v_y};
  4524. __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)(&PyComplex_Type), __pyx_callargs+__pyx_t_14, (3-__pyx_t_14) | (__pyx_t_14*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4525. __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
  4526. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 215, __pyx_L11_error)
  4527. __Pyx_GOTREF(__pyx_t_9);
  4528. }
  4529. if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 215, __pyx_L11_error)
  4530. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4531. }
  4532. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4533. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_x); __pyx_8genexpr2__pyx_v_x = 0;
  4534. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_y); __pyx_8genexpr2__pyx_v_y = 0;
  4535. goto __pyx_L17_exit_scope;
  4536. __pyx_L11_error:;
  4537. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_x); __pyx_8genexpr2__pyx_v_x = 0;
  4538. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_y); __pyx_8genexpr2__pyx_v_y = 0;
  4539. goto __pyx_L6_error;
  4540. __pyx_L17_exit_scope:;
  4541. } /* exit inner scope */
  4542. if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 215, __pyx_L6_error)
  4543. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4544. }
  4545. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4546. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_p); __pyx_8genexpr1__pyx_v_p = 0;
  4547. goto __pyx_L19_exit_scope;
  4548. __pyx_L6_error:;
  4549. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_p); __pyx_8genexpr1__pyx_v_p = 0;
  4550. goto __pyx_L1_error;
  4551. __pyx_L19_exit_scope:;
  4552. } /* exit inner scope */
  4553. __Pyx_DECREF_SET(__pyx_v_quads, ((PyObject*)__pyx_t_2));
  4554. __pyx_t_2 = 0;
  4555. /* "fontTools/qu2cu/qu2cu.py":214
  4556. * """
  4557. * is_complex = type(quads[0][0]) is complex
  4558. * if not is_complex: # <<<<<<<<<<<<<<
  4559. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  4560. *
  4561. */
  4562. }
  4563. /* "fontTools/qu2cu/qu2cu.py":217
  4564. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  4565. *
  4566. * q = [quads[0][0]] # <<<<<<<<<<<<<<
  4567. * costs = [1]
  4568. * cost = 1
  4569. */
  4570. __pyx_t_2 = __Pyx_GetItemInt_List(__pyx_v_quads, 0, long, 1, __Pyx_PyLong_From_long, 1, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error)
  4571. __Pyx_GOTREF(__pyx_t_2);
  4572. __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error)
  4573. __Pyx_GOTREF(__pyx_t_1);
  4574. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4575. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error)
  4576. __Pyx_GOTREF(__pyx_t_2);
  4577. __Pyx_GIVEREF(__pyx_t_1);
  4578. if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 217, __pyx_L1_error);
  4579. __pyx_t_1 = 0;
  4580. __pyx_v_q = ((PyObject*)__pyx_t_2);
  4581. __pyx_t_2 = 0;
  4582. /* "fontTools/qu2cu/qu2cu.py":218
  4583. *
  4584. * q = [quads[0][0]]
  4585. * costs = [1] # <<<<<<<<<<<<<<
  4586. * cost = 1
  4587. * for p in quads:
  4588. */
  4589. __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error)
  4590. __Pyx_GOTREF(__pyx_t_2);
  4591. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  4592. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
  4593. if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 218, __pyx_L1_error);
  4594. __pyx_v_costs = ((PyObject*)__pyx_t_2);
  4595. __pyx_t_2 = 0;
  4596. /* "fontTools/qu2cu/qu2cu.py":219
  4597. * q = [quads[0][0]]
  4598. * costs = [1]
  4599. * cost = 1 # <<<<<<<<<<<<<<
  4600. * for p in quads:
  4601. * assert q[-1] == p[0]
  4602. */
  4603. __pyx_v_cost = 1;
  4604. /* "fontTools/qu2cu/qu2cu.py":220
  4605. * costs = [1]
  4606. * cost = 1
  4607. * for p in quads: # <<<<<<<<<<<<<<
  4608. * assert q[-1] == p[0]
  4609. * for i in range(len(p) - 2):
  4610. */
  4611. __pyx_t_2 = __pyx_v_quads; __Pyx_INCREF(__pyx_t_2);
  4612. __pyx_t_4 = 0;
  4613. for (;;) {
  4614. {
  4615. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
  4616. #if !CYTHON_ASSUME_SAFE_SIZE
  4617. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 220, __pyx_L1_error)
  4618. #endif
  4619. if (__pyx_t_4 >= __pyx_temp) break;
  4620. }
  4621. __pyx_t_1 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_4, __Pyx_ReferenceSharing_OwnStrongReference);
  4622. ++__pyx_t_4;
  4623. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 220, __pyx_L1_error)
  4624. __Pyx_GOTREF(__pyx_t_1);
  4625. __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_1);
  4626. __pyx_t_1 = 0;
  4627. /* "fontTools/qu2cu/qu2cu.py":221
  4628. * cost = 1
  4629. * for p in quads:
  4630. * assert q[-1] == p[0] # <<<<<<<<<<<<<<
  4631. * for i in range(len(p) - 2):
  4632. * cost += 1
  4633. */
  4634. #ifndef CYTHON_WITHOUT_ASSERTIONS
  4635. if (unlikely(__pyx_assertions_enabled())) {
  4636. __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_q, -1L, long, 1, __Pyx_PyLong_From_long, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error)
  4637. __Pyx_GOTREF(__pyx_t_1);
  4638. __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_p, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 221, __pyx_L1_error)
  4639. __Pyx_GOTREF(__pyx_t_5);
  4640. __pyx_t_6 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 221, __pyx_L1_error)
  4641. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4642. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4643. __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 221, __pyx_L1_error)
  4644. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4645. if (unlikely(!__pyx_t_3)) {
  4646. __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_AssertionError))), 0, 0, 0);
  4647. __PYX_ERR(0, 221, __pyx_L1_error)
  4648. }
  4649. }
  4650. #else
  4651. if ((1)); else __PYX_ERR(0, 221, __pyx_L1_error)
  4652. #endif
  4653. /* "fontTools/qu2cu/qu2cu.py":222
  4654. * for p in quads:
  4655. * assert q[-1] == p[0]
  4656. * for i in range(len(p) - 2): # <<<<<<<<<<<<<<
  4657. * cost += 1
  4658. * costs.append(cost)
  4659. */
  4660. __pyx_t_7 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 222, __pyx_L1_error)
  4661. __pyx_t_15 = (__pyx_t_7 - 2);
  4662. __pyx_t_7 = __pyx_t_15;
  4663. for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_7; __pyx_t_16+=1) {
  4664. __pyx_v_i = __pyx_t_16;
  4665. /* "fontTools/qu2cu/qu2cu.py":223
  4666. * assert q[-1] == p[0]
  4667. * for i in range(len(p) - 2):
  4668. * cost += 1 # <<<<<<<<<<<<<<
  4669. * costs.append(cost)
  4670. * costs.append(cost)
  4671. */
  4672. __pyx_v_cost = (__pyx_v_cost + 1);
  4673. /* "fontTools/qu2cu/qu2cu.py":224
  4674. * for i in range(len(p) - 2):
  4675. * cost += 1
  4676. * costs.append(cost) # <<<<<<<<<<<<<<
  4677. * costs.append(cost)
  4678. * qq = add_implicit_on_curves(p)[1:]
  4679. */
  4680. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_cost); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 224, __pyx_L1_error)
  4681. __Pyx_GOTREF(__pyx_t_6);
  4682. __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_costs, __pyx_t_6); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 224, __pyx_L1_error)
  4683. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4684. /* "fontTools/qu2cu/qu2cu.py":225
  4685. * cost += 1
  4686. * costs.append(cost)
  4687. * costs.append(cost) # <<<<<<<<<<<<<<
  4688. * qq = add_implicit_on_curves(p)[1:]
  4689. * costs.pop()
  4690. */
  4691. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_cost); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 225, __pyx_L1_error)
  4692. __Pyx_GOTREF(__pyx_t_6);
  4693. __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_costs, __pyx_t_6); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 225, __pyx_L1_error)
  4694. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4695. }
  4696. /* "fontTools/qu2cu/qu2cu.py":226
  4697. * costs.append(cost)
  4698. * costs.append(cost)
  4699. * qq = add_implicit_on_curves(p)[1:] # <<<<<<<<<<<<<<
  4700. * costs.pop()
  4701. * q.extend(qq)
  4702. */
  4703. __pyx_t_5 = NULL;
  4704. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_add_implicit_on_curves); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
  4705. __Pyx_GOTREF(__pyx_t_1);
  4706. __pyx_t_14 = 1;
  4707. #if CYTHON_UNPACK_METHODS
  4708. if (unlikely(PyMethod_Check(__pyx_t_1))) {
  4709. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
  4710. assert(__pyx_t_5);
  4711. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
  4712. __Pyx_INCREF(__pyx_t_5);
  4713. __Pyx_INCREF(__pyx__function);
  4714. __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
  4715. __pyx_t_14 = 0;
  4716. }
  4717. #endif
  4718. {
  4719. PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_p};
  4720. __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_14, (2-__pyx_t_14) | (__pyx_t_14*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4721. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  4722. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4723. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 226, __pyx_L1_error)
  4724. __Pyx_GOTREF(__pyx_t_6);
  4725. }
  4726. __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_6, 1, 0, NULL, NULL, &__pyx_mstate_global->__pyx_slice[0], 1, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error)
  4727. __Pyx_GOTREF(__pyx_t_1);
  4728. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4729. __Pyx_XDECREF_SET(__pyx_v_qq, __pyx_t_1);
  4730. __pyx_t_1 = 0;
  4731. /* "fontTools/qu2cu/qu2cu.py":227
  4732. * costs.append(cost)
  4733. * qq = add_implicit_on_curves(p)[1:]
  4734. * costs.pop() # <<<<<<<<<<<<<<
  4735. * q.extend(qq)
  4736. * cost += 1
  4737. */
  4738. __pyx_t_1 = __Pyx_PyList_Pop(__pyx_v_costs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 227, __pyx_L1_error)
  4739. __Pyx_GOTREF(__pyx_t_1);
  4740. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4741. /* "fontTools/qu2cu/qu2cu.py":228
  4742. * qq = add_implicit_on_curves(p)[1:]
  4743. * costs.pop()
  4744. * q.extend(qq) # <<<<<<<<<<<<<<
  4745. * cost += 1
  4746. * costs.append(cost)
  4747. */
  4748. __pyx_t_17 = __Pyx_PyList_Extend(__pyx_v_q, __pyx_v_qq); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 228, __pyx_L1_error)
  4749. /* "fontTools/qu2cu/qu2cu.py":229
  4750. * costs.pop()
  4751. * q.extend(qq)
  4752. * cost += 1 # <<<<<<<<<<<<<<
  4753. * costs.append(cost)
  4754. *
  4755. */
  4756. __pyx_v_cost = (__pyx_v_cost + 1);
  4757. /* "fontTools/qu2cu/qu2cu.py":230
  4758. * q.extend(qq)
  4759. * cost += 1
  4760. * costs.append(cost) # <<<<<<<<<<<<<<
  4761. *
  4762. * curves = spline_to_curves(q, costs, max_err, all_cubic)
  4763. */
  4764. __pyx_t_1 = __Pyx_PyLong_From_int(__pyx_v_cost); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error)
  4765. __Pyx_GOTREF(__pyx_t_1);
  4766. __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_costs, __pyx_t_1); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 230, __pyx_L1_error)
  4767. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4768. /* "fontTools/qu2cu/qu2cu.py":220
  4769. * costs = [1]
  4770. * cost = 1
  4771. * for p in quads: # <<<<<<<<<<<<<<
  4772. * assert q[-1] == p[0]
  4773. * for i in range(len(p) - 2):
  4774. */
  4775. }
  4776. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4777. /* "fontTools/qu2cu/qu2cu.py":232
  4778. * costs.append(cost)
  4779. *
  4780. * curves = spline_to_curves(q, costs, max_err, all_cubic) # <<<<<<<<<<<<<<
  4781. *
  4782. * if not is_complex:
  4783. */
  4784. __pyx_t_1 = NULL;
  4785. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_spline_to_curves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 232, __pyx_L1_error)
  4786. __Pyx_GOTREF(__pyx_t_6);
  4787. __pyx_t_5 = PyFloat_FromDouble(__pyx_v_max_err); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 232, __pyx_L1_error)
  4788. __Pyx_GOTREF(__pyx_t_5);
  4789. __pyx_t_9 = __Pyx_PyBool_FromLong(__pyx_v_all_cubic); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 232, __pyx_L1_error)
  4790. __Pyx_GOTREF(__pyx_t_9);
  4791. __pyx_t_14 = 1;
  4792. #if CYTHON_UNPACK_METHODS
  4793. if (unlikely(PyMethod_Check(__pyx_t_6))) {
  4794. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
  4795. assert(__pyx_t_1);
  4796. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
  4797. __Pyx_INCREF(__pyx_t_1);
  4798. __Pyx_INCREF(__pyx__function);
  4799. __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
  4800. __pyx_t_14 = 0;
  4801. }
  4802. #endif
  4803. {
  4804. PyObject *__pyx_callargs[5] = {__pyx_t_1, __pyx_v_q, __pyx_v_costs, __pyx_t_5, __pyx_t_9};
  4805. __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_14, (5-__pyx_t_14) | (__pyx_t_14*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4806. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4807. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4808. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4809. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4810. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 232, __pyx_L1_error)
  4811. __Pyx_GOTREF(__pyx_t_2);
  4812. }
  4813. __pyx_v_curves = __pyx_t_2;
  4814. __pyx_t_2 = 0;
  4815. /* "fontTools/qu2cu/qu2cu.py":234
  4816. * curves = spline_to_curves(q, costs, max_err, all_cubic)
  4817. *
  4818. * if not is_complex: # <<<<<<<<<<<<<<
  4819. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves]
  4820. * return curves
  4821. */
  4822. __pyx_t_3 = (!(__pyx_v_is_complex != 0));
  4823. if (__pyx_t_3) {
  4824. /* "fontTools/qu2cu/qu2cu.py":235
  4825. *
  4826. * if not is_complex:
  4827. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves] # <<<<<<<<<<<<<<
  4828. * return curves
  4829. *
  4830. */
  4831. { /* enter inner scope */
  4832. __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L28_error)
  4833. __Pyx_GOTREF(__pyx_t_2);
  4834. if (likely(PyList_CheckExact(__pyx_v_curves)) || PyTuple_CheckExact(__pyx_v_curves)) {
  4835. __pyx_t_6 = __pyx_v_curves; __Pyx_INCREF(__pyx_t_6);
  4836. __pyx_t_4 = 0;
  4837. __pyx_t_8 = NULL;
  4838. } else {
  4839. __pyx_t_4 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_curves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 235, __pyx_L28_error)
  4840. __Pyx_GOTREF(__pyx_t_6);
  4841. __pyx_t_8 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 235, __pyx_L28_error)
  4842. }
  4843. for (;;) {
  4844. if (likely(!__pyx_t_8)) {
  4845. if (likely(PyList_CheckExact(__pyx_t_6))) {
  4846. {
  4847. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  4848. #if !CYTHON_ASSUME_SAFE_SIZE
  4849. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 235, __pyx_L28_error)
  4850. #endif
  4851. if (__pyx_t_4 >= __pyx_temp) break;
  4852. }
  4853. __pyx_t_9 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_4, __Pyx_ReferenceSharing_OwnStrongReference);
  4854. ++__pyx_t_4;
  4855. } else {
  4856. {
  4857. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  4858. #if !CYTHON_ASSUME_SAFE_SIZE
  4859. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 235, __pyx_L28_error)
  4860. #endif
  4861. if (__pyx_t_4 >= __pyx_temp) break;
  4862. }
  4863. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4864. __pyx_t_9 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_4));
  4865. #else
  4866. __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_4);
  4867. #endif
  4868. ++__pyx_t_4;
  4869. }
  4870. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 235, __pyx_L28_error)
  4871. } else {
  4872. __pyx_t_9 = __pyx_t_8(__pyx_t_6);
  4873. if (unlikely(!__pyx_t_9)) {
  4874. PyObject* exc_type = PyErr_Occurred();
  4875. if (exc_type) {
  4876. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 235, __pyx_L28_error)
  4877. PyErr_Clear();
  4878. }
  4879. break;
  4880. }
  4881. }
  4882. __Pyx_GOTREF(__pyx_t_9);
  4883. __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_curve, __pyx_t_9);
  4884. __pyx_t_9 = 0;
  4885. __pyx_t_9 = __pyx_pf_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_genexpr(NULL, __pyx_8genexpr3__pyx_v_curve); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 235, __pyx_L28_error)
  4886. __Pyx_GOTREF(__pyx_t_9);
  4887. __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L28_error)
  4888. __Pyx_GOTREF(__pyx_t_5);
  4889. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4890. if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 235, __pyx_L28_error)
  4891. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4892. }
  4893. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4894. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_curve); __pyx_8genexpr3__pyx_v_curve = 0;
  4895. goto __pyx_L32_exit_scope;
  4896. __pyx_L28_error:;
  4897. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_curve); __pyx_8genexpr3__pyx_v_curve = 0;
  4898. goto __pyx_L1_error;
  4899. __pyx_L32_exit_scope:;
  4900. } /* exit inner scope */
  4901. __Pyx_DECREF_SET(__pyx_v_curves, __pyx_t_2);
  4902. __pyx_t_2 = 0;
  4903. /* "fontTools/qu2cu/qu2cu.py":234
  4904. * curves = spline_to_curves(q, costs, max_err, all_cubic)
  4905. *
  4906. * if not is_complex: # <<<<<<<<<<<<<<
  4907. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves]
  4908. * return curves
  4909. */
  4910. }
  4911. /* "fontTools/qu2cu/qu2cu.py":236
  4912. * if not is_complex:
  4913. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves]
  4914. * return curves # <<<<<<<<<<<<<<
  4915. *
  4916. *
  4917. */
  4918. __Pyx_XDECREF(__pyx_r);
  4919. __pyx_t_2 = __pyx_v_curves;
  4920. __Pyx_INCREF(__pyx_t_2);
  4921. if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_2))) __PYX_ERR(0, 236, __pyx_L1_error)
  4922. __pyx_r = ((PyObject*)__pyx_t_2);
  4923. __pyx_t_2 = 0;
  4924. goto __pyx_L0;
  4925. /* "fontTools/qu2cu/qu2cu.py":178
  4926. *
  4927. *
  4928. * @cython.locals( # <<<<<<<<<<<<<<
  4929. * cost=cython.int,
  4930. * is_complex=cython.int,
  4931. */
  4932. /* function exit code */
  4933. __pyx_L1_error:;
  4934. __Pyx_XDECREF(__pyx_t_1);
  4935. __Pyx_XDECREF(__pyx_t_2);
  4936. __Pyx_XDECREF(__pyx_t_5);
  4937. __Pyx_XDECREF(__pyx_t_6);
  4938. __Pyx_XDECREF(__pyx_t_9);
  4939. __Pyx_XDECREF(__pyx_t_10);
  4940. __Pyx_XDECREF(__pyx_t_11);
  4941. __Pyx_XDECREF(__pyx_t_12);
  4942. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.quadratic_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4943. __pyx_r = NULL;
  4944. __pyx_L0:;
  4945. __Pyx_XDECREF(__pyx_v_q);
  4946. __Pyx_XDECREF(__pyx_v_costs);
  4947. __Pyx_XDECREF(__pyx_v_p);
  4948. __Pyx_XDECREF(__pyx_v_qq);
  4949. __Pyx_XDECREF(__pyx_v_curves);
  4950. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_p);
  4951. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_x);
  4952. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_y);
  4953. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_curve);
  4954. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_0);
  4955. __Pyx_XDECREF(__pyx_v_quads);
  4956. __Pyx_XGIVEREF(__pyx_r);
  4957. __Pyx_RefNannyFinishContext();
  4958. return __pyx_r;
  4959. }
  4960. /* "fontTools/qu2cu/qu2cu.py":242
  4961. *
  4962. *
  4963. * @cython.locals( # <<<<<<<<<<<<<<
  4964. * i=cython.int,
  4965. * j=cython.int,
  4966. */
  4967. /* Python wrapper */
  4968. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_7spline_to_curves(PyObject *__pyx_self,
  4969. #if CYTHON_METH_FASTCALL
  4970. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4971. #else
  4972. PyObject *__pyx_args, PyObject *__pyx_kwds
  4973. #endif
  4974. ); /*proto*/
  4975. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_6spline_to_curves, "spline_to_curves(q, costs, double tolerance=0.5, int all_cubic=False)\n\nq: quadratic spline with alternating on-curve / off-curve points.\n\ncosts: cumulative list of encoding cost of q in terms of number of\n points that need to be encoded. Implied on-curve points do not\n contribute to the cost. If all points need to be encoded, then\n costs will be range(1, len(q)+1).");
  4976. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_7spline_to_curves = {"spline_to_curves", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_7spline_to_curves, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_6spline_to_curves};
  4977. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_7spline_to_curves(PyObject *__pyx_self,
  4978. #if CYTHON_METH_FASTCALL
  4979. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4980. #else
  4981. PyObject *__pyx_args, PyObject *__pyx_kwds
  4982. #endif
  4983. ) {
  4984. PyObject *__pyx_v_q = 0;
  4985. PyObject *__pyx_v_costs = 0;
  4986. double __pyx_v_tolerance;
  4987. int __pyx_v_all_cubic;
  4988. #if !CYTHON_METH_FASTCALL
  4989. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  4990. #endif
  4991. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  4992. PyObject* values[4] = {0,0,0,0};
  4993. int __pyx_lineno = 0;
  4994. const char *__pyx_filename = NULL;
  4995. int __pyx_clineno = 0;
  4996. PyObject *__pyx_r = 0;
  4997. __Pyx_RefNannyDeclarations
  4998. __Pyx_RefNannySetupContext("spline_to_curves (wrapper)", 0);
  4999. #if !CYTHON_METH_FASTCALL
  5000. #if CYTHON_ASSUME_SAFE_SIZE
  5001. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  5002. #else
  5003. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  5004. #endif
  5005. #endif
  5006. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  5007. {
  5008. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_q,&__pyx_mstate_global->__pyx_n_u_costs,&__pyx_mstate_global->__pyx_n_u_tolerance,&__pyx_mstate_global->__pyx_n_u_all_cubic,0};
  5009. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  5010. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 242, __pyx_L3_error)
  5011. if (__pyx_kwds_len > 0) {
  5012. switch (__pyx_nargs) {
  5013. case 4:
  5014. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  5015. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 242, __pyx_L3_error)
  5016. CYTHON_FALLTHROUGH;
  5017. case 3:
  5018. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5019. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 242, __pyx_L3_error)
  5020. CYTHON_FALLTHROUGH;
  5021. case 2:
  5022. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5023. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 242, __pyx_L3_error)
  5024. CYTHON_FALLTHROUGH;
  5025. case 1:
  5026. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  5027. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 242, __pyx_L3_error)
  5028. CYTHON_FALLTHROUGH;
  5029. case 0: break;
  5030. default: goto __pyx_L5_argtuple_error;
  5031. }
  5032. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  5033. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "spline_to_curves", 0) < (0)) __PYX_ERR(0, 242, __pyx_L3_error)
  5034. for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
  5035. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("spline_to_curves", 0, 2, 4, i); __PYX_ERR(0, 242, __pyx_L3_error) }
  5036. }
  5037. } else {
  5038. switch (__pyx_nargs) {
  5039. case 4:
  5040. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  5041. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 242, __pyx_L3_error)
  5042. CYTHON_FALLTHROUGH;
  5043. case 3:
  5044. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5045. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 242, __pyx_L3_error)
  5046. CYTHON_FALLTHROUGH;
  5047. case 2:
  5048. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5049. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 242, __pyx_L3_error)
  5050. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  5051. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 242, __pyx_L3_error)
  5052. break;
  5053. default: goto __pyx_L5_argtuple_error;
  5054. }
  5055. }
  5056. __pyx_v_q = values[0];
  5057. __pyx_v_costs = values[1];
  5058. if (values[2]) {
  5059. __pyx_v_tolerance = __Pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_tolerance == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 265, __pyx_L3_error)
  5060. } else {
  5061. __pyx_v_tolerance = ((double)((double)0.5));
  5062. }
  5063. if (values[3]) {
  5064. __pyx_v_all_cubic = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_all_cubic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 265, __pyx_L3_error)
  5065. } else {
  5066. /* "fontTools/qu2cu/qu2cu.py":265
  5067. * u=cython.complex,
  5068. * )
  5069. * def spline_to_curves(q, costs, tolerance=0.5, all_cubic=False): # <<<<<<<<<<<<<<
  5070. * """
  5071. * q: quadratic spline with alternating on-curve / off-curve points.
  5072. */
  5073. __pyx_v_all_cubic = ((int)((int)0));
  5074. }
  5075. }
  5076. goto __pyx_L6_skip;
  5077. __pyx_L5_argtuple_error:;
  5078. __Pyx_RaiseArgtupleInvalid("spline_to_curves", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 242, __pyx_L3_error)
  5079. __pyx_L6_skip:;
  5080. goto __pyx_L4_argument_unpacking_done;
  5081. __pyx_L3_error:;
  5082. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5083. Py_XDECREF(values[__pyx_temp]);
  5084. }
  5085. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5086. __Pyx_RefNannyFinishContext();
  5087. return NULL;
  5088. __pyx_L4_argument_unpacking_done:;
  5089. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_6spline_to_curves(__pyx_self, __pyx_v_q, __pyx_v_costs, __pyx_v_tolerance, __pyx_v_all_cubic);
  5090. /* "fontTools/qu2cu/qu2cu.py":242
  5091. *
  5092. *
  5093. * @cython.locals( # <<<<<<<<<<<<<<
  5094. * i=cython.int,
  5095. * j=cython.int,
  5096. */
  5097. /* function exit code */
  5098. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5099. Py_XDECREF(values[__pyx_temp]);
  5100. }
  5101. __Pyx_RefNannyFinishContext();
  5102. return __pyx_r;
  5103. }
  5104. static PyObject *__pyx_gb_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
  5105. /* "fontTools/qu2cu/qu2cu.py":340
  5106. * for k, reconst in enumerate(reconstructed):
  5107. * orig = elevated_quadratics[j + k]
  5108. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig)) # <<<<<<<<<<<<<<
  5109. *
  5110. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  5111. */
  5112. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  5113. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  5114. PyObject *__pyx_r = NULL;
  5115. __Pyx_RefNannyDeclarations
  5116. int __pyx_lineno = 0;
  5117. const char *__pyx_filename = NULL;
  5118. int __pyx_clineno = 0;
  5119. __Pyx_RefNannySetupContext("genexpr", 0);
  5120. __pyx_cur_scope = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(__pyx_mstate_global->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  5121. if (unlikely(!__pyx_cur_scope)) {
  5122. __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)Py_None);
  5123. __Pyx_INCREF(Py_None);
  5124. __PYX_ERR(0, 340, __pyx_L1_error)
  5125. } else {
  5126. __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  5127. }
  5128. __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  5129. __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  5130. __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  5131. {
  5132. __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_2generator1, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_spline_to_curves_locals_genexpr, __pyx_mstate_global->__pyx_n_u_fontTools_qu2cu_qu2cu); if (unlikely(!gen)) __PYX_ERR(0, 340, __pyx_L1_error)
  5133. __Pyx_DECREF(__pyx_cur_scope);
  5134. __Pyx_RefNannyFinishContext();
  5135. return (PyObject *) gen;
  5136. }
  5137. /* function exit code */
  5138. __pyx_L1_error:;
  5139. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5140. __pyx_r = NULL;
  5141. __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  5142. __Pyx_XGIVEREF(__pyx_r);
  5143. __Pyx_RefNannyFinishContext();
  5144. return __pyx_r;
  5145. }
  5146. static PyObject *__pyx_gb_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_2generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
  5147. {
  5148. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)__pyx_generator->closure);
  5149. PyObject *__pyx_r = NULL;
  5150. PyObject *__pyx_t_1 = NULL;
  5151. Py_ssize_t __pyx_t_2;
  5152. PyObject *(*__pyx_t_3)(PyObject *);
  5153. PyObject *__pyx_t_4 = NULL;
  5154. PyObject *__pyx_t_5 = NULL;
  5155. PyObject *__pyx_t_6 = NULL;
  5156. PyObject *__pyx_t_7 = NULL;
  5157. PyObject *(*__pyx_t_8)(PyObject *);
  5158. __pyx_t_double_complex __pyx_t_9;
  5159. __pyx_t_double_complex __pyx_t_10;
  5160. int __pyx_lineno = 0;
  5161. const char *__pyx_filename = NULL;
  5162. int __pyx_clineno = 0;
  5163. __Pyx_RefNannyDeclarations
  5164. __Pyx_RefNannySetupContext("genexpr", 0);
  5165. switch (__pyx_generator->resume_label) {
  5166. case 0: goto __pyx_L3_first_run;
  5167. case 1: goto __pyx_L8_resume_from_yield;
  5168. default: /* CPython raises the right error here */
  5169. __Pyx_RefNannyFinishContext();
  5170. return NULL;
  5171. }
  5172. __pyx_L3_first_run:;
  5173. if (unlikely(__pyx_sent_value != Py_None)) {
  5174. if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started generator");
  5175. __PYX_ERR(0, 340, __pyx_L1_error)
  5176. }
  5177. if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 340, __pyx_L1_error) }
  5178. if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
  5179. __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
  5180. __pyx_t_2 = 0;
  5181. __pyx_t_3 = NULL;
  5182. } else {
  5183. __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 340, __pyx_L1_error)
  5184. __Pyx_GOTREF(__pyx_t_1);
  5185. __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 340, __pyx_L1_error)
  5186. }
  5187. for (;;) {
  5188. if (likely(!__pyx_t_3)) {
  5189. if (likely(PyList_CheckExact(__pyx_t_1))) {
  5190. {
  5191. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
  5192. #if !CYTHON_ASSUME_SAFE_SIZE
  5193. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 340, __pyx_L1_error)
  5194. #endif
  5195. if (__pyx_t_2 >= __pyx_temp) break;
  5196. }
  5197. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
  5198. ++__pyx_t_2;
  5199. } else {
  5200. {
  5201. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
  5202. #if !CYTHON_ASSUME_SAFE_SIZE
  5203. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 340, __pyx_L1_error)
  5204. #endif
  5205. if (__pyx_t_2 >= __pyx_temp) break;
  5206. }
  5207. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5208. __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
  5209. #else
  5210. __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
  5211. #endif
  5212. ++__pyx_t_2;
  5213. }
  5214. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L1_error)
  5215. } else {
  5216. __pyx_t_4 = __pyx_t_3(__pyx_t_1);
  5217. if (unlikely(!__pyx_t_4)) {
  5218. PyObject* exc_type = PyErr_Occurred();
  5219. if (exc_type) {
  5220. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 340, __pyx_L1_error)
  5221. PyErr_Clear();
  5222. }
  5223. break;
  5224. }
  5225. }
  5226. __Pyx_GOTREF(__pyx_t_4);
  5227. if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
  5228. PyObject* sequence = __pyx_t_4;
  5229. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  5230. if (unlikely(size != 2)) {
  5231. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  5232. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  5233. __PYX_ERR(0, 340, __pyx_L1_error)
  5234. }
  5235. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5236. if (likely(PyTuple_CheckExact(sequence))) {
  5237. __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
  5238. __Pyx_INCREF(__pyx_t_5);
  5239. __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
  5240. __Pyx_INCREF(__pyx_t_6);
  5241. } else {
  5242. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  5243. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 340, __pyx_L1_error)
  5244. __Pyx_XGOTREF(__pyx_t_5);
  5245. __pyx_t_6 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  5246. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 340, __pyx_L1_error)
  5247. __Pyx_XGOTREF(__pyx_t_6);
  5248. }
  5249. #else
  5250. __pyx_t_5 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 340, __pyx_L1_error)
  5251. __Pyx_GOTREF(__pyx_t_5);
  5252. __pyx_t_6 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 340, __pyx_L1_error)
  5253. __Pyx_GOTREF(__pyx_t_6);
  5254. #endif
  5255. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5256. } else {
  5257. Py_ssize_t index = -1;
  5258. __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 340, __pyx_L1_error)
  5259. __Pyx_GOTREF(__pyx_t_7);
  5260. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5261. __pyx_t_8 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7);
  5262. index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
  5263. __Pyx_GOTREF(__pyx_t_5);
  5264. index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
  5265. __Pyx_GOTREF(__pyx_t_6);
  5266. if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < (0)) __PYX_ERR(0, 340, __pyx_L1_error)
  5267. __pyx_t_8 = NULL;
  5268. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5269. goto __pyx_L7_unpacking_done;
  5270. __pyx_L6_unpacking_failed:;
  5271. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5272. __pyx_t_8 = NULL;
  5273. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  5274. __PYX_ERR(0, 340, __pyx_L1_error)
  5275. __pyx_L7_unpacking_done:;
  5276. }
  5277. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L1_error)
  5278. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5279. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L1_error)
  5280. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5281. __pyx_cur_scope->__pyx_v_v = __pyx_t_9;
  5282. __pyx_cur_scope->__pyx_v_u = __pyx_t_10;
  5283. __pyx_t_10 = __Pyx_c_diff_double(__pyx_cur_scope->__pyx_v_v, __pyx_cur_scope->__pyx_v_u);
  5284. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 340, __pyx_L1_error)
  5285. __Pyx_GOTREF(__pyx_t_4);
  5286. __pyx_r = __pyx_t_4;
  5287. __pyx_t_4 = 0;
  5288. __Pyx_XGIVEREF(__pyx_t_1);
  5289. __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
  5290. __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
  5291. __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
  5292. __Pyx_XGIVEREF(__pyx_r);
  5293. __Pyx_RefNannyFinishContext();
  5294. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  5295. /* return from generator, yielding value */
  5296. __pyx_generator->resume_label = 1;
  5297. return __pyx_r;
  5298. __pyx_L8_resume_from_yield:;
  5299. __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
  5300. __pyx_cur_scope->__pyx_t_0 = 0;
  5301. __Pyx_XGOTREF(__pyx_t_1);
  5302. __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
  5303. __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
  5304. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 340, __pyx_L1_error)
  5305. }
  5306. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5307. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  5308. /* function exit code */
  5309. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5310. goto __pyx_L0;
  5311. __pyx_L1_error:;
  5312. __Pyx_XDECREF(__pyx_t_1);
  5313. __Pyx_XDECREF(__pyx_t_4);
  5314. __Pyx_XDECREF(__pyx_t_5);
  5315. __Pyx_XDECREF(__pyx_t_6);
  5316. __Pyx_XDECREF(__pyx_t_7);
  5317. if (__Pyx_PyErr_Occurred()) {
  5318. __Pyx_Generator_Replace_StopIteration(0);
  5319. __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5320. }
  5321. __pyx_L0:;
  5322. __Pyx_XGIVEREF(__pyx_r);
  5323. #if !CYTHON_USE_EXC_INFO_STACK
  5324. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  5325. #endif
  5326. __pyx_generator->resume_label = -1;
  5327. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  5328. __Pyx_RefNannyFinishContext();
  5329. return __pyx_r;
  5330. }
  5331. /* "fontTools/qu2cu/qu2cu.py":242
  5332. *
  5333. *
  5334. * @cython.locals( # <<<<<<<<<<<<<<
  5335. * i=cython.int,
  5336. * j=cython.int,
  5337. */
  5338. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_6spline_to_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_q, PyObject *__pyx_v_costs, double __pyx_v_tolerance, int __pyx_v_all_cubic) {
  5339. int __pyx_v_i;
  5340. int __pyx_v_j;
  5341. int __pyx_v_k;
  5342. int __pyx_v_start;
  5343. int __pyx_v_i_sol_count;
  5344. int __pyx_v_j_sol_count;
  5345. double __pyx_v_err;
  5346. double __pyx_v_error;
  5347. double __pyx_v_i_sol_error;
  5348. double __pyx_v_j_sol_error;
  5349. int __pyx_v_is_cubic;
  5350. int __pyx_v_count;
  5351. __pyx_t_double_complex __pyx_v_p0;
  5352. __pyx_t_double_complex __pyx_v_p1;
  5353. __pyx_t_double_complex __pyx_v_p2;
  5354. __pyx_t_double_complex __pyx_v_p3;
  5355. PyObject *__pyx_v_elevated_quadratics = NULL;
  5356. PyObject *__pyx_v_forced = NULL;
  5357. PyObject *__pyx_v_sols = NULL;
  5358. PyObject *__pyx_v_impossible = NULL;
  5359. PyObject *__pyx_v_best_sol = NULL;
  5360. PyObject *__pyx_v_this_count = NULL;
  5361. PyObject *__pyx_v_i_sol = NULL;
  5362. PyObject *__pyx_v_curve = NULL;
  5363. PyObject *__pyx_v_ts = NULL;
  5364. PyObject *__pyx_v_reconstructed_iter = NULL;
  5365. PyObject *__pyx_v_reconstructed = NULL;
  5366. PyObject *__pyx_v_reconst = NULL;
  5367. PyObject *__pyx_v_orig = NULL;
  5368. PyObject *__pyx_v_splits = NULL;
  5369. PyObject *__pyx_v_cubic = NULL;
  5370. PyObject *__pyx_v_curves = NULL;
  5371. int __pyx_8genexpr5__pyx_v_i;
  5372. PyObject *__pyx_gb_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_2generator1 = 0;
  5373. PyObject *__pyx_r = NULL;
  5374. __Pyx_RefNannyDeclarations
  5375. Py_ssize_t __pyx_t_1;
  5376. int __pyx_t_2;
  5377. PyObject *__pyx_t_3 = NULL;
  5378. Py_ssize_t __pyx_t_4;
  5379. int __pyx_t_5;
  5380. PyObject *__pyx_t_6 = NULL;
  5381. PyObject *__pyx_t_7 = NULL;
  5382. PyObject *__pyx_t_8 = NULL;
  5383. long __pyx_t_9;
  5384. __pyx_t_double_complex __pyx_t_10;
  5385. int __pyx_t_11;
  5386. size_t __pyx_t_12;
  5387. int __pyx_t_13;
  5388. int __pyx_t_14;
  5389. int __pyx_t_15;
  5390. int __pyx_t_16;
  5391. double __pyx_t_17;
  5392. PyObject *__pyx_t_18 = NULL;
  5393. PyObject *__pyx_t_19 = NULL;
  5394. PyObject *__pyx_t_20 = NULL;
  5395. PyObject *__pyx_t_21 = NULL;
  5396. PyObject *__pyx_t_22 = NULL;
  5397. PyObject *(*__pyx_t_23)(PyObject *);
  5398. Py_ssize_t __pyx_t_24;
  5399. PyObject *(*__pyx_t_25)(PyObject *);
  5400. int __pyx_t_26;
  5401. double __pyx_t_27;
  5402. double __pyx_t_28;
  5403. __pyx_t_double_complex __pyx_t_29;
  5404. __pyx_t_double_complex __pyx_t_30;
  5405. __pyx_t_double_complex __pyx_t_31;
  5406. int __pyx_lineno = 0;
  5407. const char *__pyx_filename = NULL;
  5408. int __pyx_clineno = 0;
  5409. __Pyx_RefNannySetupContext("spline_to_curves", 0);
  5410. /* "fontTools/qu2cu/qu2cu.py":275
  5411. * """
  5412. *
  5413. * assert len(q) >= 3, "quadratic spline requires at least 3 points" # <<<<<<<<<<<<<<
  5414. *
  5415. * # Elevate quadratic segments to cubic
  5416. */
  5417. #ifndef CYTHON_WITHOUT_ASSERTIONS
  5418. if (unlikely(__pyx_assertions_enabled())) {
  5419. __pyx_t_1 = PyObject_Length(__pyx_v_q); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 275, __pyx_L1_error)
  5420. __pyx_t_2 = (__pyx_t_1 >= 3);
  5421. if (unlikely(!__pyx_t_2)) {
  5422. __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_AssertionError))), __pyx_mstate_global->__pyx_kp_u_quadratic_spline_requires_at_lea, 0, 0);
  5423. __PYX_ERR(0, 275, __pyx_L1_error)
  5424. }
  5425. }
  5426. #else
  5427. if ((1)); else __PYX_ERR(0, 275, __pyx_L1_error)
  5428. #endif
  5429. /* "fontTools/qu2cu/qu2cu.py":278
  5430. *
  5431. * # Elevate quadratic segments to cubic
  5432. * elevated_quadratics = [ # <<<<<<<<<<<<<<
  5433. * elevate_quadratic(*q[i : i + 3]) for i in range(0, len(q) - 2, 2)
  5434. * ]
  5435. */
  5436. { /* enter inner scope */
  5437. __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error)
  5438. __Pyx_GOTREF(__pyx_t_3);
  5439. /* "fontTools/qu2cu/qu2cu.py":279
  5440. * # Elevate quadratic segments to cubic
  5441. * elevated_quadratics = [
  5442. * elevate_quadratic(*q[i : i + 3]) for i in range(0, len(q) - 2, 2) # <<<<<<<<<<<<<<
  5443. * ]
  5444. *
  5445. */
  5446. __pyx_t_1 = PyObject_Length(__pyx_v_q); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 279, __pyx_L1_error)
  5447. __pyx_t_4 = (__pyx_t_1 - 2);
  5448. __pyx_t_1 = __pyx_t_4;
  5449. for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=2) {
  5450. __pyx_8genexpr5__pyx_v_i = __pyx_t_5;
  5451. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_elevate_quadratic); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 279, __pyx_L1_error)
  5452. __Pyx_GOTREF(__pyx_t_6);
  5453. __pyx_t_7 = __Pyx_PyObject_GetSlice(__pyx_v_q, __pyx_8genexpr5__pyx_v_i, (__pyx_8genexpr5__pyx_v_i + 3), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 279, __pyx_L1_error)
  5454. __Pyx_GOTREF(__pyx_t_7);
  5455. __pyx_t_8 = __Pyx_PySequence_Tuple(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 279, __pyx_L1_error)
  5456. __Pyx_GOTREF(__pyx_t_8);
  5457. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5458. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 279, __pyx_L1_error)
  5459. __Pyx_GOTREF(__pyx_t_7);
  5460. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5461. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5462. if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 278, __pyx_L1_error)
  5463. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5464. }
  5465. } /* exit inner scope */
  5466. __pyx_v_elevated_quadratics = ((PyObject*)__pyx_t_3);
  5467. __pyx_t_3 = 0;
  5468. /* "fontTools/qu2cu/qu2cu.py":283
  5469. *
  5470. * # Find sharp corners; they have to be oncurves for sure.
  5471. * forced = set() # <<<<<<<<<<<<<<
  5472. * for i in range(1, len(elevated_quadratics)):
  5473. * p0 = elevated_quadratics[i - 1][2]
  5474. */
  5475. __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
  5476. __Pyx_GOTREF(__pyx_t_3);
  5477. __pyx_v_forced = ((PyObject*)__pyx_t_3);
  5478. __pyx_t_3 = 0;
  5479. /* "fontTools/qu2cu/qu2cu.py":284
  5480. * # Find sharp corners; they have to be oncurves for sure.
  5481. * forced = set()
  5482. * for i in range(1, len(elevated_quadratics)): # <<<<<<<<<<<<<<
  5483. * p0 = elevated_quadratics[i - 1][2]
  5484. * p1 = elevated_quadratics[i][0]
  5485. */
  5486. __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_elevated_quadratics); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 284, __pyx_L1_error)
  5487. __pyx_t_1 = __pyx_t_4;
  5488. for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=1) {
  5489. __pyx_v_i = __pyx_t_5;
  5490. /* "fontTools/qu2cu/qu2cu.py":285
  5491. * forced = set()
  5492. * for i in range(1, len(elevated_quadratics)):
  5493. * p0 = elevated_quadratics[i - 1][2] # <<<<<<<<<<<<<<
  5494. * p1 = elevated_quadratics[i][0]
  5495. * p2 = elevated_quadratics[i][1]
  5496. */
  5497. __pyx_t_9 = (__pyx_v_i - 1);
  5498. __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_elevated_quadratics, __pyx_t_9, long, 1, __Pyx_PyLong_From_long, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 285, __pyx_L1_error)
  5499. __Pyx_GOTREF(__pyx_t_3);
  5500. __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_3, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 285, __pyx_L1_error)
  5501. __Pyx_GOTREF(__pyx_t_7);
  5502. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5503. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 285, __pyx_L1_error)
  5504. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5505. __pyx_v_p0 = __pyx_t_10;
  5506. /* "fontTools/qu2cu/qu2cu.py":286
  5507. * for i in range(1, len(elevated_quadratics)):
  5508. * p0 = elevated_quadratics[i - 1][2]
  5509. * p1 = elevated_quadratics[i][0] # <<<<<<<<<<<<<<
  5510. * p2 = elevated_quadratics[i][1]
  5511. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0):
  5512. */
  5513. __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_elevated_quadratics, __pyx_v_i, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 286, __pyx_L1_error)
  5514. __Pyx_GOTREF(__pyx_t_7);
  5515. __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_7, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 286, __pyx_L1_error)
  5516. __Pyx_GOTREF(__pyx_t_3);
  5517. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5518. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 286, __pyx_L1_error)
  5519. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5520. __pyx_v_p1 = __pyx_t_10;
  5521. /* "fontTools/qu2cu/qu2cu.py":287
  5522. * p0 = elevated_quadratics[i - 1][2]
  5523. * p1 = elevated_quadratics[i][0]
  5524. * p2 = elevated_quadratics[i][1] # <<<<<<<<<<<<<<
  5525. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0):
  5526. * forced.add(i)
  5527. */
  5528. __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_elevated_quadratics, __pyx_v_i, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error)
  5529. __Pyx_GOTREF(__pyx_t_3);
  5530. __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_3, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 287, __pyx_L1_error)
  5531. __Pyx_GOTREF(__pyx_t_7);
  5532. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5533. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 287, __pyx_L1_error)
  5534. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5535. __pyx_v_p2 = __pyx_t_10;
  5536. /* "fontTools/qu2cu/qu2cu.py":288
  5537. * p1 = elevated_quadratics[i][0]
  5538. * p2 = elevated_quadratics[i][1]
  5539. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0): # <<<<<<<<<<<<<<
  5540. * forced.add(i)
  5541. *
  5542. */
  5543. __pyx_t_2 = ((__Pyx_c_abs_double(__Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0)) + __Pyx_c_abs_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p1))) > (__pyx_v_tolerance + __Pyx_c_abs_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p0))));
  5544. if (__pyx_t_2) {
  5545. /* "fontTools/qu2cu/qu2cu.py":289
  5546. * p2 = elevated_quadratics[i][1]
  5547. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0):
  5548. * forced.add(i) # <<<<<<<<<<<<<<
  5549. *
  5550. * # Dynamic-Programming to find the solution with fewest number of
  5551. */
  5552. __pyx_t_7 = __Pyx_PyLong_From_int(__pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 289, __pyx_L1_error)
  5553. __Pyx_GOTREF(__pyx_t_7);
  5554. __pyx_t_11 = PySet_Add(__pyx_v_forced, __pyx_t_7); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 289, __pyx_L1_error)
  5555. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5556. /* "fontTools/qu2cu/qu2cu.py":288
  5557. * p1 = elevated_quadratics[i][0]
  5558. * p2 = elevated_quadratics[i][1]
  5559. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0): # <<<<<<<<<<<<<<
  5560. * forced.add(i)
  5561. *
  5562. */
  5563. }
  5564. }
  5565. /* "fontTools/qu2cu/qu2cu.py":293
  5566. * # Dynamic-Programming to find the solution with fewest number of
  5567. * # cubic curves, and within those the one with smallest error.
  5568. * sols = [Solution(0, 0, 0, False)] # <<<<<<<<<<<<<<
  5569. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  5570. * start = 0
  5571. */
  5572. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 293, __pyx_L1_error)
  5573. __Pyx_GOTREF(__pyx_t_7);
  5574. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 293, __pyx_L1_error)
  5575. __Pyx_GOTREF(__pyx_t_3);
  5576. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5577. __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 293, __pyx_L1_error)
  5578. __Pyx_GOTREF(__pyx_t_7);
  5579. __Pyx_GIVEREF(__pyx_t_3);
  5580. if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_3) != (0)) __PYX_ERR(0, 293, __pyx_L1_error);
  5581. __pyx_t_3 = 0;
  5582. __pyx_v_sols = ((PyObject*)__pyx_t_7);
  5583. __pyx_t_7 = 0;
  5584. /* "fontTools/qu2cu/qu2cu.py":294
  5585. * # cubic curves, and within those the one with smallest error.
  5586. * sols = [Solution(0, 0, 0, False)]
  5587. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False) # <<<<<<<<<<<<<<
  5588. * start = 0
  5589. * for i in range(1, len(elevated_quadratics) + 1):
  5590. */
  5591. __pyx_t_3 = NULL;
  5592. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 294, __pyx_L1_error)
  5593. __Pyx_GOTREF(__pyx_t_8);
  5594. __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_elevated_quadratics); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 294, __pyx_L1_error)
  5595. __pyx_t_6 = PyLong_FromSsize_t(((__pyx_t_4 * 3) + 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 294, __pyx_L1_error)
  5596. __Pyx_GOTREF(__pyx_t_6);
  5597. __pyx_t_12 = 1;
  5598. #if CYTHON_UNPACK_METHODS
  5599. if (unlikely(PyMethod_Check(__pyx_t_8))) {
  5600. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
  5601. assert(__pyx_t_3);
  5602. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
  5603. __Pyx_INCREF(__pyx_t_3);
  5604. __Pyx_INCREF(__pyx__function);
  5605. __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
  5606. __pyx_t_12 = 0;
  5607. }
  5608. #endif
  5609. {
  5610. PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_t_6, __pyx_mstate_global->__pyx_int_0, __pyx_mstate_global->__pyx_int_1, Py_False};
  5611. __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_12, (5-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5612. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5613. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5614. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5615. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 294, __pyx_L1_error)
  5616. __Pyx_GOTREF(__pyx_t_7);
  5617. }
  5618. __pyx_v_impossible = __pyx_t_7;
  5619. __pyx_t_7 = 0;
  5620. /* "fontTools/qu2cu/qu2cu.py":295
  5621. * sols = [Solution(0, 0, 0, False)]
  5622. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  5623. * start = 0 # <<<<<<<<<<<<<<
  5624. * for i in range(1, len(elevated_quadratics) + 1):
  5625. * best_sol = impossible
  5626. */
  5627. __pyx_v_start = 0;
  5628. /* "fontTools/qu2cu/qu2cu.py":296
  5629. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  5630. * start = 0
  5631. * for i in range(1, len(elevated_quadratics) + 1): # <<<<<<<<<<<<<<
  5632. * best_sol = impossible
  5633. * for j in range(start, i):
  5634. */
  5635. __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_elevated_quadratics); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 296, __pyx_L1_error)
  5636. __pyx_t_1 = (__pyx_t_4 + 1);
  5637. __pyx_t_4 = __pyx_t_1;
  5638. for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
  5639. __pyx_v_i = __pyx_t_5;
  5640. /* "fontTools/qu2cu/qu2cu.py":297
  5641. * start = 0
  5642. * for i in range(1, len(elevated_quadratics) + 1):
  5643. * best_sol = impossible # <<<<<<<<<<<<<<
  5644. * for j in range(start, i):
  5645. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  5646. */
  5647. __Pyx_INCREF(__pyx_v_impossible);
  5648. __Pyx_XDECREF_SET(__pyx_v_best_sol, __pyx_v_impossible);
  5649. /* "fontTools/qu2cu/qu2cu.py":298
  5650. * for i in range(1, len(elevated_quadratics) + 1):
  5651. * best_sol = impossible
  5652. * for j in range(start, i): # <<<<<<<<<<<<<<
  5653. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  5654. *
  5655. */
  5656. __pyx_t_13 = __pyx_v_i;
  5657. __pyx_t_14 = __pyx_t_13;
  5658. for (__pyx_t_15 = __pyx_v_start; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
  5659. __pyx_v_j = __pyx_t_15;
  5660. /* "fontTools/qu2cu/qu2cu.py":299
  5661. * best_sol = impossible
  5662. * for j in range(start, i):
  5663. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error # <<<<<<<<<<<<<<
  5664. *
  5665. * if not all_cubic:
  5666. */
  5667. __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_sols, __pyx_v_j, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 299, __pyx_L1_error)
  5668. __Pyx_GOTREF(__pyx_t_7);
  5669. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_num_points); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 299, __pyx_L1_error)
  5670. __Pyx_GOTREF(__pyx_t_8);
  5671. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5672. __pyx_t_16 = __Pyx_PyLong_As_int(__pyx_t_8); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 299, __pyx_L1_error)
  5673. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5674. __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_sols, __pyx_v_j, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 299, __pyx_L1_error)
  5675. __Pyx_GOTREF(__pyx_t_8);
  5676. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 299, __pyx_L1_error)
  5677. __Pyx_GOTREF(__pyx_t_7);
  5678. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5679. __pyx_t_17 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_17 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 299, __pyx_L1_error)
  5680. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5681. __pyx_v_j_sol_count = __pyx_t_16;
  5682. __pyx_v_j_sol_error = __pyx_t_17;
  5683. /* "fontTools/qu2cu/qu2cu.py":301
  5684. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  5685. *
  5686. * if not all_cubic: # <<<<<<<<<<<<<<
  5687. * # Solution with quadratics between j:i
  5688. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  5689. */
  5690. __pyx_t_2 = (!(__pyx_v_all_cubic != 0));
  5691. if (__pyx_t_2) {
  5692. /* "fontTools/qu2cu/qu2cu.py":303
  5693. * if not all_cubic:
  5694. * # Solution with quadratics between j:i
  5695. * this_count = costs[2 * i - 1] - costs[2 * j] + 1 # <<<<<<<<<<<<<<
  5696. * i_sol_count = j_sol_count + this_count
  5697. * i_sol_error = j_sol_error
  5698. */
  5699. __pyx_t_9 = ((2 * __pyx_v_i) - 1);
  5700. __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_costs, __pyx_t_9, long, 1, __Pyx_PyLong_From_long, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 303, __pyx_L1_error)
  5701. __Pyx_GOTREF(__pyx_t_7);
  5702. __pyx_t_9 = (2 * __pyx_v_j);
  5703. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_costs, __pyx_t_9, long, 1, __Pyx_PyLong_From_long, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L1_error)
  5704. __Pyx_GOTREF(__pyx_t_8);
  5705. __pyx_t_6 = PyNumber_Subtract(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 303, __pyx_L1_error)
  5706. __Pyx_GOTREF(__pyx_t_6);
  5707. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5708. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5709. __pyx_t_8 = __Pyx_PyLong_AddObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 303, __pyx_L1_error)
  5710. __Pyx_GOTREF(__pyx_t_8);
  5711. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5712. __Pyx_XDECREF_SET(__pyx_v_this_count, __pyx_t_8);
  5713. __pyx_t_8 = 0;
  5714. /* "fontTools/qu2cu/qu2cu.py":304
  5715. * # Solution with quadratics between j:i
  5716. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  5717. * i_sol_count = j_sol_count + this_count # <<<<<<<<<<<<<<
  5718. * i_sol_error = j_sol_error
  5719. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  5720. */
  5721. __pyx_t_8 = __Pyx_PyLong_From_int(__pyx_v_j_sol_count); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 304, __pyx_L1_error)
  5722. __Pyx_GOTREF(__pyx_t_8);
  5723. __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_v_this_count); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 304, __pyx_L1_error)
  5724. __Pyx_GOTREF(__pyx_t_6);
  5725. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5726. __pyx_t_16 = __Pyx_PyLong_As_int(__pyx_t_6); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 304, __pyx_L1_error)
  5727. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5728. __pyx_v_i_sol_count = __pyx_t_16;
  5729. /* "fontTools/qu2cu/qu2cu.py":305
  5730. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  5731. * i_sol_count = j_sol_count + this_count
  5732. * i_sol_error = j_sol_error # <<<<<<<<<<<<<<
  5733. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  5734. * if i_sol < best_sol:
  5735. */
  5736. __pyx_v_i_sol_error = __pyx_v_j_sol_error;
  5737. /* "fontTools/qu2cu/qu2cu.py":306
  5738. * i_sol_count = j_sol_count + this_count
  5739. * i_sol_error = j_sol_error
  5740. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False) # <<<<<<<<<<<<<<
  5741. * if i_sol < best_sol:
  5742. * best_sol = i_sol
  5743. */
  5744. __pyx_t_8 = NULL;
  5745. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 306, __pyx_L1_error)
  5746. __Pyx_GOTREF(__pyx_t_7);
  5747. __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_i_sol_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 306, __pyx_L1_error)
  5748. __Pyx_GOTREF(__pyx_t_3);
  5749. __pyx_t_18 = PyFloat_FromDouble(__pyx_v_i_sol_error); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 306, __pyx_L1_error)
  5750. __Pyx_GOTREF(__pyx_t_18);
  5751. __pyx_t_19 = __Pyx_PyLong_From_int((__pyx_v_i - __pyx_v_j)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 306, __pyx_L1_error)
  5752. __Pyx_GOTREF(__pyx_t_19);
  5753. __pyx_t_12 = 1;
  5754. #if CYTHON_UNPACK_METHODS
  5755. if (unlikely(PyMethod_Check(__pyx_t_7))) {
  5756. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
  5757. assert(__pyx_t_8);
  5758. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
  5759. __Pyx_INCREF(__pyx_t_8);
  5760. __Pyx_INCREF(__pyx__function);
  5761. __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
  5762. __pyx_t_12 = 0;
  5763. }
  5764. #endif
  5765. {
  5766. PyObject *__pyx_callargs[5] = {__pyx_t_8, __pyx_t_3, __pyx_t_18, __pyx_t_19, Py_False};
  5767. __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_12, (5-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5768. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5769. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5770. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  5771. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  5772. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5773. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 306, __pyx_L1_error)
  5774. __Pyx_GOTREF(__pyx_t_6);
  5775. }
  5776. __Pyx_XDECREF_SET(__pyx_v_i_sol, __pyx_t_6);
  5777. __pyx_t_6 = 0;
  5778. /* "fontTools/qu2cu/qu2cu.py":307
  5779. * i_sol_error = j_sol_error
  5780. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  5781. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  5782. * best_sol = i_sol
  5783. *
  5784. */
  5785. __pyx_t_6 = PyObject_RichCompare(__pyx_v_i_sol, __pyx_v_best_sol, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L1_error)
  5786. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 307, __pyx_L1_error)
  5787. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5788. if (__pyx_t_2) {
  5789. /* "fontTools/qu2cu/qu2cu.py":308
  5790. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  5791. * if i_sol < best_sol:
  5792. * best_sol = i_sol # <<<<<<<<<<<<<<
  5793. *
  5794. * if this_count <= 3:
  5795. */
  5796. __Pyx_INCREF(__pyx_v_i_sol);
  5797. __Pyx_DECREF_SET(__pyx_v_best_sol, __pyx_v_i_sol);
  5798. /* "fontTools/qu2cu/qu2cu.py":307
  5799. * i_sol_error = j_sol_error
  5800. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  5801. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  5802. * best_sol = i_sol
  5803. *
  5804. */
  5805. }
  5806. /* "fontTools/qu2cu/qu2cu.py":310
  5807. * best_sol = i_sol
  5808. *
  5809. * if this_count <= 3: # <<<<<<<<<<<<<<
  5810. * # Can't get any better than this in the path below
  5811. * continue
  5812. */
  5813. __pyx_t_6 = PyObject_RichCompare(__pyx_v_this_count, __pyx_mstate_global->__pyx_int_3, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 310, __pyx_L1_error)
  5814. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 310, __pyx_L1_error)
  5815. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5816. if (__pyx_t_2) {
  5817. /* "fontTools/qu2cu/qu2cu.py":312
  5818. * if this_count <= 3:
  5819. * # Can't get any better than this in the path below
  5820. * continue # <<<<<<<<<<<<<<
  5821. *
  5822. * # Fit elevated_quadratics[j:i] into one cubic
  5823. */
  5824. goto __pyx_L10_continue;
  5825. /* "fontTools/qu2cu/qu2cu.py":310
  5826. * best_sol = i_sol
  5827. *
  5828. * if this_count <= 3: # <<<<<<<<<<<<<<
  5829. * # Can't get any better than this in the path below
  5830. * continue
  5831. */
  5832. }
  5833. /* "fontTools/qu2cu/qu2cu.py":301
  5834. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  5835. *
  5836. * if not all_cubic: # <<<<<<<<<<<<<<
  5837. * # Solution with quadratics between j:i
  5838. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  5839. */
  5840. }
  5841. /* "fontTools/qu2cu/qu2cu.py":315
  5842. *
  5843. * # Fit elevated_quadratics[j:i] into one cubic
  5844. * try: # <<<<<<<<<<<<<<
  5845. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  5846. * except ZeroDivisionError:
  5847. */
  5848. {
  5849. __Pyx_PyThreadState_declare
  5850. __Pyx_PyThreadState_assign
  5851. __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
  5852. __Pyx_XGOTREF(__pyx_t_20);
  5853. __Pyx_XGOTREF(__pyx_t_21);
  5854. __Pyx_XGOTREF(__pyx_t_22);
  5855. /*try:*/ {
  5856. /* "fontTools/qu2cu/qu2cu.py":316
  5857. * # Fit elevated_quadratics[j:i] into one cubic
  5858. * try:
  5859. * curve, ts = merge_curves(elevated_quadratics, j, i - j) # <<<<<<<<<<<<<<
  5860. * except ZeroDivisionError:
  5861. * continue
  5862. */
  5863. __pyx_t_6 = __pyx_f_9fontTools_5qu2cu_5qu2cu_merge_curves(__pyx_v_elevated_quadratics, __pyx_v_j, (__pyx_v_i - __pyx_v_j)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 316, __pyx_L15_error)
  5864. __Pyx_GOTREF(__pyx_t_6);
  5865. if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
  5866. PyObject* sequence = __pyx_t_6;
  5867. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  5868. if (unlikely(size != 2)) {
  5869. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  5870. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  5871. __PYX_ERR(0, 316, __pyx_L15_error)
  5872. }
  5873. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5874. if (likely(PyTuple_CheckExact(sequence))) {
  5875. __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0);
  5876. __Pyx_INCREF(__pyx_t_7);
  5877. __pyx_t_19 = PyTuple_GET_ITEM(sequence, 1);
  5878. __Pyx_INCREF(__pyx_t_19);
  5879. } else {
  5880. __pyx_t_7 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  5881. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 316, __pyx_L15_error)
  5882. __Pyx_XGOTREF(__pyx_t_7);
  5883. __pyx_t_19 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  5884. if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 316, __pyx_L15_error)
  5885. __Pyx_XGOTREF(__pyx_t_19);
  5886. }
  5887. #else
  5888. __pyx_t_7 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 316, __pyx_L15_error)
  5889. __Pyx_GOTREF(__pyx_t_7);
  5890. __pyx_t_19 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 316, __pyx_L15_error)
  5891. __Pyx_GOTREF(__pyx_t_19);
  5892. #endif
  5893. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5894. } else {
  5895. Py_ssize_t index = -1;
  5896. __pyx_t_18 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 316, __pyx_L15_error)
  5897. __Pyx_GOTREF(__pyx_t_18);
  5898. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5899. __pyx_t_23 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_18);
  5900. index = 0; __pyx_t_7 = __pyx_t_23(__pyx_t_18); if (unlikely(!__pyx_t_7)) goto __pyx_L23_unpacking_failed;
  5901. __Pyx_GOTREF(__pyx_t_7);
  5902. index = 1; __pyx_t_19 = __pyx_t_23(__pyx_t_18); if (unlikely(!__pyx_t_19)) goto __pyx_L23_unpacking_failed;
  5903. __Pyx_GOTREF(__pyx_t_19);
  5904. if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_18), 2) < (0)) __PYX_ERR(0, 316, __pyx_L15_error)
  5905. __pyx_t_23 = NULL;
  5906. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  5907. goto __pyx_L24_unpacking_done;
  5908. __pyx_L23_unpacking_failed:;
  5909. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  5910. __pyx_t_23 = NULL;
  5911. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  5912. __PYX_ERR(0, 316, __pyx_L15_error)
  5913. __pyx_L24_unpacking_done:;
  5914. }
  5915. __Pyx_XDECREF_SET(__pyx_v_curve, __pyx_t_7);
  5916. __pyx_t_7 = 0;
  5917. __Pyx_XDECREF_SET(__pyx_v_ts, __pyx_t_19);
  5918. __pyx_t_19 = 0;
  5919. /* "fontTools/qu2cu/qu2cu.py":315
  5920. *
  5921. * # Fit elevated_quadratics[j:i] into one cubic
  5922. * try: # <<<<<<<<<<<<<<
  5923. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  5924. * except ZeroDivisionError:
  5925. */
  5926. }
  5927. __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
  5928. __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
  5929. __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
  5930. goto __pyx_L22_try_end;
  5931. __pyx_L15_error:;
  5932. __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
  5933. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  5934. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5935. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5936. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5937. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  5938. /* "fontTools/qu2cu/qu2cu.py":317
  5939. * try:
  5940. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  5941. * except ZeroDivisionError: # <<<<<<<<<<<<<<
  5942. * continue
  5943. *
  5944. */
  5945. __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ZeroDivisionError))));
  5946. if (__pyx_t_16) {
  5947. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5948. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_19, &__pyx_t_7) < 0) __PYX_ERR(0, 317, __pyx_L17_except_error)
  5949. __Pyx_XGOTREF(__pyx_t_6);
  5950. __Pyx_XGOTREF(__pyx_t_19);
  5951. __Pyx_XGOTREF(__pyx_t_7);
  5952. /* "fontTools/qu2cu/qu2cu.py":318
  5953. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  5954. * except ZeroDivisionError:
  5955. * continue # <<<<<<<<<<<<<<
  5956. *
  5957. * # Now reconstruct the segments from the fitted curve
  5958. */
  5959. goto __pyx_L25_except_continue;
  5960. __pyx_L25_except_continue:;
  5961. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5962. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  5963. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5964. goto __pyx_L21_try_continue;
  5965. }
  5966. goto __pyx_L17_except_error;
  5967. /* "fontTools/qu2cu/qu2cu.py":315
  5968. *
  5969. * # Fit elevated_quadratics[j:i] into one cubic
  5970. * try: # <<<<<<<<<<<<<<
  5971. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  5972. * except ZeroDivisionError:
  5973. */
  5974. __pyx_L17_except_error:;
  5975. __Pyx_XGIVEREF(__pyx_t_20);
  5976. __Pyx_XGIVEREF(__pyx_t_21);
  5977. __Pyx_XGIVEREF(__pyx_t_22);
  5978. __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
  5979. goto __pyx_L1_error;
  5980. __pyx_L21_try_continue:;
  5981. __Pyx_XGIVEREF(__pyx_t_20);
  5982. __Pyx_XGIVEREF(__pyx_t_21);
  5983. __Pyx_XGIVEREF(__pyx_t_22);
  5984. __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
  5985. goto __pyx_L10_continue;
  5986. __pyx_L22_try_end:;
  5987. }
  5988. /* "fontTools/qu2cu/qu2cu.py":321
  5989. *
  5990. * # Now reconstruct the segments from the fitted curve
  5991. * reconstructed_iter = splitCubicAtTC(*curve, *ts) # <<<<<<<<<<<<<<
  5992. * reconstructed = []
  5993. *
  5994. */
  5995. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_splitCubicAtTC); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 321, __pyx_L1_error)
  5996. __Pyx_GOTREF(__pyx_t_7);
  5997. __pyx_t_19 = __Pyx_PySequence_Tuple(__pyx_v_curve); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 321, __pyx_L1_error)
  5998. __Pyx_GOTREF(__pyx_t_19);
  5999. __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_v_ts); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 321, __pyx_L1_error)
  6000. __Pyx_GOTREF(__pyx_t_6);
  6001. __pyx_t_18 = PyNumber_Add(__pyx_t_19, __pyx_t_6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 321, __pyx_L1_error)
  6002. __Pyx_GOTREF(__pyx_t_18);
  6003. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6004. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6005. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_18, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 321, __pyx_L1_error)
  6006. __Pyx_GOTREF(__pyx_t_6);
  6007. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6008. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6009. __Pyx_XDECREF_SET(__pyx_v_reconstructed_iter, __pyx_t_6);
  6010. __pyx_t_6 = 0;
  6011. /* "fontTools/qu2cu/qu2cu.py":322
  6012. * # Now reconstruct the segments from the fitted curve
  6013. * reconstructed_iter = splitCubicAtTC(*curve, *ts)
  6014. * reconstructed = [] # <<<<<<<<<<<<<<
  6015. *
  6016. * # Knot errors
  6017. */
  6018. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 322, __pyx_L1_error)
  6019. __Pyx_GOTREF(__pyx_t_6);
  6020. __Pyx_XDECREF_SET(__pyx_v_reconstructed, ((PyObject*)__pyx_t_6));
  6021. __pyx_t_6 = 0;
  6022. /* "fontTools/qu2cu/qu2cu.py":325
  6023. *
  6024. * # Knot errors
  6025. * error = 0 # <<<<<<<<<<<<<<
  6026. * for k, reconst in enumerate(reconstructed_iter):
  6027. * orig = elevated_quadratics[j + k]
  6028. */
  6029. __pyx_v_error = 0.0;
  6030. /* "fontTools/qu2cu/qu2cu.py":326
  6031. * # Knot errors
  6032. * error = 0
  6033. * for k, reconst in enumerate(reconstructed_iter): # <<<<<<<<<<<<<<
  6034. * orig = elevated_quadratics[j + k]
  6035. * err = abs(reconst[3] - orig[3])
  6036. */
  6037. __pyx_t_16 = 0;
  6038. if (likely(PyList_CheckExact(__pyx_v_reconstructed_iter)) || PyTuple_CheckExact(__pyx_v_reconstructed_iter)) {
  6039. __pyx_t_6 = __pyx_v_reconstructed_iter; __Pyx_INCREF(__pyx_t_6);
  6040. __pyx_t_24 = 0;
  6041. __pyx_t_25 = NULL;
  6042. } else {
  6043. __pyx_t_24 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_reconstructed_iter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 326, __pyx_L1_error)
  6044. __Pyx_GOTREF(__pyx_t_6);
  6045. __pyx_t_25 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 326, __pyx_L1_error)
  6046. }
  6047. for (;;) {
  6048. if (likely(!__pyx_t_25)) {
  6049. if (likely(PyList_CheckExact(__pyx_t_6))) {
  6050. {
  6051. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6052. #if !CYTHON_ASSUME_SAFE_SIZE
  6053. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 326, __pyx_L1_error)
  6054. #endif
  6055. if (__pyx_t_24 >= __pyx_temp) break;
  6056. }
  6057. __pyx_t_18 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_24, __Pyx_ReferenceSharing_OwnStrongReference);
  6058. ++__pyx_t_24;
  6059. } else {
  6060. {
  6061. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  6062. #if !CYTHON_ASSUME_SAFE_SIZE
  6063. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 326, __pyx_L1_error)
  6064. #endif
  6065. if (__pyx_t_24 >= __pyx_temp) break;
  6066. }
  6067. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6068. __pyx_t_18 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_24));
  6069. #else
  6070. __pyx_t_18 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_24);
  6071. #endif
  6072. ++__pyx_t_24;
  6073. }
  6074. if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 326, __pyx_L1_error)
  6075. } else {
  6076. __pyx_t_18 = __pyx_t_25(__pyx_t_6);
  6077. if (unlikely(!__pyx_t_18)) {
  6078. PyObject* exc_type = PyErr_Occurred();
  6079. if (exc_type) {
  6080. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 326, __pyx_L1_error)
  6081. PyErr_Clear();
  6082. }
  6083. break;
  6084. }
  6085. }
  6086. __Pyx_GOTREF(__pyx_t_18);
  6087. __Pyx_XDECREF_SET(__pyx_v_reconst, __pyx_t_18);
  6088. __pyx_t_18 = 0;
  6089. __pyx_v_k = __pyx_t_16;
  6090. __pyx_t_16 = (__pyx_t_16 + 1);
  6091. /* "fontTools/qu2cu/qu2cu.py":327
  6092. * error = 0
  6093. * for k, reconst in enumerate(reconstructed_iter):
  6094. * orig = elevated_quadratics[j + k] # <<<<<<<<<<<<<<
  6095. * err = abs(reconst[3] - orig[3])
  6096. * error = max(error, err)
  6097. */
  6098. __pyx_t_26 = (__pyx_v_j + __pyx_v_k);
  6099. __pyx_t_18 = __Pyx_GetItemInt_List(__pyx_v_elevated_quadratics, __pyx_t_26, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 327, __pyx_L1_error)
  6100. __Pyx_GOTREF(__pyx_t_18);
  6101. __Pyx_XDECREF_SET(__pyx_v_orig, __pyx_t_18);
  6102. __pyx_t_18 = 0;
  6103. /* "fontTools/qu2cu/qu2cu.py":328
  6104. * for k, reconst in enumerate(reconstructed_iter):
  6105. * orig = elevated_quadratics[j + k]
  6106. * err = abs(reconst[3] - orig[3]) # <<<<<<<<<<<<<<
  6107. * error = max(error, err)
  6108. * if error > tolerance:
  6109. */
  6110. __pyx_t_18 = __Pyx_GetItemInt(__pyx_v_reconst, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 328, __pyx_L1_error)
  6111. __Pyx_GOTREF(__pyx_t_18);
  6112. __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_orig, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 328, __pyx_L1_error)
  6113. __Pyx_GOTREF(__pyx_t_7);
  6114. __pyx_t_19 = PyNumber_Subtract(__pyx_t_18, __pyx_t_7); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 328, __pyx_L1_error)
  6115. __Pyx_GOTREF(__pyx_t_19);
  6116. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6117. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6118. __pyx_t_7 = __Pyx_PyNumber_Absolute(__pyx_t_19); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 328, __pyx_L1_error)
  6119. __Pyx_GOTREF(__pyx_t_7);
  6120. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6121. __pyx_t_17 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_17 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 328, __pyx_L1_error)
  6122. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6123. __pyx_v_err = __pyx_t_17;
  6124. /* "fontTools/qu2cu/qu2cu.py":329
  6125. * orig = elevated_quadratics[j + k]
  6126. * err = abs(reconst[3] - orig[3])
  6127. * error = max(error, err) # <<<<<<<<<<<<<<
  6128. * if error > tolerance:
  6129. * break
  6130. */
  6131. __pyx_t_17 = __pyx_v_err;
  6132. __pyx_t_27 = __pyx_v_error;
  6133. __pyx_t_2 = (__pyx_t_17 > __pyx_t_27);
  6134. if (__pyx_t_2) {
  6135. __pyx_t_28 = __pyx_t_17;
  6136. } else {
  6137. __pyx_t_28 = __pyx_t_27;
  6138. }
  6139. __pyx_v_error = __pyx_t_28;
  6140. /* "fontTools/qu2cu/qu2cu.py":330
  6141. * err = abs(reconst[3] - orig[3])
  6142. * error = max(error, err)
  6143. * if error > tolerance: # <<<<<<<<<<<<<<
  6144. * break
  6145. * reconstructed.append(reconst)
  6146. */
  6147. __pyx_t_2 = (__pyx_v_error > __pyx_v_tolerance);
  6148. if (__pyx_t_2) {
  6149. /* "fontTools/qu2cu/qu2cu.py":331
  6150. * error = max(error, err)
  6151. * if error > tolerance:
  6152. * break # <<<<<<<<<<<<<<
  6153. * reconstructed.append(reconst)
  6154. * if error > tolerance:
  6155. */
  6156. goto __pyx_L28_break;
  6157. /* "fontTools/qu2cu/qu2cu.py":330
  6158. * err = abs(reconst[3] - orig[3])
  6159. * error = max(error, err)
  6160. * if error > tolerance: # <<<<<<<<<<<<<<
  6161. * break
  6162. * reconstructed.append(reconst)
  6163. */
  6164. }
  6165. /* "fontTools/qu2cu/qu2cu.py":332
  6166. * if error > tolerance:
  6167. * break
  6168. * reconstructed.append(reconst) # <<<<<<<<<<<<<<
  6169. * if error > tolerance:
  6170. * # Not feasible
  6171. */
  6172. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_reconstructed, __pyx_v_reconst); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 332, __pyx_L1_error)
  6173. /* "fontTools/qu2cu/qu2cu.py":326
  6174. * # Knot errors
  6175. * error = 0
  6176. * for k, reconst in enumerate(reconstructed_iter): # <<<<<<<<<<<<<<
  6177. * orig = elevated_quadratics[j + k]
  6178. * err = abs(reconst[3] - orig[3])
  6179. */
  6180. }
  6181. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6182. goto __pyx_L30_for_end;
  6183. __pyx_L28_break:;
  6184. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6185. goto __pyx_L30_for_end;
  6186. __pyx_L30_for_end:;
  6187. /* "fontTools/qu2cu/qu2cu.py":333
  6188. * break
  6189. * reconstructed.append(reconst)
  6190. * if error > tolerance: # <<<<<<<<<<<<<<
  6191. * # Not feasible
  6192. * continue
  6193. */
  6194. __pyx_t_2 = (__pyx_v_error > __pyx_v_tolerance);
  6195. if (__pyx_t_2) {
  6196. /* "fontTools/qu2cu/qu2cu.py":335
  6197. * if error > tolerance:
  6198. * # Not feasible
  6199. * continue # <<<<<<<<<<<<<<
  6200. *
  6201. * # Interior errors
  6202. */
  6203. goto __pyx_L10_continue;
  6204. /* "fontTools/qu2cu/qu2cu.py":333
  6205. * break
  6206. * reconstructed.append(reconst)
  6207. * if error > tolerance: # <<<<<<<<<<<<<<
  6208. * # Not feasible
  6209. * continue
  6210. */
  6211. }
  6212. /* "fontTools/qu2cu/qu2cu.py":338
  6213. *
  6214. * # Interior errors
  6215. * for k, reconst in enumerate(reconstructed): # <<<<<<<<<<<<<<
  6216. * orig = elevated_quadratics[j + k]
  6217. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  6218. */
  6219. __pyx_t_16 = 0;
  6220. __pyx_t_6 = __pyx_v_reconstructed; __Pyx_INCREF(__pyx_t_6);
  6221. __pyx_t_24 = 0;
  6222. for (;;) {
  6223. {
  6224. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6225. #if !CYTHON_ASSUME_SAFE_SIZE
  6226. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 338, __pyx_L1_error)
  6227. #endif
  6228. if (__pyx_t_24 >= __pyx_temp) break;
  6229. }
  6230. __pyx_t_7 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_24, __Pyx_ReferenceSharing_OwnStrongReference);
  6231. ++__pyx_t_24;
  6232. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 338, __pyx_L1_error)
  6233. __Pyx_GOTREF(__pyx_t_7);
  6234. __Pyx_XDECREF_SET(__pyx_v_reconst, __pyx_t_7);
  6235. __pyx_t_7 = 0;
  6236. __pyx_v_k = __pyx_t_16;
  6237. __pyx_t_16 = (__pyx_t_16 + 1);
  6238. /* "fontTools/qu2cu/qu2cu.py":339
  6239. * # Interior errors
  6240. * for k, reconst in enumerate(reconstructed):
  6241. * orig = elevated_quadratics[j + k] # <<<<<<<<<<<<<<
  6242. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  6243. *
  6244. */
  6245. __pyx_t_26 = (__pyx_v_j + __pyx_v_k);
  6246. __pyx_t_7 = __Pyx_GetItemInt_List(__pyx_v_elevated_quadratics, __pyx_t_26, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 339, __pyx_L1_error)
  6247. __Pyx_GOTREF(__pyx_t_7);
  6248. __Pyx_XDECREF_SET(__pyx_v_orig, __pyx_t_7);
  6249. __pyx_t_7 = 0;
  6250. /* "fontTools/qu2cu/qu2cu.py":340
  6251. * for k, reconst in enumerate(reconstructed):
  6252. * orig = elevated_quadratics[j + k]
  6253. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig)) # <<<<<<<<<<<<<<
  6254. *
  6255. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  6256. */
  6257. __pyx_t_19 = NULL;
  6258. __pyx_t_12 = 1;
  6259. {
  6260. PyObject *__pyx_callargs[3] = {__pyx_t_19, __pyx_v_reconst, __pyx_v_orig};
  6261. __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_zip, __pyx_callargs+__pyx_t_12, (3-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  6262. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  6263. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 340, __pyx_L1_error)
  6264. __Pyx_GOTREF(__pyx_t_7);
  6265. }
  6266. __pyx_t_19 = __pyx_pf_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_genexpr(NULL, __pyx_t_7); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 340, __pyx_L1_error)
  6267. __Pyx_GOTREF(__pyx_t_19);
  6268. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6269. __pyx_t_7 = __Pyx_PySequence_Tuple(__pyx_t_19); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 340, __pyx_L1_error)
  6270. __Pyx_GOTREF(__pyx_t_7);
  6271. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6272. if (1) {
  6273. PyObject* sequence = __pyx_t_7;
  6274. Py_ssize_t size = __Pyx_PyTuple_GET_SIZE(sequence);
  6275. if (unlikely(size != 4)) {
  6276. if (size > 4) __Pyx_RaiseTooManyValuesError(4);
  6277. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  6278. __PYX_ERR(0, 340, __pyx_L1_error)
  6279. }
  6280. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6281. __pyx_t_19 = PyTuple_GET_ITEM(sequence, 0);
  6282. __Pyx_INCREF(__pyx_t_19);
  6283. __pyx_t_18 = PyTuple_GET_ITEM(sequence, 1);
  6284. __Pyx_INCREF(__pyx_t_18);
  6285. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2);
  6286. __Pyx_INCREF(__pyx_t_3);
  6287. __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3);
  6288. __Pyx_INCREF(__pyx_t_8);
  6289. #else
  6290. {
  6291. Py_ssize_t i;
  6292. PyObject** temps[4] = {&__pyx_t_19,&__pyx_t_18,&__pyx_t_3,&__pyx_t_8};
  6293. for (i=0; i < 4; i++) {
  6294. PyObject* item = __Pyx_PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 340, __pyx_L1_error)
  6295. __Pyx_GOTREF(item);
  6296. *(temps[i]) = item;
  6297. }
  6298. }
  6299. #endif
  6300. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6301. }
  6302. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_19); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L1_error)
  6303. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6304. __pyx_t_29 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_18); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L1_error)
  6305. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6306. __pyx_t_30 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L1_error)
  6307. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6308. __pyx_t_31 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 340, __pyx_L1_error)
  6309. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6310. __pyx_v_p0 = __pyx_t_10;
  6311. __pyx_v_p1 = __pyx_t_29;
  6312. __pyx_v_p2 = __pyx_t_30;
  6313. __pyx_v_p3 = __pyx_t_31;
  6314. /* "fontTools/qu2cu/qu2cu.py":342
  6315. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  6316. *
  6317. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): # <<<<<<<<<<<<<<
  6318. * error = tolerance + 1
  6319. * break
  6320. */
  6321. __pyx_t_26 = __pyx_f_9fontTools_5qu2cu_5qu2cu_cubic_farthest_fit_inside(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3, __pyx_v_tolerance); if (unlikely(__pyx_t_26 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 342, __pyx_L1_error)
  6322. __pyx_t_2 = (!(__pyx_t_26 != 0));
  6323. if (__pyx_t_2) {
  6324. /* "fontTools/qu2cu/qu2cu.py":343
  6325. *
  6326. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  6327. * error = tolerance + 1 # <<<<<<<<<<<<<<
  6328. * break
  6329. * if error > tolerance:
  6330. */
  6331. __pyx_v_error = (__pyx_v_tolerance + 1.0);
  6332. /* "fontTools/qu2cu/qu2cu.py":344
  6333. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  6334. * error = tolerance + 1
  6335. * break # <<<<<<<<<<<<<<
  6336. * if error > tolerance:
  6337. * # Not feasible
  6338. */
  6339. goto __pyx_L33_break;
  6340. /* "fontTools/qu2cu/qu2cu.py":342
  6341. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  6342. *
  6343. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): # <<<<<<<<<<<<<<
  6344. * error = tolerance + 1
  6345. * break
  6346. */
  6347. }
  6348. /* "fontTools/qu2cu/qu2cu.py":338
  6349. *
  6350. * # Interior errors
  6351. * for k, reconst in enumerate(reconstructed): # <<<<<<<<<<<<<<
  6352. * orig = elevated_quadratics[j + k]
  6353. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  6354. */
  6355. }
  6356. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6357. goto __pyx_L35_for_end;
  6358. __pyx_L33_break:;
  6359. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6360. goto __pyx_L35_for_end;
  6361. __pyx_L35_for_end:;
  6362. /* "fontTools/qu2cu/qu2cu.py":345
  6363. * error = tolerance + 1
  6364. * break
  6365. * if error > tolerance: # <<<<<<<<<<<<<<
  6366. * # Not feasible
  6367. * continue
  6368. */
  6369. __pyx_t_2 = (__pyx_v_error > __pyx_v_tolerance);
  6370. if (__pyx_t_2) {
  6371. /* "fontTools/qu2cu/qu2cu.py":347
  6372. * if error > tolerance:
  6373. * # Not feasible
  6374. * continue # <<<<<<<<<<<<<<
  6375. *
  6376. * # Save best solution
  6377. */
  6378. goto __pyx_L10_continue;
  6379. /* "fontTools/qu2cu/qu2cu.py":345
  6380. * error = tolerance + 1
  6381. * break
  6382. * if error > tolerance: # <<<<<<<<<<<<<<
  6383. * # Not feasible
  6384. * continue
  6385. */
  6386. }
  6387. /* "fontTools/qu2cu/qu2cu.py":350
  6388. *
  6389. * # Save best solution
  6390. * i_sol_count = j_sol_count + 3 # <<<<<<<<<<<<<<
  6391. * i_sol_error = max(j_sol_error, error)
  6392. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  6393. */
  6394. __pyx_v_i_sol_count = (__pyx_v_j_sol_count + 3);
  6395. /* "fontTools/qu2cu/qu2cu.py":351
  6396. * # Save best solution
  6397. * i_sol_count = j_sol_count + 3
  6398. * i_sol_error = max(j_sol_error, error) # <<<<<<<<<<<<<<
  6399. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  6400. * if i_sol < best_sol:
  6401. */
  6402. __pyx_t_28 = __pyx_v_error;
  6403. __pyx_t_17 = __pyx_v_j_sol_error;
  6404. __pyx_t_2 = (__pyx_t_28 > __pyx_t_17);
  6405. if (__pyx_t_2) {
  6406. __pyx_t_27 = __pyx_t_28;
  6407. } else {
  6408. __pyx_t_27 = __pyx_t_17;
  6409. }
  6410. __pyx_v_i_sol_error = __pyx_t_27;
  6411. /* "fontTools/qu2cu/qu2cu.py":352
  6412. * i_sol_count = j_sol_count + 3
  6413. * i_sol_error = max(j_sol_error, error)
  6414. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True) # <<<<<<<<<<<<<<
  6415. * if i_sol < best_sol:
  6416. * best_sol = i_sol
  6417. */
  6418. __pyx_t_7 = NULL;
  6419. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 352, __pyx_L1_error)
  6420. __Pyx_GOTREF(__pyx_t_8);
  6421. __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_i_sol_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 352, __pyx_L1_error)
  6422. __Pyx_GOTREF(__pyx_t_3);
  6423. __pyx_t_18 = PyFloat_FromDouble(__pyx_v_i_sol_error); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 352, __pyx_L1_error)
  6424. __Pyx_GOTREF(__pyx_t_18);
  6425. __pyx_t_19 = __Pyx_PyLong_From_int((__pyx_v_i - __pyx_v_j)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 352, __pyx_L1_error)
  6426. __Pyx_GOTREF(__pyx_t_19);
  6427. __pyx_t_12 = 1;
  6428. #if CYTHON_UNPACK_METHODS
  6429. if (unlikely(PyMethod_Check(__pyx_t_8))) {
  6430. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
  6431. assert(__pyx_t_7);
  6432. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
  6433. __Pyx_INCREF(__pyx_t_7);
  6434. __Pyx_INCREF(__pyx__function);
  6435. __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
  6436. __pyx_t_12 = 0;
  6437. }
  6438. #endif
  6439. {
  6440. PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_18, __pyx_t_19, Py_True};
  6441. __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_12, (5-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  6442. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6443. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6444. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6445. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6446. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6447. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 352, __pyx_L1_error)
  6448. __Pyx_GOTREF(__pyx_t_6);
  6449. }
  6450. __Pyx_XDECREF_SET(__pyx_v_i_sol, __pyx_t_6);
  6451. __pyx_t_6 = 0;
  6452. /* "fontTools/qu2cu/qu2cu.py":353
  6453. * i_sol_error = max(j_sol_error, error)
  6454. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  6455. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  6456. * best_sol = i_sol
  6457. *
  6458. */
  6459. __pyx_t_6 = PyObject_RichCompare(__pyx_v_i_sol, __pyx_v_best_sol, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 353, __pyx_L1_error)
  6460. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 353, __pyx_L1_error)
  6461. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6462. if (__pyx_t_2) {
  6463. /* "fontTools/qu2cu/qu2cu.py":354
  6464. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  6465. * if i_sol < best_sol:
  6466. * best_sol = i_sol # <<<<<<<<<<<<<<
  6467. *
  6468. * if i_sol_count == 3:
  6469. */
  6470. __Pyx_INCREF(__pyx_v_i_sol);
  6471. __Pyx_DECREF_SET(__pyx_v_best_sol, __pyx_v_i_sol);
  6472. /* "fontTools/qu2cu/qu2cu.py":353
  6473. * i_sol_error = max(j_sol_error, error)
  6474. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  6475. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  6476. * best_sol = i_sol
  6477. *
  6478. */
  6479. }
  6480. /* "fontTools/qu2cu/qu2cu.py":356
  6481. * best_sol = i_sol
  6482. *
  6483. * if i_sol_count == 3: # <<<<<<<<<<<<<<
  6484. * # Can't get any better than this
  6485. * break
  6486. */
  6487. __pyx_t_2 = (__pyx_v_i_sol_count == 3);
  6488. if (__pyx_t_2) {
  6489. /* "fontTools/qu2cu/qu2cu.py":358
  6490. * if i_sol_count == 3:
  6491. * # Can't get any better than this
  6492. * break # <<<<<<<<<<<<<<
  6493. *
  6494. * sols.append(best_sol)
  6495. */
  6496. goto __pyx_L11_break;
  6497. /* "fontTools/qu2cu/qu2cu.py":356
  6498. * best_sol = i_sol
  6499. *
  6500. * if i_sol_count == 3: # <<<<<<<<<<<<<<
  6501. * # Can't get any better than this
  6502. * break
  6503. */
  6504. }
  6505. __pyx_L10_continue:;
  6506. }
  6507. __pyx_L11_break:;
  6508. /* "fontTools/qu2cu/qu2cu.py":360
  6509. * break
  6510. *
  6511. * sols.append(best_sol) # <<<<<<<<<<<<<<
  6512. * if i in forced:
  6513. * start = i
  6514. */
  6515. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_sols, __pyx_v_best_sol); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 360, __pyx_L1_error)
  6516. /* "fontTools/qu2cu/qu2cu.py":361
  6517. *
  6518. * sols.append(best_sol)
  6519. * if i in forced: # <<<<<<<<<<<<<<
  6520. * start = i
  6521. *
  6522. */
  6523. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 361, __pyx_L1_error)
  6524. __Pyx_GOTREF(__pyx_t_6);
  6525. __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_t_6, __pyx_v_forced, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 361, __pyx_L1_error)
  6526. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6527. if (__pyx_t_2) {
  6528. /* "fontTools/qu2cu/qu2cu.py":362
  6529. * sols.append(best_sol)
  6530. * if i in forced:
  6531. * start = i # <<<<<<<<<<<<<<
  6532. *
  6533. * # Reconstruct solution
  6534. */
  6535. __pyx_v_start = __pyx_v_i;
  6536. /* "fontTools/qu2cu/qu2cu.py":361
  6537. *
  6538. * sols.append(best_sol)
  6539. * if i in forced: # <<<<<<<<<<<<<<
  6540. * start = i
  6541. *
  6542. */
  6543. }
  6544. }
  6545. /* "fontTools/qu2cu/qu2cu.py":365
  6546. *
  6547. * # Reconstruct solution
  6548. * splits = [] # <<<<<<<<<<<<<<
  6549. * cubic = []
  6550. * i = len(sols) - 1
  6551. */
  6552. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 365, __pyx_L1_error)
  6553. __Pyx_GOTREF(__pyx_t_6);
  6554. __pyx_v_splits = ((PyObject*)__pyx_t_6);
  6555. __pyx_t_6 = 0;
  6556. /* "fontTools/qu2cu/qu2cu.py":366
  6557. * # Reconstruct solution
  6558. * splits = []
  6559. * cubic = [] # <<<<<<<<<<<<<<
  6560. * i = len(sols) - 1
  6561. * while i:
  6562. */
  6563. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 366, __pyx_L1_error)
  6564. __Pyx_GOTREF(__pyx_t_6);
  6565. __pyx_v_cubic = ((PyObject*)__pyx_t_6);
  6566. __pyx_t_6 = 0;
  6567. /* "fontTools/qu2cu/qu2cu.py":367
  6568. * splits = []
  6569. * cubic = []
  6570. * i = len(sols) - 1 # <<<<<<<<<<<<<<
  6571. * while i:
  6572. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  6573. */
  6574. __pyx_t_1 = __Pyx_PyList_GET_SIZE(__pyx_v_sols); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 367, __pyx_L1_error)
  6575. __pyx_v_i = (__pyx_t_1 - 1);
  6576. /* "fontTools/qu2cu/qu2cu.py":368
  6577. * cubic = []
  6578. * i = len(sols) - 1
  6579. * while i: # <<<<<<<<<<<<<<
  6580. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  6581. * splits.append(i)
  6582. */
  6583. while (1) {
  6584. __pyx_t_2 = (__pyx_v_i != 0);
  6585. if (!__pyx_t_2) break;
  6586. /* "fontTools/qu2cu/qu2cu.py":369
  6587. * i = len(sols) - 1
  6588. * while i:
  6589. * count, is_cubic = sols[i].start_index, sols[i].is_cubic # <<<<<<<<<<<<<<
  6590. * splits.append(i)
  6591. * cubic.append(is_cubic)
  6592. */
  6593. __pyx_t_6 = __Pyx_GetItemInt_List(__pyx_v_sols, __pyx_v_i, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 369, __pyx_L1_error)
  6594. __Pyx_GOTREF(__pyx_t_6);
  6595. __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_start_index); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 369, __pyx_L1_error)
  6596. __Pyx_GOTREF(__pyx_t_8);
  6597. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6598. __pyx_t_5 = __Pyx_PyLong_As_int(__pyx_t_8); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 369, __pyx_L1_error)
  6599. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6600. __pyx_t_8 = __Pyx_GetItemInt_List(__pyx_v_sols, __pyx_v_i, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 369, __pyx_L1_error)
  6601. __Pyx_GOTREF(__pyx_t_8);
  6602. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_is_cubic); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 369, __pyx_L1_error)
  6603. __Pyx_GOTREF(__pyx_t_6);
  6604. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6605. __pyx_t_13 = __Pyx_PyLong_As_int(__pyx_t_6); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 369, __pyx_L1_error)
  6606. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6607. __pyx_v_count = __pyx_t_5;
  6608. __pyx_v_is_cubic = __pyx_t_13;
  6609. /* "fontTools/qu2cu/qu2cu.py":370
  6610. * while i:
  6611. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  6612. * splits.append(i) # <<<<<<<<<<<<<<
  6613. * cubic.append(is_cubic)
  6614. * i -= count
  6615. */
  6616. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 370, __pyx_L1_error)
  6617. __Pyx_GOTREF(__pyx_t_6);
  6618. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_splits, __pyx_t_6); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 370, __pyx_L1_error)
  6619. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6620. /* "fontTools/qu2cu/qu2cu.py":371
  6621. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  6622. * splits.append(i)
  6623. * cubic.append(is_cubic) # <<<<<<<<<<<<<<
  6624. * i -= count
  6625. * curves = []
  6626. */
  6627. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_is_cubic); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 371, __pyx_L1_error)
  6628. __Pyx_GOTREF(__pyx_t_6);
  6629. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_cubic, __pyx_t_6); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 371, __pyx_L1_error)
  6630. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6631. /* "fontTools/qu2cu/qu2cu.py":372
  6632. * splits.append(i)
  6633. * cubic.append(is_cubic)
  6634. * i -= count # <<<<<<<<<<<<<<
  6635. * curves = []
  6636. * j = 0
  6637. */
  6638. __pyx_v_i = (__pyx_v_i - __pyx_v_count);
  6639. }
  6640. /* "fontTools/qu2cu/qu2cu.py":373
  6641. * cubic.append(is_cubic)
  6642. * i -= count
  6643. * curves = [] # <<<<<<<<<<<<<<
  6644. * j = 0
  6645. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  6646. */
  6647. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 373, __pyx_L1_error)
  6648. __Pyx_GOTREF(__pyx_t_6);
  6649. __pyx_v_curves = ((PyObject*)__pyx_t_6);
  6650. __pyx_t_6 = 0;
  6651. /* "fontTools/qu2cu/qu2cu.py":374
  6652. * i -= count
  6653. * curves = []
  6654. * j = 0 # <<<<<<<<<<<<<<
  6655. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  6656. * if is_cubic:
  6657. */
  6658. __pyx_v_j = 0;
  6659. /* "fontTools/qu2cu/qu2cu.py":375
  6660. * curves = []
  6661. * j = 0
  6662. * for i, is_cubic in reversed(list(zip(splits, cubic))): # <<<<<<<<<<<<<<
  6663. * if is_cubic:
  6664. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  6665. */
  6666. __pyx_t_8 = NULL;
  6667. __pyx_t_12 = 1;
  6668. {
  6669. PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_v_splits, __pyx_v_cubic};
  6670. __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_zip, __pyx_callargs+__pyx_t_12, (3-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  6671. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  6672. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 375, __pyx_L1_error)
  6673. __Pyx_GOTREF(__pyx_t_6);
  6674. }
  6675. __pyx_t_8 = __Pyx_PySequence_ListKeepNew(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 375, __pyx_L1_error)
  6676. __Pyx_GOTREF(__pyx_t_8);
  6677. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6678. __pyx_t_6 = __pyx_t_8; __Pyx_INCREF(__pyx_t_6);
  6679. __pyx_t_1 = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6680. #if !CYTHON_ASSUME_SAFE_SIZE
  6681. if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 375, __pyx_L1_error)
  6682. #endif
  6683. --__pyx_t_1;
  6684. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6685. for (;;) {
  6686. if (__pyx_t_1 < 0) break;
  6687. {
  6688. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6689. #if !CYTHON_ASSUME_SAFE_SIZE
  6690. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 375, __pyx_L1_error)
  6691. #endif
  6692. if (__pyx_t_1 >= __pyx_temp) break;
  6693. }
  6694. __pyx_t_8 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_1, __Pyx_ReferenceSharing_OwnStrongReference);
  6695. --__pyx_t_1;
  6696. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 375, __pyx_L1_error)
  6697. __Pyx_GOTREF(__pyx_t_8);
  6698. if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
  6699. PyObject* sequence = __pyx_t_8;
  6700. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  6701. if (unlikely(size != 2)) {
  6702. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  6703. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  6704. __PYX_ERR(0, 375, __pyx_L1_error)
  6705. }
  6706. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6707. if (likely(PyTuple_CheckExact(sequence))) {
  6708. __pyx_t_19 = PyTuple_GET_ITEM(sequence, 0);
  6709. __Pyx_INCREF(__pyx_t_19);
  6710. __pyx_t_18 = PyTuple_GET_ITEM(sequence, 1);
  6711. __Pyx_INCREF(__pyx_t_18);
  6712. } else {
  6713. __pyx_t_19 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  6714. if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 375, __pyx_L1_error)
  6715. __Pyx_XGOTREF(__pyx_t_19);
  6716. __pyx_t_18 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  6717. if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 375, __pyx_L1_error)
  6718. __Pyx_XGOTREF(__pyx_t_18);
  6719. }
  6720. #else
  6721. __pyx_t_19 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 375, __pyx_L1_error)
  6722. __Pyx_GOTREF(__pyx_t_19);
  6723. __pyx_t_18 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 375, __pyx_L1_error)
  6724. __Pyx_GOTREF(__pyx_t_18);
  6725. #endif
  6726. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6727. } else {
  6728. Py_ssize_t index = -1;
  6729. __pyx_t_3 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L1_error)
  6730. __Pyx_GOTREF(__pyx_t_3);
  6731. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6732. __pyx_t_23 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3);
  6733. index = 0; __pyx_t_19 = __pyx_t_23(__pyx_t_3); if (unlikely(!__pyx_t_19)) goto __pyx_L44_unpacking_failed;
  6734. __Pyx_GOTREF(__pyx_t_19);
  6735. index = 1; __pyx_t_18 = __pyx_t_23(__pyx_t_3); if (unlikely(!__pyx_t_18)) goto __pyx_L44_unpacking_failed;
  6736. __Pyx_GOTREF(__pyx_t_18);
  6737. if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_3), 2) < (0)) __PYX_ERR(0, 375, __pyx_L1_error)
  6738. __pyx_t_23 = NULL;
  6739. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6740. goto __pyx_L45_unpacking_done;
  6741. __pyx_L44_unpacking_failed:;
  6742. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6743. __pyx_t_23 = NULL;
  6744. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  6745. __PYX_ERR(0, 375, __pyx_L1_error)
  6746. __pyx_L45_unpacking_done:;
  6747. }
  6748. __pyx_t_13 = __Pyx_PyLong_As_int(__pyx_t_19); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 375, __pyx_L1_error)
  6749. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6750. __pyx_t_5 = __Pyx_PyLong_As_int(__pyx_t_18); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 375, __pyx_L1_error)
  6751. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6752. __pyx_v_i = __pyx_t_13;
  6753. __pyx_v_is_cubic = __pyx_t_5;
  6754. /* "fontTools/qu2cu/qu2cu.py":376
  6755. * j = 0
  6756. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  6757. * if is_cubic: # <<<<<<<<<<<<<<
  6758. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  6759. * else:
  6760. */
  6761. __pyx_t_2 = (__pyx_v_is_cubic != 0);
  6762. if (__pyx_t_2) {
  6763. /* "fontTools/qu2cu/qu2cu.py":377
  6764. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  6765. * if is_cubic:
  6766. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0]) # <<<<<<<<<<<<<<
  6767. * else:
  6768. * for k in range(j, i):
  6769. */
  6770. __pyx_t_8 = __pyx_f_9fontTools_5qu2cu_5qu2cu_merge_curves(__pyx_v_elevated_quadratics, __pyx_v_j, (__pyx_v_i - __pyx_v_j)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 377, __pyx_L1_error)
  6771. __Pyx_GOTREF(__pyx_t_8);
  6772. __pyx_t_18 = __Pyx_GetItemInt(__pyx_t_8, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 377, __pyx_L1_error)
  6773. __Pyx_GOTREF(__pyx_t_18);
  6774. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6775. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_curves, __pyx_t_18); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 377, __pyx_L1_error)
  6776. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6777. /* "fontTools/qu2cu/qu2cu.py":376
  6778. * j = 0
  6779. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  6780. * if is_cubic: # <<<<<<<<<<<<<<
  6781. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  6782. * else:
  6783. */
  6784. goto __pyx_L46;
  6785. }
  6786. /* "fontTools/qu2cu/qu2cu.py":379
  6787. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  6788. * else:
  6789. * for k in range(j, i): # <<<<<<<<<<<<<<
  6790. * curves.append(q[k * 2 : k * 2 + 3])
  6791. * j = i
  6792. */
  6793. /*else*/ {
  6794. __pyx_t_5 = __pyx_v_i;
  6795. __pyx_t_13 = __pyx_t_5;
  6796. for (__pyx_t_14 = __pyx_v_j; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
  6797. __pyx_v_k = __pyx_t_14;
  6798. /* "fontTools/qu2cu/qu2cu.py":380
  6799. * else:
  6800. * for k in range(j, i):
  6801. * curves.append(q[k * 2 : k * 2 + 3]) # <<<<<<<<<<<<<<
  6802. * j = i
  6803. *
  6804. */
  6805. __pyx_t_18 = __Pyx_PyObject_GetSlice(__pyx_v_q, (__pyx_v_k * 2), ((__pyx_v_k * 2) + 3), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 380, __pyx_L1_error)
  6806. __Pyx_GOTREF(__pyx_t_18);
  6807. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_curves, __pyx_t_18); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 380, __pyx_L1_error)
  6808. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6809. }
  6810. }
  6811. __pyx_L46:;
  6812. /* "fontTools/qu2cu/qu2cu.py":381
  6813. * for k in range(j, i):
  6814. * curves.append(q[k * 2 : k * 2 + 3])
  6815. * j = i # <<<<<<<<<<<<<<
  6816. *
  6817. * return curves
  6818. */
  6819. __pyx_v_j = __pyx_v_i;
  6820. /* "fontTools/qu2cu/qu2cu.py":375
  6821. * curves = []
  6822. * j = 0
  6823. * for i, is_cubic in reversed(list(zip(splits, cubic))): # <<<<<<<<<<<<<<
  6824. * if is_cubic:
  6825. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  6826. */
  6827. }
  6828. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6829. /* "fontTools/qu2cu/qu2cu.py":383
  6830. * j = i
  6831. *
  6832. * return curves # <<<<<<<<<<<<<<
  6833. *
  6834. *
  6835. */
  6836. __Pyx_XDECREF(__pyx_r);
  6837. __Pyx_INCREF(__pyx_v_curves);
  6838. __pyx_r = __pyx_v_curves;
  6839. goto __pyx_L0;
  6840. /* "fontTools/qu2cu/qu2cu.py":242
  6841. *
  6842. *
  6843. * @cython.locals( # <<<<<<<<<<<<<<
  6844. * i=cython.int,
  6845. * j=cython.int,
  6846. */
  6847. /* function exit code */
  6848. __pyx_L1_error:;
  6849. __Pyx_XDECREF(__pyx_t_3);
  6850. __Pyx_XDECREF(__pyx_t_6);
  6851. __Pyx_XDECREF(__pyx_t_7);
  6852. __Pyx_XDECREF(__pyx_t_8);
  6853. __Pyx_XDECREF(__pyx_t_18);
  6854. __Pyx_XDECREF(__pyx_t_19);
  6855. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6856. __pyx_r = NULL;
  6857. __pyx_L0:;
  6858. __Pyx_XDECREF(__pyx_v_elevated_quadratics);
  6859. __Pyx_XDECREF(__pyx_v_forced);
  6860. __Pyx_XDECREF(__pyx_v_sols);
  6861. __Pyx_XDECREF(__pyx_v_impossible);
  6862. __Pyx_XDECREF(__pyx_v_best_sol);
  6863. __Pyx_XDECREF(__pyx_v_this_count);
  6864. __Pyx_XDECREF(__pyx_v_i_sol);
  6865. __Pyx_XDECREF(__pyx_v_curve);
  6866. __Pyx_XDECREF(__pyx_v_ts);
  6867. __Pyx_XDECREF(__pyx_v_reconstructed_iter);
  6868. __Pyx_XDECREF(__pyx_v_reconstructed);
  6869. __Pyx_XDECREF(__pyx_v_reconst);
  6870. __Pyx_XDECREF(__pyx_v_orig);
  6871. __Pyx_XDECREF(__pyx_v_splits);
  6872. __Pyx_XDECREF(__pyx_v_cubic);
  6873. __Pyx_XDECREF(__pyx_v_curves);
  6874. __Pyx_XDECREF(__pyx_gb_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_2generator1);
  6875. __Pyx_XGIVEREF(__pyx_r);
  6876. __Pyx_RefNannyFinishContext();
  6877. return __pyx_r;
  6878. }
  6879. /* "fontTools/qu2cu/qu2cu.py":386
  6880. *
  6881. *
  6882. * def main(): # <<<<<<<<<<<<<<
  6883. * from fontTools.cu2qu.benchmark import generate_curve
  6884. * from fontTools.cu2qu import curve_to_quadratic
  6885. */
  6886. /* Python wrapper */
  6887. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_9main(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  6888. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_8main, "main()");
  6889. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_9main = {"main", (PyCFunction)__pyx_pw_9fontTools_5qu2cu_5qu2cu_9main, METH_NOARGS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_8main};
  6890. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_9main(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  6891. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  6892. PyObject *__pyx_r = 0;
  6893. __Pyx_RefNannyDeclarations
  6894. __Pyx_RefNannySetupContext("main (wrapper)", 0);
  6895. __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  6896. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_8main(__pyx_self);
  6897. /* function exit code */
  6898. __Pyx_RefNannyFinishContext();
  6899. return __pyx_r;
  6900. }
  6901. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_8main(CYTHON_UNUSED PyObject *__pyx_self) {
  6902. PyObject *__pyx_v_generate_curve = NULL;
  6903. PyObject *__pyx_v_curve_to_quadratic = NULL;
  6904. double __pyx_v_tolerance;
  6905. double __pyx_v_reconstruct_tolerance;
  6906. PyObject *__pyx_v_curve = NULL;
  6907. PyObject *__pyx_v_quadratics = NULL;
  6908. PyObject *__pyx_v_curves = NULL;
  6909. PyObject *__pyx_r = NULL;
  6910. __Pyx_RefNannyDeclarations
  6911. PyObject *__pyx_t_1 = NULL;
  6912. PyObject *__pyx_t_2 = NULL;
  6913. Py_ssize_t __pyx_t_3;
  6914. PyObject *__pyx_t_4 = NULL;
  6915. PyObject *__pyx_t_5 = NULL;
  6916. size_t __pyx_t_6;
  6917. PyObject *__pyx_t_7 = NULL;
  6918. PyObject *__pyx_t_8 = NULL;
  6919. int __pyx_lineno = 0;
  6920. const char *__pyx_filename = NULL;
  6921. int __pyx_clineno = 0;
  6922. __Pyx_RefNannySetupContext("main", 0);
  6923. /* "fontTools/qu2cu/qu2cu.py":387
  6924. *
  6925. * def main():
  6926. * from fontTools.cu2qu.benchmark import generate_curve # <<<<<<<<<<<<<<
  6927. * from fontTools.cu2qu import curve_to_quadratic
  6928. *
  6929. */
  6930. {
  6931. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_generate_curve};
  6932. __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_fontTools_cu2qu_benchmark, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 387, __pyx_L1_error)
  6933. }
  6934. __pyx_t_1 = __pyx_t_2;
  6935. __Pyx_GOTREF(__pyx_t_1);
  6936. {
  6937. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_generate_curve};
  6938. __pyx_t_3 = 0; {
  6939. __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_1, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 387, __pyx_L1_error)
  6940. __Pyx_GOTREF(__pyx_t_4);
  6941. switch (__pyx_t_3) {
  6942. case 0:
  6943. __Pyx_INCREF(__pyx_t_4);
  6944. __pyx_v_generate_curve = __pyx_t_4;
  6945. break;
  6946. default:;
  6947. }
  6948. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6949. }
  6950. }
  6951. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6952. /* "fontTools/qu2cu/qu2cu.py":388
  6953. * def main():
  6954. * from fontTools.cu2qu.benchmark import generate_curve
  6955. * from fontTools.cu2qu import curve_to_quadratic # <<<<<<<<<<<<<<
  6956. *
  6957. * tolerance = 0.05
  6958. */
  6959. {
  6960. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_curve_to_quadratic};
  6961. __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_fontTools_cu2qu, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 388, __pyx_L1_error)
  6962. }
  6963. __pyx_t_1 = __pyx_t_2;
  6964. __Pyx_GOTREF(__pyx_t_1);
  6965. {
  6966. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_curve_to_quadratic};
  6967. __pyx_t_3 = 0; {
  6968. __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_1, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 388, __pyx_L1_error)
  6969. __Pyx_GOTREF(__pyx_t_4);
  6970. switch (__pyx_t_3) {
  6971. case 0:
  6972. __Pyx_INCREF(__pyx_t_4);
  6973. __pyx_v_curve_to_quadratic = __pyx_t_4;
  6974. break;
  6975. default:;
  6976. }
  6977. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  6978. }
  6979. }
  6980. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6981. /* "fontTools/qu2cu/qu2cu.py":390
  6982. * from fontTools.cu2qu import curve_to_quadratic
  6983. *
  6984. * tolerance = 0.05 # <<<<<<<<<<<<<<
  6985. * reconstruct_tolerance = tolerance * 1
  6986. * curve = generate_curve()
  6987. */
  6988. __pyx_v_tolerance = 0.05;
  6989. /* "fontTools/qu2cu/qu2cu.py":391
  6990. *
  6991. * tolerance = 0.05
  6992. * reconstruct_tolerance = tolerance * 1 # <<<<<<<<<<<<<<
  6993. * curve = generate_curve()
  6994. * quadratics = curve_to_quadratic(curve, tolerance)
  6995. */
  6996. __pyx_v_reconstruct_tolerance = (__pyx_v_tolerance * 1.0);
  6997. /* "fontTools/qu2cu/qu2cu.py":392
  6998. * tolerance = 0.05
  6999. * reconstruct_tolerance = tolerance * 1
  7000. * curve = generate_curve() # <<<<<<<<<<<<<<
  7001. * quadratics = curve_to_quadratic(curve, tolerance)
  7002. * print(
  7003. */
  7004. __pyx_t_4 = NULL;
  7005. __Pyx_INCREF(__pyx_v_generate_curve);
  7006. __pyx_t_5 = __pyx_v_generate_curve;
  7007. __pyx_t_6 = 1;
  7008. #if CYTHON_UNPACK_METHODS
  7009. if (unlikely(PyMethod_Check(__pyx_t_5))) {
  7010. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
  7011. assert(__pyx_t_4);
  7012. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
  7013. __Pyx_INCREF(__pyx_t_4);
  7014. __Pyx_INCREF(__pyx__function);
  7015. __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
  7016. __pyx_t_6 = 0;
  7017. }
  7018. #endif
  7019. {
  7020. PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
  7021. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7022. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7023. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7024. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 392, __pyx_L1_error)
  7025. __Pyx_GOTREF(__pyx_t_1);
  7026. }
  7027. __pyx_v_curve = __pyx_t_1;
  7028. __pyx_t_1 = 0;
  7029. /* "fontTools/qu2cu/qu2cu.py":393
  7030. * reconstruct_tolerance = tolerance * 1
  7031. * curve = generate_curve()
  7032. * quadratics = curve_to_quadratic(curve, tolerance) # <<<<<<<<<<<<<<
  7033. * print(
  7034. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance)
  7035. */
  7036. __pyx_t_5 = NULL;
  7037. __Pyx_INCREF(__pyx_v_curve_to_quadratic);
  7038. __pyx_t_4 = __pyx_v_curve_to_quadratic;
  7039. __pyx_t_7 = PyFloat_FromDouble(__pyx_v_tolerance); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 393, __pyx_L1_error)
  7040. __Pyx_GOTREF(__pyx_t_7);
  7041. __pyx_t_6 = 1;
  7042. #if CYTHON_UNPACK_METHODS
  7043. if (unlikely(PyMethod_Check(__pyx_t_4))) {
  7044. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  7045. assert(__pyx_t_5);
  7046. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
  7047. __Pyx_INCREF(__pyx_t_5);
  7048. __Pyx_INCREF(__pyx__function);
  7049. __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
  7050. __pyx_t_6 = 0;
  7051. }
  7052. #endif
  7053. {
  7054. PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_v_curve, __pyx_t_7};
  7055. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7056. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7057. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7058. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7059. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error)
  7060. __Pyx_GOTREF(__pyx_t_1);
  7061. }
  7062. __pyx_v_quadratics = __pyx_t_1;
  7063. __pyx_t_1 = 0;
  7064. /* "fontTools/qu2cu/qu2cu.py":394
  7065. * curve = generate_curve()
  7066. * quadratics = curve_to_quadratic(curve, tolerance)
  7067. * print( # <<<<<<<<<<<<<<
  7068. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance)
  7069. * )
  7070. */
  7071. __pyx_t_4 = NULL;
  7072. /* "fontTools/qu2cu/qu2cu.py":395
  7073. * quadratics = curve_to_quadratic(curve, tolerance)
  7074. * print(
  7075. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance) # <<<<<<<<<<<<<<
  7076. * )
  7077. * print("One random cubic turned into %d quadratics." % len(quadratics))
  7078. */
  7079. __pyx_t_7 = PyFloat_FromDouble(__pyx_v_tolerance); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 395, __pyx_L1_error)
  7080. __Pyx_GOTREF(__pyx_t_7);
  7081. __pyx_t_5 = PyFloat_FromDouble(__pyx_v_reconstruct_tolerance); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 395, __pyx_L1_error)
  7082. __Pyx_GOTREF(__pyx_t_5);
  7083. __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 395, __pyx_L1_error)
  7084. __Pyx_GOTREF(__pyx_t_8);
  7085. __Pyx_GIVEREF(__pyx_t_7);
  7086. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 395, __pyx_L1_error);
  7087. __Pyx_GIVEREF(__pyx_t_5);
  7088. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 395, __pyx_L1_error);
  7089. __pyx_t_7 = 0;
  7090. __pyx_t_5 = 0;
  7091. __pyx_t_5 = PyUnicode_Format(__pyx_mstate_global->__pyx_kp_u_cu2qu_tolerance_g_qu2cu_toleranc, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 395, __pyx_L1_error)
  7092. __Pyx_GOTREF(__pyx_t_5);
  7093. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7094. __pyx_t_6 = 1;
  7095. {
  7096. PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_5};
  7097. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7098. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7099. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7100. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __pyx_L1_error)
  7101. __Pyx_GOTREF(__pyx_t_1);
  7102. }
  7103. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7104. /* "fontTools/qu2cu/qu2cu.py":397
  7105. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance)
  7106. * )
  7107. * print("One random cubic turned into %d quadratics." % len(quadratics)) # <<<<<<<<<<<<<<
  7108. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance)
  7109. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7110. */
  7111. __pyx_t_5 = NULL;
  7112. __pyx_t_3 = PyObject_Length(__pyx_v_quadratics); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 397, __pyx_L1_error)
  7113. __pyx_t_4 = PyLong_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 397, __pyx_L1_error)
  7114. __Pyx_GOTREF(__pyx_t_4);
  7115. __pyx_t_8 = PyUnicode_Format(__pyx_mstate_global->__pyx_kp_u_One_random_cubic_turned_into_d_q, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 397, __pyx_L1_error)
  7116. __Pyx_GOTREF(__pyx_t_8);
  7117. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7118. __pyx_t_6 = 1;
  7119. {
  7120. PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_8};
  7121. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7122. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7123. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7124. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 397, __pyx_L1_error)
  7125. __Pyx_GOTREF(__pyx_t_1);
  7126. }
  7127. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7128. /* "fontTools/qu2cu/qu2cu.py":398
  7129. * )
  7130. * print("One random cubic turned into %d quadratics." % len(quadratics))
  7131. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance) # <<<<<<<<<<<<<<
  7132. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7133. * print("Original curve:", curve)
  7134. */
  7135. __pyx_t_8 = NULL;
  7136. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_quadratic_to_curves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 398, __pyx_L1_error)
  7137. __Pyx_GOTREF(__pyx_t_5);
  7138. __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 398, __pyx_L1_error)
  7139. __Pyx_GOTREF(__pyx_t_4);
  7140. __Pyx_INCREF(__pyx_v_quadratics);
  7141. __Pyx_GIVEREF(__pyx_v_quadratics);
  7142. if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_quadratics) != (0)) __PYX_ERR(0, 398, __pyx_L1_error);
  7143. __pyx_t_7 = PyFloat_FromDouble(__pyx_v_reconstruct_tolerance); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 398, __pyx_L1_error)
  7144. __Pyx_GOTREF(__pyx_t_7);
  7145. __pyx_t_6 = 1;
  7146. #if CYTHON_UNPACK_METHODS
  7147. if (unlikely(PyMethod_Check(__pyx_t_5))) {
  7148. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
  7149. assert(__pyx_t_8);
  7150. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
  7151. __Pyx_INCREF(__pyx_t_8);
  7152. __Pyx_INCREF(__pyx__function);
  7153. __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
  7154. __pyx_t_6 = 0;
  7155. }
  7156. #endif
  7157. {
  7158. PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_t_4, __pyx_t_7};
  7159. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7160. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  7161. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7162. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7163. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7164. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 398, __pyx_L1_error)
  7165. __Pyx_GOTREF(__pyx_t_1);
  7166. }
  7167. __pyx_v_curves = __pyx_t_1;
  7168. __pyx_t_1 = 0;
  7169. /* "fontTools/qu2cu/qu2cu.py":399
  7170. * print("One random cubic turned into %d quadratics." % len(quadratics))
  7171. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance)
  7172. * print("Those quadratics turned back into %d cubics. " % len(curves)) # <<<<<<<<<<<<<<
  7173. * print("Original curve:", curve)
  7174. * print("Reconstructed curve(s):", curves)
  7175. */
  7176. __pyx_t_5 = NULL;
  7177. __pyx_t_3 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 399, __pyx_L1_error)
  7178. __pyx_t_7 = PyLong_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 399, __pyx_L1_error)
  7179. __Pyx_GOTREF(__pyx_t_7);
  7180. __pyx_t_4 = PyUnicode_Format(__pyx_mstate_global->__pyx_kp_u_Those_quadratics_turned_back_int, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 399, __pyx_L1_error)
  7181. __Pyx_GOTREF(__pyx_t_4);
  7182. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7183. __pyx_t_6 = 1;
  7184. {
  7185. PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4};
  7186. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7187. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7188. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7189. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 399, __pyx_L1_error)
  7190. __Pyx_GOTREF(__pyx_t_1);
  7191. }
  7192. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7193. /* "fontTools/qu2cu/qu2cu.py":400
  7194. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance)
  7195. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7196. * print("Original curve:", curve) # <<<<<<<<<<<<<<
  7197. * print("Reconstructed curve(s):", curves)
  7198. *
  7199. */
  7200. __pyx_t_4 = NULL;
  7201. __pyx_t_6 = 1;
  7202. {
  7203. PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Original_curve, __pyx_v_curve};
  7204. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7205. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7206. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 400, __pyx_L1_error)
  7207. __Pyx_GOTREF(__pyx_t_1);
  7208. }
  7209. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7210. /* "fontTools/qu2cu/qu2cu.py":401
  7211. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7212. * print("Original curve:", curve)
  7213. * print("Reconstructed curve(s):", curves) # <<<<<<<<<<<<<<
  7214. *
  7215. *
  7216. */
  7217. __pyx_t_4 = NULL;
  7218. __pyx_t_6 = 1;
  7219. {
  7220. PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Reconstructed_curve_s, __pyx_v_curves};
  7221. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_print, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  7222. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7223. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 401, __pyx_L1_error)
  7224. __Pyx_GOTREF(__pyx_t_1);
  7225. }
  7226. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7227. /* "fontTools/qu2cu/qu2cu.py":386
  7228. *
  7229. *
  7230. * def main(): # <<<<<<<<<<<<<<
  7231. * from fontTools.cu2qu.benchmark import generate_curve
  7232. * from fontTools.cu2qu import curve_to_quadratic
  7233. */
  7234. /* function exit code */
  7235. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7236. goto __pyx_L0;
  7237. __pyx_L1_error:;
  7238. __Pyx_XDECREF(__pyx_t_1);
  7239. __Pyx_XDECREF(__pyx_t_4);
  7240. __Pyx_XDECREF(__pyx_t_5);
  7241. __Pyx_XDECREF(__pyx_t_7);
  7242. __Pyx_XDECREF(__pyx_t_8);
  7243. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.main", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7244. __pyx_r = NULL;
  7245. __pyx_L0:;
  7246. __Pyx_XDECREF(__pyx_v_generate_curve);
  7247. __Pyx_XDECREF(__pyx_v_curve_to_quadratic);
  7248. __Pyx_XDECREF(__pyx_v_curve);
  7249. __Pyx_XDECREF(__pyx_v_quadratics);
  7250. __Pyx_XDECREF(__pyx_v_curves);
  7251. __Pyx_XGIVEREF(__pyx_r);
  7252. __Pyx_RefNannyFinishContext();
  7253. return __pyx_r;
  7254. }
  7255. /* #### Code section: module_exttypes ### */
  7256. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  7257. PyObject *o;
  7258. #if CYTHON_USE_FREELISTS
  7259. if (likely((int)(__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr))))
  7260. {
  7261. o = (PyObject*)__pyx_mstate_global->__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr[--__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr];
  7262. #if CYTHON_USE_TYPE_SPECS
  7263. Py_DECREF(Py_TYPE(o));
  7264. #endif
  7265. memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr));
  7266. #if CYTHON_COMPILING_IN_LIMITED_API
  7267. (void) PyObject_Init(o, t);
  7268. #else
  7269. (void) PyObject_INIT(o, t);
  7270. #endif
  7271. PyObject_GC_Track(o);
  7272. } else
  7273. #endif
  7274. {
  7275. o = __Pyx_AllocateExtensionType(t, 1);
  7276. if (unlikely(!o)) return 0;
  7277. }
  7278. return o;
  7279. }
  7280. static void __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyObject *o) {
  7281. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)o;
  7282. #if CYTHON_USE_TP_FINALIZE
  7283. if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
  7284. if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr) {
  7285. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7286. }
  7287. }
  7288. #endif
  7289. PyObject_GC_UnTrack(o);
  7290. Py_CLEAR(p->__pyx_genexpr_arg_0);
  7291. Py_CLEAR(p->__pyx_v_c);
  7292. Py_CLEAR(p->__pyx_t_0);
  7293. #if CYTHON_USE_FREELISTS
  7294. if (likely((int)(__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr))))
  7295. {
  7296. __pyx_mstate_global->__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr[__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr++] = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)o);
  7297. } else
  7298. #endif
  7299. {
  7300. PyTypeObject *tp = Py_TYPE(o);
  7301. #if CYTHON_USE_TYPE_SLOTS
  7302. (*tp->tp_free)(o);
  7303. #else
  7304. {
  7305. freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
  7306. if (tp_free) tp_free(o);
  7307. }
  7308. #endif
  7309. #if CYTHON_USE_TYPE_SPECS
  7310. Py_DECREF(tp);
  7311. #endif
  7312. }
  7313. }
  7314. static int __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyObject *o, visitproc v, void *a) {
  7315. int e;
  7316. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)o;
  7317. {
  7318. e = __Pyx_call_type_traverse(o, 1, v, a);
  7319. if (e) return e;
  7320. }
  7321. if (p->__pyx_genexpr_arg_0) {
  7322. e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  7323. }
  7324. if (p->__pyx_v_c) {
  7325. e = (*v)(p->__pyx_v_c, a); if (e) return e;
  7326. }
  7327. if (p->__pyx_t_0) {
  7328. e = (*v)(p->__pyx_t_0, a); if (e) return e;
  7329. }
  7330. return 0;
  7331. }
  7332. #if CYTHON_USE_TYPE_SPECS
  7333. static PyType_Slot __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_slots[] = {
  7334. {Py_tp_dealloc, (void *)__pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr},
  7335. {Py_tp_traverse, (void *)__pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr},
  7336. {Py_tp_new, (void *)__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr},
  7337. {0, 0},
  7338. };
  7339. static PyType_Spec __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_spec = {
  7340. "fontTools.qu2cu.qu2cu.__pyx_scope_struct__genexpr",
  7341. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr),
  7342. 0,
  7343. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  7344. __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_slots,
  7345. };
  7346. #else
  7347. static PyTypeObject __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr = {
  7348. PyVarObject_HEAD_INIT(0, 0)
  7349. "fontTools.qu2cu.qu2cu.""__pyx_scope_struct__genexpr", /*tp_name*/
  7350. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr), /*tp_basicsize*/
  7351. 0, /*tp_itemsize*/
  7352. __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, /*tp_dealloc*/
  7353. 0, /*tp_vectorcall_offset*/
  7354. 0, /*tp_getattr*/
  7355. 0, /*tp_setattr*/
  7356. 0, /*tp_as_async*/
  7357. 0, /*tp_repr*/
  7358. 0, /*tp_as_number*/
  7359. 0, /*tp_as_sequence*/
  7360. 0, /*tp_as_mapping*/
  7361. 0, /*tp_hash*/
  7362. 0, /*tp_call*/
  7363. 0, /*tp_str*/
  7364. 0, /*tp_getattro*/
  7365. 0, /*tp_setattro*/
  7366. 0, /*tp_as_buffer*/
  7367. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7368. 0, /*tp_doc*/
  7369. __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, /*tp_traverse*/
  7370. 0, /*tp_clear*/
  7371. 0, /*tp_richcompare*/
  7372. 0, /*tp_weaklistoffset*/
  7373. 0, /*tp_iter*/
  7374. 0, /*tp_iternext*/
  7375. 0, /*tp_methods*/
  7376. 0, /*tp_members*/
  7377. 0, /*tp_getset*/
  7378. 0, /*tp_base*/
  7379. 0, /*tp_dict*/
  7380. 0, /*tp_descr_get*/
  7381. 0, /*tp_descr_set*/
  7382. #if !CYTHON_USE_TYPE_SPECS
  7383. 0, /*tp_dictoffset*/
  7384. #endif
  7385. 0, /*tp_init*/
  7386. 0, /*tp_alloc*/
  7387. __pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, /*tp_new*/
  7388. 0, /*tp_free*/
  7389. 0, /*tp_is_gc*/
  7390. 0, /*tp_bases*/
  7391. 0, /*tp_mro*/
  7392. 0, /*tp_cache*/
  7393. 0, /*tp_subclasses*/
  7394. 0, /*tp_weaklist*/
  7395. 0, /*tp_del*/
  7396. 0, /*tp_version_tag*/
  7397. #if CYTHON_USE_TP_FINALIZE
  7398. 0, /*tp_finalize*/
  7399. #else
  7400. NULL, /*tp_finalize*/
  7401. #endif
  7402. #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  7403. 0, /*tp_vectorcall*/
  7404. #endif
  7405. #if __PYX_NEED_TP_PRINT_SLOT == 1
  7406. 0, /*tp_print*/
  7407. #endif
  7408. #if PY_VERSION_HEX >= 0x030C0000
  7409. 0, /*tp_watched*/
  7410. #endif
  7411. #if PY_VERSION_HEX >= 0x030d00A4
  7412. 0, /*tp_versions_used*/
  7413. #endif
  7414. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  7415. 0, /*tp_pypy_flags*/
  7416. #endif
  7417. };
  7418. #endif
  7419. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  7420. PyObject *o;
  7421. #if CYTHON_USE_FREELISTS
  7422. if (likely((int)(__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr))))
  7423. {
  7424. o = (PyObject*)__pyx_mstate_global->__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr[--__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr];
  7425. #if CYTHON_USE_TYPE_SPECS
  7426. Py_DECREF(Py_TYPE(o));
  7427. #endif
  7428. memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr));
  7429. #if CYTHON_COMPILING_IN_LIMITED_API
  7430. (void) PyObject_Init(o, t);
  7431. #else
  7432. (void) PyObject_INIT(o, t);
  7433. #endif
  7434. PyObject_GC_Track(o);
  7435. } else
  7436. #endif
  7437. {
  7438. o = __Pyx_AllocateExtensionType(t, 1);
  7439. if (unlikely(!o)) return 0;
  7440. }
  7441. return o;
  7442. }
  7443. static void __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyObject *o) {
  7444. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)o;
  7445. #if CYTHON_USE_TP_FINALIZE
  7446. if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
  7447. if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr) {
  7448. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7449. }
  7450. }
  7451. #endif
  7452. PyObject_GC_UnTrack(o);
  7453. Py_CLEAR(p->__pyx_genexpr_arg_0);
  7454. Py_CLEAR(p->__pyx_t_0);
  7455. #if CYTHON_USE_FREELISTS
  7456. if (likely((int)(__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr))))
  7457. {
  7458. __pyx_mstate_global->__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr[__pyx_mstate_global->__pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr++] = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)o);
  7459. } else
  7460. #endif
  7461. {
  7462. PyTypeObject *tp = Py_TYPE(o);
  7463. #if CYTHON_USE_TYPE_SLOTS
  7464. (*tp->tp_free)(o);
  7465. #else
  7466. {
  7467. freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
  7468. if (tp_free) tp_free(o);
  7469. }
  7470. #endif
  7471. #if CYTHON_USE_TYPE_SPECS
  7472. Py_DECREF(tp);
  7473. #endif
  7474. }
  7475. }
  7476. static int __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  7477. int e;
  7478. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)o;
  7479. {
  7480. e = __Pyx_call_type_traverse(o, 1, v, a);
  7481. if (e) return e;
  7482. }
  7483. if (p->__pyx_genexpr_arg_0) {
  7484. e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  7485. }
  7486. if (p->__pyx_t_0) {
  7487. e = (*v)(p->__pyx_t_0, a); if (e) return e;
  7488. }
  7489. return 0;
  7490. }
  7491. #if CYTHON_USE_TYPE_SPECS
  7492. static PyType_Slot __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_slots[] = {
  7493. {Py_tp_dealloc, (void *)__pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr},
  7494. {Py_tp_traverse, (void *)__pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr},
  7495. {Py_tp_new, (void *)__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr},
  7496. {0, 0},
  7497. };
  7498. static PyType_Spec __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_spec = {
  7499. "fontTools.qu2cu.qu2cu.__pyx_scope_struct_1_genexpr",
  7500. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr),
  7501. 0,
  7502. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  7503. __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_slots,
  7504. };
  7505. #else
  7506. static PyTypeObject __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr = {
  7507. PyVarObject_HEAD_INIT(0, 0)
  7508. "fontTools.qu2cu.qu2cu.""__pyx_scope_struct_1_genexpr", /*tp_name*/
  7509. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  7510. 0, /*tp_itemsize*/
  7511. __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  7512. 0, /*tp_vectorcall_offset*/
  7513. 0, /*tp_getattr*/
  7514. 0, /*tp_setattr*/
  7515. 0, /*tp_as_async*/
  7516. 0, /*tp_repr*/
  7517. 0, /*tp_as_number*/
  7518. 0, /*tp_as_sequence*/
  7519. 0, /*tp_as_mapping*/
  7520. 0, /*tp_hash*/
  7521. 0, /*tp_call*/
  7522. 0, /*tp_str*/
  7523. 0, /*tp_getattro*/
  7524. 0, /*tp_setattro*/
  7525. 0, /*tp_as_buffer*/
  7526. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  7527. 0, /*tp_doc*/
  7528. __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  7529. 0, /*tp_clear*/
  7530. 0, /*tp_richcompare*/
  7531. 0, /*tp_weaklistoffset*/
  7532. 0, /*tp_iter*/
  7533. 0, /*tp_iternext*/
  7534. 0, /*tp_methods*/
  7535. 0, /*tp_members*/
  7536. 0, /*tp_getset*/
  7537. 0, /*tp_base*/
  7538. 0, /*tp_dict*/
  7539. 0, /*tp_descr_get*/
  7540. 0, /*tp_descr_set*/
  7541. #if !CYTHON_USE_TYPE_SPECS
  7542. 0, /*tp_dictoffset*/
  7543. #endif
  7544. 0, /*tp_init*/
  7545. 0, /*tp_alloc*/
  7546. __pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, /*tp_new*/
  7547. 0, /*tp_free*/
  7548. 0, /*tp_is_gc*/
  7549. 0, /*tp_bases*/
  7550. 0, /*tp_mro*/
  7551. 0, /*tp_cache*/
  7552. 0, /*tp_subclasses*/
  7553. 0, /*tp_weaklist*/
  7554. 0, /*tp_del*/
  7555. 0, /*tp_version_tag*/
  7556. #if CYTHON_USE_TP_FINALIZE
  7557. 0, /*tp_finalize*/
  7558. #else
  7559. NULL, /*tp_finalize*/
  7560. #endif
  7561. #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  7562. 0, /*tp_vectorcall*/
  7563. #endif
  7564. #if __PYX_NEED_TP_PRINT_SLOT == 1
  7565. 0, /*tp_print*/
  7566. #endif
  7567. #if PY_VERSION_HEX >= 0x030C0000
  7568. 0, /*tp_watched*/
  7569. #endif
  7570. #if PY_VERSION_HEX >= 0x030d00A4
  7571. 0, /*tp_versions_used*/
  7572. #endif
  7573. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  7574. 0, /*tp_pypy_flags*/
  7575. #endif
  7576. };
  7577. #endif
  7578. static PyMethodDef __pyx_methods[] = {
  7579. {0, 0, 0, 0}
  7580. };
  7581. /* #### Code section: initfunc_declarations ### */
  7582. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7583. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7584. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/
  7585. static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7586. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7587. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7588. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7589. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7590. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7591. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7592. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7593. static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7594. /* #### Code section: init_module ### */
  7595. static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) {
  7596. __Pyx_RefNannyDeclarations
  7597. CYTHON_UNUSED_VAR(__pyx_mstate);
  7598. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  7599. /*--- Global init code ---*/
  7600. __Pyx_RefNannyFinishContext();
  7601. return 0;
  7602. }
  7603. static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) {
  7604. __Pyx_RefNannyDeclarations
  7605. CYTHON_UNUSED_VAR(__pyx_mstate);
  7606. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  7607. /*--- Variable export code ---*/
  7608. __Pyx_RefNannyFinishContext();
  7609. return 0;
  7610. }
  7611. static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) {
  7612. __Pyx_RefNannyDeclarations
  7613. CYTHON_UNUSED_VAR(__pyx_mstate);
  7614. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  7615. /*--- Function export code ---*/
  7616. __Pyx_RefNannyFinishContext();
  7617. return 0;
  7618. }
  7619. static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) {
  7620. __Pyx_RefNannyDeclarations
  7621. CYTHON_UNUSED_VAR(__pyx_mstate);
  7622. int __pyx_lineno = 0;
  7623. const char *__pyx_filename = NULL;
  7624. int __pyx_clineno = 0;
  7625. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  7626. /*--- Type init code ---*/
  7627. #if CYTHON_USE_TYPE_SPECS
  7628. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr)) __PYX_ERR(0, 235, __pyx_L1_error)
  7629. if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_spec, __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr) < (0)) __PYX_ERR(0, 235, __pyx_L1_error)
  7630. #else
  7631. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr = &__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  7632. #endif
  7633. #if !CYTHON_COMPILING_IN_LIMITED_API
  7634. #endif
  7635. #if !CYTHON_USE_TYPE_SPECS
  7636. if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr) < (0)) __PYX_ERR(0, 235, __pyx_L1_error)
  7637. #endif
  7638. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7639. PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  7640. #endif
  7641. #if !CYTHON_COMPILING_IN_LIMITED_API
  7642. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr->tp_getattro == PyObject_GenericGetAttr)) {
  7643. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr->tp_getattro = PyObject_GenericGetAttr;
  7644. }
  7645. #endif
  7646. #if CYTHON_USE_TYPE_SPECS
  7647. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr)) __PYX_ERR(0, 340, __pyx_L1_error)
  7648. if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_spec, __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr) < (0)) __PYX_ERR(0, 340, __pyx_L1_error)
  7649. #else
  7650. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr = &__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  7651. #endif
  7652. #if !CYTHON_COMPILING_IN_LIMITED_API
  7653. #endif
  7654. #if !CYTHON_USE_TYPE_SPECS
  7655. if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr) < (0)) __PYX_ERR(0, 340, __pyx_L1_error)
  7656. #endif
  7657. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7658. PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  7659. #endif
  7660. #if !CYTHON_COMPILING_IN_LIMITED_API
  7661. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
  7662. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr->tp_getattro = PyObject_GenericGetAttr;
  7663. }
  7664. #endif
  7665. __Pyx_RefNannyFinishContext();
  7666. return 0;
  7667. __pyx_L1_error:;
  7668. __Pyx_RefNannyFinishContext();
  7669. return -1;
  7670. }
  7671. static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) {
  7672. __Pyx_RefNannyDeclarations
  7673. CYTHON_UNUSED_VAR(__pyx_mstate);
  7674. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  7675. /*--- Type import code ---*/
  7676. __Pyx_RefNannyFinishContext();
  7677. return 0;
  7678. }
  7679. static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) {
  7680. __Pyx_RefNannyDeclarations
  7681. CYTHON_UNUSED_VAR(__pyx_mstate);
  7682. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  7683. /*--- Variable import code ---*/
  7684. __Pyx_RefNannyFinishContext();
  7685. return 0;
  7686. }
  7687. static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) {
  7688. __Pyx_RefNannyDeclarations
  7689. CYTHON_UNUSED_VAR(__pyx_mstate);
  7690. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  7691. /*--- Function import code ---*/
  7692. __Pyx_RefNannyFinishContext();
  7693. return 0;
  7694. }
  7695. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7696. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  7697. static int __pyx_pymod_exec_qu2cu(PyObject* module); /*proto*/
  7698. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  7699. {Py_mod_create, (void*)__pyx_pymod_create},
  7700. {Py_mod_exec, (void*)__pyx_pymod_exec_qu2cu},
  7701. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7702. {Py_mod_gil, Py_MOD_GIL_USED},
  7703. #endif
  7704. #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE
  7705. {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
  7706. #endif
  7707. {0, NULL}
  7708. };
  7709. #endif
  7710. #ifdef __cplusplus
  7711. namespace {
  7712. struct PyModuleDef __pyx_moduledef =
  7713. #else
  7714. static struct PyModuleDef __pyx_moduledef =
  7715. #endif
  7716. {
  7717. PyModuleDef_HEAD_INIT,
  7718. "qu2cu",
  7719. 0, /* m_doc */
  7720. #if CYTHON_USE_MODULE_STATE
  7721. sizeof(__pyx_mstatetype), /* m_size */
  7722. #else
  7723. (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */
  7724. #endif
  7725. __pyx_methods /* m_methods */,
  7726. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7727. __pyx_moduledef_slots, /* m_slots */
  7728. #else
  7729. NULL, /* m_reload */
  7730. #endif
  7731. #if CYTHON_USE_MODULE_STATE
  7732. __pyx_m_traverse, /* m_traverse */
  7733. __pyx_m_clear, /* m_clear */
  7734. NULL /* m_free */
  7735. #else
  7736. NULL, /* m_traverse */
  7737. NULL, /* m_clear */
  7738. NULL /* m_free */
  7739. #endif
  7740. };
  7741. #ifdef __cplusplus
  7742. } /* anonymous namespace */
  7743. #endif
  7744. /* PyModInitFuncType */
  7745. #ifndef CYTHON_NO_PYINIT_EXPORT
  7746. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  7747. #else
  7748. #ifdef __cplusplus
  7749. #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
  7750. #else
  7751. #define __Pyx_PyMODINIT_FUNC PyObject *
  7752. #endif
  7753. #endif
  7754. __Pyx_PyMODINIT_FUNC PyInit_qu2cu(void) CYTHON_SMALL_CODE; /*proto*/
  7755. __Pyx_PyMODINIT_FUNC PyInit_qu2cu(void)
  7756. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7757. {
  7758. return PyModuleDef_Init(&__pyx_moduledef);
  7759. }
  7760. /* ModuleCreationPEP489 */
  7761. #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  7762. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  7763. static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) {
  7764. {
  7765. PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think
  7766. if (!module) {
  7767. PyErr_Clear(); // just try the 3.8-3.12 version
  7768. module = PyImport_ImportModule("_xxsubinterpreters");
  7769. if (!module) goto bad;
  7770. }
  7771. PyObject *current = PyObject_CallMethod(module, "get_current", NULL);
  7772. Py_DECREF(module);
  7773. if (!current) goto bad;
  7774. if (PyTuple_Check(current)) {
  7775. PyObject *new_current = PySequence_GetItem(current, 0);
  7776. Py_DECREF(current);
  7777. current = new_current;
  7778. if (!new_current) goto bad;
  7779. }
  7780. long long as_c_int = PyLong_AsLongLong(current);
  7781. Py_DECREF(current);
  7782. return as_c_int;
  7783. }
  7784. bad:
  7785. PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n");
  7786. return -1;
  7787. }
  7788. #endif
  7789. #if !CYTHON_USE_MODULE_STATE
  7790. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  7791. static PY_INT64_T main_interpreter_id = -1;
  7792. #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  7793. PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  7794. #elif CYTHON_COMPILING_IN_GRAAL
  7795. PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  7796. #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  7797. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  7798. PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId();
  7799. #elif CYTHON_COMPILING_IN_LIMITED_API
  7800. PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get());
  7801. #else
  7802. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  7803. #endif
  7804. if (unlikely(current_id == -1)) {
  7805. return -1;
  7806. }
  7807. if (main_interpreter_id == -1) {
  7808. main_interpreter_id = current_id;
  7809. return 0;
  7810. } else if (unlikely(main_interpreter_id != current_id)) {
  7811. PyErr_SetString(
  7812. PyExc_ImportError,
  7813. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  7814. return -1;
  7815. }
  7816. return 0;
  7817. }
  7818. #endif
  7819. static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none)
  7820. {
  7821. PyObject *value = PyObject_GetAttrString(spec, from_name);
  7822. int result = 0;
  7823. if (likely(value)) {
  7824. if (allow_none || value != Py_None) {
  7825. result = PyDict_SetItemString(moddict, to_name, value);
  7826. }
  7827. Py_DECREF(value);
  7828. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  7829. PyErr_Clear();
  7830. } else {
  7831. result = -1;
  7832. }
  7833. return result;
  7834. }
  7835. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) {
  7836. PyObject *module = NULL, *moddict, *modname;
  7837. CYTHON_UNUSED_VAR(def);
  7838. #if !CYTHON_USE_MODULE_STATE
  7839. if (__Pyx_check_single_interpreter())
  7840. return NULL;
  7841. #endif
  7842. if (__pyx_m)
  7843. return __Pyx_NewRef(__pyx_m);
  7844. modname = PyObject_GetAttrString(spec, "name");
  7845. if (unlikely(!modname)) goto bad;
  7846. module = PyModule_NewObject(modname);
  7847. Py_DECREF(modname);
  7848. if (unlikely(!module)) goto bad;
  7849. moddict = PyModule_GetDict(module);
  7850. if (unlikely(!moddict)) goto bad;
  7851. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  7852. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  7853. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  7854. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  7855. return module;
  7856. bad:
  7857. Py_XDECREF(module);
  7858. return NULL;
  7859. }
  7860. static CYTHON_SMALL_CODE int __pyx_pymod_exec_qu2cu(PyObject *__pyx_pyinit_module)
  7861. #endif
  7862. {
  7863. int stringtab_initialized = 0;
  7864. #if CYTHON_USE_MODULE_STATE
  7865. int pystate_addmodule_run = 0;
  7866. #endif
  7867. __pyx_mstatetype *__pyx_mstate = NULL;
  7868. PyObject *__pyx_t_1 = NULL;
  7869. PyObject *__pyx_t_2 = NULL;
  7870. PyObject *__pyx_t_3 = NULL;
  7871. PyObject *__pyx_t_4 = NULL;
  7872. Py_ssize_t __pyx_t_5;
  7873. PyObject *__pyx_t_6 = NULL;
  7874. PyObject *__pyx_t_7 = NULL;
  7875. PyObject *__pyx_t_8 = NULL;
  7876. size_t __pyx_t_9;
  7877. int __pyx_t_10;
  7878. int __pyx_lineno = 0;
  7879. const char *__pyx_filename = NULL;
  7880. int __pyx_clineno = 0;
  7881. __Pyx_RefNannyDeclarations
  7882. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7883. if (__pyx_m) {
  7884. if (__pyx_m == __pyx_pyinit_module) return 0;
  7885. PyErr_SetString(PyExc_RuntimeError, "Module 'qu2cu' has already been imported. Re-initialisation is not supported.");
  7886. return -1;
  7887. }
  7888. #else
  7889. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  7890. #endif
  7891. /*--- Module creation code ---*/
  7892. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7893. __pyx_t_1 = __pyx_pyinit_module;
  7894. Py_INCREF(__pyx_t_1);
  7895. #else
  7896. __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  7897. #endif
  7898. #if CYTHON_USE_MODULE_STATE
  7899. {
  7900. int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef);
  7901. __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "qu2cu" pseudovariable */
  7902. if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7903. pystate_addmodule_run = 1;
  7904. }
  7905. #else
  7906. __pyx_m = __pyx_t_1;
  7907. #endif
  7908. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7909. PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED);
  7910. #endif
  7911. __pyx_mstate = __pyx_mstate_global;
  7912. CYTHON_UNUSED_VAR(__pyx_t_1);
  7913. __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  7914. Py_INCREF(__pyx_mstate->__pyx_d);
  7915. __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  7916. __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  7917. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7918. /* ImportRefnannyAPI */
  7919. #if CYTHON_REFNANNY
  7920. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  7921. if (!__Pyx_RefNanny) {
  7922. PyErr_Clear();
  7923. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  7924. if (!__Pyx_RefNanny)
  7925. Py_FatalError("failed to import 'refnanny' module");
  7926. }
  7927. #endif
  7928. __Pyx_RefNannySetupContext("PyInit_qu2cu", 0);
  7929. __Pyx_init_runtime_version();
  7930. if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7931. __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  7932. __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  7933. __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  7934. /*--- Library function declarations ---*/
  7935. /*--- Initialize various global constants etc. ---*/
  7936. if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7937. stringtab_initialized = 1;
  7938. if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7939. if (__pyx_module_is_main_fontTools__qu2cu__qu2cu) {
  7940. if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_name, __pyx_mstate_global->__pyx_n_u_main) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7941. }
  7942. {
  7943. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  7944. if (!PyDict_GetItemString(modules, "fontTools.qu2cu.qu2cu")) {
  7945. if (unlikely((PyDict_SetItemString(modules, "fontTools.qu2cu.qu2cu", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7946. }
  7947. }
  7948. /*--- Builtin init code ---*/
  7949. if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7950. /*--- Constants init code ---*/
  7951. if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7952. if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7953. /*--- Global type/function init code ---*/
  7954. (void)__Pyx_modinit_global_init_code(__pyx_mstate);
  7955. (void)__Pyx_modinit_variable_export_code(__pyx_mstate);
  7956. (void)__Pyx_modinit_function_export_code(__pyx_mstate);
  7957. if (unlikely((__Pyx_modinit_type_init_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7958. (void)__Pyx_modinit_type_import_code(__pyx_mstate);
  7959. (void)__Pyx_modinit_variable_import_code(__pyx_mstate);
  7960. (void)__Pyx_modinit_function_import_code(__pyx_mstate);
  7961. /*--- Execution code ---*/
  7962. /* "fontTools/qu2cu/qu2cu.py":19
  7963. * # limitations under the License.
  7964. *
  7965. * try: # <<<<<<<<<<<<<<
  7966. * import cython
  7967. * except (AttributeError, ImportError):
  7968. */
  7969. {
  7970. (void)__pyx_t_1; (void)__pyx_t_2; (void)__pyx_t_3; /* mark used */
  7971. /*try:*/ {
  7972. /* "fontTools/qu2cu/qu2cu.py":20
  7973. *
  7974. * try:
  7975. * import cython # <<<<<<<<<<<<<<
  7976. * except (AttributeError, ImportError):
  7977. * # if cython not installed, use mock module with no-op decorators and types
  7978. */
  7979. }
  7980. }
  7981. /* "fontTools/qu2cu/qu2cu.py":24
  7982. * # if cython not installed, use mock module with no-op decorators and types
  7983. * from fontTools.misc import cython
  7984. * COMPILED = cython.compiled # <<<<<<<<<<<<<<
  7985. *
  7986. * from fontTools.misc.bezierTools import splitCubicAtTC
  7987. */
  7988. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_COMPILED, Py_True) < (0)) __PYX_ERR(0, 24, __pyx_L1_error)
  7989. /* "fontTools/qu2cu/qu2cu.py":26
  7990. * COMPILED = cython.compiled
  7991. *
  7992. * from fontTools.misc.bezierTools import splitCubicAtTC # <<<<<<<<<<<<<<
  7993. * from collections import namedtuple
  7994. * import math
  7995. */
  7996. {
  7997. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_splitCubicAtTC};
  7998. __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_fontTools_misc_bezierTools, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
  7999. }
  8000. __pyx_t_4 = __pyx_t_3;
  8001. __Pyx_GOTREF(__pyx_t_4);
  8002. {
  8003. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_splitCubicAtTC};
  8004. __pyx_t_5 = 0; {
  8005. __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_5]); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 26, __pyx_L1_error)
  8006. __Pyx_GOTREF(__pyx_t_6);
  8007. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_5], __pyx_t_6) < (0)) __PYX_ERR(0, 26, __pyx_L1_error)
  8008. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8009. }
  8010. }
  8011. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8012. /* "fontTools/qu2cu/qu2cu.py":27
  8013. *
  8014. * from fontTools.misc.bezierTools import splitCubicAtTC
  8015. * from collections import namedtuple # <<<<<<<<<<<<<<
  8016. * import math
  8017. * from typing import (
  8018. */
  8019. {
  8020. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_namedtuple};
  8021. __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_collections, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
  8022. }
  8023. __pyx_t_4 = __pyx_t_3;
  8024. __Pyx_GOTREF(__pyx_t_4);
  8025. {
  8026. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_namedtuple};
  8027. __pyx_t_5 = 0; {
  8028. __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_5]); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 27, __pyx_L1_error)
  8029. __Pyx_GOTREF(__pyx_t_6);
  8030. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_5], __pyx_t_6) < (0)) __PYX_ERR(0, 27, __pyx_L1_error)
  8031. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8032. }
  8033. }
  8034. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8035. /* "fontTools/qu2cu/qu2cu.py":28
  8036. * from fontTools.misc.bezierTools import splitCubicAtTC
  8037. * from collections import namedtuple
  8038. * import math # <<<<<<<<<<<<<<
  8039. * from typing import (
  8040. * List,
  8041. */
  8042. __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_math, 0, 0, NULL, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error)
  8043. __pyx_t_4 = __pyx_t_3;
  8044. __Pyx_GOTREF(__pyx_t_4);
  8045. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_math, __pyx_t_4) < (0)) __PYX_ERR(0, 28, __pyx_L1_error)
  8046. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8047. /* "fontTools/qu2cu/qu2cu.py":29
  8048. * from collections import namedtuple
  8049. * import math
  8050. * from typing import ( # <<<<<<<<<<<<<<
  8051. * List,
  8052. * Tuple,
  8053. */
  8054. {
  8055. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_List,__pyx_mstate_global->__pyx_n_u_Tuple,__pyx_mstate_global->__pyx_n_u_Union};
  8056. __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_typing, __pyx_imported_names, 3, NULL, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
  8057. }
  8058. __pyx_t_4 = __pyx_t_3;
  8059. __Pyx_GOTREF(__pyx_t_4);
  8060. {
  8061. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_List,__pyx_mstate_global->__pyx_n_u_Tuple,__pyx_mstate_global->__pyx_n_u_Union};
  8062. for (__pyx_t_5=0; __pyx_t_5 < 3; __pyx_t_5++) {
  8063. __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_5]); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 29, __pyx_L1_error)
  8064. __Pyx_GOTREF(__pyx_t_6);
  8065. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_5], __pyx_t_6) < (0)) __PYX_ERR(0, 29, __pyx_L1_error)
  8066. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8067. }
  8068. }
  8069. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8070. /* "fontTools/qu2cu/qu2cu.py":36
  8071. *
  8072. *
  8073. * __all__ = ["quadratic_to_curves"] # <<<<<<<<<<<<<<
  8074. *
  8075. *
  8076. */
  8077. __pyx_t_4 = __Pyx_PyList_Pack(1, __pyx_mstate_global->__pyx_n_u_quadratic_to_curves); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error)
  8078. __Pyx_GOTREF(__pyx_t_4);
  8079. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_all, __pyx_t_4) < (0)) __PYX_ERR(0, 36, __pyx_L1_error)
  8080. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8081. /* "fontTools/qu2cu/qu2cu.py":82
  8082. *
  8083. *
  8084. * @cython.locals( # <<<<<<<<<<<<<<
  8085. * p0=cython.complex,
  8086. * p1=cython.complex,
  8087. */
  8088. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_1elevate_quadratic, 0, __pyx_mstate_global->__pyx_n_u_elevate_quadratic, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_qu2cu_qu2cu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error)
  8089. __Pyx_GOTREF(__pyx_t_4);
  8090. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8091. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8092. #endif
  8093. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_elevate_quadratic, __pyx_t_4) < (0)) __PYX_ERR(0, 82, __pyx_L1_error)
  8094. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8095. /* "fontTools/qu2cu/qu2cu.py":154
  8096. *
  8097. *
  8098. * @cython.locals( # <<<<<<<<<<<<<<
  8099. * count=cython.int,
  8100. * num_offcurves=cython.int,
  8101. */
  8102. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_3add_implicit_on_curves, 0, __pyx_mstate_global->__pyx_n_u_add_implicit_on_curves, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_qu2cu_qu2cu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 154, __pyx_L1_error)
  8103. __Pyx_GOTREF(__pyx_t_4);
  8104. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8105. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8106. #endif
  8107. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_add_implicit_on_curves, __pyx_t_4) < (0)) __PYX_ERR(0, 154, __pyx_L1_error)
  8108. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8109. /* "fontTools/qu2cu/qu2cu.py":175
  8110. *
  8111. *
  8112. * Point = Union[Tuple[float, float], complex] # <<<<<<<<<<<<<<
  8113. *
  8114. *
  8115. */
  8116. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_Union); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 175, __pyx_L1_error)
  8117. __Pyx_GOTREF(__pyx_t_4);
  8118. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_Tuple); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 175, __pyx_L1_error)
  8119. __Pyx_GOTREF(__pyx_t_6);
  8120. __pyx_t_7 = PyTuple_Pack(2, ((PyObject *)(&PyFloat_Type)), ((PyObject *)(&PyFloat_Type))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 175, __pyx_L1_error)
  8121. __Pyx_GOTREF(__pyx_t_7);
  8122. __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 175, __pyx_L1_error)
  8123. __Pyx_GOTREF(__pyx_t_8);
  8124. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8125. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8126. __pyx_t_7 = PyTuple_Pack(2, __pyx_t_8, ((PyObject *)(&PyComplex_Type))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 175, __pyx_L1_error)
  8127. __Pyx_GOTREF(__pyx_t_7);
  8128. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8129. __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 175, __pyx_L1_error)
  8130. __Pyx_GOTREF(__pyx_t_8);
  8131. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8132. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8133. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Point, __pyx_t_8) < (0)) __PYX_ERR(0, 175, __pyx_L1_error)
  8134. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8135. /* "fontTools/qu2cu/qu2cu.py":184
  8136. * def quadratic_to_curves(
  8137. * quads: List[List[Point]],
  8138. * max_err: float = 0.5, # <<<<<<<<<<<<<<
  8139. * all_cubic: bool = False,
  8140. * ) -> List[Tuple[Point, ...]]:
  8141. */
  8142. __pyx_t_8 = PyFloat_FromDouble(((double)0.5)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 184, __pyx_L1_error)
  8143. __Pyx_GOTREF(__pyx_t_8);
  8144. /* "fontTools/qu2cu/qu2cu.py":185
  8145. * quads: List[List[Point]],
  8146. * max_err: float = 0.5,
  8147. * all_cubic: bool = False, # <<<<<<<<<<<<<<
  8148. * ) -> List[Tuple[Point, ...]]:
  8149. * """Converts a connecting list of quadratic splines to a list of quadratic
  8150. */
  8151. __pyx_t_7 = __Pyx_PyBool_FromLong(((int)0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 185, __pyx_L1_error)
  8152. __Pyx_GOTREF(__pyx_t_7);
  8153. /* "fontTools/qu2cu/qu2cu.py":178
  8154. *
  8155. *
  8156. * @cython.locals( # <<<<<<<<<<<<<<
  8157. * cost=cython.int,
  8158. * is_complex=cython.int,
  8159. */
  8160. __pyx_t_4 = PyTuple_Pack(2, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 178, __pyx_L1_error)
  8161. __Pyx_GOTREF(__pyx_t_4);
  8162. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8163. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8164. __pyx_t_7 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 178, __pyx_L1_error)
  8165. __Pyx_GOTREF(__pyx_t_7);
  8166. if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_quads, __pyx_mstate_global->__pyx_kp_u_List_List_Point) < (0)) __PYX_ERR(0, 178, __pyx_L1_error)
  8167. if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_max_err, __pyx_mstate_global->__pyx_n_u_float) < (0)) __PYX_ERR(0, 178, __pyx_L1_error)
  8168. if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_all_cubic, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 178, __pyx_L1_error)
  8169. if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_List_Tuple_Point) < (0)) __PYX_ERR(0, 178, __pyx_L1_error)
  8170. __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_5quadratic_to_curves, 0, __pyx_mstate_global->__pyx_n_u_quadratic_to_curves, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_qu2cu_qu2cu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 178, __pyx_L1_error)
  8171. __Pyx_GOTREF(__pyx_t_8);
  8172. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8173. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  8174. #endif
  8175. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_t_4);
  8176. __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_7);
  8177. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8178. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8179. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_quadratic_to_curves, __pyx_t_8) < (0)) __PYX_ERR(0, 178, __pyx_L1_error)
  8180. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8181. /* "fontTools/qu2cu/qu2cu.py":239
  8182. *
  8183. *
  8184. * Solution = namedtuple("Solution", ["num_points", "error", "start_index", "is_cubic"]) # <<<<<<<<<<<<<<
  8185. *
  8186. *
  8187. */
  8188. __pyx_t_7 = NULL;
  8189. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_namedtuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 239, __pyx_L1_error)
  8190. __Pyx_GOTREF(__pyx_t_4);
  8191. __pyx_t_6 = __Pyx_PyList_Pack(4, __pyx_mstate_global->__pyx_n_u_num_points, __pyx_mstate_global->__pyx_n_u_error, __pyx_mstate_global->__pyx_n_u_start_index, __pyx_mstate_global->__pyx_n_u_is_cubic); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 239, __pyx_L1_error)
  8192. __Pyx_GOTREF(__pyx_t_6);
  8193. __pyx_t_9 = 1;
  8194. {
  8195. PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Solution, __pyx_t_6};
  8196. __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  8197. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  8198. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8199. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8200. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 239, __pyx_L1_error)
  8201. __Pyx_GOTREF(__pyx_t_8);
  8202. }
  8203. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Solution, __pyx_t_8) < (0)) __PYX_ERR(0, 239, __pyx_L1_error)
  8204. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8205. /* "fontTools/qu2cu/qu2cu.py":265
  8206. * u=cython.complex,
  8207. * )
  8208. * def spline_to_curves(q, costs, tolerance=0.5, all_cubic=False): # <<<<<<<<<<<<<<
  8209. * """
  8210. * q: quadratic spline with alternating on-curve / off-curve points.
  8211. */
  8212. __pyx_t_8 = PyFloat_FromDouble(((double)0.5)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 265, __pyx_L1_error)
  8213. __Pyx_GOTREF(__pyx_t_8);
  8214. __pyx_t_4 = __Pyx_PyBool_FromLong(((int)0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 265, __pyx_L1_error)
  8215. __Pyx_GOTREF(__pyx_t_4);
  8216. /* "fontTools/qu2cu/qu2cu.py":242
  8217. *
  8218. *
  8219. * @cython.locals( # <<<<<<<<<<<<<<
  8220. * i=cython.int,
  8221. * j=cython.int,
  8222. */
  8223. __pyx_t_6 = PyTuple_Pack(2, __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 242, __pyx_L1_error)
  8224. __Pyx_GOTREF(__pyx_t_6);
  8225. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8226. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8227. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_7spline_to_curves, 0, __pyx_mstate_global->__pyx_n_u_spline_to_curves, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_qu2cu_qu2cu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L1_error)
  8228. __Pyx_GOTREF(__pyx_t_4);
  8229. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8230. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8231. #endif
  8232. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_6);
  8233. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8234. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_spline_to_curves, __pyx_t_4) < (0)) __PYX_ERR(0, 242, __pyx_L1_error)
  8235. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8236. /* "fontTools/qu2cu/qu2cu.py":386
  8237. *
  8238. *
  8239. * def main(): # <<<<<<<<<<<<<<
  8240. * from fontTools.cu2qu.benchmark import generate_curve
  8241. * from fontTools.cu2qu import curve_to_quadratic
  8242. */
  8243. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_9main, 0, __pyx_mstate_global->__pyx_n_u_main_2, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_qu2cu_qu2cu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 386, __pyx_L1_error)
  8244. __Pyx_GOTREF(__pyx_t_4);
  8245. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8246. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8247. #endif
  8248. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_main_2, __pyx_t_4) < (0)) __PYX_ERR(0, 386, __pyx_L1_error)
  8249. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8250. /* "fontTools/qu2cu/qu2cu.py":404
  8251. *
  8252. *
  8253. * if __name__ == "__main__": # <<<<<<<<<<<<<<
  8254. * main()
  8255. */
  8256. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 404, __pyx_L1_error)
  8257. __Pyx_GOTREF(__pyx_t_4);
  8258. __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_main, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 404, __pyx_L1_error)
  8259. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8260. if (__pyx_t_10) {
  8261. /* "fontTools/qu2cu/qu2cu.py":405
  8262. *
  8263. * if __name__ == "__main__":
  8264. * main() # <<<<<<<<<<<<<<
  8265. */
  8266. __pyx_t_6 = NULL;
  8267. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_main_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 405, __pyx_L1_error)
  8268. __Pyx_GOTREF(__pyx_t_8);
  8269. __pyx_t_9 = 1;
  8270. {
  8271. PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
  8272. __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  8273. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  8274. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8275. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 405, __pyx_L1_error)
  8276. __Pyx_GOTREF(__pyx_t_4);
  8277. }
  8278. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8279. /* "fontTools/qu2cu/qu2cu.py":404
  8280. *
  8281. *
  8282. * if __name__ == "__main__": # <<<<<<<<<<<<<<
  8283. * main()
  8284. */
  8285. }
  8286. /* "fontTools/qu2cu/qu2cu.py":1
  8287. * # cython: language_level=3 # <<<<<<<<<<<<<<
  8288. * # distutils: define_macros=CYTHON_TRACE_NOGIL=1
  8289. *
  8290. */
  8291. __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  8292. __Pyx_GOTREF(__pyx_t_4);
  8293. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_4) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  8294. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8295. /*--- Wrapped vars code ---*/
  8296. goto __pyx_L0;
  8297. __pyx_L1_error:;
  8298. __Pyx_XDECREF(__pyx_t_4);
  8299. __Pyx_XDECREF(__pyx_t_6);
  8300. __Pyx_XDECREF(__pyx_t_7);
  8301. __Pyx_XDECREF(__pyx_t_8);
  8302. if (__pyx_m) {
  8303. if (__pyx_mstate->__pyx_d && stringtab_initialized) {
  8304. __Pyx_AddTraceback("init fontTools.qu2cu.qu2cu", __pyx_clineno, __pyx_lineno, __pyx_filename);
  8305. }
  8306. #if !CYTHON_USE_MODULE_STATE
  8307. Py_CLEAR(__pyx_m);
  8308. #else
  8309. Py_DECREF(__pyx_m);
  8310. if (pystate_addmodule_run) {
  8311. PyObject *tp, *value, *tb;
  8312. PyErr_Fetch(&tp, &value, &tb);
  8313. PyState_RemoveModule(&__pyx_moduledef);
  8314. PyErr_Restore(tp, value, tb);
  8315. }
  8316. #endif
  8317. } else if (!PyErr_Occurred()) {
  8318. PyErr_SetString(PyExc_ImportError, "init fontTools.qu2cu.qu2cu");
  8319. }
  8320. __pyx_L0:;
  8321. __Pyx_RefNannyFinishContext();
  8322. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8323. return (__pyx_m != NULL) ? 0 : -1;
  8324. #else
  8325. return __pyx_m;
  8326. #endif
  8327. }
  8328. /* #### Code section: pystring_table ### */
  8329. /* #### Code section: cached_builtins ### */
  8330. static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) {
  8331. CYTHON_UNUSED_VAR(__pyx_mstate);
  8332. __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 326, __pyx_L1_error)
  8333. __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 375, __pyx_L1_error)
  8334. __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 375, __pyx_L1_error)
  8335. __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_print); if (!__pyx_builtin_print) __PYX_ERR(0, 394, __pyx_L1_error)
  8336. /* Cached unbound methods */
  8337. __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  8338. __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items;
  8339. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  8340. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop;
  8341. __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type;
  8342. __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values;
  8343. __pyx_mstate->__pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
  8344. __pyx_mstate->__pyx_umethod_PyList_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop;
  8345. return 0;
  8346. __pyx_L1_error:;
  8347. return -1;
  8348. }
  8349. /* #### Code section: cached_constants ### */
  8350. static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) {
  8351. __Pyx_RefNannyDeclarations
  8352. CYTHON_UNUSED_VAR(__pyx_mstate);
  8353. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  8354. /* "fontTools/qu2cu/qu2cu.py":226
  8355. * costs.append(cost)
  8356. * costs.append(cost)
  8357. * qq = add_implicit_on_curves(p)[1:] # <<<<<<<<<<<<<<
  8358. * costs.pop()
  8359. * q.extend(qq)
  8360. */
  8361. __pyx_mstate_global->__pyx_slice[0] = PySlice_New(__pyx_mstate_global->__pyx_int_1, Py_None, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_slice[0])) __PYX_ERR(0, 226, __pyx_L1_error)
  8362. __Pyx_GOTREF(__pyx_mstate_global->__pyx_slice[0]);
  8363. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_slice[0]);
  8364. /* "fontTools/qu2cu/qu2cu.py":293
  8365. * # Dynamic-Programming to find the solution with fewest number of
  8366. * # cubic curves, and within those the one with smallest error.
  8367. * sols = [Solution(0, 0, 0, False)] # <<<<<<<<<<<<<<
  8368. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  8369. * start = 0
  8370. */
  8371. __pyx_mstate_global->__pyx_tuple[0] = PyTuple_Pack(4, __pyx_mstate_global->__pyx_int_0, __pyx_mstate_global->__pyx_int_0, __pyx_mstate_global->__pyx_int_0, Py_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[0])) __PYX_ERR(0, 293, __pyx_L1_error)
  8372. __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]);
  8373. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]);
  8374. #if CYTHON_IMMORTAL_CONSTANTS
  8375. {
  8376. PyObject **table = __pyx_mstate->__pyx_tuple;
  8377. for (Py_ssize_t i=0; i<1; ++i) {
  8378. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8379. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  8380. #else
  8381. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  8382. #endif
  8383. }
  8384. }
  8385. #endif
  8386. #if CYTHON_IMMORTAL_CONSTANTS
  8387. {
  8388. PyObject **table = __pyx_mstate->__pyx_slice;
  8389. for (Py_ssize_t i=0; i<1; ++i) {
  8390. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8391. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  8392. #else
  8393. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  8394. #endif
  8395. }
  8396. }
  8397. #endif
  8398. __Pyx_RefNannyFinishContext();
  8399. return 0;
  8400. __pyx_L1_error:;
  8401. __Pyx_RefNannyFinishContext();
  8402. return -1;
  8403. }
  8404. /* #### Code section: init_constants ### */
  8405. static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) {
  8406. CYTHON_UNUSED_VAR(__pyx_mstate);
  8407. {
  8408. const struct { const unsigned int length: 10; } index[] = {{1},{28},{17},{23},{179},{43},{15},{23},{45},{1},{8},{39},{7},{6},{2},{9},{43},{8},{4},{5},{20},{8},{5},{5},{22},{7},{9},{18},{8},{4},{1},{17},{18},{5},{11},{4},{5},{5},{5},{5},{18},{6},{17},{19},{9},{3},{5},{5},{15},{25},{26},{21},{6},{8},{14},{7},{1},{5},{11},{11},{4},{10},{10},{13},{8},{5},{1},{11},{11},{1},{8},{4},{4},{7},{10},{8},{10},{4},{13},{10},{4},{4},{2},{4},{1},{2},{2},{6},{2},{2},{3},{5},{1},{2},{19},{36},{10},{5},{12},{4},{7},{21},{13},{18},{6},{8},{4},{12},{10},{4},{16},{33},{14},{6},{5},{11},{8},{10},{14},{5},{9},{2},{6},{1},{1},{5},{6},{1},{1},{3},{112},{131},{262},{56},{2},{2},{914}};
  8409. #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1847 bytes) */
  8410. const char* const cstring = "BZh91AY&SY\307\325n\034\000\001'\377\377\377\377\377\377\376\367\375}\277\367\376\252\277\377\377\374@@@@@@@@@\000@@@\000@\000`\006\233\272L\215j\230\225k(+\355\340;\300\325?I)\250\304\3002\233I\261\0364\247\246M5M\014\320\232{T\006\320\t\221\211\241\220b=F\206\310\236\232\236\231L%\010#\020M&\t\243&\247\221#CF \321\210\000\000\000\000\001\240\320\036\240h`\324\300%4I\351\r\017P\320\007\250\320\003F@\000\000\000\000\000\000\r\251\232 \tM \232\202S\366\223OBS\366\245?Rg\251=M\037\2254\300hM\000\032\0310@\323L\230\214\321\032hbdd\034\000\000\000\000\000\000\000\r\000\000\000\000\000\000\000\000\021ORFC\324\300LL\232`L\004b`\230L\t\2011\030\000F\021\246\021\21010\032:\351jG\222\227\n\203s\334\366\346`\240\375S6\203;\016y\273\350h*L\032J\222 \016\212\340\223\302T'Bm2>s\320&\004\230Ha! \224i\r\200\"\025>\232;H\226ip\342B\024T\020p\024c\264E\350fJ\330j\340\016A\315\255r\214\222C\024$\022\332\023<\302\246\022x$\010A\236c\357\023F \352\343\\HI\201&\204TJ\257R\222$O\003k\r\200U\204^%n\303=\330c~\353d\311\275u\205\002i\024*\234\314WP\036Py\202\224/\213Y;\211\034\230\260\211\177\nL\336H\215\003\034\\\216\245*\302\326~\365\225\220\276\327\273\202\005\222b\324\021\371\037\nq\265\031\272\302c\314\347\346\374\376\230\014`^^\005\2333\236\337Z\345\331\")\374~\344ak\020\342\300\2217u@dl)x^\327Q2\026\233\";\344\241&\004\007w\243\321\362\342\374\007~`\033t9x\341\0029w\241\3260\317\023\356\273\037{\"\333x\\{73\264\351\342y_\3004\025yU\247\345\377y56\265`\321\2252\006C~\r\006F|\021\376\025\250JL\225\301#RVtfj\330_m\224(\205\002\224\364&{\336\334\035W\n\234\375\276~\277i\320N\"\376\177\001\034\233 T\233\305\344\010't#\021\007\211\030\2310\335\375\364^\272]\233l\366\265D\277\273\267C\005\327t\244\363\224 u\362}s\375\371c\371mu\235y\030\254\354L\311#\014\013C>\\\256\271EB\002\305\356\372\244\324\013K\302\265\033Z\207\245\250\0175*\014\256\006%ff\315{\001`{\216\241\036\310 \330\303d\216\035\037\246\037\353\306Yl\352\355\353u\033\255\233=u\254V\224\240@\240\252,:d\224\252\003\207\230\227F""\242\021\333B\227V\003\016}L\344\324bA\020[t\202\271\226\017\343\224(.GLt\246v;$C\263@\344^\205/<<\311e\222\224\250)\226l\201>GlM\251\2517mS\232\316~\345p\344z\361\360\337\217A\271\372\231\302vQ\371\352\260\235\311B\352\212-z\\\260L\345\353!\000\367\\\211\265\234[\354N\230X\257\354\250\005\006\330\0056\320\n\242\311\321<\221-\250\202\314\346F\310\3312l\323\270\205c\213C\245a\203\322\222\255\345&\004\221\226\263=\223.g \2636v\214\222#l\251T\017\"\"\267\364\252\216\257\334\201R\312q{\347\211\322XR\271F\264\261\364\324\332\302m*\270^\024\272\2734\322\2718\271\250mrMB2\327\024\272\222}\243bi\247\360\262\325\227\245\304c\025\311:_\314\305\370\277%\272\2129xG\267d\236\377\016\260\330\321\307X\325\\xW\034b\020\210;\244\334m\217:lJ\274\323\303\010)\003\315D4&\322\2660\211\221l\325my\355\330\313\r\223\310\030\232\213[\235\31574\363U\202Z\364\327d\210\2621\030p\313\030FAtww*AB+?\360J\021a1\013\326 I\272f\241\261F6\234\244\006\307i\2015\276%\225\214\210\210\301\037O\026E\252\202\255\307z\237q\302\302\307\222@\2172\235\3747\251\001\244\230E\346L#.[\254\017T.N\013c\337\323\250\232G\211d\201\2648F\3778\237\246\351\251\337+\320\324\206\2761-v\\\312D\236H\270\207v\274\016B\244\206O\327\325\277=i\2457\314\310?%O\346\350\351\332\246\355\037{[\200\277\252i[\203\001!lA\352\317\245\264\355\234F\342\361H\373\023\223\220\212&\270\324/\341p\271R\364\014\327\363\"\370e\250\255\227d\252\356\233}Uy\332\322\244q\307\n\",J\302\240L\251\206<\246S1\232\024\301g\241\267~\212\310\271\321 \354\365\005J9sC%K\2261\256R3\350$\355\225\322\010\213\030\023\361\343,\341k\251'\332\017\035(\335E\006{\210U\230\303\032I\344%7\354\345z\016E\271[\025U:\n\\\261\203\244,\006U\"2\340\353\201\257w\033I\310\030iF\225\026\027\2512h(\277\363\232\341\"\346Y\333|\336f\230\345r\235b\313m-\263Ei2a2=\264\005\302\031\220V\032\344\241\251\360\343\304\332o\241\3174\204\201\034O\235\305\243\304SN$\031Q5hIU\2568\224L\257\263\241\310\375x&\210(\343(\3103\324Q4=\303\310\002\200\200\t\001tC\306\361\027\254\222x\004\202K\017\240""\200\001B#]\237\302s\261\271\030A\223n\373\204wCyh\207\033\263\253\254\226X\037\014T m\276U\245\302\007\337x]1\352`\355\275T\263\"\350\033<\263\2254\326 \206@P\353\026\272r\262?\014(\212E\246\211\244\301\376\2058\226.\305\025\201X\242/\340\003\247\201\035;\256\250y\302pOD\256\367\2318P\370\221\221\311\\B\223\337\367\300:\031\205B\341\014\320\215\020\030\004?\363\005\013\t\243E\0245\"\177\250\032(\224P\027\341\267\016\361\254E\271\000\205%\rKH5\300\323\212%D\"\206\n\005\210\3222\251\220\277\034\017\211\342h\2152\314f\233\335\307\230&\223\216\213\324\322R\372\227q\r=-\300\342W3\362\252\255\302A\246\316\\\306\332[\211m\217c\237\306\302\376\216\207[p\034\221R\253M[\316U\211\302D\341\3154T\306\251\217\220\254\036\3766\025\234X$\t\"\034\\\370\245J]\231/J\304\222WrU\205\206\375-\246\333\233)\335\022\345\211\222\316=\257^gy\205\351o\377K\237G\037\254g\\\306\\gk\035\335\301\322\017|E\360\r\353\235V=\230\331\335W\363\234\316Ve\336\253DC\021\023\025\212d\256\323\010\233d@\215Y\202\226rxPL\220\204\306\204w\035\370R\344\263\000\215S\035kh?\201\301\312\324\316\323M\242*\243\261\252\264\210\nHp\362\210A\202\207!\223\377\027rE8P\220\307\325n\034";
  8411. PyObject *data = __Pyx_DecompressString(cstring, 1847, 2);
  8412. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  8413. const char* const bytes = __Pyx_PyBytes_AsString(data);
  8414. #if !CYTHON_ASSUME_SAFE_MACROS
  8415. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  8416. #endif
  8417. #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1783 bytes) */
  8418. const char* const cstring = "x\332uTMs\032G\032\026\262p\220\203\034\300he\307\261w\220\242\322f\313\306\001T\251\254\343\312\026\222?\222-\307\026\372\250\324VJ5\325\014\2154\3660\003\323=\212\224\335\203\217s\234c\037\3478G\216s\344'p\234#?A?a\237\356A {w)h\372\363\355\367\371x\273\372\332l?\351:6?t\034\213=\031xu\303K\333j\377\342\265\311\370o\252\331sL\233\037\037\253\376\241\327\267h:\363H\253V\253\307\307o\034N5~J\270\266{\301O\035[3\231\326\241\226\331\246.\341\324\272\320\030wM\203SWn\262\265\275\027{\217\267\277\337\326\210\335\321\\\372\216\032\234i\314k\033\026a\2142\315\351jm\317\264\270ik\374\242OYU\373\271\253]8\236fS\332\321\270\243\365\261\357\372\001~Jm\215Q.;\332\026\261m\207\023n:\266\216\343\246}\262\245uL\027\227\230gT\236~I,F\253om\252\271H\300\351i\206\3276\r\215{\256\215\360\000\345h\233\035m\340\221\016\2227\rV}\353\232'\246M,lt\317\350\323}j86\000y\000\324I\347\376\302\276yzx\3520z\355\330U\30061\336\317\242\252\253\000\350\357\244\323\321\221&5\274\372\300CV\026\230\262\r\252m\236T5\305\376\307s\035\223\221\266E\251-\333\023\303di\2573\273Nc}\313\224\220\350\300\003X\246A\013\213\022\306\265\206\326\227J\261\335\267\277\354\375\374\372\305s)\241\322N\327\367.\316\361{\016e\3647\364\234\357\323\356\201cy\2229%\361\221\215\236L\324\354!\270ar\035\224*\274L\327\211e\245\215\202D\330\205m\230N\325p\\\007\001l\312\332\224q\2359V\033\2662t]I\245\237Pnr\332\223C\354\321M(\344\022\203J\212\014\013\364\031\216eI\241\300\257\3410.\177\350x6W\227\250\253U\243sG\237AO3\242\026=\203\327\346\323\323\211\316|\006\244y=\345H\352\272\370:n\327r\010\237\231\277\252\304\370dXmS\3338\355\021\367\375|\241g2\003\363\177\230\324U\023\363\225\264pT\333u\\\003\267\353]\317\006\376\023j\253\233S\376\344\350\274\357\232\246dH5\272\202\231vUjf\217\234\200w\2071\023B\233\014\033\240\002=\327Uw\312\262\354Kf$\251\354\335\273y\240w\363@\357u\275G\300\264j{\204\003\313\271\\\301\204\323\361,\252\343c\223\036M\333\016\227\312#;\016\256t\247\333M\331\225\203\324F\230\252\341Wwl\344x\322\357\177\333""\257\365kz]o\364\353\375F\337\351\003\225\315\007\370\\\261.\265J\203\374\217\251\3523\3131P\217?V\247\224\314\305\222=\370\014\177V\232\236K\211\345Nko^\202\372\254N\334\353u\371\321@\007?P\\\026\244K\317\250\313h\007^\2006x3\246\330\321\353\320.\361, \264XZL\3634?\035\377W\332r\003\337\225R4\371\341\256\0321\306\211\313U\003\243w\240\234\316eM\350\374TI\010\225To\246\031?u\235\337ghpR=^\336\331\031\261<\252\032v~\361\207\331\377\220\271,-d\227\375%\277\351\267\222\245\274\337L\226\312\301n0\0207D]`&\347g\375\243\240\0224\002\222\344\276\360\007A&(^uJA=h%\271\025l\330\010\216\304\272x\031\256\207\315$\267\354\257MW\367\003W\254\205\231$W\304\251\245\317\375\332\207L\262\264<^\376kTQ\377Z\230\231,\025\002L~%\376\021\266\243\214L\341\215\300bq\\\334\010k\341\253\250\206\215>\256\254\0177\206\277\215\260\035\243\361\255\357\343\305x#n\305$YZ\031\257 LX\014\037G\203$]}\032\257\307\273\361`\224\231\216\037H$\252\267\031\266\000\371\326B~\005\007%b I\2627/\277[\310\226\202r\320\n\250\250\211\035A\004\017\033!\202\177\366\201\373\265$W\220\260\203-Q\024\033\342 \314\206\007\321\315\310\030\226\207Gqe\002\2122\376\252O|\027[*\212C\031\030`S\366Z)]\213\340\350@d\020\242\222\344\362\376\213`5 \001\023\025\321\020m0\224/\007\315$_\014\326\344\226y'\007t\222\207\235\220\204\003I\365\241\244?%\270\250\362\222\223\277\006\315\2405\221L\000\2510\302\265hyX\234\\%\017\356\203\315\300\035\337\373[\\\216\3779\"S!.\313\013\331\333\376ApC\351\004\352\262\010\234,\347\375] )A\360\266\310|:\314-\213bT\304\331\352\202\366$\"2D\336o\000;K\321]\336\\\310\336\227\000\357\211\022\210l\212\303\260\024\326\303\303\250\034\035\r7\207\203\370F\334\210I\314F\353\243\335\321\3402\267\220-J\361\347&3R~\246\232\312\263\373\341 \312\\\233\251I\207}<\372|\232\302z\360\\,B!IA)\334\016\335\350\313a}x\020g\342;\361\016\254\222/\005_\203tuo\336\257\371?\201\266\003\030\275!\300I1\270\253\344m\215\0376pj\177\350\342\324.R\255L\313\342\243$\307_>\211\334!\024\270\023\324\346r\376\216@\371{\342a\310\243Z""\264\023\365\342m\230pqT\231\344\277\360yP\233\024\036\210\243\260\242@\271Q)jD\355av\330\032\266\225\231\367\343ARx(\254h=j\312\016I\nwE\016(\037 P\035\3132\225\302\235\340;ImR\376\263\030L0\372\001X\213\223\362*\230_\271\235\024\326\002O\274\2162\343o~\214\215QiT\037\265\222;\345\244P\224\313\353\341C\344|7\206\275\276\022M9\263*=W\200\003~\020\246\242\271\2606^CmF\365h\037\305T\370\223\322c\013\265\265\201\224%(dv\037\302\276\nk\327RYM\000\354\327\260\031\266\022\000=\223n\232\244W\026\377\177\3542\304Z\022/\302\325\320\210\212\022\311\366x\355\333a\006Eu\010\233\036\216\212I\371\352M\300\005\237\304\275/\036\251\225\274\364{\017o\004\312\347'\330\3558z\014\335J\322d\263#*c\251\300\277\245\320\0100\201^\257\202Z\240\234SG\005\244\325'\275{{\366\010\346\374\033p\310Kx\n\203[~E\026\361\277\304\327x\031\\\320\310\207\265\341\316\020/\342m\377\004\217\006\231\025\241\354\264\246O\013\336\2054\316\263\340\\\014\302%\020t\020e\242\273\3226\362u\200\035\345\213\362($\343\255g\260\232\233\n6\"\023h\222\305\203ZQ\316\204\n'@I\020b\021\357\353\363h\021\016\331\201u2\322x\315\211\254\346\377\000\010\324o#";
  8419. PyObject *data = __Pyx_DecompressString(cstring, 1783, 1);
  8420. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  8421. const char* const bytes = __Pyx_PyBytes_AsString(data);
  8422. #if !CYTHON_ASSUME_SAFE_MACROS
  8423. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  8424. #endif
  8425. #else /* compression: none (2937 bytes) */
  8426. const char* const bytes = ".Lib/fontTools/qu2cu/qu2cu.pyList[List[Point]]List[Tuple[Point, ...]]Note that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.One random cubic turned into %d quadratics.Original curve:Reconstructed curve(s):Those quadratics turned back into %d cubics. ?add_notecu2qu tolerance %g. qu2cu tolerance %g.disableenablegcisenabledquadratic spline requires at least 3 pointsCOMPILEDListPoint__Pyx_PyDict_NextRefSolutionTupleUnionadd_implicit_on_curves__all__all_cubicasyncio.coroutinesbest_solboolc__class_getitem__cline_in_tracebackclosecollectionscostcostscountcubiccurvecurve_to_quadraticcurveselevate_quadraticelevated_quadraticsenumerateerrerrorfloatfontTools.cu2qufontTools.cu2qu.benchmarkfontTools.misc.bezierToolsfontTools.qu2cu.qu2cuforced__func__generate_curvegenexprii_soli_sol_counti_sol_errorimagimpossibleis_complex_is_coroutineis_cubicitemsjj_sol_countj_sol_errork__main__mainmathmax_err__module____name__namedtuplenextnum_offcurvesnum_pointsoff1off2onorigpp0p1p1_2_3p2p3popprintqqqquadratic_to_curvesquadratic_to_curves.<locals>.genexprquadraticsquads__qualname__realreconstreconstruct_tolerancereconstructedreconstructed_iterreturnreversedsend__set_name__setdefaultsolsspline_to_curvesspline_to_curves.<locals>.genexprsplitCubicAtTCsplitsstartstart_index__test__this_countthis_sol_countthrowtolerancetstypinguvvaluevaluesxyzip\200\001\360\022\000\005\t\210\004\210A\210Q\330\004\014\210A\330\004\024\220C\220q\230\003\2302\230Q\330\004\010\210\005\210U\220!\2203\220a\330\010\017\210q\220\001\220\021\330\010\017\210q\220\001\220\022\2202\220Q\330\010\r\210U\220#\220U\230\"\230F\240\"\240A\330\010\t\210\027\220\001\220\022\2202\220R\220r\230\027\240\001\330\010\021\220\021\330\004\013\2101\200\001\330\004\t\320\t*\250!\330\004\t\320\t \240\001\340\004\020\220\001\330\004\034\230J\240b\250\001\330\004\014\210N\230!\330\004\021\320\021#\2401\240G\2501\330\004\t""\210\021\330\0102\260#\260[\300\001\340\004\t\210\021\320\n8\270\002\270#\270Q\270a\330\004\r\320\r \240\001\240\021\240-\250q\330\004\t\210\021\320\n:\270\"\270C\270q\300\001\330\004\t\210\021\320\n\035\230Q\330\004\t\210\021\320\n%\240Q\200\001\360\n\000\014\r\330\004\r\210Q\330\004\017\210q\330\005\006\3606\000\005\022\220\024\220Q\220e\2301\230B\230a\230t\2403\240a\330\004\007\200t\2101\330\010\020\220\001\220\021\220'\230\021\230#\230S\240\005\240S\250\006\250c\260\024\260U\270!\340\004\010\210\001\210\025\210a\210r\220\021\220!\330\004\014\210A\210Q\330\004\013\2101\330\004\010\210\005\210Q\330\010\017\210q\220\002\220#\220S\230\001\230\021\230!\330\010\014\210E\220\025\220a\220s\230!\2303\230b\240\001\330\014\024\220A\330\014\021\220\027\230\001\230\021\330\014\021\220\027\230\001\230\021\330\010\r\320\r#\2401\240B\240a\240q\330\010\r\210T\220\021\330\010\t\210\027\220\001\220\021\330\010\020\220\001\330\010\r\210W\220A\220Q\340\004\r\320\r\035\230Q\230c\240\027\250\t\260\021\340\004\007\200t\2101\330\010\021\220\021\220%\220r\320\0319\270\024\270Y\300a\330\004\013\2101\200\001\360\024\000\005\016\210S\220\003\2202\220R\220q\330\004\005\330\010\t\330\t\014\210C\210r\220\022\2203\220b\230\001\330\t\014\210C\210r\220\022\2203\220b\230\001\330\010\t\230\021\250\021\200\001\360.\000 /\250a\360\024\000\005\014\2103\210a\210s\220#\220S\230\001\360\006\000\005\033\230!\330\010\031\230\022\2301\230A\230T\240\022\2402\240T\250\024\250U\260%\260q\270\003\2703\270a\270s\300\"\300C\300q\360\010\000\005\021\220\001\330\004\010\210\005\210U\220!\2203\220c\230\021\230!\330\010\r\320\r \240\001\240\022\2402\240R\240q\250\001\330\010\r\320\r \240\001\240\022\2401\240A\330\010\r\320\r \240\001\240\022\2401\240A\330\010\013\2103\210a\210s\220\"\220D\230\002\230#\230Q\230c\240\022\2404\240r\250\032\2602\260S\270\001\270\023\270B\270a\330\014\022\220$\220a\220q\360\010\000\005\014\2101\210H\220A\220S\230\003\2303\230a\330\004\021\220\030\230\021\230#\230Q\320\0363\2602\260R\260r""\270\023\270C\270s\300!\330\004\014\210A\330\004\010\210\005\210U\220!\2203\220c\230\021\320\032/\250r\260\021\330\010\023\2201\330\010\014\210E\220\025\220a\220w\230a\330\014\031\230\036\240t\2501\250B\250m\2704\270q\300\002\300!\340\014\017\210t\2201\340\020\035\230U\240!\2402\240R\240r\250\022\2503\250b\260\005\260Q\260b\270\002\270#\270R\270q\330\020\036\230l\250\"\250A\330\020\036\230a\330\020\030\230\010\240\001\240\035\250m\2702\270R\270s\300!\330\020\023\2206\230\022\2301\330\024\037\230q\340\020\023\220;\230c\240\021\340\024\025\360\006\000\r\016\330\020\027\220u\230L\250\001\320)>\270c\300\022\3002\300Q\330\023\024\330\020\021\360\006\000\r\"\240\036\250r\260\030\270\021\330\014\034\230A\360\006\000\r\025\220A\330\014\020\220\003\220;\230i\240q\250\001\330\020\027\320\027*\250!\2502\250R\250q\330\020\026\220c\230\021\230'\240\021\240#\240R\240t\2501\250A\330\020\033\2301\230G\2401\330\020\023\2206\230\022\2301\330\024\025\330\020\035\230W\240A\240Q\330\014\017\210v\220R\220q\340\020\021\360\006\000\r\021\220\003\220;\230i\240q\250\001\330\020\027\320\027*\250!\2502\250R\250q\330\020\024\220D\230\004\230E\240\025\240c\250\021\340\020\023\2204\320\0270\260\001\260\024\260T\270\024\270T\300\021\330\024\034\230J\240b\250\001\330\024\025\330\014\017\210v\220R\220q\340\020\021\360\006\000\r\033\230,\240b\250\001\330\014\035\230Q\230m\2501\330\014\024\220H\230A\230]\250-\260r\270\022\2703\270a\330\014\017\210v\220R\220q\330\020\033\2301\340\014\017\210|\2303\230a\340\020\021\340\010\014\210G\2201\220A\330\010\013\2102\210S\220\001\330\014\024\220A\360\006\000\005\016\210Q\330\004\014\210A\330\004\010\210\003\2101\210F\220\"\220A\330\004\n\210!\330\010\017\210{\230$\230a\230r\240\036\250t\2601\260B\260a\330\010\016\210g\220Q\220a\330\010\r\210W\220A\220Q\330\010\r\210Q\330\004\r\210Q\330\004\010\210\001\330\004\010\210\003\210<\220x\230q\240\004\240A\240S\250\001\250\030\260\021\330\010\013\2101\330\014\022\220'\230\021\230,\240a\320'<\270C\270r\300\022\3002\300Q""\300a\340\014\020\220\005\220U\230!\2303\230a\330\020\026\220g\230Q\230a\230q\240\002\240\"\240D\250\002\250\"\250B\250b\260\001\330\010\014\210A\340\004\013\2101";
  8427. PyObject *data = NULL;
  8428. CYTHON_UNUSED_VAR(__Pyx_DecompressString);
  8429. #endif
  8430. PyObject **stringtab = __pyx_mstate->__pyx_string_tab;
  8431. Py_ssize_t pos = 0;
  8432. for (int i = 0; i < 130; i++) {
  8433. Py_ssize_t bytes_length = index[i].length;
  8434. PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL);
  8435. if (likely(string) && i >= 17) PyUnicode_InternInPlace(&string);
  8436. if (unlikely(!string)) {
  8437. Py_XDECREF(data);
  8438. __PYX_ERR(0, 1, __pyx_L1_error)
  8439. }
  8440. stringtab[i] = string;
  8441. pos += bytes_length;
  8442. }
  8443. for (int i = 130; i < 137; i++) {
  8444. Py_ssize_t bytes_length = index[i].length;
  8445. PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length);
  8446. stringtab[i] = string;
  8447. pos += bytes_length;
  8448. if (unlikely(!string)) {
  8449. Py_XDECREF(data);
  8450. __PYX_ERR(0, 1, __pyx_L1_error)
  8451. }
  8452. }
  8453. Py_XDECREF(data);
  8454. for (Py_ssize_t i = 0; i < 137; i++) {
  8455. if (unlikely(PyObject_Hash(stringtab[i]) == -1)) {
  8456. __PYX_ERR(0, 1, __pyx_L1_error)
  8457. }
  8458. }
  8459. #if CYTHON_IMMORTAL_CONSTANTS
  8460. {
  8461. PyObject **table = stringtab + 130;
  8462. for (Py_ssize_t i=0; i<7; ++i) {
  8463. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8464. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  8465. #else
  8466. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  8467. #endif
  8468. }
  8469. }
  8470. #endif
  8471. }
  8472. {
  8473. PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0;
  8474. int8_t const cint_constants_1[] = {0,1,3};
  8475. for (int i = 0; i < 3; i++) {
  8476. numbertab[i] = PyLong_FromLong(cint_constants_1[i - 0]);
  8477. if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error)
  8478. }
  8479. }
  8480. #if CYTHON_IMMORTAL_CONSTANTS
  8481. {
  8482. PyObject **table = __pyx_mstate->__pyx_number_tab;
  8483. for (Py_ssize_t i=0; i<3; ++i) {
  8484. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8485. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  8486. #else
  8487. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  8488. #endif
  8489. }
  8490. }
  8491. #endif
  8492. return 0;
  8493. __pyx_L1_error:;
  8494. return -1;
  8495. }
  8496. /* #### Code section: init_codeobjects ### */
  8497. typedef struct {
  8498. unsigned int argcount : 3;
  8499. unsigned int num_posonly_args : 1;
  8500. unsigned int num_kwonly_args : 1;
  8501. unsigned int nlocals : 6;
  8502. unsigned int flags : 10;
  8503. unsigned int first_line : 9;
  8504. } __Pyx_PyCode_New_function_description;
  8505. /* NewCodeObj.proto */
  8506. static PyObject* __Pyx_PyCode_New(
  8507. const __Pyx_PyCode_New_function_description descr,
  8508. PyObject * const *varnames,
  8509. PyObject *filename,
  8510. PyObject *funcname,
  8511. PyObject *line_table,
  8512. PyObject *tuple_dedup_map
  8513. );
  8514. static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) {
  8515. PyObject* tuple_dedup_map = PyDict_New();
  8516. if (unlikely(!tuple_dedup_map)) return -1;
  8517. {
  8518. const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 235};
  8519. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_cost, __pyx_mstate->__pyx_n_u_is_complex, __pyx_mstate->__pyx_n_u_c};
  8520. __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591__3, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad;
  8521. }
  8522. {
  8523. const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 21, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 340};
  8524. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_j, __pyx_mstate->__pyx_n_u_k, __pyx_mstate->__pyx_n_u_start, __pyx_mstate->__pyx_n_u_i_sol_count, __pyx_mstate->__pyx_n_u_j_sol_count, __pyx_mstate->__pyx_n_u_this_sol_count, __pyx_mstate->__pyx_n_u_tolerance, __pyx_mstate->__pyx_n_u_err, __pyx_mstate->__pyx_n_u_error, __pyx_mstate->__pyx_n_u_i_sol_error, __pyx_mstate->__pyx_n_u_j_sol_error, __pyx_mstate->__pyx_n_u_all_cubic, __pyx_mstate->__pyx_n_u_is_cubic, __pyx_mstate->__pyx_n_u_count, __pyx_mstate->__pyx_n_u_p0, __pyx_mstate->__pyx_n_u_p1, __pyx_mstate->__pyx_n_u_p2, __pyx_mstate->__pyx_n_u_p3, __pyx_mstate->__pyx_n_u_v, __pyx_mstate->__pyx_n_u_u};
  8525. __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591__4, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad;
  8526. }
  8527. {
  8528. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 82};
  8529. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_p0, __pyx_mstate->__pyx_n_u_p1, __pyx_mstate->__pyx_n_u_p2, __pyx_mstate->__pyx_n_u_p1_2_3};
  8530. __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py, __pyx_mstate->__pyx_n_u_elevate_quadratic, __pyx_mstate->__pyx_kp_b_iso88591_S_2Rq_Cr_3b_Cr_3b, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad;
  8531. }
  8532. {
  8533. const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 154};
  8534. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_p, __pyx_mstate->__pyx_n_u_count, __pyx_mstate->__pyx_n_u_num_offcurves, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_off1, __pyx_mstate->__pyx_n_u_off2, __pyx_mstate->__pyx_n_u_on, __pyx_mstate->__pyx_n_u_q};
  8535. __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py, __pyx_mstate->__pyx_n_u_add_implicit_on_curves, __pyx_mstate->__pyx_kp_b_iso88591_AQ_A_Cq_2Q_U_3a_q_q_2Q_U_U_F_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad;
  8536. }
  8537. {
  8538. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 17, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 178};
  8539. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_quads, __pyx_mstate->__pyx_n_u_max_err, __pyx_mstate->__pyx_n_u_all_cubic, __pyx_mstate->__pyx_n_u_cost, __pyx_mstate->__pyx_n_u_is_complex, __pyx_mstate->__pyx_n_u_q, __pyx_mstate->__pyx_n_u_costs, __pyx_mstate->__pyx_n_u_p, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_qq, __pyx_mstate->__pyx_n_u_curves, __pyx_mstate->__pyx_n_u_p, __pyx_mstate->__pyx_n_u_x, __pyx_mstate->__pyx_n_u_y, __pyx_mstate->__pyx_n_u_curve, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr};
  8540. __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py, __pyx_mstate->__pyx_n_u_quadratic_to_curves, __pyx_mstate->__pyx_kp_b_iso88591_Q_q_6_Qe1Bat3a_t1_S_S_c_U_ar_AQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad;
  8541. }
  8542. {
  8543. const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 42, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 242};
  8544. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_q, __pyx_mstate->__pyx_n_u_costs, __pyx_mstate->__pyx_n_u_tolerance, __pyx_mstate->__pyx_n_u_all_cubic, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_j, __pyx_mstate->__pyx_n_u_k, __pyx_mstate->__pyx_n_u_start, __pyx_mstate->__pyx_n_u_i_sol_count, __pyx_mstate->__pyx_n_u_j_sol_count, __pyx_mstate->__pyx_n_u_this_sol_count, __pyx_mstate->__pyx_n_u_err, __pyx_mstate->__pyx_n_u_error, __pyx_mstate->__pyx_n_u_i_sol_error, __pyx_mstate->__pyx_n_u_j_sol_error, __pyx_mstate->__pyx_n_u_is_cubic, __pyx_mstate->__pyx_n_u_count, __pyx_mstate->__pyx_n_u_p0, __pyx_mstate->__pyx_n_u_p1, __pyx_mstate->__pyx_n_u_p2, __pyx_mstate->__pyx_n_u_p3, __pyx_mstate->__pyx_n_u_v, __pyx_mstate->__pyx_n_u_u, __pyx_mstate->__pyx_n_u_elevated_quadratics, __pyx_mstate->__pyx_n_u_forced, __pyx_mstate->__pyx_n_u_sols, __pyx_mstate->__pyx_n_u_impossible, __pyx_mstate->__pyx_n_u_best_sol, __pyx_mstate->__pyx_n_u_this_count, __pyx_mstate->__pyx_n_u_i_sol, __pyx_mstate->__pyx_n_u_curve, __pyx_mstate->__pyx_n_u_ts, __pyx_mstate->__pyx_n_u_reconstructed_iter, __pyx_mstate->__pyx_n_u_reconstructed, __pyx_mstate->__pyx_n_u_reconst, __pyx_mstate->__pyx_n_u_orig, __pyx_mstate->__pyx_n_u_splits, __pyx_mstate->__pyx_n_u_cubic, __pyx_mstate->__pyx_n_u_curves, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr};
  8545. __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py, __pyx_mstate->__pyx_n_u_spline_to_curves, __pyx_mstate->__pyx_kp_b_iso88591_a_3as_S_1AT_2T_U_q_3as_Cq_U_3c, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad;
  8546. }
  8547. {
  8548. const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 386};
  8549. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_generate_curve, __pyx_mstate->__pyx_n_u_curve_to_quadratic, __pyx_mstate->__pyx_n_u_tolerance, __pyx_mstate->__pyx_n_u_reconstruct_tolerance, __pyx_mstate->__pyx_n_u_curve, __pyx_mstate->__pyx_n_u_quadratics, __pyx_mstate->__pyx_n_u_curves};
  8550. __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py, __pyx_mstate->__pyx_n_u_main_2, __pyx_mstate->__pyx_kp_b_iso88591_Jb_N_1G1_2_8_Qa_q_Cq_Q_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad;
  8551. }
  8552. Py_DECREF(tuple_dedup_map);
  8553. return 0;
  8554. bad:
  8555. Py_DECREF(tuple_dedup_map);
  8556. return -1;
  8557. }
  8558. /* #### Code section: init_globals ### */
  8559. static int __Pyx_InitGlobals(void) {
  8560. /* PythonCompatibility.init */
  8561. if (likely(__Pyx_init_co_variables() == 0)); else
  8562. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  8563. /* AssertionsEnabled.init */
  8564. if (likely(__Pyx_init_assertions_enabled() == 0)); else
  8565. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  8566. /* CommonTypesMetaclass.init */
  8567. if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else
  8568. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  8569. /* CachedMethodType.init */
  8570. #if CYTHON_COMPILING_IN_LIMITED_API
  8571. {
  8572. PyObject *typesModule=NULL;
  8573. typesModule = PyImport_ImportModule("types");
  8574. if (typesModule) {
  8575. __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType");
  8576. Py_DECREF(typesModule);
  8577. }
  8578. } // error handling follows
  8579. #endif
  8580. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  8581. /* CythonFunctionShared.init */
  8582. if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else
  8583. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  8584. /* Generator.init */
  8585. if (likely(__pyx_Generator_init(__pyx_m) == 0)); else
  8586. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  8587. return 0;
  8588. __pyx_L1_error:;
  8589. return -1;
  8590. }
  8591. /* #### Code section: cleanup_globals ### */
  8592. /* #### Code section: cleanup_module ### */
  8593. /* #### Code section: main_method ### */
  8594. /* #### Code section: utility_code_pragmas ### */
  8595. #ifdef _MSC_VER
  8596. #pragma warning( push )
  8597. /* Warning 4127: conditional expression is constant
  8598. * Cython uses constant conditional expressions to allow in inline functions to be optimized at
  8599. * compile-time, so this warning is not useful
  8600. */
  8601. #pragma warning( disable : 4127 )
  8602. #endif
  8603. /* #### Code section: utility_code_def ### */
  8604. /* --- Runtime support code --- */
  8605. /* Refnanny */
  8606. #if CYTHON_REFNANNY
  8607. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  8608. PyObject *m = NULL, *p = NULL;
  8609. void *r = NULL;
  8610. m = PyImport_ImportModule(modname);
  8611. if (!m) goto end;
  8612. p = PyObject_GetAttrString(m, "RefNannyAPI");
  8613. if (!p) goto end;
  8614. r = PyLong_AsVoidPtr(p);
  8615. end:
  8616. Py_XDECREF(p);
  8617. Py_XDECREF(m);
  8618. return (__Pyx_RefNannyAPIStruct *)r;
  8619. }
  8620. #endif
  8621. /* PyErrExceptionMatches (used by PyObjectGetAttrStrNoError) */
  8622. #if CYTHON_FAST_THREAD_STATE
  8623. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  8624. Py_ssize_t i, n;
  8625. n = PyTuple_GET_SIZE(tuple);
  8626. for (i=0; i<n; i++) {
  8627. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  8628. }
  8629. for (i=0; i<n; i++) {
  8630. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  8631. }
  8632. return 0;
  8633. }
  8634. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  8635. int result;
  8636. PyObject *exc_type;
  8637. #if PY_VERSION_HEX >= 0x030C00A6
  8638. PyObject *current_exception = tstate->current_exception;
  8639. if (unlikely(!current_exception)) return 0;
  8640. exc_type = (PyObject*) Py_TYPE(current_exception);
  8641. if (exc_type == err) return 1;
  8642. #else
  8643. exc_type = tstate->curexc_type;
  8644. if (exc_type == err) return 1;
  8645. if (unlikely(!exc_type)) return 0;
  8646. #endif
  8647. #if CYTHON_AVOID_BORROWED_REFS
  8648. Py_INCREF(exc_type);
  8649. #endif
  8650. if (unlikely(PyTuple_Check(err))) {
  8651. result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  8652. } else {
  8653. result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  8654. }
  8655. #if CYTHON_AVOID_BORROWED_REFS
  8656. Py_DECREF(exc_type);
  8657. #endif
  8658. return result;
  8659. }
  8660. #endif
  8661. /* PyErrFetchRestore (used by PyObjectGetAttrStrNoError) */
  8662. #if CYTHON_FAST_THREAD_STATE
  8663. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  8664. #if PY_VERSION_HEX >= 0x030C00A6
  8665. PyObject *tmp_value;
  8666. assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
  8667. if (value) {
  8668. #if CYTHON_COMPILING_IN_CPYTHON
  8669. if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
  8670. #endif
  8671. PyException_SetTraceback(value, tb);
  8672. }
  8673. tmp_value = tstate->current_exception;
  8674. tstate->current_exception = value;
  8675. Py_XDECREF(tmp_value);
  8676. Py_XDECREF(type);
  8677. Py_XDECREF(tb);
  8678. #else
  8679. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8680. tmp_type = tstate->curexc_type;
  8681. tmp_value = tstate->curexc_value;
  8682. tmp_tb = tstate->curexc_traceback;
  8683. tstate->curexc_type = type;
  8684. tstate->curexc_value = value;
  8685. tstate->curexc_traceback = tb;
  8686. Py_XDECREF(tmp_type);
  8687. Py_XDECREF(tmp_value);
  8688. Py_XDECREF(tmp_tb);
  8689. #endif
  8690. }
  8691. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  8692. #if PY_VERSION_HEX >= 0x030C00A6
  8693. PyObject* exc_value;
  8694. exc_value = tstate->current_exception;
  8695. tstate->current_exception = 0;
  8696. *value = exc_value;
  8697. *type = NULL;
  8698. *tb = NULL;
  8699. if (exc_value) {
  8700. *type = (PyObject*) Py_TYPE(exc_value);
  8701. Py_INCREF(*type);
  8702. #if CYTHON_COMPILING_IN_CPYTHON
  8703. *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
  8704. Py_XINCREF(*tb);
  8705. #else
  8706. *tb = PyException_GetTraceback(exc_value);
  8707. #endif
  8708. }
  8709. #else
  8710. *type = tstate->curexc_type;
  8711. *value = tstate->curexc_value;
  8712. *tb = tstate->curexc_traceback;
  8713. tstate->curexc_type = 0;
  8714. tstate->curexc_value = 0;
  8715. tstate->curexc_traceback = 0;
  8716. #endif
  8717. }
  8718. #endif
  8719. /* PyObjectGetAttrStr (used by PyObjectGetAttrStrNoError) */
  8720. #if CYTHON_USE_TYPE_SLOTS
  8721. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  8722. PyTypeObject* tp = Py_TYPE(obj);
  8723. if (likely(tp->tp_getattro))
  8724. return tp->tp_getattro(obj, attr_name);
  8725. return PyObject_GetAttr(obj, attr_name);
  8726. }
  8727. #endif
  8728. /* PyObjectGetAttrStrNoError (used by GetBuiltinName) */
  8729. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  8730. static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
  8731. __Pyx_PyThreadState_declare
  8732. __Pyx_PyThreadState_assign
  8733. if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  8734. __Pyx_PyErr_Clear();
  8735. }
  8736. #endif
  8737. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
  8738. PyObject *result;
  8739. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  8740. (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
  8741. return result;
  8742. #else
  8743. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS
  8744. PyTypeObject* tp = Py_TYPE(obj);
  8745. if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
  8746. return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
  8747. }
  8748. #endif
  8749. result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
  8750. if (unlikely(!result)) {
  8751. __Pyx_PyObject_GetAttrStr_ClearAttributeError();
  8752. }
  8753. return result;
  8754. #endif
  8755. }
  8756. /* GetBuiltinName */
  8757. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  8758. PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name);
  8759. if (unlikely(!result) && !PyErr_Occurred()) {
  8760. PyErr_Format(PyExc_NameError,
  8761. "name '%U' is not defined", name);
  8762. }
  8763. return result;
  8764. }
  8765. /* TupleAndListFromArray (used by fastcall) */
  8766. #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL
  8767. static CYTHON_INLINE PyObject *
  8768. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  8769. {
  8770. PyObject *res;
  8771. Py_ssize_t i;
  8772. if (n <= 0) {
  8773. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  8774. }
  8775. res = PyTuple_New(n);
  8776. if (unlikely(res == NULL)) return NULL;
  8777. for (i = 0; i < n; i++) {
  8778. if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) {
  8779. Py_DECREF(res);
  8780. return NULL;
  8781. }
  8782. Py_INCREF(src[i]);
  8783. }
  8784. return res;
  8785. }
  8786. #elif CYTHON_COMPILING_IN_CPYTHON
  8787. static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
  8788. PyObject *v;
  8789. Py_ssize_t i;
  8790. for (i = 0; i < length; i++) {
  8791. v = dest[i] = src[i];
  8792. Py_INCREF(v);
  8793. }
  8794. }
  8795. static CYTHON_INLINE PyObject *
  8796. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  8797. {
  8798. PyObject *res;
  8799. if (n <= 0) {
  8800. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  8801. }
  8802. res = PyTuple_New(n);
  8803. if (unlikely(res == NULL)) return NULL;
  8804. __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
  8805. return res;
  8806. }
  8807. static CYTHON_INLINE PyObject *
  8808. __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
  8809. {
  8810. PyObject *res;
  8811. if (n <= 0) {
  8812. return PyList_New(0);
  8813. }
  8814. res = PyList_New(n);
  8815. if (unlikely(res == NULL)) return NULL;
  8816. __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
  8817. return res;
  8818. }
  8819. #endif
  8820. /* BytesEquals (used by UnicodeEquals) */
  8821. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  8822. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\
  8823. !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS)
  8824. return PyObject_RichCompareBool(s1, s2, equals);
  8825. #else
  8826. if (s1 == s2) {
  8827. return (equals == Py_EQ);
  8828. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  8829. const char *ps1, *ps2;
  8830. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  8831. if (length != PyBytes_GET_SIZE(s2))
  8832. return (equals == Py_NE);
  8833. ps1 = PyBytes_AS_STRING(s1);
  8834. ps2 = PyBytes_AS_STRING(s2);
  8835. if (ps1[0] != ps2[0]) {
  8836. return (equals == Py_NE);
  8837. } else if (length == 1) {
  8838. return (equals == Py_EQ);
  8839. } else {
  8840. int result;
  8841. #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
  8842. Py_hash_t hash1, hash2;
  8843. hash1 = ((PyBytesObject*)s1)->ob_shash;
  8844. hash2 = ((PyBytesObject*)s2)->ob_shash;
  8845. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  8846. return (equals == Py_NE);
  8847. }
  8848. #endif
  8849. result = memcmp(ps1, ps2, (size_t)length);
  8850. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  8851. }
  8852. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  8853. return (equals == Py_NE);
  8854. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  8855. return (equals == Py_NE);
  8856. } else {
  8857. int result;
  8858. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  8859. if (!py_result)
  8860. return -1;
  8861. result = __Pyx_PyObject_IsTrue(py_result);
  8862. Py_DECREF(py_result);
  8863. return result;
  8864. }
  8865. #endif
  8866. }
  8867. /* UnicodeEquals (used by fastcall) */
  8868. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  8869. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  8870. return PyObject_RichCompareBool(s1, s2, equals);
  8871. #else
  8872. int s1_is_unicode, s2_is_unicode;
  8873. if (s1 == s2) {
  8874. goto return_eq;
  8875. }
  8876. s1_is_unicode = PyUnicode_CheckExact(s1);
  8877. s2_is_unicode = PyUnicode_CheckExact(s2);
  8878. if (s1_is_unicode & s2_is_unicode) {
  8879. Py_ssize_t length, length2;
  8880. int kind;
  8881. void *data1, *data2;
  8882. #if !CYTHON_COMPILING_IN_LIMITED_API
  8883. if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
  8884. return -1;
  8885. #endif
  8886. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  8887. #if !CYTHON_ASSUME_SAFE_SIZE
  8888. if (unlikely(length < 0)) return -1;
  8889. #endif
  8890. length2 = __Pyx_PyUnicode_GET_LENGTH(s2);
  8891. #if !CYTHON_ASSUME_SAFE_SIZE
  8892. if (unlikely(length2 < 0)) return -1;
  8893. #endif
  8894. if (length != length2) {
  8895. goto return_ne;
  8896. }
  8897. #if CYTHON_USE_UNICODE_INTERNALS
  8898. {
  8899. Py_hash_t hash1, hash2;
  8900. hash1 = ((PyASCIIObject*)s1)->hash;
  8901. hash2 = ((PyASCIIObject*)s2)->hash;
  8902. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  8903. goto return_ne;
  8904. }
  8905. }
  8906. #endif
  8907. kind = __Pyx_PyUnicode_KIND(s1);
  8908. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  8909. goto return_ne;
  8910. }
  8911. data1 = __Pyx_PyUnicode_DATA(s1);
  8912. data2 = __Pyx_PyUnicode_DATA(s2);
  8913. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  8914. goto return_ne;
  8915. } else if (length == 1) {
  8916. goto return_eq;
  8917. } else {
  8918. int result = memcmp(data1, data2, (size_t)(length * kind));
  8919. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  8920. }
  8921. } else if ((s1 == Py_None) & s2_is_unicode) {
  8922. goto return_ne;
  8923. } else if ((s2 == Py_None) & s1_is_unicode) {
  8924. goto return_ne;
  8925. } else {
  8926. int result;
  8927. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  8928. if (!py_result)
  8929. return -1;
  8930. result = __Pyx_PyObject_IsTrue(py_result);
  8931. Py_DECREF(py_result);
  8932. return result;
  8933. }
  8934. return_eq:
  8935. return (equals == Py_EQ);
  8936. return_ne:
  8937. return (equals == Py_NE);
  8938. #endif
  8939. }
  8940. /* fastcall */
  8941. #if CYTHON_METH_FASTCALL
  8942. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
  8943. {
  8944. Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames);
  8945. #if !CYTHON_ASSUME_SAFE_SIZE
  8946. if (unlikely(n == -1)) return NULL;
  8947. #endif
  8948. for (i = 0; i < n; i++)
  8949. {
  8950. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  8951. #if !CYTHON_ASSUME_SAFE_MACROS
  8952. if (unlikely(!namei)) return NULL;
  8953. #endif
  8954. if (s == namei) return kwvalues[i];
  8955. }
  8956. for (i = 0; i < n; i++)
  8957. {
  8958. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  8959. #if !CYTHON_ASSUME_SAFE_MACROS
  8960. if (unlikely(!namei)) return NULL;
  8961. #endif
  8962. int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ);
  8963. if (unlikely(eq != 0)) {
  8964. if (unlikely(eq < 0)) return NULL;
  8965. return kwvalues[i];
  8966. }
  8967. }
  8968. return NULL;
  8969. }
  8970. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  8971. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
  8972. Py_ssize_t i, nkwargs;
  8973. PyObject *dict;
  8974. #if !CYTHON_ASSUME_SAFE_SIZE
  8975. nkwargs = PyTuple_Size(kwnames);
  8976. if (unlikely(nkwargs < 0)) return NULL;
  8977. #else
  8978. nkwargs = PyTuple_GET_SIZE(kwnames);
  8979. #endif
  8980. dict = PyDict_New();
  8981. if (unlikely(!dict))
  8982. return NULL;
  8983. for (i=0; i<nkwargs; i++) {
  8984. #if !CYTHON_ASSUME_SAFE_MACROS
  8985. PyObject *key = PyTuple_GetItem(kwnames, i);
  8986. if (!key) goto bad;
  8987. #else
  8988. PyObject *key = PyTuple_GET_ITEM(kwnames, i);
  8989. #endif
  8990. if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
  8991. goto bad;
  8992. }
  8993. return dict;
  8994. bad:
  8995. Py_DECREF(dict);
  8996. return NULL;
  8997. }
  8998. #endif
  8999. #endif
  9000. /* PyObjectCall (used by PyObjectFastCall) */
  9001. #if CYTHON_COMPILING_IN_CPYTHON
  9002. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  9003. PyObject *result;
  9004. ternaryfunc call = Py_TYPE(func)->tp_call;
  9005. if (unlikely(!call))
  9006. return PyObject_Call(func, arg, kw);
  9007. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  9008. return NULL;
  9009. result = (*call)(func, arg, kw);
  9010. Py_LeaveRecursiveCall();
  9011. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  9012. PyErr_SetString(
  9013. PyExc_SystemError,
  9014. "NULL result without error in PyObject_Call");
  9015. }
  9016. return result;
  9017. }
  9018. #endif
  9019. /* PyObjectCallMethO (used by PyObjectFastCall) */
  9020. #if CYTHON_COMPILING_IN_CPYTHON
  9021. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  9022. PyObject *self, *result;
  9023. PyCFunction cfunc;
  9024. cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func);
  9025. self = __Pyx_CyOrPyCFunction_GET_SELF(func);
  9026. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  9027. return NULL;
  9028. result = cfunc(self, arg);
  9029. Py_LeaveRecursiveCall();
  9030. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  9031. PyErr_SetString(
  9032. PyExc_SystemError,
  9033. "NULL result without error in PyObject_Call");
  9034. }
  9035. return result;
  9036. }
  9037. #endif
  9038. /* PyObjectFastCall (used by PyObjectCallOneArg) */
  9039. #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
  9040. static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) {
  9041. PyObject *argstuple;
  9042. PyObject *result = 0;
  9043. size_t i;
  9044. argstuple = PyTuple_New((Py_ssize_t)nargs);
  9045. if (unlikely(!argstuple)) return NULL;
  9046. for (i = 0; i < nargs; i++) {
  9047. Py_INCREF(args[i]);
  9048. if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad;
  9049. }
  9050. result = __Pyx_PyObject_Call(func, argstuple, kwargs);
  9051. bad:
  9052. Py_DECREF(argstuple);
  9053. return result;
  9054. }
  9055. #endif
  9056. #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API
  9057. #if PY_VERSION_HEX < 0x03090000
  9058. #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable)
  9059. #elif CYTHON_COMPILING_IN_CPYTHON
  9060. static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) {
  9061. PyTypeObject *tp = Py_TYPE(callable);
  9062. #if defined(__Pyx_CyFunction_USED)
  9063. if (__Pyx_CyFunction_CheckExact(callable)) {
  9064. return __Pyx_CyFunction_func_vectorcall(callable);
  9065. }
  9066. #endif
  9067. if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) {
  9068. return NULL;
  9069. }
  9070. assert(PyCallable_Check(callable));
  9071. Py_ssize_t offset = tp->tp_vectorcall_offset;
  9072. assert(offset > 0);
  9073. vectorcallfunc ptr;
  9074. memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
  9075. return ptr;
  9076. }
  9077. #else
  9078. #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable)
  9079. #endif
  9080. #endif
  9081. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) {
  9082. Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
  9083. #if CYTHON_COMPILING_IN_CPYTHON
  9084. if (nargs == 0 && kwargs == NULL) {
  9085. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
  9086. return __Pyx_PyObject_CallMethO(func, NULL);
  9087. }
  9088. else if (nargs == 1 && kwargs == NULL) {
  9089. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O))
  9090. return __Pyx_PyObject_CallMethO(func, args[0]);
  9091. }
  9092. #endif
  9093. if (kwargs == NULL) {
  9094. #if CYTHON_VECTORCALL
  9095. #if CYTHON_COMPILING_IN_LIMITED_API
  9096. return PyObject_Vectorcall(func, args, _nargs, NULL);
  9097. #else
  9098. vectorcallfunc f = __Pyx_PyVectorcall_Function(func);
  9099. if (f) {
  9100. return f(func, args, _nargs, NULL);
  9101. }
  9102. #endif
  9103. #endif
  9104. }
  9105. if (nargs == 0) {
  9106. return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs);
  9107. }
  9108. #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
  9109. return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
  9110. #else
  9111. return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
  9112. #endif
  9113. }
  9114. /* PyObjectCallOneArg (used by CallUnboundCMethod0) */
  9115. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  9116. PyObject *args[2] = {NULL, arg};
  9117. return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  9118. }
  9119. /* UnpackUnboundCMethod (used by CallUnboundCMethod0) */
  9120. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  9121. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) {
  9122. PyObject *result;
  9123. PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
  9124. if (unlikely(!selfless_args)) return NULL;
  9125. result = PyObject_Call(method, selfless_args, kwargs);
  9126. Py_DECREF(selfless_args);
  9127. return result;
  9128. }
  9129. #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000
  9130. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) {
  9131. return _PyObject_Vectorcall
  9132. (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames);
  9133. }
  9134. #else
  9135. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) {
  9136. return
  9137. #if PY_VERSION_HEX < 0x03090000
  9138. _PyObject_Vectorcall
  9139. #else
  9140. PyObject_Vectorcall
  9141. #endif
  9142. (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames);
  9143. }
  9144. #endif
  9145. static PyMethodDef __Pyx_UnboundCMethod_Def = {
  9146. "CythonUnboundCMethod",
  9147. __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall),
  9148. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  9149. METH_VARARGS | METH_KEYWORDS,
  9150. #else
  9151. METH_FASTCALL | METH_KEYWORDS,
  9152. #endif
  9153. NULL
  9154. };
  9155. static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
  9156. PyObject *method, *result=NULL;
  9157. method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
  9158. if (unlikely(!method))
  9159. return -1;
  9160. result = method;
  9161. #if CYTHON_COMPILING_IN_CPYTHON
  9162. if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
  9163. {
  9164. PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
  9165. target->func = descr->d_method->ml_meth;
  9166. target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
  9167. } else
  9168. #endif
  9169. #if CYTHON_COMPILING_IN_PYPY
  9170. #else
  9171. if (PyCFunction_Check(method))
  9172. #endif
  9173. {
  9174. PyObject *self;
  9175. int self_found;
  9176. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  9177. self = PyObject_GetAttrString(method, "__self__");
  9178. if (!self) {
  9179. PyErr_Clear();
  9180. }
  9181. #else
  9182. self = PyCFunction_GET_SELF(method);
  9183. #endif
  9184. self_found = (self && self != Py_None);
  9185. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  9186. Py_XDECREF(self);
  9187. #endif
  9188. if (self_found) {
  9189. PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method);
  9190. if (unlikely(!unbound_method)) return -1;
  9191. Py_DECREF(method);
  9192. result = unbound_method;
  9193. }
  9194. }
  9195. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9196. if (unlikely(target->method)) {
  9197. Py_DECREF(result);
  9198. } else
  9199. #endif
  9200. target->method = result;
  9201. return 0;
  9202. }
  9203. /* CallUnboundCMethod0 */
  9204. #if CYTHON_COMPILING_IN_CPYTHON
  9205. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  9206. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  9207. if (likely(was_initialized == 2 && cfunc->func)) {
  9208. if (likely(cfunc->flag == METH_NOARGS))
  9209. return __Pyx_CallCFunction(cfunc, self, NULL);
  9210. if (likely(cfunc->flag == METH_FASTCALL))
  9211. return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0);
  9212. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  9213. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL);
  9214. if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS)))
  9215. return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  9216. if (cfunc->flag == METH_VARARGS)
  9217. return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple);
  9218. return __Pyx__CallUnboundCMethod0(cfunc, self);
  9219. }
  9220. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9221. else if (unlikely(was_initialized == 1)) {
  9222. __Pyx_CachedCFunction tmp_cfunc = {
  9223. #ifndef __cplusplus
  9224. 0
  9225. #endif
  9226. };
  9227. tmp_cfunc.type = cfunc->type;
  9228. tmp_cfunc.method_name = cfunc->method_name;
  9229. return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self);
  9230. }
  9231. #endif
  9232. PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self);
  9233. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  9234. return result;
  9235. }
  9236. #endif
  9237. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  9238. PyObject *result;
  9239. if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  9240. result = __Pyx_PyObject_CallOneArg(cfunc->method, self);
  9241. return result;
  9242. }
  9243. /* py_dict_items (used by OwnedDictNext) */
  9244. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
  9245. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d);
  9246. }
  9247. /* py_dict_values (used by OwnedDictNext) */
  9248. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
  9249. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d);
  9250. }
  9251. /* OwnedDictNext (used by ParseKeywordsImpl) */
  9252. #if CYTHON_AVOID_BORROWED_REFS
  9253. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) {
  9254. PyObject *next = NULL;
  9255. if (!*ppos) {
  9256. if (pvalue) {
  9257. PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p);
  9258. if (unlikely(!dictview)) goto bad;
  9259. *ppos = PyObject_GetIter(dictview);
  9260. Py_DECREF(dictview);
  9261. } else {
  9262. *ppos = PyObject_GetIter(p);
  9263. }
  9264. if (unlikely(!*ppos)) goto bad;
  9265. }
  9266. next = PyIter_Next(*ppos);
  9267. if (!next) {
  9268. if (PyErr_Occurred()) goto bad;
  9269. return 0;
  9270. }
  9271. if (pkey && pvalue) {
  9272. *pkey = __Pyx_PySequence_ITEM(next, 0);
  9273. if (unlikely(*pkey)) goto bad;
  9274. *pvalue = __Pyx_PySequence_ITEM(next, 1);
  9275. if (unlikely(*pvalue)) goto bad;
  9276. Py_DECREF(next);
  9277. } else if (pkey) {
  9278. *pkey = next;
  9279. } else {
  9280. assert(pvalue);
  9281. *pvalue = next;
  9282. }
  9283. return 1;
  9284. bad:
  9285. Py_XDECREF(next);
  9286. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  9287. PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef");
  9288. #else
  9289. PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef);
  9290. #endif
  9291. if (pkey) *pkey = NULL;
  9292. if (pvalue) *pvalue = NULL;
  9293. return 0;
  9294. }
  9295. #else // !CYTHON_AVOID_BORROWED_REFS
  9296. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) {
  9297. int result = PyDict_Next(p, ppos, pkey, pvalue);
  9298. if (likely(result == 1)) {
  9299. if (pkey) Py_INCREF(*pkey);
  9300. if (pvalue) Py_INCREF(*pvalue);
  9301. }
  9302. return result;
  9303. }
  9304. #endif
  9305. /* RaiseDoubleKeywords (used by ParseKeywordsImpl) */
  9306. static void __Pyx_RaiseDoubleKeywordsError(
  9307. const char* func_name,
  9308. PyObject* kw_name)
  9309. {
  9310. PyErr_Format(PyExc_TypeError,
  9311. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  9312. }
  9313. /* CallUnboundCMethod2 */
  9314. #if CYTHON_COMPILING_IN_CPYTHON
  9315. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
  9316. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  9317. if (likely(was_initialized == 2 && cfunc->func)) {
  9318. PyObject *args[2] = {arg1, arg2};
  9319. if (cfunc->flag == METH_FASTCALL) {
  9320. return __Pyx_CallCFunctionFast(cfunc, self, args, 2);
  9321. }
  9322. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  9323. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL);
  9324. }
  9325. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9326. else if (unlikely(was_initialized == 1)) {
  9327. __Pyx_CachedCFunction tmp_cfunc = {
  9328. #ifndef __cplusplus
  9329. 0
  9330. #endif
  9331. };
  9332. tmp_cfunc.type = cfunc->type;
  9333. tmp_cfunc.method_name = cfunc->method_name;
  9334. return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2);
  9335. }
  9336. #endif
  9337. PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
  9338. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  9339. return result;
  9340. }
  9341. #endif
  9342. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
  9343. if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  9344. #if CYTHON_COMPILING_IN_CPYTHON
  9345. if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
  9346. PyObject *result = NULL;
  9347. PyObject *args = PyTuple_New(2);
  9348. if (unlikely(!args)) return NULL;
  9349. Py_INCREF(arg1);
  9350. PyTuple_SET_ITEM(args, 0, arg1);
  9351. Py_INCREF(arg2);
  9352. PyTuple_SET_ITEM(args, 1, arg2);
  9353. if (cfunc->flag & METH_KEYWORDS)
  9354. result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL);
  9355. else
  9356. result = __Pyx_CallCFunction(cfunc, self, args);
  9357. Py_DECREF(args);
  9358. return result;
  9359. }
  9360. #endif
  9361. {
  9362. PyObject *args[4] = {NULL, self, arg1, arg2};
  9363. return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  9364. }
  9365. }
  9366. /* ParseKeywordsImpl (used by ParseKeywords) */
  9367. static int __Pyx_ValidateDuplicatePosArgs(
  9368. PyObject *kwds,
  9369. PyObject ** const argnames[],
  9370. PyObject ** const *first_kw_arg,
  9371. const char* function_name)
  9372. {
  9373. PyObject ** const *name = argnames;
  9374. while (name != first_kw_arg) {
  9375. PyObject *key = **name;
  9376. int found = PyDict_Contains(kwds, key);
  9377. if (unlikely(found)) {
  9378. if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9379. goto bad;
  9380. }
  9381. name++;
  9382. }
  9383. return 0;
  9384. bad:
  9385. return -1;
  9386. }
  9387. #if CYTHON_USE_UNICODE_INTERNALS
  9388. static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) {
  9389. int kind;
  9390. Py_ssize_t len = PyUnicode_GET_LENGTH(s1);
  9391. if (len != PyUnicode_GET_LENGTH(s2)) return 0;
  9392. kind = PyUnicode_KIND(s1);
  9393. if (kind != PyUnicode_KIND(s2)) return 0;
  9394. const void *data1 = PyUnicode_DATA(s1);
  9395. const void *data2 = PyUnicode_DATA(s2);
  9396. return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0);
  9397. }
  9398. #endif
  9399. static int __Pyx_MatchKeywordArg_str(
  9400. PyObject *key,
  9401. PyObject ** const argnames[],
  9402. PyObject ** const *first_kw_arg,
  9403. size_t *index_found,
  9404. const char *function_name)
  9405. {
  9406. PyObject ** const *name;
  9407. #if CYTHON_USE_UNICODE_INTERNALS
  9408. Py_hash_t key_hash = ((PyASCIIObject*)key)->hash;
  9409. if (unlikely(key_hash == -1)) {
  9410. key_hash = PyObject_Hash(key);
  9411. if (unlikely(key_hash == -1))
  9412. goto bad;
  9413. }
  9414. #endif
  9415. name = first_kw_arg;
  9416. while (*name) {
  9417. PyObject *name_str = **name;
  9418. #if CYTHON_USE_UNICODE_INTERNALS
  9419. if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) {
  9420. *index_found = (size_t) (name - argnames);
  9421. return 1;
  9422. }
  9423. #else
  9424. #if CYTHON_ASSUME_SAFE_SIZE
  9425. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  9426. #endif
  9427. {
  9428. int cmp = PyUnicode_Compare(name_str, key);
  9429. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  9430. if (cmp == 0) {
  9431. *index_found = (size_t) (name - argnames);
  9432. return 1;
  9433. }
  9434. }
  9435. #endif
  9436. name++;
  9437. }
  9438. name = argnames;
  9439. while (name != first_kw_arg) {
  9440. PyObject *name_str = **name;
  9441. #if CYTHON_USE_UNICODE_INTERNALS
  9442. if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) {
  9443. if (__Pyx_UnicodeKeywordsEqual(name_str, key))
  9444. goto arg_passed_twice;
  9445. }
  9446. #else
  9447. #if CYTHON_ASSUME_SAFE_SIZE
  9448. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  9449. #endif
  9450. {
  9451. if (unlikely(name_str == key)) goto arg_passed_twice;
  9452. int cmp = PyUnicode_Compare(name_str, key);
  9453. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  9454. if (cmp == 0) goto arg_passed_twice;
  9455. }
  9456. #endif
  9457. name++;
  9458. }
  9459. return 0;
  9460. arg_passed_twice:
  9461. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9462. goto bad;
  9463. bad:
  9464. return -1;
  9465. }
  9466. static int __Pyx_MatchKeywordArg_nostr(
  9467. PyObject *key,
  9468. PyObject ** const argnames[],
  9469. PyObject ** const *first_kw_arg,
  9470. size_t *index_found,
  9471. const char *function_name)
  9472. {
  9473. PyObject ** const *name;
  9474. if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type;
  9475. name = first_kw_arg;
  9476. while (*name) {
  9477. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  9478. if (cmp == 1) {
  9479. *index_found = (size_t) (name - argnames);
  9480. return 1;
  9481. }
  9482. if (unlikely(cmp == -1)) goto bad;
  9483. name++;
  9484. }
  9485. name = argnames;
  9486. while (name != first_kw_arg) {
  9487. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  9488. if (unlikely(cmp != 0)) {
  9489. if (cmp == 1) goto arg_passed_twice;
  9490. else goto bad;
  9491. }
  9492. name++;
  9493. }
  9494. return 0;
  9495. arg_passed_twice:
  9496. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9497. goto bad;
  9498. invalid_keyword_type:
  9499. PyErr_Format(PyExc_TypeError,
  9500. "%.200s() keywords must be strings", function_name);
  9501. goto bad;
  9502. bad:
  9503. return -1;
  9504. }
  9505. static CYTHON_INLINE int __Pyx_MatchKeywordArg(
  9506. PyObject *key,
  9507. PyObject ** const argnames[],
  9508. PyObject ** const *first_kw_arg,
  9509. size_t *index_found,
  9510. const char *function_name)
  9511. {
  9512. return likely(PyUnicode_CheckExact(key)) ?
  9513. __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) :
  9514. __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name);
  9515. }
  9516. static void __Pyx_RejectUnknownKeyword(
  9517. PyObject *kwds,
  9518. PyObject ** const argnames[],
  9519. PyObject ** const *first_kw_arg,
  9520. const char *function_name)
  9521. {
  9522. #if CYTHON_AVOID_BORROWED_REFS
  9523. PyObject *pos = NULL;
  9524. #else
  9525. Py_ssize_t pos = 0;
  9526. #endif
  9527. PyObject *key = NULL;
  9528. __Pyx_BEGIN_CRITICAL_SECTION(kwds);
  9529. while (
  9530. #if CYTHON_AVOID_BORROWED_REFS
  9531. __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL)
  9532. #else
  9533. PyDict_Next(kwds, &pos, &key, NULL)
  9534. #endif
  9535. ) {
  9536. PyObject** const *name = first_kw_arg;
  9537. while (*name && (**name != key)) name++;
  9538. if (!*name) {
  9539. size_t index_found = 0;
  9540. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  9541. if (cmp != 1) {
  9542. if (cmp == 0) {
  9543. PyErr_Format(PyExc_TypeError,
  9544. "%s() got an unexpected keyword argument '%U'",
  9545. function_name, key);
  9546. }
  9547. #if CYTHON_AVOID_BORROWED_REFS
  9548. Py_DECREF(key);
  9549. #endif
  9550. break;
  9551. }
  9552. }
  9553. #if CYTHON_AVOID_BORROWED_REFS
  9554. Py_DECREF(key);
  9555. #endif
  9556. }
  9557. __Pyx_END_CRITICAL_SECTION();
  9558. #if CYTHON_AVOID_BORROWED_REFS
  9559. Py_XDECREF(pos);
  9560. #endif
  9561. assert(PyErr_Occurred());
  9562. }
  9563. static int __Pyx_ParseKeywordDict(
  9564. PyObject *kwds,
  9565. PyObject ** const argnames[],
  9566. PyObject *values[],
  9567. Py_ssize_t num_pos_args,
  9568. Py_ssize_t num_kwargs,
  9569. const char* function_name,
  9570. int ignore_unknown_kwargs)
  9571. {
  9572. PyObject** const *name;
  9573. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9574. Py_ssize_t extracted = 0;
  9575. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  9576. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  9577. #endif
  9578. name = first_kw_arg;
  9579. while (*name && num_kwargs > extracted) {
  9580. PyObject * key = **name;
  9581. PyObject *value;
  9582. int found = 0;
  9583. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  9584. found = PyDict_GetItemRef(kwds, key, &value);
  9585. #else
  9586. value = PyDict_GetItemWithError(kwds, key);
  9587. if (value) {
  9588. Py_INCREF(value);
  9589. found = 1;
  9590. } else {
  9591. if (unlikely(PyErr_Occurred())) goto bad;
  9592. }
  9593. #endif
  9594. if (found) {
  9595. if (unlikely(found < 0)) goto bad;
  9596. values[name-argnames] = value;
  9597. extracted++;
  9598. }
  9599. name++;
  9600. }
  9601. if (num_kwargs > extracted) {
  9602. if (ignore_unknown_kwargs) {
  9603. if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1))
  9604. goto bad;
  9605. } else {
  9606. __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name);
  9607. goto bad;
  9608. }
  9609. }
  9610. return 0;
  9611. bad:
  9612. return -1;
  9613. }
  9614. static int __Pyx_ParseKeywordDictToDict(
  9615. PyObject *kwds,
  9616. PyObject ** const argnames[],
  9617. PyObject *kwds2,
  9618. PyObject *values[],
  9619. Py_ssize_t num_pos_args,
  9620. const char* function_name)
  9621. {
  9622. PyObject** const *name;
  9623. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9624. Py_ssize_t len;
  9625. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  9626. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  9627. #endif
  9628. if (PyDict_Update(kwds2, kwds) < 0) goto bad;
  9629. name = first_kw_arg;
  9630. while (*name) {
  9631. PyObject *key = **name;
  9632. PyObject *value;
  9633. #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop))
  9634. int found = PyDict_Pop(kwds2, key, &value);
  9635. if (found) {
  9636. if (unlikely(found < 0)) goto bad;
  9637. values[name-argnames] = value;
  9638. }
  9639. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  9640. int found = PyDict_GetItemRef(kwds2, key, &value);
  9641. if (found) {
  9642. if (unlikely(found < 0)) goto bad;
  9643. values[name-argnames] = value;
  9644. if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad;
  9645. }
  9646. #else
  9647. #if CYTHON_COMPILING_IN_CPYTHON
  9648. value = _PyDict_Pop(kwds2, key, kwds2);
  9649. #else
  9650. value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2);
  9651. #endif
  9652. if (value == kwds2) {
  9653. Py_DECREF(value);
  9654. } else {
  9655. if (unlikely(!value)) goto bad;
  9656. values[name-argnames] = value;
  9657. }
  9658. #endif
  9659. name++;
  9660. }
  9661. len = PyDict_Size(kwds2);
  9662. if (len > 0) {
  9663. return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name);
  9664. } else if (unlikely(len == -1)) {
  9665. goto bad;
  9666. }
  9667. return 0;
  9668. bad:
  9669. return -1;
  9670. }
  9671. static int __Pyx_ParseKeywordsTuple(
  9672. PyObject *kwds,
  9673. PyObject * const *kwvalues,
  9674. PyObject ** const argnames[],
  9675. PyObject *kwds2,
  9676. PyObject *values[],
  9677. Py_ssize_t num_pos_args,
  9678. Py_ssize_t num_kwargs,
  9679. const char* function_name,
  9680. int ignore_unknown_kwargs)
  9681. {
  9682. PyObject *key = NULL;
  9683. PyObject** const * name;
  9684. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9685. for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
  9686. #if CYTHON_AVOID_BORROWED_REFS
  9687. key = __Pyx_PySequence_ITEM(kwds, pos);
  9688. #else
  9689. key = __Pyx_PyTuple_GET_ITEM(kwds, pos);
  9690. #endif
  9691. #if !CYTHON_ASSUME_SAFE_MACROS
  9692. if (unlikely(!key)) goto bad;
  9693. #endif
  9694. name = first_kw_arg;
  9695. while (*name && (**name != key)) name++;
  9696. if (*name) {
  9697. PyObject *value = kwvalues[pos];
  9698. values[name-argnames] = __Pyx_NewRef(value);
  9699. } else {
  9700. size_t index_found = 0;
  9701. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  9702. if (cmp == 1) {
  9703. PyObject *value = kwvalues[pos];
  9704. values[index_found] = __Pyx_NewRef(value);
  9705. } else {
  9706. if (unlikely(cmp == -1)) goto bad;
  9707. if (kwds2) {
  9708. PyObject *value = kwvalues[pos];
  9709. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  9710. } else if (!ignore_unknown_kwargs) {
  9711. goto invalid_keyword;
  9712. }
  9713. }
  9714. }
  9715. #if CYTHON_AVOID_BORROWED_REFS
  9716. Py_DECREF(key);
  9717. key = NULL;
  9718. #endif
  9719. }
  9720. return 0;
  9721. invalid_keyword:
  9722. PyErr_Format(PyExc_TypeError,
  9723. "%s() got an unexpected keyword argument '%U'",
  9724. function_name, key);
  9725. goto bad;
  9726. bad:
  9727. #if CYTHON_AVOID_BORROWED_REFS
  9728. Py_XDECREF(key);
  9729. #endif
  9730. return -1;
  9731. }
  9732. /* ParseKeywords */
  9733. static int __Pyx_ParseKeywords(
  9734. PyObject *kwds,
  9735. PyObject * const *kwvalues,
  9736. PyObject ** const argnames[],
  9737. PyObject *kwds2,
  9738. PyObject *values[],
  9739. Py_ssize_t num_pos_args,
  9740. Py_ssize_t num_kwargs,
  9741. const char* function_name,
  9742. int ignore_unknown_kwargs)
  9743. {
  9744. if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)))
  9745. return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  9746. else if (kwds2)
  9747. return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name);
  9748. else
  9749. return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  9750. }
  9751. /* RaiseArgTupleInvalid */
  9752. static void __Pyx_RaiseArgtupleInvalid(
  9753. const char* func_name,
  9754. int exact,
  9755. Py_ssize_t num_min,
  9756. Py_ssize_t num_max,
  9757. Py_ssize_t num_found)
  9758. {
  9759. Py_ssize_t num_expected;
  9760. const char *more_or_less;
  9761. if (num_found < num_min) {
  9762. num_expected = num_min;
  9763. more_or_less = "at least";
  9764. } else {
  9765. num_expected = num_max;
  9766. more_or_less = "at most";
  9767. }
  9768. if (exact) {
  9769. more_or_less = "exactly";
  9770. }
  9771. PyErr_Format(PyExc_TypeError,
  9772. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  9773. func_name, more_or_less, num_expected,
  9774. (num_expected == 1) ? "" : "s", num_found);
  9775. }
  9776. /* GetItemInt */
  9777. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  9778. PyObject *r;
  9779. if (unlikely(!j)) return NULL;
  9780. r = PyObject_GetItem(o, j);
  9781. Py_DECREF(j);
  9782. return r;
  9783. }
  9784. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  9785. int wraparound, int boundscheck, int unsafe_shared) {
  9786. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  9787. #if CYTHON_ASSUME_SAFE_SIZE
  9788. Py_ssize_t wrapped_i = i;
  9789. if (wraparound & unlikely(i < 0)) {
  9790. wrapped_i += PyList_GET_SIZE(o);
  9791. }
  9792. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS)) {
  9793. return __Pyx_PyList_GetItemRefFast(o, wrapped_i, unsafe_shared);
  9794. } else
  9795. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
  9796. return __Pyx_NewRef(PyList_GET_ITEM(o, wrapped_i));
  9797. }
  9798. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  9799. #else
  9800. (void)wraparound;
  9801. (void)boundscheck;
  9802. return PySequence_GetItem(o, i);
  9803. #endif
  9804. }
  9805. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  9806. int wraparound, int boundscheck, int unsafe_shared) {
  9807. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  9808. #if CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  9809. Py_ssize_t wrapped_i = i;
  9810. if (wraparound & unlikely(i < 0)) {
  9811. wrapped_i += PyTuple_GET_SIZE(o);
  9812. }
  9813. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
  9814. return __Pyx_NewRef(PyTuple_GET_ITEM(o, wrapped_i));
  9815. }
  9816. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  9817. #else
  9818. (void)wraparound;
  9819. (void)boundscheck;
  9820. return PySequence_GetItem(o, i);
  9821. #endif
  9822. }
  9823. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
  9824. int wraparound, int boundscheck, int unsafe_shared) {
  9825. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  9826. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  9827. if (is_list || PyList_CheckExact(o)) {
  9828. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  9829. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) {
  9830. return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared);
  9831. } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
  9832. return __Pyx_NewRef(PyList_GET_ITEM(o, n));
  9833. }
  9834. } else
  9835. #if !CYTHON_AVOID_BORROWED_REFS
  9836. if (PyTuple_CheckExact(o)) {
  9837. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  9838. if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
  9839. return __Pyx_NewRef(PyTuple_GET_ITEM(o, n));
  9840. }
  9841. } else
  9842. #endif
  9843. #endif
  9844. #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
  9845. {
  9846. PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
  9847. PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
  9848. if (!is_list && mm && mm->mp_subscript) {
  9849. PyObject *r, *key = PyLong_FromSsize_t(i);
  9850. if (unlikely(!key)) return NULL;
  9851. r = mm->mp_subscript(o, key);
  9852. Py_DECREF(key);
  9853. return r;
  9854. }
  9855. if (is_list || likely(sm && sm->sq_item)) {
  9856. if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
  9857. Py_ssize_t l = sm->sq_length(o);
  9858. if (likely(l >= 0)) {
  9859. i += l;
  9860. } else {
  9861. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  9862. return NULL;
  9863. PyErr_Clear();
  9864. }
  9865. }
  9866. return sm->sq_item(o, i);
  9867. }
  9868. }
  9869. #else
  9870. if (is_list || !PyMapping_Check(o)) {
  9871. return PySequence_GetItem(o, i);
  9872. }
  9873. #endif
  9874. (void)wraparound;
  9875. (void)boundscheck;
  9876. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  9877. }
  9878. /* RaiseException */
  9879. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  9880. PyObject* owned_instance = NULL;
  9881. if (tb == Py_None) {
  9882. tb = 0;
  9883. } else if (tb && !PyTraceBack_Check(tb)) {
  9884. PyErr_SetString(PyExc_TypeError,
  9885. "raise: arg 3 must be a traceback or None");
  9886. goto bad;
  9887. }
  9888. if (value == Py_None)
  9889. value = 0;
  9890. if (PyExceptionInstance_Check(type)) {
  9891. if (value) {
  9892. PyErr_SetString(PyExc_TypeError,
  9893. "instance exception may not have a separate value");
  9894. goto bad;
  9895. }
  9896. value = type;
  9897. type = (PyObject*) Py_TYPE(value);
  9898. } else if (PyExceptionClass_Check(type)) {
  9899. PyObject *instance_class = NULL;
  9900. if (value && PyExceptionInstance_Check(value)) {
  9901. instance_class = (PyObject*) Py_TYPE(value);
  9902. if (instance_class != type) {
  9903. int is_subclass = PyObject_IsSubclass(instance_class, type);
  9904. if (!is_subclass) {
  9905. instance_class = NULL;
  9906. } else if (unlikely(is_subclass == -1)) {
  9907. goto bad;
  9908. } else {
  9909. type = instance_class;
  9910. }
  9911. }
  9912. }
  9913. if (!instance_class) {
  9914. PyObject *args;
  9915. if (!value)
  9916. args = PyTuple_New(0);
  9917. else if (PyTuple_Check(value)) {
  9918. Py_INCREF(value);
  9919. args = value;
  9920. } else
  9921. args = PyTuple_Pack(1, value);
  9922. if (!args)
  9923. goto bad;
  9924. owned_instance = PyObject_Call(type, args, NULL);
  9925. Py_DECREF(args);
  9926. if (!owned_instance)
  9927. goto bad;
  9928. value = owned_instance;
  9929. if (!PyExceptionInstance_Check(value)) {
  9930. PyErr_Format(PyExc_TypeError,
  9931. "calling %R should have returned an instance of "
  9932. "BaseException, not %R",
  9933. type, Py_TYPE(value));
  9934. goto bad;
  9935. }
  9936. }
  9937. } else {
  9938. PyErr_SetString(PyExc_TypeError,
  9939. "raise: exception class must be a subclass of BaseException");
  9940. goto bad;
  9941. }
  9942. if (cause) {
  9943. PyObject *fixed_cause;
  9944. if (cause == Py_None) {
  9945. fixed_cause = NULL;
  9946. } else if (PyExceptionClass_Check(cause)) {
  9947. fixed_cause = PyObject_CallObject(cause, NULL);
  9948. if (fixed_cause == NULL)
  9949. goto bad;
  9950. } else if (PyExceptionInstance_Check(cause)) {
  9951. fixed_cause = cause;
  9952. Py_INCREF(fixed_cause);
  9953. } else {
  9954. PyErr_SetString(PyExc_TypeError,
  9955. "exception causes must derive from "
  9956. "BaseException");
  9957. goto bad;
  9958. }
  9959. PyException_SetCause(value, fixed_cause);
  9960. }
  9961. PyErr_SetObject(type, value);
  9962. if (tb) {
  9963. #if PY_VERSION_HEX >= 0x030C00A6
  9964. PyException_SetTraceback(value, tb);
  9965. #elif CYTHON_FAST_THREAD_STATE
  9966. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  9967. PyObject* tmp_tb = tstate->curexc_traceback;
  9968. if (tb != tmp_tb) {
  9969. Py_INCREF(tb);
  9970. tstate->curexc_traceback = tb;
  9971. Py_XDECREF(tmp_tb);
  9972. }
  9973. #else
  9974. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9975. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  9976. Py_INCREF(tb);
  9977. PyErr_Restore(tmp_type, tmp_value, tb);
  9978. Py_XDECREF(tmp_tb);
  9979. #endif
  9980. }
  9981. bad:
  9982. Py_XDECREF(owned_instance);
  9983. return;
  9984. }
  9985. /* py_abs */
  9986. #if CYTHON_USE_PYLONG_INTERNALS
  9987. static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) {
  9988. #if PY_VERSION_HEX >= 0x030C00A7
  9989. if (likely(__Pyx_PyLong_IsCompact(n))) {
  9990. return PyLong_FromSize_t(__Pyx_PyLong_CompactValueUnsigned(n));
  9991. }
  9992. #else
  9993. if (likely(Py_SIZE(n) == -1)) {
  9994. return PyLong_FromUnsignedLong(__Pyx_PyLong_Digits(n)[0]);
  9995. }
  9996. #endif
  9997. #if CYTHON_COMPILING_IN_CPYTHON
  9998. {
  9999. PyObject *copy = _PyLong_Copy((PyLongObject*)n);
  10000. if (likely(copy)) {
  10001. #if PY_VERSION_HEX >= 0x030C00A7
  10002. ((PyLongObject*)copy)->long_value.lv_tag ^= ((PyLongObject*)copy)->long_value.lv_tag & _PyLong_SIGN_MASK;
  10003. #else
  10004. __Pyx_SET_SIZE(copy, -Py_SIZE(copy));
  10005. #endif
  10006. }
  10007. return copy;
  10008. }
  10009. #else
  10010. return PyNumber_Negative(n);
  10011. #endif
  10012. }
  10013. #endif
  10014. /* SliceTupleAndList */
  10015. #if CYTHON_COMPILING_IN_CPYTHON
  10016. static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
  10017. Py_ssize_t start = *_start, stop = *_stop, length = *_length;
  10018. if (start < 0) {
  10019. start += length;
  10020. if (start < 0)
  10021. start = 0;
  10022. }
  10023. if (stop < 0)
  10024. stop += length;
  10025. else if (stop > length)
  10026. stop = length;
  10027. *_length = stop - start;
  10028. *_start = start;
  10029. *_stop = stop;
  10030. }
  10031. static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
  10032. PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
  10033. Py_ssize_t length = PyTuple_GET_SIZE(src);
  10034. __Pyx_crop_slice(&start, &stop, &length);
  10035. return __Pyx_PyTuple_FromArray(((PyTupleObject*)src)->ob_item + start, length);
  10036. }
  10037. static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice_locked(
  10038. PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
  10039. Py_ssize_t length = PyList_GET_SIZE(src);
  10040. __Pyx_crop_slice(&start, &stop, &length);
  10041. if (length <= 0) {
  10042. return PyList_New(0);
  10043. }
  10044. return __Pyx_PyList_FromArray(((PyListObject*)src)->ob_item + start, length);
  10045. }
  10046. static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
  10047. PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
  10048. PyObject *result;
  10049. __Pyx_BEGIN_CRITICAL_SECTION(src);
  10050. result = __Pyx_PyList_GetSlice_locked(src, start, stop);
  10051. __Pyx_END_CRITICAL_SECTION();
  10052. return result;
  10053. }
  10054. #endif // CYTHON_COMPILING_IN_CPYTHON
  10055. /* PyLongBinop */
  10056. #if !CYTHON_COMPILING_IN_PYPY
  10057. static PyObject* __Pyx_Fallback___Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, int inplace) {
  10058. return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
  10059. }
  10060. #if CYTHON_USE_PYLONG_INTERNALS
  10061. static PyObject* __Pyx_Unpacked___Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  10062. CYTHON_MAYBE_UNUSED_VAR(inplace);
  10063. CYTHON_UNUSED_VAR(zerodivision_check);
  10064. const long a = intval;
  10065. long b;
  10066. const PY_LONG_LONG lla = intval;
  10067. PY_LONG_LONG llb;
  10068. if (unlikely(__Pyx_PyLong_IsZero(op2))) {
  10069. return __Pyx_NewRef(op1);
  10070. }
  10071. const int is_positive = __Pyx_PyLong_IsPos(op2);
  10072. const digit* digits = __Pyx_PyLong_Digits(op2);
  10073. const Py_ssize_t size = __Pyx_PyLong_DigitCount(op2);
  10074. if (likely(size == 1)) {
  10075. b = (long) digits[0];
  10076. if (!is_positive) b *= -1;
  10077. } else {
  10078. switch (size) {
  10079. case 2:
  10080. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10081. b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10082. if (!is_positive) b *= -1;
  10083. goto calculate_long;
  10084. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  10085. llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  10086. if (!is_positive) llb *= -1;
  10087. goto calculate_long_long;
  10088. }
  10089. break;
  10090. case 3:
  10091. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10092. b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10093. if (!is_positive) b *= -1;
  10094. goto calculate_long;
  10095. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  10096. llb = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  10097. if (!is_positive) llb *= -1;
  10098. goto calculate_long_long;
  10099. }
  10100. break;
  10101. case 4:
  10102. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  10103. b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10104. if (!is_positive) b *= -1;
  10105. goto calculate_long;
  10106. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  10107. llb = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  10108. if (!is_positive) llb *= -1;
  10109. goto calculate_long_long;
  10110. }
  10111. break;
  10112. }
  10113. return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
  10114. }
  10115. calculate_long:
  10116. {
  10117. long x;
  10118. x = a - b;
  10119. return PyLong_FromLong(x);
  10120. }
  10121. calculate_long_long:
  10122. {
  10123. PY_LONG_LONG llx;
  10124. llx = lla - llb;
  10125. return PyLong_FromLongLong(llx);
  10126. }
  10127. }
  10128. #endif
  10129. static PyObject* __Pyx_Float___Pyx_PyLong_SubtractCObj(PyObject *float_val, long intval, int zerodivision_check) {
  10130. CYTHON_UNUSED_VAR(zerodivision_check);
  10131. const long a = intval;
  10132. double b = __Pyx_PyFloat_AS_DOUBLE(float_val);
  10133. double result;
  10134. result = ((double)a) - (double)b;
  10135. return PyFloat_FromDouble(result);
  10136. }
  10137. static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  10138. CYTHON_MAYBE_UNUSED_VAR(intval);
  10139. CYTHON_UNUSED_VAR(zerodivision_check);
  10140. #if CYTHON_USE_PYLONG_INTERNALS
  10141. if (likely(PyLong_CheckExact(op2))) {
  10142. return __Pyx_Unpacked___Pyx_PyLong_SubtractCObj(op1, op2, intval, inplace, zerodivision_check);
  10143. }
  10144. #endif
  10145. if (PyFloat_CheckExact(op2)) {
  10146. return __Pyx_Float___Pyx_PyLong_SubtractCObj(op2, intval, zerodivision_check);
  10147. }
  10148. return __Pyx_Fallback___Pyx_PyLong_SubtractCObj(op1, op2, inplace);
  10149. }
  10150. #endif
  10151. /* ArgTypeTestFunc (used by ArgTypeTest) */
  10152. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
  10153. {
  10154. __Pyx_TypeName type_name;
  10155. __Pyx_TypeName obj_type_name;
  10156. PyObject *extra_info = __pyx_mstate_global->__pyx_empty_unicode;
  10157. int from_annotation_subclass = 0;
  10158. if (unlikely(!type)) {
  10159. PyErr_SetString(PyExc_SystemError, "Missing type object");
  10160. return 0;
  10161. }
  10162. else if (!exact) {
  10163. if (likely(__Pyx_TypeCheck(obj, type))) return 1;
  10164. } else if (exact == 2) {
  10165. if (__Pyx_TypeCheck(obj, type)) {
  10166. from_annotation_subclass = 1;
  10167. extra_info = __pyx_mstate_global->__pyx_kp_u_Note_that_Cython_is_deliberately;
  10168. }
  10169. }
  10170. type_name = __Pyx_PyType_GetFullyQualifiedName(type);
  10171. obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  10172. PyErr_Format(PyExc_TypeError,
  10173. "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME
  10174. ", got " __Pyx_FMT_TYPENAME ")"
  10175. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  10176. "%s%U"
  10177. #endif
  10178. , name, type_name, obj_type_name
  10179. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  10180. , (from_annotation_subclass ? ". " : ""), extra_info
  10181. #endif
  10182. );
  10183. #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  10184. if (exact == 2 && from_annotation_subclass) {
  10185. PyObject *res;
  10186. PyObject *vargs[2];
  10187. vargs[0] = PyErr_GetRaisedException();
  10188. vargs[1] = extra_info;
  10189. res = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_kp_u_add_note, vargs, 2, NULL);
  10190. Py_XDECREF(res);
  10191. PyErr_SetRaisedException(vargs[0]);
  10192. }
  10193. #endif
  10194. __Pyx_DECREF_TypeName(type_name);
  10195. __Pyx_DECREF_TypeName(obj_type_name);
  10196. return 0;
  10197. }
  10198. /* RaiseUnboundLocalError */
  10199. static void __Pyx_RaiseUnboundLocalError(const char *varname) {
  10200. PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
  10201. }
  10202. /* GetException (used by pep479) */
  10203. #if CYTHON_FAST_THREAD_STATE
  10204. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
  10205. #else
  10206. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
  10207. #endif
  10208. {
  10209. PyObject *local_type = NULL, *local_value, *local_tb = NULL;
  10210. #if CYTHON_FAST_THREAD_STATE
  10211. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10212. #if PY_VERSION_HEX >= 0x030C0000
  10213. local_value = tstate->current_exception;
  10214. tstate->current_exception = 0;
  10215. #else
  10216. local_type = tstate->curexc_type;
  10217. local_value = tstate->curexc_value;
  10218. local_tb = tstate->curexc_traceback;
  10219. tstate->curexc_type = 0;
  10220. tstate->curexc_value = 0;
  10221. tstate->curexc_traceback = 0;
  10222. #endif
  10223. #elif __PYX_LIMITED_VERSION_HEX > 0x030C0000
  10224. local_value = PyErr_GetRaisedException();
  10225. #else
  10226. PyErr_Fetch(&local_type, &local_value, &local_tb);
  10227. #endif
  10228. #if __PYX_LIMITED_VERSION_HEX > 0x030C0000
  10229. if (likely(local_value)) {
  10230. local_type = (PyObject*) Py_TYPE(local_value);
  10231. Py_INCREF(local_type);
  10232. local_tb = PyException_GetTraceback(local_value);
  10233. }
  10234. #else
  10235. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  10236. #if CYTHON_FAST_THREAD_STATE
  10237. if (unlikely(tstate->curexc_type))
  10238. #else
  10239. if (unlikely(PyErr_Occurred()))
  10240. #endif
  10241. goto bad;
  10242. if (local_tb) {
  10243. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  10244. goto bad;
  10245. }
  10246. #endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000
  10247. Py_XINCREF(local_tb);
  10248. Py_XINCREF(local_type);
  10249. Py_XINCREF(local_value);
  10250. *type = local_type;
  10251. *value = local_value;
  10252. *tb = local_tb;
  10253. #if CYTHON_FAST_THREAD_STATE
  10254. #if CYTHON_USE_EXC_INFO_STACK
  10255. {
  10256. _PyErr_StackItem *exc_info = tstate->exc_info;
  10257. #if PY_VERSION_HEX >= 0x030B00a4
  10258. tmp_value = exc_info->exc_value;
  10259. exc_info->exc_value = local_value;
  10260. tmp_type = NULL;
  10261. tmp_tb = NULL;
  10262. Py_XDECREF(local_type);
  10263. Py_XDECREF(local_tb);
  10264. #else
  10265. tmp_type = exc_info->exc_type;
  10266. tmp_value = exc_info->exc_value;
  10267. tmp_tb = exc_info->exc_traceback;
  10268. exc_info->exc_type = local_type;
  10269. exc_info->exc_value = local_value;
  10270. exc_info->exc_traceback = local_tb;
  10271. #endif
  10272. }
  10273. #else
  10274. tmp_type = tstate->exc_type;
  10275. tmp_value = tstate->exc_value;
  10276. tmp_tb = tstate->exc_traceback;
  10277. tstate->exc_type = local_type;
  10278. tstate->exc_value = local_value;
  10279. tstate->exc_traceback = local_tb;
  10280. #endif
  10281. Py_XDECREF(tmp_type);
  10282. Py_XDECREF(tmp_value);
  10283. Py_XDECREF(tmp_tb);
  10284. #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  10285. PyErr_SetHandledException(local_value);
  10286. Py_XDECREF(local_value);
  10287. Py_XDECREF(local_type);
  10288. Py_XDECREF(local_tb);
  10289. #else
  10290. PyErr_SetExcInfo(local_type, local_value, local_tb);
  10291. #endif
  10292. return 0;
  10293. #if __PYX_LIMITED_VERSION_HEX <= 0x030C0000
  10294. bad:
  10295. *type = 0;
  10296. *value = 0;
  10297. *tb = 0;
  10298. Py_XDECREF(local_type);
  10299. Py_XDECREF(local_value);
  10300. Py_XDECREF(local_tb);
  10301. return -1;
  10302. #endif
  10303. }
  10304. /* pep479 */
  10305. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen) {
  10306. PyObject *exc, *val, *tb, *cur_exc, *new_exc;
  10307. __Pyx_PyThreadState_declare
  10308. int is_async_stopiteration = 0;
  10309. CYTHON_MAYBE_UNUSED_VAR(in_async_gen);
  10310. __Pyx_PyThreadState_assign
  10311. cur_exc = __Pyx_PyErr_CurrentExceptionType();
  10312. if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) {
  10313. if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopAsyncIteration))) {
  10314. is_async_stopiteration = 1;
  10315. } else {
  10316. return;
  10317. }
  10318. }
  10319. __Pyx_GetException(&exc, &val, &tb);
  10320. Py_XDECREF(exc);
  10321. Py_XDECREF(tb);
  10322. new_exc = PyObject_CallFunction(PyExc_RuntimeError, "s",
  10323. is_async_stopiteration ? "async generator raised StopAsyncIteration" :
  10324. in_async_gen ? "async generator raised StopIteration" :
  10325. "generator raised StopIteration");
  10326. if (!new_exc) {
  10327. Py_XDECREF(val);
  10328. return;
  10329. }
  10330. PyException_SetCause(new_exc, val); // steals ref to val
  10331. PyErr_SetObject(PyExc_RuntimeError, new_exc);
  10332. }
  10333. /* RaiseTooManyValuesToUnpack */
  10334. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  10335. PyErr_Format(PyExc_ValueError,
  10336. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  10337. }
  10338. /* RaiseNeedMoreValuesToUnpack */
  10339. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  10340. PyErr_Format(PyExc_ValueError,
  10341. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  10342. index, (index == 1) ? "" : "s");
  10343. }
  10344. /* IterFinish */
  10345. static CYTHON_INLINE int __Pyx_IterFinish(void) {
  10346. PyObject* exc_type;
  10347. __Pyx_PyThreadState_declare
  10348. __Pyx_PyThreadState_assign
  10349. exc_type = __Pyx_PyErr_CurrentExceptionType();
  10350. if (unlikely(exc_type)) {
  10351. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
  10352. return -1;
  10353. __Pyx_PyErr_Clear();
  10354. return 0;
  10355. }
  10356. return 0;
  10357. }
  10358. /* UnpackItemEndCheck */
  10359. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
  10360. if (unlikely(retval)) {
  10361. Py_DECREF(retval);
  10362. __Pyx_RaiseTooManyValuesError(expected);
  10363. return -1;
  10364. }
  10365. return __Pyx_IterFinish();
  10366. }
  10367. /* PyDictVersioning (used by GetModuleGlobalName) */
  10368. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  10369. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
  10370. PyObject *dict = Py_TYPE(obj)->tp_dict;
  10371. return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
  10372. }
  10373. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
  10374. PyObject **dictptr = NULL;
  10375. Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
  10376. if (offset) {
  10377. #if CYTHON_COMPILING_IN_CPYTHON
  10378. dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
  10379. #else
  10380. dictptr = _PyObject_GetDictPtr(obj);
  10381. #endif
  10382. }
  10383. return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
  10384. }
  10385. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
  10386. PyObject *dict = Py_TYPE(obj)->tp_dict;
  10387. if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
  10388. return 0;
  10389. return obj_dict_version == __Pyx_get_object_dict_version(obj);
  10390. }
  10391. #endif
  10392. /* GetModuleGlobalName */
  10393. #if CYTHON_USE_DICT_VERSIONS
  10394. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
  10395. #else
  10396. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
  10397. #endif
  10398. {
  10399. PyObject *result;
  10400. #if CYTHON_COMPILING_IN_LIMITED_API
  10401. if (unlikely(!__pyx_m)) {
  10402. if (!PyErr_Occurred())
  10403. PyErr_SetNone(PyExc_NameError);
  10404. return NULL;
  10405. }
  10406. result = PyObject_GetAttr(__pyx_m, name);
  10407. if (likely(result)) {
  10408. return result;
  10409. }
  10410. PyErr_Clear();
  10411. #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  10412. if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear();
  10413. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  10414. if (likely(result)) {
  10415. return result;
  10416. }
  10417. #else
  10418. result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash);
  10419. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  10420. if (likely(result)) {
  10421. return __Pyx_NewRef(result);
  10422. }
  10423. PyErr_Clear();
  10424. #endif
  10425. return __Pyx_GetBuiltinName(name);
  10426. }
  10427. /* SliceObject */
  10428. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
  10429. Py_ssize_t cstart, Py_ssize_t cstop,
  10430. PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
  10431. int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
  10432. __Pyx_TypeName obj_type_name;
  10433. #if CYTHON_USE_TYPE_SLOTS
  10434. PyMappingMethods* mp = Py_TYPE(obj)->tp_as_mapping;
  10435. if (likely(mp && mp->mp_subscript))
  10436. #endif
  10437. {
  10438. PyObject* result;
  10439. PyObject *py_slice, *py_start, *py_stop;
  10440. if (_py_slice) {
  10441. py_slice = *_py_slice;
  10442. } else {
  10443. PyObject* owned_start = NULL;
  10444. PyObject* owned_stop = NULL;
  10445. if (_py_start) {
  10446. py_start = *_py_start;
  10447. } else {
  10448. if (has_cstart) {
  10449. owned_start = py_start = PyLong_FromSsize_t(cstart);
  10450. if (unlikely(!py_start)) goto bad;
  10451. } else
  10452. py_start = Py_None;
  10453. }
  10454. if (_py_stop) {
  10455. py_stop = *_py_stop;
  10456. } else {
  10457. if (has_cstop) {
  10458. owned_stop = py_stop = PyLong_FromSsize_t(cstop);
  10459. if (unlikely(!py_stop)) {
  10460. Py_XDECREF(owned_start);
  10461. goto bad;
  10462. }
  10463. } else
  10464. py_stop = Py_None;
  10465. }
  10466. py_slice = PySlice_New(py_start, py_stop, Py_None);
  10467. Py_XDECREF(owned_start);
  10468. Py_XDECREF(owned_stop);
  10469. if (unlikely(!py_slice)) goto bad;
  10470. }
  10471. #if CYTHON_USE_TYPE_SLOTS
  10472. result = mp->mp_subscript(obj, py_slice);
  10473. #else
  10474. result = PyObject_GetItem(obj, py_slice);
  10475. #endif
  10476. if (!_py_slice) {
  10477. Py_DECREF(py_slice);
  10478. }
  10479. return result;
  10480. }
  10481. obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  10482. PyErr_Format(PyExc_TypeError,
  10483. "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj_type_name);
  10484. __Pyx_DECREF_TypeName(obj_type_name);
  10485. bad:
  10486. return NULL;
  10487. }
  10488. /* PyObjectCallNoArg (used by PyObjectCallMethod0) */
  10489. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  10490. PyObject *arg[2] = {NULL, NULL};
  10491. return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  10492. }
  10493. /* PyObjectGetMethod (used by PyObjectCallMethod0) */
  10494. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  10495. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
  10496. PyObject *attr;
  10497. #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
  10498. __Pyx_TypeName type_name;
  10499. PyTypeObject *tp = Py_TYPE(obj);
  10500. PyObject *descr;
  10501. descrgetfunc f = NULL;
  10502. PyObject **dictptr, *dict;
  10503. int meth_found = 0;
  10504. assert (*method == NULL);
  10505. if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
  10506. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  10507. goto try_unpack;
  10508. }
  10509. if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
  10510. return 0;
  10511. }
  10512. descr = _PyType_Lookup(tp, name);
  10513. if (likely(descr != NULL)) {
  10514. Py_INCREF(descr);
  10515. #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR
  10516. if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR))
  10517. #else
  10518. #ifdef __Pyx_CyFunction_USED
  10519. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
  10520. #else
  10521. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type)))
  10522. #endif
  10523. #endif
  10524. {
  10525. meth_found = 1;
  10526. } else {
  10527. f = Py_TYPE(descr)->tp_descr_get;
  10528. if (f != NULL && PyDescr_IsData(descr)) {
  10529. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  10530. Py_DECREF(descr);
  10531. goto try_unpack;
  10532. }
  10533. }
  10534. }
  10535. dictptr = _PyObject_GetDictPtr(obj);
  10536. if (dictptr != NULL && (dict = *dictptr) != NULL) {
  10537. Py_INCREF(dict);
  10538. attr = __Pyx_PyDict_GetItemStr(dict, name);
  10539. if (attr != NULL) {
  10540. Py_INCREF(attr);
  10541. Py_DECREF(dict);
  10542. Py_XDECREF(descr);
  10543. goto try_unpack;
  10544. }
  10545. Py_DECREF(dict);
  10546. }
  10547. if (meth_found) {
  10548. *method = descr;
  10549. return 1;
  10550. }
  10551. if (f != NULL) {
  10552. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  10553. Py_DECREF(descr);
  10554. goto try_unpack;
  10555. }
  10556. if (likely(descr != NULL)) {
  10557. *method = descr;
  10558. return 0;
  10559. }
  10560. type_name = __Pyx_PyType_GetFullyQualifiedName(tp);
  10561. PyErr_Format(PyExc_AttributeError,
  10562. "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
  10563. type_name, name);
  10564. __Pyx_DECREF_TypeName(type_name);
  10565. return 0;
  10566. #else
  10567. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  10568. goto try_unpack;
  10569. #endif
  10570. try_unpack:
  10571. #if CYTHON_UNPACK_METHODS
  10572. if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
  10573. PyObject *function = PyMethod_GET_FUNCTION(attr);
  10574. Py_INCREF(function);
  10575. Py_DECREF(attr);
  10576. *method = function;
  10577. return 1;
  10578. }
  10579. #endif
  10580. *method = attr;
  10581. return 0;
  10582. }
  10583. #endif
  10584. /* PyObjectCallMethod0 (used by pop) */
  10585. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
  10586. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  10587. PyObject *args[1] = {obj};
  10588. (void) __Pyx_PyObject_CallOneArg;
  10589. (void) __Pyx_PyObject_CallNoArg;
  10590. return PyObject_VectorcallMethod(method_name, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  10591. #else
  10592. PyObject *method = NULL, *result = NULL;
  10593. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  10594. if (likely(is_method)) {
  10595. result = __Pyx_PyObject_CallOneArg(method, obj);
  10596. Py_DECREF(method);
  10597. return result;
  10598. }
  10599. if (unlikely(!method)) goto bad;
  10600. result = __Pyx_PyObject_CallNoArg(method);
  10601. Py_DECREF(method);
  10602. bad:
  10603. return result;
  10604. #endif
  10605. }
  10606. /* pop */
  10607. static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
  10608. if (__Pyx_IS_TYPE(L, &PySet_Type)) {
  10609. return PySet_Pop(L);
  10610. }
  10611. return __Pyx_PyObject_CallMethod0(L, __pyx_mstate_global->__pyx_n_u_pop);
  10612. }
  10613. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  10614. static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
  10615. if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
  10616. __Pyx_SET_SIZE(L, Py_SIZE(L) - 1);
  10617. return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
  10618. }
  10619. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyList_Type_pop, L);
  10620. }
  10621. #endif
  10622. /* RaiseUnexpectedTypeError */
  10623. static int
  10624. __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj)
  10625. {
  10626. __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  10627. PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME,
  10628. expected, obj_type_name);
  10629. __Pyx_DECREF_TypeName(obj_type_name);
  10630. return 0;
  10631. }
  10632. /* PyLongBinop */
  10633. #if !CYTHON_COMPILING_IN_PYPY
  10634. static PyObject* __Pyx_Fallback___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, int inplace) {
  10635. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  10636. }
  10637. #if CYTHON_USE_PYLONG_INTERNALS
  10638. static PyObject* __Pyx_Unpacked___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  10639. CYTHON_MAYBE_UNUSED_VAR(inplace);
  10640. CYTHON_UNUSED_VAR(zerodivision_check);
  10641. const long b = intval;
  10642. long a;
  10643. const PY_LONG_LONG llb = intval;
  10644. PY_LONG_LONG lla;
  10645. if (unlikely(__Pyx_PyLong_IsZero(op1))) {
  10646. return __Pyx_NewRef(op2);
  10647. }
  10648. const int is_positive = __Pyx_PyLong_IsPos(op1);
  10649. const digit* digits = __Pyx_PyLong_Digits(op1);
  10650. const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
  10651. if (likely(size == 1)) {
  10652. a = (long) digits[0];
  10653. if (!is_positive) a *= -1;
  10654. } else {
  10655. switch (size) {
  10656. case 2:
  10657. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10658. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10659. if (!is_positive) a *= -1;
  10660. goto calculate_long;
  10661. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  10662. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  10663. if (!is_positive) lla *= -1;
  10664. goto calculate_long_long;
  10665. }
  10666. break;
  10667. case 3:
  10668. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10669. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10670. if (!is_positive) a *= -1;
  10671. goto calculate_long;
  10672. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  10673. lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  10674. if (!is_positive) lla *= -1;
  10675. goto calculate_long_long;
  10676. }
  10677. break;
  10678. case 4:
  10679. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  10680. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10681. if (!is_positive) a *= -1;
  10682. goto calculate_long;
  10683. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  10684. lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  10685. if (!is_positive) lla *= -1;
  10686. goto calculate_long_long;
  10687. }
  10688. break;
  10689. }
  10690. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  10691. }
  10692. calculate_long:
  10693. {
  10694. long x;
  10695. x = a + b;
  10696. return PyLong_FromLong(x);
  10697. }
  10698. calculate_long_long:
  10699. {
  10700. PY_LONG_LONG llx;
  10701. llx = lla + llb;
  10702. return PyLong_FromLongLong(llx);
  10703. }
  10704. }
  10705. #endif
  10706. static PyObject* __Pyx_Float___Pyx_PyLong_AddObjC(PyObject *float_val, long intval, int zerodivision_check) {
  10707. CYTHON_UNUSED_VAR(zerodivision_check);
  10708. const long b = intval;
  10709. double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
  10710. double result;
  10711. result = ((double)a) + (double)b;
  10712. return PyFloat_FromDouble(result);
  10713. }
  10714. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  10715. CYTHON_MAYBE_UNUSED_VAR(intval);
  10716. CYTHON_UNUSED_VAR(zerodivision_check);
  10717. #if CYTHON_USE_PYLONG_INTERNALS
  10718. if (likely(PyLong_CheckExact(op1))) {
  10719. return __Pyx_Unpacked___Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check);
  10720. }
  10721. #endif
  10722. if (PyFloat_CheckExact(op1)) {
  10723. return __Pyx_Float___Pyx_PyLong_AddObjC(op1, intval, zerodivision_check);
  10724. }
  10725. return __Pyx_Fallback___Pyx_PyLong_AddObjC(op1, op2, inplace);
  10726. }
  10727. #endif
  10728. /* GetTopmostException (used by SaveResetException) */
  10729. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  10730. static _PyErr_StackItem *
  10731. __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
  10732. {
  10733. _PyErr_StackItem *exc_info = tstate->exc_info;
  10734. while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
  10735. exc_info->previous_item != NULL)
  10736. {
  10737. exc_info = exc_info->previous_item;
  10738. }
  10739. return exc_info;
  10740. }
  10741. #endif
  10742. /* SaveResetException */
  10743. #if CYTHON_FAST_THREAD_STATE
  10744. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  10745. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  10746. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  10747. PyObject *exc_value = exc_info->exc_value;
  10748. if (exc_value == NULL || exc_value == Py_None) {
  10749. *value = NULL;
  10750. *type = NULL;
  10751. *tb = NULL;
  10752. } else {
  10753. *value = exc_value;
  10754. Py_INCREF(*value);
  10755. *type = (PyObject*) Py_TYPE(exc_value);
  10756. Py_INCREF(*type);
  10757. *tb = PyException_GetTraceback(exc_value);
  10758. }
  10759. #elif CYTHON_USE_EXC_INFO_STACK
  10760. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  10761. *type = exc_info->exc_type;
  10762. *value = exc_info->exc_value;
  10763. *tb = exc_info->exc_traceback;
  10764. Py_XINCREF(*type);
  10765. Py_XINCREF(*value);
  10766. Py_XINCREF(*tb);
  10767. #else
  10768. *type = tstate->exc_type;
  10769. *value = tstate->exc_value;
  10770. *tb = tstate->exc_traceback;
  10771. Py_XINCREF(*type);
  10772. Py_XINCREF(*value);
  10773. Py_XINCREF(*tb);
  10774. #endif
  10775. }
  10776. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  10777. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  10778. _PyErr_StackItem *exc_info = tstate->exc_info;
  10779. PyObject *tmp_value = exc_info->exc_value;
  10780. exc_info->exc_value = value;
  10781. Py_XDECREF(tmp_value);
  10782. Py_XDECREF(type);
  10783. Py_XDECREF(tb);
  10784. #else
  10785. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10786. #if CYTHON_USE_EXC_INFO_STACK
  10787. _PyErr_StackItem *exc_info = tstate->exc_info;
  10788. tmp_type = exc_info->exc_type;
  10789. tmp_value = exc_info->exc_value;
  10790. tmp_tb = exc_info->exc_traceback;
  10791. exc_info->exc_type = type;
  10792. exc_info->exc_value = value;
  10793. exc_info->exc_traceback = tb;
  10794. #else
  10795. tmp_type = tstate->exc_type;
  10796. tmp_value = tstate->exc_value;
  10797. tmp_tb = tstate->exc_traceback;
  10798. tstate->exc_type = type;
  10799. tstate->exc_value = value;
  10800. tstate->exc_traceback = tb;
  10801. #endif
  10802. Py_XDECREF(tmp_type);
  10803. Py_XDECREF(tmp_value);
  10804. Py_XDECREF(tmp_tb);
  10805. #endif
  10806. }
  10807. #endif
  10808. /* pyfrozenset_new (used by PySetContains) */
  10809. static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
  10810. if (it) {
  10811. PyObject* result;
  10812. #if CYTHON_COMPILING_IN_PYPY
  10813. PyObject* args;
  10814. args = PyTuple_Pack(1, it);
  10815. if (unlikely(!args))
  10816. return NULL;
  10817. result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
  10818. Py_DECREF(args);
  10819. return result;
  10820. #else
  10821. if (PyFrozenSet_CheckExact(it)) {
  10822. Py_INCREF(it);
  10823. return it;
  10824. }
  10825. result = PyFrozenSet_New(it);
  10826. if (unlikely(!result))
  10827. return NULL;
  10828. if ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
  10829. #if CYTHON_COMPILING_IN_LIMITED_API
  10830. || __Pyx_get_runtime_version() >= 0x030A0000
  10831. #endif
  10832. )
  10833. return result;
  10834. {
  10835. Py_ssize_t size = __Pyx_PySet_GET_SIZE(result);
  10836. if (likely(size > 0))
  10837. return result;
  10838. #if !CYTHON_ASSUME_SAFE_SIZE
  10839. if (unlikely(size < 0)) {
  10840. Py_DECREF(result);
  10841. return NULL;
  10842. }
  10843. #endif
  10844. }
  10845. Py_DECREF(result);
  10846. #endif
  10847. }
  10848. return __Pyx_PyObject_CallNoArg((PyObject*) &PyFrozenSet_Type);
  10849. }
  10850. /* PySetContains */
  10851. static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
  10852. int result = -1;
  10853. if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
  10854. PyObject *tmpkey;
  10855. PyErr_Clear();
  10856. tmpkey = __Pyx_PyFrozenSet_New(key);
  10857. if (tmpkey != NULL) {
  10858. result = PySet_Contains(set, tmpkey);
  10859. Py_DECREF(tmpkey);
  10860. }
  10861. }
  10862. return result;
  10863. }
  10864. static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
  10865. int result = PySet_Contains(set, key);
  10866. if (unlikely(result < 0)) {
  10867. result = __Pyx_PySet_ContainsUnhashable(set, key);
  10868. }
  10869. return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
  10870. }
  10871. /* HasAttr (used by ImportImpl) */
  10872. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  10873. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
  10874. PyObject *r;
  10875. if (unlikely(!PyUnicode_Check(n))) {
  10876. PyErr_SetString(PyExc_TypeError,
  10877. "hasattr(): attribute name must be string");
  10878. return -1;
  10879. }
  10880. r = __Pyx_PyObject_GetAttrStrNoError(o, n);
  10881. if (!r) {
  10882. return (unlikely(PyErr_Occurred())) ? -1 : 0;
  10883. } else {
  10884. Py_DECREF(r);
  10885. return 1;
  10886. }
  10887. }
  10888. #endif
  10889. /* ImportImpl (used by Import) */
  10890. static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) {
  10891. PyObject *imported_module = PyImport_GetModule(qualname);
  10892. if (unlikely(!imported_module)) {
  10893. *module = NULL;
  10894. if (PyErr_Occurred()) {
  10895. return -1;
  10896. }
  10897. return 0;
  10898. }
  10899. *module = imported_module;
  10900. return 1;
  10901. }
  10902. static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) {
  10903. PyObject *imported_module;
  10904. PyObject *top_level_package_name;
  10905. Py_ssize_t i;
  10906. int status, module_found;
  10907. Py_ssize_t dot_index;
  10908. module_found = __Pyx__Import_GetModule(qualname, &imported_module);
  10909. if (unlikely(!module_found || module_found == -1)) {
  10910. *module = NULL;
  10911. return module_found;
  10912. }
  10913. if (imported_names) {
  10914. for (i = 0; i < len_imported_names; i++) {
  10915. PyObject *imported_name = imported_names[i];
  10916. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  10917. int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name);
  10918. #else
  10919. int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name);
  10920. if (unlikely(has_imported_attribute == -1)) goto error;
  10921. #endif
  10922. if (!has_imported_attribute) {
  10923. goto not_found;
  10924. }
  10925. }
  10926. *module = imported_module;
  10927. return 1;
  10928. }
  10929. dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1);
  10930. if (dot_index == -1) {
  10931. *module = imported_module;
  10932. return 1;
  10933. }
  10934. if (unlikely(dot_index == -2)) goto error;
  10935. top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index);
  10936. if (unlikely(!top_level_package_name)) goto error;
  10937. Py_DECREF(imported_module);
  10938. status = __Pyx__Import_GetModule(top_level_package_name, module);
  10939. Py_DECREF(top_level_package_name);
  10940. return status;
  10941. error:
  10942. Py_DECREF(imported_module);
  10943. *module = NULL;
  10944. return -1;
  10945. not_found:
  10946. Py_DECREF(imported_module);
  10947. *module = NULL;
  10948. return 0;
  10949. }
  10950. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level) {
  10951. PyObject *module = 0;
  10952. PyObject *empty_dict = 0;
  10953. PyObject *from_list = 0;
  10954. int module_found;
  10955. if (!qualname) {
  10956. qualname = name;
  10957. }
  10958. module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module);
  10959. if (likely(module_found == 1)) {
  10960. return module;
  10961. } else if (unlikely(module_found == -1)) {
  10962. return NULL;
  10963. }
  10964. empty_dict = PyDict_New();
  10965. if (unlikely(!empty_dict))
  10966. goto bad;
  10967. if (imported_names) {
  10968. #if CYTHON_COMPILING_IN_CPYTHON
  10969. from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names);
  10970. if (unlikely(!from_list))
  10971. goto bad;
  10972. #else
  10973. from_list = PyList_New(len_imported_names);
  10974. if (unlikely(!from_list)) goto bad;
  10975. for (Py_ssize_t i=0; i<len_imported_names; ++i) {
  10976. if (PyList_SetItem(from_list, i, __Pyx_NewRef(imported_names[i])) < 0) goto bad;
  10977. }
  10978. #endif
  10979. }
  10980. if (level == -1) {
  10981. const char* package_sep = strchr(__Pyx_MODULE_NAME, '.');
  10982. if (package_sep != (0)) {
  10983. module = PyImport_ImportModuleLevelObject(
  10984. name, moddict, empty_dict, from_list, 1);
  10985. if (unlikely(!module)) {
  10986. if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
  10987. goto bad;
  10988. PyErr_Clear();
  10989. }
  10990. }
  10991. level = 0;
  10992. }
  10993. if (!module) {
  10994. module = PyImport_ImportModuleLevelObject(
  10995. name, moddict, empty_dict, from_list, level);
  10996. }
  10997. bad:
  10998. Py_XDECREF(from_list);
  10999. Py_XDECREF(empty_dict);
  11000. return module;
  11001. }
  11002. /* Import */
  11003. static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) {
  11004. return __Pyx__Import(name, imported_names, len_imported_names, qualname, __pyx_mstate_global->__pyx_d, level);
  11005. }
  11006. /* ImportFrom */
  11007. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  11008. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  11009. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  11010. const char* module_name_str = 0;
  11011. PyObject* module_name = 0;
  11012. PyObject* module_dot = 0;
  11013. PyObject* full_name = 0;
  11014. PyErr_Clear();
  11015. module_name_str = PyModule_GetName(module);
  11016. if (unlikely(!module_name_str)) { goto modbad; }
  11017. module_name = PyUnicode_FromString(module_name_str);
  11018. if (unlikely(!module_name)) { goto modbad; }
  11019. module_dot = PyUnicode_Concat(module_name, __pyx_mstate_global->__pyx_kp_u_);
  11020. if (unlikely(!module_dot)) { goto modbad; }
  11021. full_name = PyUnicode_Concat(module_dot, name);
  11022. if (unlikely(!full_name)) { goto modbad; }
  11023. #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) ||\
  11024. CYTHON_COMPILING_IN_GRAAL
  11025. {
  11026. PyObject *modules = PyImport_GetModuleDict();
  11027. if (unlikely(!modules))
  11028. goto modbad;
  11029. value = PyObject_GetItem(modules, full_name);
  11030. }
  11031. #else
  11032. value = PyImport_GetModule(full_name);
  11033. #endif
  11034. modbad:
  11035. Py_XDECREF(full_name);
  11036. Py_XDECREF(module_dot);
  11037. Py_XDECREF(module_name);
  11038. }
  11039. if (unlikely(!value)) {
  11040. PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
  11041. }
  11042. return value;
  11043. }
  11044. /* AllocateExtensionType */
  11045. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) {
  11046. if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) {
  11047. allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc);
  11048. return alloc_func(t, 0);
  11049. } else {
  11050. newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc);
  11051. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11052. if (!tp_new) {
  11053. PyObject *new_str = PyUnicode_FromString("__new__");
  11054. if (likely(new_str)) {
  11055. PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL);
  11056. Py_DECREF(new_str);
  11057. return o;
  11058. } else
  11059. return NULL;
  11060. } else
  11061. #endif
  11062. return tp_new(t, __pyx_mstate_global->__pyx_empty_tuple, 0);
  11063. }
  11064. }
  11065. /* CallTypeTraverse */
  11066. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  11067. #else
  11068. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) {
  11069. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000
  11070. if (__Pyx_get_runtime_version() < 0x03090000) return 0;
  11071. #endif
  11072. if (!always_call) {
  11073. PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*);
  11074. unsigned long flags = PyType_GetFlags(base);
  11075. if (flags & Py_TPFLAGS_HEAPTYPE) {
  11076. return 0;
  11077. }
  11078. }
  11079. Py_VISIT((PyObject*)Py_TYPE(o));
  11080. return 0;
  11081. }
  11082. #endif
  11083. /* LimitedApiGetTypeDict (used by SetItemOnTypeDict) */
  11084. #if CYTHON_COMPILING_IN_LIMITED_API
  11085. static Py_ssize_t __Pyx_GetTypeDictOffset(void) {
  11086. PyObject *tp_dictoffset_o;
  11087. Py_ssize_t tp_dictoffset;
  11088. tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__");
  11089. if (unlikely(!tp_dictoffset_o)) return -1;
  11090. tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o);
  11091. Py_DECREF(tp_dictoffset_o);
  11092. if (unlikely(tp_dictoffset == 0)) {
  11093. PyErr_SetString(
  11094. PyExc_TypeError,
  11095. "'type' doesn't have a dictoffset");
  11096. return -1;
  11097. } else if (unlikely(tp_dictoffset < 0)) {
  11098. PyErr_SetString(
  11099. PyExc_TypeError,
  11100. "'type' has an unexpected negative dictoffset. "
  11101. "Please report this as Cython bug");
  11102. return -1;
  11103. }
  11104. return tp_dictoffset;
  11105. }
  11106. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) {
  11107. static Py_ssize_t tp_dictoffset = 0;
  11108. if (unlikely(tp_dictoffset == 0)) {
  11109. tp_dictoffset = __Pyx_GetTypeDictOffset();
  11110. if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) {
  11111. tp_dictoffset = 0; // try again next time?
  11112. return NULL;
  11113. }
  11114. }
  11115. return *(PyObject**)((char*)tp + tp_dictoffset);
  11116. }
  11117. #endif
  11118. /* SetItemOnTypeDict (used by FixUpExtensionType) */
  11119. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) {
  11120. int result;
  11121. PyObject *tp_dict;
  11122. #if CYTHON_COMPILING_IN_LIMITED_API
  11123. tp_dict = __Pyx_GetTypeDict(tp);
  11124. if (unlikely(!tp_dict)) return -1;
  11125. #else
  11126. tp_dict = tp->tp_dict;
  11127. #endif
  11128. result = PyDict_SetItem(tp_dict, k, v);
  11129. if (likely(!result)) {
  11130. PyType_Modified(tp);
  11131. if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) {
  11132. PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL);
  11133. if (!setNameResult) return -1;
  11134. Py_DECREF(setNameResult);
  11135. }
  11136. }
  11137. return result;
  11138. }
  11139. /* FixUpExtensionType */
  11140. static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) {
  11141. #if __PYX_LIMITED_VERSION_HEX > 0x030900B1
  11142. CYTHON_UNUSED_VAR(spec);
  11143. CYTHON_UNUSED_VAR(type);
  11144. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  11145. #else
  11146. const PyType_Slot *slot = spec->slots;
  11147. int changed = 0;
  11148. #if !CYTHON_COMPILING_IN_LIMITED_API
  11149. while (slot && slot->slot && slot->slot != Py_tp_members)
  11150. slot++;
  11151. if (slot && slot->slot == Py_tp_members) {
  11152. #if !CYTHON_COMPILING_IN_CPYTHON
  11153. const
  11154. #endif // !CYTHON_COMPILING_IN_CPYTHON)
  11155. PyMemberDef *memb = (PyMemberDef*) slot->pfunc;
  11156. while (memb && memb->name) {
  11157. if (memb->name[0] == '_' && memb->name[1] == '_') {
  11158. if (strcmp(memb->name, "__weaklistoffset__") == 0) {
  11159. assert(memb->type == T_PYSSIZET);
  11160. assert(memb->flags == READONLY);
  11161. type->tp_weaklistoffset = memb->offset;
  11162. changed = 1;
  11163. }
  11164. else if (strcmp(memb->name, "__dictoffset__") == 0) {
  11165. assert(memb->type == T_PYSSIZET);
  11166. assert(memb->flags == READONLY);
  11167. type->tp_dictoffset = memb->offset;
  11168. changed = 1;
  11169. }
  11170. #if CYTHON_METH_FASTCALL
  11171. else if (strcmp(memb->name, "__vectorcalloffset__") == 0) {
  11172. assert(memb->type == T_PYSSIZET);
  11173. assert(memb->flags == READONLY);
  11174. type->tp_vectorcall_offset = memb->offset;
  11175. changed = 1;
  11176. }
  11177. #endif // CYTHON_METH_FASTCALL
  11178. #if !CYTHON_COMPILING_IN_PYPY
  11179. else if (strcmp(memb->name, "__module__") == 0) {
  11180. PyObject *descr;
  11181. assert(memb->type == T_OBJECT);
  11182. assert(memb->flags == 0 || memb->flags == READONLY);
  11183. descr = PyDescr_NewMember(type, memb);
  11184. if (unlikely(!descr))
  11185. return -1;
  11186. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  11187. Py_DECREF(descr);
  11188. if (unlikely(set_item_result < 0)) {
  11189. return -1;
  11190. }
  11191. changed = 1;
  11192. }
  11193. #endif // !CYTHON_COMPILING_IN_PYPY
  11194. }
  11195. memb++;
  11196. }
  11197. }
  11198. #endif // !CYTHON_COMPILING_IN_LIMITED_API
  11199. #if !CYTHON_COMPILING_IN_PYPY
  11200. slot = spec->slots;
  11201. while (slot && slot->slot && slot->slot != Py_tp_getset)
  11202. slot++;
  11203. if (slot && slot->slot == Py_tp_getset) {
  11204. PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc;
  11205. while (getset && getset->name) {
  11206. if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) {
  11207. PyObject *descr = PyDescr_NewGetSet(type, getset);
  11208. if (unlikely(!descr))
  11209. return -1;
  11210. #if CYTHON_COMPILING_IN_LIMITED_API
  11211. PyObject *pyname = PyUnicode_FromString(getset->name);
  11212. if (unlikely(!pyname)) {
  11213. Py_DECREF(descr);
  11214. return -1;
  11215. }
  11216. int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr);
  11217. Py_DECREF(pyname);
  11218. #else
  11219. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  11220. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  11221. #endif
  11222. Py_DECREF(descr);
  11223. if (unlikely(set_item_result < 0)) {
  11224. return -1;
  11225. }
  11226. changed = 1;
  11227. }
  11228. ++getset;
  11229. }
  11230. }
  11231. #else
  11232. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  11233. #endif // !CYTHON_COMPILING_IN_PYPY
  11234. if (changed)
  11235. PyType_Modified(type);
  11236. #endif // PY_VERSION_HEX > 0x030900B1
  11237. return 0;
  11238. }
  11239. /* ValidateBasesTuple (used by PyType_Ready) */
  11240. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  11241. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) {
  11242. Py_ssize_t i, n;
  11243. #if CYTHON_ASSUME_SAFE_SIZE
  11244. n = PyTuple_GET_SIZE(bases);
  11245. #else
  11246. n = PyTuple_Size(bases);
  11247. if (unlikely(n < 0)) return -1;
  11248. #endif
  11249. for (i = 1; i < n; i++)
  11250. {
  11251. PyTypeObject *b;
  11252. #if CYTHON_AVOID_BORROWED_REFS
  11253. PyObject *b0 = PySequence_GetItem(bases, i);
  11254. if (!b0) return -1;
  11255. #elif CYTHON_ASSUME_SAFE_MACROS
  11256. PyObject *b0 = PyTuple_GET_ITEM(bases, i);
  11257. #else
  11258. PyObject *b0 = PyTuple_GetItem(bases, i);
  11259. if (!b0) return -1;
  11260. #endif
  11261. b = (PyTypeObject*) b0;
  11262. if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
  11263. {
  11264. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  11265. PyErr_Format(PyExc_TypeError,
  11266. "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name);
  11267. __Pyx_DECREF_TypeName(b_name);
  11268. #if CYTHON_AVOID_BORROWED_REFS
  11269. Py_DECREF(b0);
  11270. #endif
  11271. return -1;
  11272. }
  11273. if (dictoffset == 0)
  11274. {
  11275. Py_ssize_t b_dictoffset = 0;
  11276. #if CYTHON_USE_TYPE_SLOTS
  11277. b_dictoffset = b->tp_dictoffset;
  11278. #else
  11279. PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__");
  11280. if (!py_b_dictoffset) goto dictoffset_return;
  11281. b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset);
  11282. Py_DECREF(py_b_dictoffset);
  11283. if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return;
  11284. #endif
  11285. if (b_dictoffset) {
  11286. {
  11287. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  11288. PyErr_Format(PyExc_TypeError,
  11289. "extension type '%.200s' has no __dict__ slot, "
  11290. "but base type '" __Pyx_FMT_TYPENAME "' has: "
  11291. "either add 'cdef dict __dict__' to the extension type "
  11292. "or add '__slots__ = [...]' to the base type",
  11293. type_name, b_name);
  11294. __Pyx_DECREF_TypeName(b_name);
  11295. }
  11296. #if !CYTHON_USE_TYPE_SLOTS
  11297. dictoffset_return:
  11298. #endif
  11299. #if CYTHON_AVOID_BORROWED_REFS
  11300. Py_DECREF(b0);
  11301. #endif
  11302. return -1;
  11303. }
  11304. }
  11305. #if CYTHON_AVOID_BORROWED_REFS
  11306. Py_DECREF(b0);
  11307. #endif
  11308. }
  11309. return 0;
  11310. }
  11311. #endif
  11312. /* PyType_Ready */
  11313. CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) {
  11314. while (t) {
  11315. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  11316. if (bases) {
  11317. return 1;
  11318. }
  11319. t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*);
  11320. }
  11321. return 0;
  11322. }
  11323. static int __Pyx_PyType_Ready(PyTypeObject *t) {
  11324. #if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION)
  11325. (void)__Pyx_PyObject_CallMethod0;
  11326. #if CYTHON_USE_TYPE_SPECS
  11327. (void)__Pyx_validate_bases_tuple;
  11328. #endif
  11329. return PyType_Ready(t);
  11330. #else
  11331. int r;
  11332. if (!__Pyx_PyType_HasMultipleInheritance(t)) {
  11333. return PyType_Ready(t);
  11334. }
  11335. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  11336. if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1))
  11337. return -1;
  11338. #if !defined(PYSTON_MAJOR_VERSION)
  11339. {
  11340. int gc_was_enabled;
  11341. #if PY_VERSION_HEX >= 0x030A00b1
  11342. gc_was_enabled = PyGC_Disable();
  11343. (void)__Pyx_PyObject_CallMethod0;
  11344. #else
  11345. PyObject *ret, *py_status;
  11346. PyObject *gc = NULL;
  11347. #if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) &&\
  11348. !CYTHON_COMPILING_IN_GRAAL
  11349. gc = PyImport_GetModule(__pyx_mstate_global->__pyx_kp_u_gc);
  11350. #endif
  11351. if (unlikely(!gc)) gc = PyImport_Import(__pyx_mstate_global->__pyx_kp_u_gc);
  11352. if (unlikely(!gc)) return -1;
  11353. py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_isenabled);
  11354. if (unlikely(!py_status)) {
  11355. Py_DECREF(gc);
  11356. return -1;
  11357. }
  11358. gc_was_enabled = __Pyx_PyObject_IsTrue(py_status);
  11359. Py_DECREF(py_status);
  11360. if (gc_was_enabled > 0) {
  11361. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_disable);
  11362. if (unlikely(!ret)) {
  11363. Py_DECREF(gc);
  11364. return -1;
  11365. }
  11366. Py_DECREF(ret);
  11367. } else if (unlikely(gc_was_enabled == -1)) {
  11368. Py_DECREF(gc);
  11369. return -1;
  11370. }
  11371. #endif
  11372. t->tp_flags |= Py_TPFLAGS_HEAPTYPE;
  11373. #if PY_VERSION_HEX >= 0x030A0000
  11374. t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
  11375. #endif
  11376. #else
  11377. (void)__Pyx_PyObject_CallMethod0;
  11378. #endif
  11379. r = PyType_Ready(t);
  11380. #if !defined(PYSTON_MAJOR_VERSION)
  11381. t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
  11382. #if PY_VERSION_HEX >= 0x030A00b1
  11383. if (gc_was_enabled)
  11384. PyGC_Enable();
  11385. #else
  11386. if (gc_was_enabled) {
  11387. PyObject *tp, *v, *tb;
  11388. PyErr_Fetch(&tp, &v, &tb);
  11389. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_enable);
  11390. if (likely(ret || r == -1)) {
  11391. Py_XDECREF(ret);
  11392. PyErr_Restore(tp, v, tb);
  11393. } else {
  11394. Py_XDECREF(tp);
  11395. Py_XDECREF(v);
  11396. Py_XDECREF(tb);
  11397. r = -1;
  11398. }
  11399. }
  11400. Py_DECREF(gc);
  11401. #endif
  11402. }
  11403. #endif
  11404. return r;
  11405. #endif
  11406. }
  11407. /* ListPack */
  11408. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...) {
  11409. va_list va;
  11410. PyObject *l = PyList_New(n);
  11411. va_start(va, n);
  11412. if (unlikely(!l)) goto end;
  11413. for (Py_ssize_t i=0; i<n; ++i) {
  11414. PyObject *arg = va_arg(va, PyObject*);
  11415. Py_INCREF(arg);
  11416. if (__Pyx_PyList_SET_ITEM(l, i, arg) != (0)) {
  11417. Py_CLEAR(l);
  11418. goto end;
  11419. }
  11420. }
  11421. end:
  11422. va_end(va);
  11423. return l;
  11424. }
  11425. /* dict_setdefault (used by FetchCommonType) */
  11426. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) {
  11427. PyObject* value;
  11428. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  11429. PyObject *args[] = {d, key, default_value};
  11430. value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  11431. #elif CYTHON_COMPILING_IN_LIMITED_API
  11432. value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL);
  11433. #elif PY_VERSION_HEX >= 0x030d0000
  11434. PyDict_SetDefaultRef(d, key, default_value, &value);
  11435. #else
  11436. value = PyDict_SetDefault(d, key, default_value);
  11437. if (unlikely(!value)) return NULL;
  11438. Py_INCREF(value);
  11439. #endif
  11440. return value;
  11441. }
  11442. /* AddModuleRef (used by FetchSharedCythonModule) */
  11443. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  11444. static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) {
  11445. PyObject *module_dict = PyImport_GetModuleDict();
  11446. PyObject *m;
  11447. if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) {
  11448. return NULL;
  11449. }
  11450. if (m != NULL && PyModule_Check(m)) {
  11451. return m;
  11452. }
  11453. Py_XDECREF(m);
  11454. m = PyModule_NewObject(name);
  11455. if (m == NULL)
  11456. return NULL;
  11457. if (PyDict_CheckExact(module_dict)) {
  11458. PyObject *new_m;
  11459. (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m);
  11460. Py_DECREF(m);
  11461. return new_m;
  11462. } else {
  11463. if (PyObject_SetItem(module_dict, name, m) != 0) {
  11464. Py_DECREF(m);
  11465. return NULL;
  11466. }
  11467. return m;
  11468. }
  11469. }
  11470. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  11471. PyObject *py_name = PyUnicode_FromString(name);
  11472. if (!py_name) return NULL;
  11473. PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name);
  11474. Py_DECREF(py_name);
  11475. return module;
  11476. }
  11477. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  11478. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  11479. #else
  11480. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  11481. PyObject *module = PyImport_AddModule(name);
  11482. Py_XINCREF(module);
  11483. return module;
  11484. }
  11485. #endif
  11486. /* FetchSharedCythonModule (used by FetchCommonType) */
  11487. static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
  11488. return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME);
  11489. }
  11490. /* FetchCommonType (used by CommonTypesMetaclass) */
  11491. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  11492. static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  11493. PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases);
  11494. if (result && metaclass) {
  11495. PyObject *old_tp = (PyObject*)Py_TYPE(result);
  11496. Py_INCREF((PyObject*)metaclass);
  11497. #if __PYX_LIMITED_VERSION_HEX >= 0x03090000
  11498. Py_SET_TYPE(result, metaclass);
  11499. #else
  11500. result->ob_type = metaclass;
  11501. #endif
  11502. Py_DECREF(old_tp);
  11503. }
  11504. return result;
  11505. }
  11506. #else
  11507. #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b)
  11508. #endif
  11509. static int __Pyx_VerifyCachedType(PyObject *cached_type,
  11510. const char *name,
  11511. Py_ssize_t expected_basicsize) {
  11512. Py_ssize_t basicsize;
  11513. if (!PyType_Check(cached_type)) {
  11514. PyErr_Format(PyExc_TypeError,
  11515. "Shared Cython type %.200s is not a type object", name);
  11516. return -1;
  11517. }
  11518. if (expected_basicsize == 0) {
  11519. return 0; // size is inherited, nothing useful to check
  11520. }
  11521. #if CYTHON_COMPILING_IN_LIMITED_API
  11522. PyObject *py_basicsize;
  11523. py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__");
  11524. if (unlikely(!py_basicsize)) return -1;
  11525. basicsize = PyLong_AsSsize_t(py_basicsize);
  11526. Py_DECREF(py_basicsize);
  11527. py_basicsize = NULL;
  11528. if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1;
  11529. #else
  11530. basicsize = ((PyTypeObject*) cached_type)->tp_basicsize;
  11531. #endif
  11532. if (basicsize != expected_basicsize) {
  11533. PyErr_Format(PyExc_TypeError,
  11534. "Shared Cython type %.200s has the wrong size, try recompiling",
  11535. name);
  11536. return -1;
  11537. }
  11538. return 0;
  11539. }
  11540. static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  11541. PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name;
  11542. int get_item_ref_result;
  11543. const char* object_name = strrchr(spec->name, '.');
  11544. object_name = object_name ? object_name+1 : spec->name;
  11545. py_object_name = PyUnicode_FromString(object_name);
  11546. if (!py_object_name) return NULL;
  11547. abi_module = __Pyx_FetchSharedCythonABIModule();
  11548. if (!abi_module) goto done;
  11549. abi_module_dict = PyModule_GetDict(abi_module);
  11550. if (!abi_module_dict) goto done;
  11551. get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type);
  11552. if (get_item_ref_result == 1) {
  11553. if (__Pyx_VerifyCachedType(
  11554. cached_type,
  11555. object_name,
  11556. spec->basicsize) < 0) {
  11557. goto bad;
  11558. }
  11559. goto done;
  11560. } else if (unlikely(get_item_ref_result == -1)) {
  11561. goto bad;
  11562. }
  11563. cached_type = __Pyx_PyType_FromMetaclass(
  11564. metaclass,
  11565. CYTHON_USE_MODULE_STATE ? module : abi_module,
  11566. spec, bases);
  11567. if (unlikely(!cached_type)) goto bad;
  11568. if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad;
  11569. new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type);
  11570. if (unlikely(new_cached_type != cached_type)) {
  11571. if (unlikely(!new_cached_type)) goto bad;
  11572. Py_DECREF(cached_type);
  11573. cached_type = new_cached_type;
  11574. if (__Pyx_VerifyCachedType(
  11575. cached_type,
  11576. object_name,
  11577. spec->basicsize) < 0) {
  11578. goto bad;
  11579. }
  11580. goto done;
  11581. } else {
  11582. Py_DECREF(new_cached_type);
  11583. }
  11584. done:
  11585. Py_XDECREF(abi_module);
  11586. Py_DECREF(py_object_name);
  11587. assert(cached_type == NULL || PyType_Check(cached_type));
  11588. return (PyTypeObject *) cached_type;
  11589. bad:
  11590. Py_XDECREF(cached_type);
  11591. cached_type = NULL;
  11592. goto done;
  11593. }
  11594. /* CommonTypesMetaclass (used by CythonFunctionShared) */
  11595. static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) {
  11596. return PyUnicode_FromString(__PYX_ABI_MODULE_NAME);
  11597. }
  11598. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11599. static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) {
  11600. PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types");
  11601. return NULL;
  11602. }
  11603. static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) {
  11604. PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable");
  11605. return -1;
  11606. }
  11607. #endif
  11608. static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = {
  11609. {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL},
  11610. {0, 0, 0, 0, 0}
  11611. };
  11612. static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = {
  11613. {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset},
  11614. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11615. {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call},
  11616. {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call},
  11617. {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr},
  11618. #endif
  11619. {0, 0}
  11620. };
  11621. static PyType_Spec __pyx_CommonTypesMetaclass_spec = {
  11622. __PYX_TYPE_MODULE_PREFIX "_common_types_metatype",
  11623. 0,
  11624. 0,
  11625. Py_TPFLAGS_IMMUTABLETYPE |
  11626. Py_TPFLAGS_DISALLOW_INSTANTIATION |
  11627. Py_TPFLAGS_DEFAULT,
  11628. __pyx_CommonTypesMetaclass_slots
  11629. };
  11630. static int __pyx_CommonTypesMetaclass_init(PyObject *module) {
  11631. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  11632. PyObject *bases = PyTuple_Pack(1, &PyType_Type);
  11633. if (unlikely(!bases)) {
  11634. return -1;
  11635. }
  11636. mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases);
  11637. Py_DECREF(bases);
  11638. if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) {
  11639. return -1;
  11640. }
  11641. return 0;
  11642. }
  11643. /* PyMethodNew (used by CythonFunctionShared) */
  11644. #if CYTHON_COMPILING_IN_LIMITED_API
  11645. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  11646. PyObject *result;
  11647. CYTHON_UNUSED_VAR(typ);
  11648. if (!self)
  11649. return __Pyx_NewRef(func);
  11650. #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  11651. {
  11652. PyObject *args[] = {func, self};
  11653. result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL);
  11654. }
  11655. #else
  11656. result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL);
  11657. #endif
  11658. return result;
  11659. }
  11660. #else
  11661. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  11662. CYTHON_UNUSED_VAR(typ);
  11663. if (!self)
  11664. return __Pyx_NewRef(func);
  11665. return PyMethod_New(func, self);
  11666. }
  11667. #endif
  11668. /* PyVectorcallFastCallDict (used by CythonFunctionShared) */
  11669. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  11670. static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  11671. {
  11672. PyObject *res = NULL;
  11673. PyObject *kwnames;
  11674. PyObject **newargs;
  11675. PyObject **kwvalues;
  11676. Py_ssize_t i;
  11677. #if CYTHON_AVOID_BORROWED_REFS
  11678. PyObject *pos;
  11679. #else
  11680. Py_ssize_t pos;
  11681. #endif
  11682. size_t j;
  11683. PyObject *key, *value;
  11684. unsigned long keys_are_strings;
  11685. #if !CYTHON_ASSUME_SAFE_SIZE
  11686. Py_ssize_t nkw = PyDict_Size(kw);
  11687. if (unlikely(nkw == -1)) return NULL;
  11688. #else
  11689. Py_ssize_t nkw = PyDict_GET_SIZE(kw);
  11690. #endif
  11691. newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0]));
  11692. if (unlikely(newargs == NULL)) {
  11693. PyErr_NoMemory();
  11694. return NULL;
  11695. }
  11696. for (j = 0; j < nargs; j++) newargs[j] = args[j];
  11697. kwnames = PyTuple_New(nkw);
  11698. if (unlikely(kwnames == NULL)) {
  11699. PyMem_Free(newargs);
  11700. return NULL;
  11701. }
  11702. kwvalues = newargs + nargs;
  11703. pos = 0;
  11704. i = 0;
  11705. keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS;
  11706. while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) {
  11707. keys_are_strings &=
  11708. #if CYTHON_COMPILING_IN_LIMITED_API
  11709. PyType_GetFlags(Py_TYPE(key));
  11710. #else
  11711. Py_TYPE(key)->tp_flags;
  11712. #endif
  11713. #if !CYTHON_ASSUME_SAFE_MACROS
  11714. if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup;
  11715. #else
  11716. PyTuple_SET_ITEM(kwnames, i, key);
  11717. #endif
  11718. kwvalues[i] = value;
  11719. i++;
  11720. }
  11721. if (unlikely(!keys_are_strings)) {
  11722. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  11723. goto cleanup;
  11724. }
  11725. res = vc(func, newargs, nargs, kwnames);
  11726. cleanup:
  11727. #if CYTHON_AVOID_BORROWED_REFS
  11728. Py_DECREF(pos);
  11729. #endif
  11730. Py_DECREF(kwnames);
  11731. for (i = 0; i < nkw; i++)
  11732. Py_DECREF(kwvalues[i]);
  11733. PyMem_Free(newargs);
  11734. return res;
  11735. }
  11736. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  11737. {
  11738. Py_ssize_t kw_size =
  11739. likely(kw == NULL) ?
  11740. 0 :
  11741. #if !CYTHON_ASSUME_SAFE_SIZE
  11742. PyDict_Size(kw);
  11743. #else
  11744. PyDict_GET_SIZE(kw);
  11745. #endif
  11746. if (kw_size == 0) {
  11747. return vc(func, args, nargs, NULL);
  11748. }
  11749. #if !CYTHON_ASSUME_SAFE_SIZE
  11750. else if (unlikely(kw_size == -1)) {
  11751. return NULL;
  11752. }
  11753. #endif
  11754. return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw);
  11755. }
  11756. #endif
  11757. /* CythonFunctionShared (used by CythonFunction) */
  11758. #if CYTHON_COMPILING_IN_LIMITED_API
  11759. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
  11760. if (__Pyx_CyFunction_Check(func)) {
  11761. return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
  11762. } else if (PyCFunction_Check(func)) {
  11763. return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
  11764. }
  11765. return 0;
  11766. }
  11767. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  11768. if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) {
  11769. int result;
  11770. PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func);
  11771. if (unlikely(!newFunc)) {
  11772. PyErr_Clear(); // It's only an optimization, so don't throw an error
  11773. return 0;
  11774. }
  11775. result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
  11776. Py_DECREF(newFunc);
  11777. return result;
  11778. }
  11779. return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
  11780. }
  11781. #else
  11782. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  11783. if (PyMethod_Check(func)) {
  11784. func = PyMethod_GET_FUNCTION(func);
  11785. }
  11786. return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  11787. }
  11788. #endif
  11789. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
  11790. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  11791. __Pyx_Py_XDECREF_SET(
  11792. __Pyx_CyFunction_GetClassObj(f),
  11793. ((classobj) ? __Pyx_NewRef(classobj) : NULL));
  11794. #else
  11795. __Pyx_Py_XDECREF_SET(
  11796. ((PyCMethodObject *) (f))->mm_class,
  11797. (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
  11798. #endif
  11799. }
  11800. static PyObject *
  11801. __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
  11802. {
  11803. if (unlikely(op->func_doc == NULL)) {
  11804. #if CYTHON_COMPILING_IN_LIMITED_API
  11805. op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
  11806. if (unlikely(!op->func_doc)) return NULL;
  11807. #else
  11808. if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
  11809. op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
  11810. if (unlikely(op->func_doc == NULL))
  11811. return NULL;
  11812. } else {
  11813. Py_INCREF(Py_None);
  11814. return Py_None;
  11815. }
  11816. #endif
  11817. }
  11818. Py_INCREF(op->func_doc);
  11819. return op->func_doc;
  11820. }
  11821. static PyObject *
  11822. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) {
  11823. PyObject *result;
  11824. CYTHON_UNUSED_VAR(closure);
  11825. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11826. result = __Pyx_CyFunction_get_doc_locked(op);
  11827. __Pyx_END_CRITICAL_SECTION();
  11828. return result;
  11829. }
  11830. static int
  11831. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11832. {
  11833. CYTHON_UNUSED_VAR(context);
  11834. if (value == NULL) {
  11835. value = Py_None;
  11836. }
  11837. Py_INCREF(value);
  11838. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11839. __Pyx_Py_XDECREF_SET(op->func_doc, value);
  11840. __Pyx_END_CRITICAL_SECTION();
  11841. return 0;
  11842. }
  11843. static PyObject *
  11844. __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
  11845. {
  11846. if (unlikely(op->func_name == NULL)) {
  11847. #if CYTHON_COMPILING_IN_LIMITED_API
  11848. op->func_name = PyObject_GetAttrString(op->func, "__name__");
  11849. #else
  11850. op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
  11851. #endif
  11852. if (unlikely(op->func_name == NULL))
  11853. return NULL;
  11854. }
  11855. Py_INCREF(op->func_name);
  11856. return op->func_name;
  11857. }
  11858. static PyObject *
  11859. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
  11860. {
  11861. PyObject *result = NULL;
  11862. CYTHON_UNUSED_VAR(context);
  11863. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11864. result = __Pyx_CyFunction_get_name_locked(op);
  11865. __Pyx_END_CRITICAL_SECTION();
  11866. return result;
  11867. }
  11868. static int
  11869. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11870. {
  11871. CYTHON_UNUSED_VAR(context);
  11872. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11873. PyErr_SetString(PyExc_TypeError,
  11874. "__name__ must be set to a string object");
  11875. return -1;
  11876. }
  11877. Py_INCREF(value);
  11878. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11879. __Pyx_Py_XDECREF_SET(op->func_name, value);
  11880. __Pyx_END_CRITICAL_SECTION();
  11881. return 0;
  11882. }
  11883. static PyObject *
  11884. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
  11885. {
  11886. CYTHON_UNUSED_VAR(context);
  11887. PyObject *result;
  11888. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11889. Py_INCREF(op->func_qualname);
  11890. result = op->func_qualname;
  11891. __Pyx_END_CRITICAL_SECTION();
  11892. return result;
  11893. }
  11894. static int
  11895. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11896. {
  11897. CYTHON_UNUSED_VAR(context);
  11898. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11899. PyErr_SetString(PyExc_TypeError,
  11900. "__qualname__ must be set to a string object");
  11901. return -1;
  11902. }
  11903. Py_INCREF(value);
  11904. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11905. __Pyx_Py_XDECREF_SET(op->func_qualname, value);
  11906. __Pyx_END_CRITICAL_SECTION();
  11907. return 0;
  11908. }
  11909. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11910. static PyObject *
  11911. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
  11912. {
  11913. CYTHON_UNUSED_VAR(context);
  11914. if (unlikely(op->func_dict == NULL)) {
  11915. op->func_dict = PyDict_New();
  11916. if (unlikely(op->func_dict == NULL))
  11917. return NULL;
  11918. }
  11919. Py_INCREF(op->func_dict);
  11920. return op->func_dict;
  11921. }
  11922. #endif
  11923. static PyObject *
  11924. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
  11925. {
  11926. CYTHON_UNUSED_VAR(context);
  11927. Py_INCREF(op->func_globals);
  11928. return op->func_globals;
  11929. }
  11930. static PyObject *
  11931. __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
  11932. {
  11933. CYTHON_UNUSED_VAR(op);
  11934. CYTHON_UNUSED_VAR(context);
  11935. Py_INCREF(Py_None);
  11936. return Py_None;
  11937. }
  11938. static PyObject *
  11939. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
  11940. {
  11941. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  11942. CYTHON_UNUSED_VAR(context);
  11943. Py_INCREF(result);
  11944. return result;
  11945. }
  11946. static int
  11947. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  11948. int result = 0;
  11949. PyObject *res = op->defaults_getter((PyObject *) op);
  11950. if (unlikely(!res))
  11951. return -1;
  11952. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11953. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  11954. Py_INCREF(op->defaults_tuple);
  11955. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  11956. Py_INCREF(op->defaults_kwdict);
  11957. #else
  11958. op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
  11959. if (unlikely(!op->defaults_tuple)) result = -1;
  11960. else {
  11961. op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
  11962. if (unlikely(!op->defaults_kwdict)) result = -1;
  11963. }
  11964. #endif
  11965. Py_DECREF(res);
  11966. return result;
  11967. }
  11968. static int
  11969. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11970. CYTHON_UNUSED_VAR(context);
  11971. if (!value) {
  11972. value = Py_None;
  11973. } else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
  11974. PyErr_SetString(PyExc_TypeError,
  11975. "__defaults__ must be set to a tuple object");
  11976. return -1;
  11977. }
  11978. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
  11979. "currently affect the values used in function calls", 1);
  11980. Py_INCREF(value);
  11981. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11982. __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
  11983. __Pyx_END_CRITICAL_SECTION();
  11984. return 0;
  11985. }
  11986. static PyObject *
  11987. __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
  11988. PyObject* result = op->defaults_tuple;
  11989. if (unlikely(!result)) {
  11990. if (op->defaults_getter) {
  11991. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  11992. result = op->defaults_tuple;
  11993. } else {
  11994. result = Py_None;
  11995. }
  11996. }
  11997. Py_INCREF(result);
  11998. return result;
  11999. }
  12000. static PyObject *
  12001. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
  12002. PyObject* result = NULL;
  12003. CYTHON_UNUSED_VAR(context);
  12004. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12005. result = __Pyx_CyFunction_get_defaults_locked(op);
  12006. __Pyx_END_CRITICAL_SECTION();
  12007. return result;
  12008. }
  12009. static int
  12010. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  12011. CYTHON_UNUSED_VAR(context);
  12012. if (!value) {
  12013. value = Py_None;
  12014. } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
  12015. PyErr_SetString(PyExc_TypeError,
  12016. "__kwdefaults__ must be set to a dict object");
  12017. return -1;
  12018. }
  12019. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
  12020. "currently affect the values used in function calls", 1);
  12021. Py_INCREF(value);
  12022. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12023. __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
  12024. __Pyx_END_CRITICAL_SECTION();
  12025. return 0;
  12026. }
  12027. static PyObject *
  12028. __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
  12029. PyObject* result = op->defaults_kwdict;
  12030. if (unlikely(!result)) {
  12031. if (op->defaults_getter) {
  12032. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  12033. result = op->defaults_kwdict;
  12034. } else {
  12035. result = Py_None;
  12036. }
  12037. }
  12038. Py_INCREF(result);
  12039. return result;
  12040. }
  12041. static PyObject *
  12042. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
  12043. PyObject* result;
  12044. CYTHON_UNUSED_VAR(context);
  12045. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12046. result = __Pyx_CyFunction_get_kwdefaults_locked(op);
  12047. __Pyx_END_CRITICAL_SECTION();
  12048. return result;
  12049. }
  12050. static int
  12051. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  12052. CYTHON_UNUSED_VAR(context);
  12053. if (!value || value == Py_None) {
  12054. value = NULL;
  12055. } else if (unlikely(!PyDict_Check(value))) {
  12056. PyErr_SetString(PyExc_TypeError,
  12057. "__annotations__ must be set to a dict object");
  12058. return -1;
  12059. }
  12060. Py_XINCREF(value);
  12061. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12062. __Pyx_Py_XDECREF_SET(op->func_annotations, value);
  12063. __Pyx_END_CRITICAL_SECTION();
  12064. return 0;
  12065. }
  12066. static PyObject *
  12067. __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
  12068. PyObject* result = op->func_annotations;
  12069. if (unlikely(!result)) {
  12070. result = PyDict_New();
  12071. if (unlikely(!result)) return NULL;
  12072. op->func_annotations = result;
  12073. }
  12074. Py_INCREF(result);
  12075. return result;
  12076. }
  12077. static PyObject *
  12078. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) {
  12079. PyObject *result;
  12080. CYTHON_UNUSED_VAR(context);
  12081. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12082. result = __Pyx_CyFunction_get_annotations_locked(op);
  12083. __Pyx_END_CRITICAL_SECTION();
  12084. return result;
  12085. }
  12086. static PyObject *
  12087. __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
  12088. int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
  12089. if (is_coroutine) {
  12090. PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine;
  12091. fromlist = PyList_New(1);
  12092. if (unlikely(!fromlist)) return NULL;
  12093. Py_INCREF(marker);
  12094. #if CYTHON_ASSUME_SAFE_MACROS
  12095. PyList_SET_ITEM(fromlist, 0, marker);
  12096. #else
  12097. if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
  12098. Py_DECREF(marker);
  12099. Py_DECREF(fromlist);
  12100. return NULL;
  12101. }
  12102. #endif
  12103. module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0);
  12104. Py_DECREF(fromlist);
  12105. if (unlikely(!module)) goto ignore;
  12106. is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
  12107. Py_DECREF(module);
  12108. if (likely(is_coroutine_value)) {
  12109. return is_coroutine_value;
  12110. }
  12111. ignore:
  12112. PyErr_Clear();
  12113. }
  12114. return __Pyx_PyBool_FromLong(is_coroutine);
  12115. }
  12116. static PyObject *
  12117. __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
  12118. PyObject *result;
  12119. CYTHON_UNUSED_VAR(context);
  12120. if (op->func_is_coroutine) {
  12121. return __Pyx_NewRef(op->func_is_coroutine);
  12122. }
  12123. result = __Pyx_CyFunction_get_is_coroutine_value(op);
  12124. if (unlikely(!result))
  12125. return NULL;
  12126. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12127. if (op->func_is_coroutine) {
  12128. Py_DECREF(result);
  12129. result = __Pyx_NewRef(op->func_is_coroutine);
  12130. } else {
  12131. op->func_is_coroutine = __Pyx_NewRef(result);
  12132. }
  12133. __Pyx_END_CRITICAL_SECTION();
  12134. return result;
  12135. }
  12136. static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) {
  12137. #if CYTHON_COMPILING_IN_LIMITED_API
  12138. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  12139. if (!py_name) return;
  12140. PyErr_Format(PyExc_TypeError,
  12141. "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  12142. py_name, message, size);
  12143. Py_DECREF(py_name);
  12144. #else
  12145. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  12146. PyErr_Format(PyExc_TypeError,
  12147. "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  12148. name, message, size);
  12149. #endif
  12150. }
  12151. static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) {
  12152. #if CYTHON_COMPILING_IN_LIMITED_API
  12153. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  12154. if (!py_name) return;
  12155. PyErr_Format(PyExc_TypeError,
  12156. "%.200S() %s",
  12157. py_name, message);
  12158. Py_DECREF(py_name);
  12159. #else
  12160. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  12161. PyErr_Format(PyExc_TypeError,
  12162. "%.200s() %s",
  12163. name, message);
  12164. #endif
  12165. }
  12166. #if CYTHON_COMPILING_IN_LIMITED_API
  12167. static PyObject *
  12168. __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
  12169. CYTHON_UNUSED_VAR(context);
  12170. return PyObject_GetAttrString(op->func, "__module__");
  12171. }
  12172. static int
  12173. __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  12174. CYTHON_UNUSED_VAR(context);
  12175. return PyObject_SetAttrString(op->func, "__module__", value);
  12176. }
  12177. #endif
  12178. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  12179. {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  12180. {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  12181. {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  12182. {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  12183. {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  12184. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  12185. {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  12186. {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  12187. #else
  12188. {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  12189. {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  12190. #endif
  12191. {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  12192. {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  12193. {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  12194. {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  12195. {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  12196. {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  12197. {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  12198. {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  12199. {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  12200. {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  12201. {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
  12202. #if CYTHON_COMPILING_IN_LIMITED_API
  12203. {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
  12204. #endif
  12205. {0, 0, 0, 0, 0}
  12206. };
  12207. static PyMemberDef __pyx_CyFunction_members[] = {
  12208. #if !CYTHON_COMPILING_IN_LIMITED_API
  12209. {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
  12210. #endif
  12211. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  12212. {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
  12213. #endif
  12214. #if CYTHON_METH_FASTCALL
  12215. #if CYTHON_COMPILING_IN_LIMITED_API
  12216. {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
  12217. #else
  12218. {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
  12219. #endif
  12220. #if CYTHON_COMPILING_IN_LIMITED_API
  12221. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
  12222. #else
  12223. {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
  12224. #endif
  12225. #endif
  12226. {0, 0, 0, 0, 0}
  12227. };
  12228. static PyObject *
  12229. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
  12230. {
  12231. PyObject *result = NULL;
  12232. CYTHON_UNUSED_VAR(args);
  12233. __Pyx_BEGIN_CRITICAL_SECTION(m);
  12234. Py_INCREF(m->func_qualname);
  12235. result = m->func_qualname;
  12236. __Pyx_END_CRITICAL_SECTION();
  12237. return result;
  12238. }
  12239. static PyMethodDef __pyx_CyFunction_methods[] = {
  12240. {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  12241. {0, 0, 0, 0}
  12242. };
  12243. #if CYTHON_COMPILING_IN_LIMITED_API
  12244. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  12245. #else
  12246. #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
  12247. #endif
  12248. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
  12249. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  12250. #if !CYTHON_COMPILING_IN_LIMITED_API
  12251. PyCFunctionObject *cf = (PyCFunctionObject*) op;
  12252. #endif
  12253. if (unlikely(op == NULL))
  12254. return NULL;
  12255. #if CYTHON_COMPILING_IN_LIMITED_API
  12256. op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
  12257. if (unlikely(!op->func)) return NULL;
  12258. #endif
  12259. op->flags = flags;
  12260. __Pyx_CyFunction_weakreflist(op) = NULL;
  12261. #if !CYTHON_COMPILING_IN_LIMITED_API
  12262. cf->m_ml = ml;
  12263. cf->m_self = (PyObject *) op;
  12264. #endif
  12265. Py_XINCREF(closure);
  12266. op->func_closure = closure;
  12267. #if !CYTHON_COMPILING_IN_LIMITED_API
  12268. Py_XINCREF(module);
  12269. cf->m_module = module;
  12270. #endif
  12271. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  12272. op->func_dict = NULL;
  12273. #endif
  12274. op->func_name = NULL;
  12275. Py_INCREF(qualname);
  12276. op->func_qualname = qualname;
  12277. op->func_doc = NULL;
  12278. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  12279. op->func_classobj = NULL;
  12280. #else
  12281. ((PyCMethodObject*)op)->mm_class = NULL;
  12282. #endif
  12283. op->func_globals = globals;
  12284. Py_INCREF(op->func_globals);
  12285. Py_XINCREF(code);
  12286. op->func_code = code;
  12287. op->defaults = NULL;
  12288. op->defaults_tuple = NULL;
  12289. op->defaults_kwdict = NULL;
  12290. op->defaults_getter = NULL;
  12291. op->func_annotations = NULL;
  12292. op->func_is_coroutine = NULL;
  12293. #if CYTHON_METH_FASTCALL
  12294. switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
  12295. case METH_NOARGS:
  12296. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
  12297. break;
  12298. case METH_O:
  12299. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
  12300. break;
  12301. case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
  12302. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
  12303. break;
  12304. case METH_FASTCALL | METH_KEYWORDS:
  12305. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
  12306. break;
  12307. case METH_VARARGS | METH_KEYWORDS:
  12308. __Pyx_CyFunction_func_vectorcall(op) = NULL;
  12309. break;
  12310. default:
  12311. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  12312. Py_DECREF(op);
  12313. return NULL;
  12314. }
  12315. #endif
  12316. return (PyObject *) op;
  12317. }
  12318. static int
  12319. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  12320. {
  12321. Py_CLEAR(m->func_closure);
  12322. #if CYTHON_COMPILING_IN_LIMITED_API
  12323. Py_CLEAR(m->func);
  12324. #else
  12325. Py_CLEAR(((PyCFunctionObject*)m)->m_module);
  12326. #endif
  12327. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  12328. Py_CLEAR(m->func_dict);
  12329. #elif PY_VERSION_HEX < 0x030d0000
  12330. _PyObject_ClearManagedDict((PyObject*)m);
  12331. #else
  12332. PyObject_ClearManagedDict((PyObject*)m);
  12333. #endif
  12334. Py_CLEAR(m->func_name);
  12335. Py_CLEAR(m->func_qualname);
  12336. Py_CLEAR(m->func_doc);
  12337. Py_CLEAR(m->func_globals);
  12338. Py_CLEAR(m->func_code);
  12339. #if !CYTHON_COMPILING_IN_LIMITED_API
  12340. #if PY_VERSION_HEX < 0x030900B1
  12341. Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
  12342. #else
  12343. {
  12344. PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
  12345. ((PyCMethodObject *) (m))->mm_class = NULL;
  12346. Py_XDECREF(cls);
  12347. }
  12348. #endif
  12349. #endif
  12350. Py_CLEAR(m->defaults_tuple);
  12351. Py_CLEAR(m->defaults_kwdict);
  12352. Py_CLEAR(m->func_annotations);
  12353. Py_CLEAR(m->func_is_coroutine);
  12354. Py_CLEAR(m->defaults);
  12355. return 0;
  12356. }
  12357. static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
  12358. {
  12359. if (__Pyx_CyFunction_weakreflist(m) != NULL)
  12360. PyObject_ClearWeakRefs((PyObject *) m);
  12361. __Pyx_CyFunction_clear(m);
  12362. __Pyx_PyHeapTypeObject_GC_Del(m);
  12363. }
  12364. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  12365. {
  12366. PyObject_GC_UnTrack(m);
  12367. __Pyx__CyFunction_dealloc(m);
  12368. }
  12369. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  12370. {
  12371. {
  12372. int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg);
  12373. if (e) return e;
  12374. }
  12375. Py_VISIT(m->func_closure);
  12376. #if CYTHON_COMPILING_IN_LIMITED_API
  12377. Py_VISIT(m->func);
  12378. #else
  12379. Py_VISIT(((PyCFunctionObject*)m)->m_module);
  12380. #endif
  12381. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  12382. Py_VISIT(m->func_dict);
  12383. #else
  12384. {
  12385. int e =
  12386. #if PY_VERSION_HEX < 0x030d0000
  12387. _PyObject_VisitManagedDict
  12388. #else
  12389. PyObject_VisitManagedDict
  12390. #endif
  12391. ((PyObject*)m, visit, arg);
  12392. if (e != 0) return e;
  12393. }
  12394. #endif
  12395. __Pyx_VISIT_CONST(m->func_name);
  12396. __Pyx_VISIT_CONST(m->func_qualname);
  12397. Py_VISIT(m->func_doc);
  12398. Py_VISIT(m->func_globals);
  12399. __Pyx_VISIT_CONST(m->func_code);
  12400. #if !CYTHON_COMPILING_IN_LIMITED_API
  12401. Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
  12402. #endif
  12403. Py_VISIT(m->defaults_tuple);
  12404. Py_VISIT(m->defaults_kwdict);
  12405. Py_VISIT(m->func_is_coroutine);
  12406. Py_VISIT(m->defaults);
  12407. return 0;
  12408. }
  12409. static PyObject*
  12410. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  12411. {
  12412. PyObject *repr;
  12413. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12414. repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
  12415. op->func_qualname, (void *)op);
  12416. __Pyx_END_CRITICAL_SECTION();
  12417. return repr;
  12418. }
  12419. static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  12420. #if CYTHON_COMPILING_IN_LIMITED_API
  12421. PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
  12422. PyCFunction meth;
  12423. int flags;
  12424. meth = PyCFunction_GetFunction(f);
  12425. if (unlikely(!meth)) return NULL;
  12426. flags = PyCFunction_GetFlags(f);
  12427. if (unlikely(flags < 0)) return NULL;
  12428. #else
  12429. PyCFunctionObject* f = (PyCFunctionObject*)func;
  12430. PyCFunction meth = f->m_ml->ml_meth;
  12431. int flags = f->m_ml->ml_flags;
  12432. #endif
  12433. Py_ssize_t size;
  12434. switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
  12435. case METH_VARARGS:
  12436. if (likely(kw == NULL || PyDict_Size(kw) == 0))
  12437. return (*meth)(self, arg);
  12438. break;
  12439. case METH_VARARGS | METH_KEYWORDS:
  12440. return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
  12441. case METH_NOARGS:
  12442. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  12443. #if CYTHON_ASSUME_SAFE_SIZE
  12444. size = PyTuple_GET_SIZE(arg);
  12445. #else
  12446. size = PyTuple_Size(arg);
  12447. if (unlikely(size < 0)) return NULL;
  12448. #endif
  12449. if (likely(size == 0))
  12450. return (*meth)(self, NULL);
  12451. __Pyx_CyFunction_raise_argument_count_error(
  12452. (__pyx_CyFunctionObject*)func,
  12453. "takes no arguments", size);
  12454. return NULL;
  12455. }
  12456. break;
  12457. case METH_O:
  12458. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  12459. #if CYTHON_ASSUME_SAFE_SIZE
  12460. size = PyTuple_GET_SIZE(arg);
  12461. #else
  12462. size = PyTuple_Size(arg);
  12463. if (unlikely(size < 0)) return NULL;
  12464. #endif
  12465. if (likely(size == 1)) {
  12466. PyObject *result, *arg0;
  12467. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  12468. arg0 = PyTuple_GET_ITEM(arg, 0);
  12469. #else
  12470. arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
  12471. #endif
  12472. result = (*meth)(self, arg0);
  12473. #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  12474. Py_DECREF(arg0);
  12475. #endif
  12476. return result;
  12477. }
  12478. __Pyx_CyFunction_raise_argument_count_error(
  12479. (__pyx_CyFunctionObject*)func,
  12480. "takes exactly one argument", size);
  12481. return NULL;
  12482. }
  12483. break;
  12484. default:
  12485. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  12486. return NULL;
  12487. }
  12488. __Pyx_CyFunction_raise_type_error(
  12489. (__pyx_CyFunctionObject*)func, "takes no keyword arguments");
  12490. return NULL;
  12491. }
  12492. static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  12493. PyObject *self, *result;
  12494. #if CYTHON_COMPILING_IN_LIMITED_API
  12495. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
  12496. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  12497. #else
  12498. self = ((PyCFunctionObject*)func)->m_self;
  12499. #endif
  12500. result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
  12501. return result;
  12502. }
  12503. static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
  12504. PyObject *result;
  12505. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  12506. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  12507. __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
  12508. if (vc) {
  12509. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  12510. return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
  12511. #else
  12512. (void) &__Pyx_PyVectorcall_FastCallDict;
  12513. return PyVectorcall_Call(func, args, kw);
  12514. #endif
  12515. }
  12516. #endif
  12517. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  12518. Py_ssize_t argc;
  12519. PyObject *new_args;
  12520. PyObject *self;
  12521. #if CYTHON_ASSUME_SAFE_SIZE
  12522. argc = PyTuple_GET_SIZE(args);
  12523. #else
  12524. argc = PyTuple_Size(args);
  12525. if (unlikely(argc < 0)) return NULL;
  12526. #endif
  12527. new_args = PyTuple_GetSlice(args, 1, argc);
  12528. if (unlikely(!new_args))
  12529. return NULL;
  12530. self = PyTuple_GetItem(args, 0);
  12531. if (unlikely(!self)) {
  12532. Py_DECREF(new_args);
  12533. PyErr_Format(PyExc_TypeError,
  12534. "unbound method %.200S() needs an argument",
  12535. cyfunc->func_qualname);
  12536. return NULL;
  12537. }
  12538. result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
  12539. Py_DECREF(new_args);
  12540. } else {
  12541. result = __Pyx_CyFunction_Call(func, args, kw);
  12542. }
  12543. return result;
  12544. }
  12545. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  12546. static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
  12547. {
  12548. int ret = 0;
  12549. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  12550. if (unlikely(nargs < 1)) {
  12551. __Pyx_CyFunction_raise_type_error(
  12552. cyfunc, "needs an argument");
  12553. return -1;
  12554. }
  12555. ret = 1;
  12556. }
  12557. if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
  12558. __Pyx_CyFunction_raise_type_error(
  12559. cyfunc, "takes no keyword arguments");
  12560. return -1;
  12561. }
  12562. return ret;
  12563. }
  12564. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  12565. {
  12566. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  12567. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  12568. PyObject *self;
  12569. #if CYTHON_COMPILING_IN_LIMITED_API
  12570. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  12571. if (unlikely(!meth)) return NULL;
  12572. #else
  12573. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  12574. #endif
  12575. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  12576. case 1:
  12577. self = args[0];
  12578. args += 1;
  12579. nargs -= 1;
  12580. break;
  12581. case 0:
  12582. #if CYTHON_COMPILING_IN_LIMITED_API
  12583. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  12584. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  12585. #else
  12586. self = ((PyCFunctionObject*)cyfunc)->m_self;
  12587. #endif
  12588. break;
  12589. default:
  12590. return NULL;
  12591. }
  12592. if (unlikely(nargs != 0)) {
  12593. __Pyx_CyFunction_raise_argument_count_error(
  12594. cyfunc, "takes no arguments", nargs);
  12595. return NULL;
  12596. }
  12597. return meth(self, NULL);
  12598. }
  12599. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  12600. {
  12601. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  12602. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  12603. PyObject *self;
  12604. #if CYTHON_COMPILING_IN_LIMITED_API
  12605. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  12606. if (unlikely(!meth)) return NULL;
  12607. #else
  12608. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  12609. #endif
  12610. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  12611. case 1:
  12612. self = args[0];
  12613. args += 1;
  12614. nargs -= 1;
  12615. break;
  12616. case 0:
  12617. #if CYTHON_COMPILING_IN_LIMITED_API
  12618. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  12619. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  12620. #else
  12621. self = ((PyCFunctionObject*)cyfunc)->m_self;
  12622. #endif
  12623. break;
  12624. default:
  12625. return NULL;
  12626. }
  12627. if (unlikely(nargs != 1)) {
  12628. __Pyx_CyFunction_raise_argument_count_error(
  12629. cyfunc, "takes exactly one argument", nargs);
  12630. return NULL;
  12631. }
  12632. return meth(self, args[0]);
  12633. }
  12634. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  12635. {
  12636. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  12637. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  12638. PyObject *self;
  12639. #if CYTHON_COMPILING_IN_LIMITED_API
  12640. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  12641. if (unlikely(!meth)) return NULL;
  12642. #else
  12643. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  12644. #endif
  12645. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  12646. case 1:
  12647. self = args[0];
  12648. args += 1;
  12649. nargs -= 1;
  12650. break;
  12651. case 0:
  12652. #if CYTHON_COMPILING_IN_LIMITED_API
  12653. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  12654. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  12655. #else
  12656. self = ((PyCFunctionObject*)cyfunc)->m_self;
  12657. #endif
  12658. break;
  12659. default:
  12660. return NULL;
  12661. }
  12662. return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
  12663. }
  12664. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  12665. {
  12666. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  12667. PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
  12668. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  12669. PyObject *self;
  12670. #if CYTHON_COMPILING_IN_LIMITED_API
  12671. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  12672. if (unlikely(!meth)) return NULL;
  12673. #else
  12674. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  12675. #endif
  12676. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  12677. case 1:
  12678. self = args[0];
  12679. args += 1;
  12680. nargs -= 1;
  12681. break;
  12682. case 0:
  12683. #if CYTHON_COMPILING_IN_LIMITED_API
  12684. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  12685. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  12686. #else
  12687. self = ((PyCFunctionObject*)cyfunc)->m_self;
  12688. #endif
  12689. break;
  12690. default:
  12691. return NULL;
  12692. }
  12693. #if PY_VERSION_HEX < 0x030e00A6
  12694. size_t nargs_value = (size_t) nargs;
  12695. #else
  12696. Py_ssize_t nargs_value = nargs;
  12697. #endif
  12698. return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames);
  12699. }
  12700. #endif
  12701. static PyType_Slot __pyx_CyFunctionType_slots[] = {
  12702. {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
  12703. {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
  12704. {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
  12705. {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
  12706. {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
  12707. {Py_tp_methods, (void *)__pyx_CyFunction_methods},
  12708. {Py_tp_members, (void *)__pyx_CyFunction_members},
  12709. {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
  12710. {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
  12711. {0, 0},
  12712. };
  12713. static PyType_Spec __pyx_CyFunctionType_spec = {
  12714. __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
  12715. sizeof(__pyx_CyFunctionObject),
  12716. 0,
  12717. #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
  12718. Py_TPFLAGS_METHOD_DESCRIPTOR |
  12719. #endif
  12720. #if CYTHON_METH_FASTCALL
  12721. #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
  12722. Py_TPFLAGS_HAVE_VECTORCALL |
  12723. #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
  12724. _Py_TPFLAGS_HAVE_VECTORCALL |
  12725. #endif
  12726. #endif // CYTHON_METH_FASTCALL
  12727. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  12728. Py_TPFLAGS_MANAGED_DICT |
  12729. #endif
  12730. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  12731. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
  12732. __pyx_CyFunctionType_slots
  12733. };
  12734. static int __pyx_CyFunction_init(PyObject *module) {
  12735. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  12736. mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(
  12737. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL);
  12738. if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
  12739. return -1;
  12740. }
  12741. return 0;
  12742. }
  12743. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
  12744. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12745. m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
  12746. if (unlikely(!m->defaults))
  12747. return NULL;
  12748. return m->defaults;
  12749. }
  12750. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  12751. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12752. m->defaults_tuple = tuple;
  12753. Py_INCREF(tuple);
  12754. }
  12755. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  12756. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12757. m->defaults_kwdict = dict;
  12758. Py_INCREF(dict);
  12759. }
  12760. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  12761. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  12762. m->func_annotations = dict;
  12763. Py_INCREF(dict);
  12764. }
  12765. /* CythonFunction */
  12766. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
  12767. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  12768. PyObject *op = __Pyx_CyFunction_Init(
  12769. PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType),
  12770. ml, flags, qualname, closure, module, globals, code
  12771. );
  12772. if (likely(op)) {
  12773. PyObject_GC_Track(op);
  12774. }
  12775. return op;
  12776. }
  12777. /* ObjectGetItem */
  12778. #if CYTHON_USE_TYPE_SLOTS
  12779. static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
  12780. PyObject *runerr = NULL;
  12781. Py_ssize_t key_value;
  12782. key_value = __Pyx_PyIndex_AsSsize_t(index);
  12783. if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
  12784. return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1, 1);
  12785. }
  12786. if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
  12787. __Pyx_TypeName index_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(index));
  12788. PyErr_Clear();
  12789. PyErr_Format(PyExc_IndexError,
  12790. "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name);
  12791. __Pyx_DECREF_TypeName(index_type_name);
  12792. }
  12793. return NULL;
  12794. }
  12795. static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
  12796. __Pyx_TypeName obj_type_name;
  12797. if (likely(PyType_Check(obj))) {
  12798. PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, __pyx_mstate_global->__pyx_n_u_class_getitem);
  12799. if (!meth) {
  12800. PyErr_Clear();
  12801. } else {
  12802. PyObject *result = __Pyx_PyObject_CallOneArg(meth, key);
  12803. Py_DECREF(meth);
  12804. return result;
  12805. }
  12806. }
  12807. obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  12808. PyErr_Format(PyExc_TypeError,
  12809. "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name);
  12810. __Pyx_DECREF_TypeName(obj_type_name);
  12811. return NULL;
  12812. }
  12813. static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) {
  12814. PyTypeObject *tp = Py_TYPE(obj);
  12815. PyMappingMethods *mm = tp->tp_as_mapping;
  12816. PySequenceMethods *sm = tp->tp_as_sequence;
  12817. if (likely(mm && mm->mp_subscript)) {
  12818. return mm->mp_subscript(obj, key);
  12819. }
  12820. if (likely(sm && sm->sq_item)) {
  12821. return __Pyx_PyObject_GetIndex(obj, key);
  12822. }
  12823. return __Pyx_PyObject_GetItem_Slow(obj, key);
  12824. }
  12825. #endif
  12826. /* CLineInTraceback (used by AddTraceback) */
  12827. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  12828. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  12829. #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
  12830. #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12831. #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
  12832. #else
  12833. PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
  12834. PyObject **dict_ptr = _PyObject_GetDictPtr(o);
  12835. return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
  12836. }
  12837. #endif
  12838. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
  12839. PyObject *use_cline = NULL;
  12840. PyObject *ptype, *pvalue, *ptraceback;
  12841. PyObject *cython_runtime_dict;
  12842. CYTHON_MAYBE_UNUSED_VAR(tstate);
  12843. if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) {
  12844. return c_line;
  12845. }
  12846. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  12847. cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime);
  12848. if (likely(cython_runtime_dict)) {
  12849. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  12850. use_cline, cython_runtime_dict,
  12851. __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False))
  12852. }
  12853. if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  12854. c_line = 0;
  12855. }
  12856. Py_XDECREF(use_cline);
  12857. Py_XDECREF(cython_runtime_dict);
  12858. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  12859. return c_line;
  12860. }
  12861. #endif
  12862. /* CodeObjectCache (used by AddTraceback) */
  12863. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  12864. int start = 0, mid = 0, end = count - 1;
  12865. if (end >= 0 && code_line > entries[end].code_line) {
  12866. return count;
  12867. }
  12868. while (start < end) {
  12869. mid = start + (end - start) / 2;
  12870. if (code_line < entries[mid].code_line) {
  12871. end = mid;
  12872. } else if (code_line > entries[mid].code_line) {
  12873. start = mid + 1;
  12874. } else {
  12875. return mid;
  12876. }
  12877. }
  12878. if (code_line <= entries[mid].code_line) {
  12879. return mid;
  12880. } else {
  12881. return mid + 1;
  12882. }
  12883. }
  12884. static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) {
  12885. __Pyx_CachedCodeObjectType* code_object;
  12886. int pos;
  12887. if (unlikely(!code_line) || unlikely(!code_cache->entries)) {
  12888. return NULL;
  12889. }
  12890. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  12891. if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) {
  12892. return NULL;
  12893. }
  12894. code_object = code_cache->entries[pos].code_object;
  12895. Py_INCREF(code_object);
  12896. return code_object;
  12897. }
  12898. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) {
  12899. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  12900. (void)__pyx__find_code_object;
  12901. return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss.
  12902. #else
  12903. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  12904. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12905. __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count);
  12906. if (old_count < 0) {
  12907. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  12908. return NULL;
  12909. }
  12910. #endif
  12911. __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line);
  12912. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12913. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  12914. #endif
  12915. return result;
  12916. #endif
  12917. }
  12918. static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object)
  12919. {
  12920. int pos, i;
  12921. __Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
  12922. if (unlikely(!code_line)) {
  12923. return;
  12924. }
  12925. if (unlikely(!entries)) {
  12926. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  12927. if (likely(entries)) {
  12928. code_cache->entries = entries;
  12929. code_cache->max_count = 64;
  12930. code_cache->count = 1;
  12931. entries[0].code_line = code_line;
  12932. entries[0].code_object = code_object;
  12933. Py_INCREF(code_object);
  12934. }
  12935. return;
  12936. }
  12937. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  12938. if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) {
  12939. __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object;
  12940. entries[pos].code_object = code_object;
  12941. Py_INCREF(code_object);
  12942. Py_DECREF(tmp);
  12943. return;
  12944. }
  12945. if (code_cache->count == code_cache->max_count) {
  12946. int new_max = code_cache->max_count + 64;
  12947. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  12948. code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
  12949. if (unlikely(!entries)) {
  12950. return;
  12951. }
  12952. code_cache->entries = entries;
  12953. code_cache->max_count = new_max;
  12954. }
  12955. for (i=code_cache->count; i>pos; i--) {
  12956. entries[i] = entries[i-1];
  12957. }
  12958. entries[pos].code_line = code_line;
  12959. entries[pos].code_object = code_object;
  12960. code_cache->count++;
  12961. Py_INCREF(code_object);
  12962. }
  12963. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) {
  12964. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  12965. (void)__pyx__insert_code_object;
  12966. return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail.
  12967. #else
  12968. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  12969. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12970. __pyx_nonatomic_int_type expected = 0;
  12971. if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) {
  12972. return;
  12973. }
  12974. #endif
  12975. __pyx__insert_code_object(code_cache, code_line, code_object);
  12976. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12977. __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN);
  12978. #endif
  12979. #endif
  12980. }
  12981. /* AddTraceback */
  12982. #include "compile.h"
  12983. #include "frameobject.h"
  12984. #include "traceback.h"
  12985. #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
  12986. #ifndef Py_BUILD_CORE
  12987. #define Py_BUILD_CORE 1
  12988. #endif
  12989. #include "internal/pycore_frame.h"
  12990. #endif
  12991. #if CYTHON_COMPILING_IN_LIMITED_API
  12992. static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
  12993. PyObject *firstlineno, PyObject *name) {
  12994. PyObject *replace = NULL;
  12995. if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
  12996. if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
  12997. replace = PyObject_GetAttrString(code, "replace");
  12998. if (likely(replace)) {
  12999. PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict);
  13000. Py_DECREF(replace);
  13001. return result;
  13002. }
  13003. PyErr_Clear();
  13004. return NULL;
  13005. }
  13006. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  13007. int py_line, const char *filename) {
  13008. PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
  13009. PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
  13010. PyObject *exc_type, *exc_value, *exc_traceback;
  13011. int success = 0;
  13012. if (c_line) {
  13013. c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
  13014. }
  13015. PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
  13016. code_object = __pyx_find_code_object(c_line ? -c_line : py_line);
  13017. if (!code_object) {
  13018. code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
  13019. if (unlikely(!code_object)) goto bad;
  13020. py_py_line = PyLong_FromLong(py_line);
  13021. if (unlikely(!py_py_line)) goto bad;
  13022. if (c_line) {
  13023. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  13024. } else {
  13025. py_funcname = PyUnicode_FromString(funcname);
  13026. }
  13027. if (unlikely(!py_funcname)) goto bad;
  13028. dict = PyDict_New();
  13029. if (unlikely(!dict)) goto bad;
  13030. {
  13031. PyObject *old_code_object = code_object;
  13032. code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
  13033. Py_DECREF(old_code_object);
  13034. }
  13035. if (unlikely(!code_object)) goto bad;
  13036. __pyx_insert_code_object(c_line ? -c_line : py_line, code_object);
  13037. } else {
  13038. dict = PyDict_New();
  13039. }
  13040. getframe = PySys_GetObject("_getframe");
  13041. if (unlikely(!getframe)) goto bad;
  13042. if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
  13043. frame = PyEval_EvalCode(code_object, dict, dict);
  13044. if (unlikely(!frame) || frame == Py_None) goto bad;
  13045. success = 1;
  13046. bad:
  13047. PyErr_Restore(exc_type, exc_value, exc_traceback);
  13048. Py_XDECREF(code_object);
  13049. Py_XDECREF(py_py_line);
  13050. Py_XDECREF(py_funcname);
  13051. Py_XDECREF(dict);
  13052. Py_XDECREF(replace);
  13053. if (success) {
  13054. PyTraceBack_Here(
  13055. (struct _frame*)frame);
  13056. }
  13057. Py_XDECREF(frame);
  13058. }
  13059. #else
  13060. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  13061. const char *funcname, int c_line,
  13062. int py_line, const char *filename) {
  13063. PyCodeObject *py_code = NULL;
  13064. PyObject *py_funcname = NULL;
  13065. if (c_line) {
  13066. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  13067. if (!py_funcname) goto bad;
  13068. funcname = PyUnicode_AsUTF8(py_funcname);
  13069. if (!funcname) goto bad;
  13070. }
  13071. py_code = PyCode_NewEmpty(filename, funcname, py_line);
  13072. Py_XDECREF(py_funcname);
  13073. return py_code;
  13074. bad:
  13075. Py_XDECREF(py_funcname);
  13076. return NULL;
  13077. }
  13078. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  13079. int py_line, const char *filename) {
  13080. PyCodeObject *py_code = 0;
  13081. PyFrameObject *py_frame = 0;
  13082. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  13083. PyObject *ptype, *pvalue, *ptraceback;
  13084. if (c_line) {
  13085. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  13086. }
  13087. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  13088. if (!py_code) {
  13089. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  13090. py_code = __Pyx_CreateCodeObjectForTraceback(
  13091. funcname, c_line, py_line, filename);
  13092. if (!py_code) {
  13093. /* If the code object creation fails, then we should clear the
  13094. fetched exception references and propagate the new exception */
  13095. Py_XDECREF(ptype);
  13096. Py_XDECREF(pvalue);
  13097. Py_XDECREF(ptraceback);
  13098. goto bad;
  13099. }
  13100. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  13101. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  13102. }
  13103. py_frame = PyFrame_New(
  13104. tstate, /*PyThreadState *tstate,*/
  13105. py_code, /*PyCodeObject *code,*/
  13106. __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/
  13107. 0 /*PyObject *locals*/
  13108. );
  13109. if (!py_frame) goto bad;
  13110. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  13111. PyTraceBack_Here(py_frame);
  13112. bad:
  13113. Py_XDECREF(py_code);
  13114. Py_XDECREF(py_frame);
  13115. }
  13116. #endif
  13117. /* Declarations */
  13118. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  13119. #ifdef __cplusplus
  13120. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  13121. return ::std::complex< double >(x, y);
  13122. }
  13123. #else
  13124. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  13125. return x + y*(__pyx_t_double_complex)_Complex_I;
  13126. }
  13127. #endif
  13128. #else
  13129. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  13130. __pyx_t_double_complex z;
  13131. z.real = x;
  13132. z.imag = y;
  13133. return z;
  13134. }
  13135. #endif
  13136. /* Arithmetic */
  13137. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  13138. #else
  13139. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  13140. return (a.real == b.real) && (a.imag == b.imag);
  13141. }
  13142. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  13143. __pyx_t_double_complex z;
  13144. z.real = a.real + b.real;
  13145. z.imag = a.imag + b.imag;
  13146. return z;
  13147. }
  13148. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  13149. __pyx_t_double_complex z;
  13150. z.real = a.real - b.real;
  13151. z.imag = a.imag - b.imag;
  13152. return z;
  13153. }
  13154. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  13155. __pyx_t_double_complex z;
  13156. z.real = a.real * b.real - a.imag * b.imag;
  13157. z.imag = a.real * b.imag + a.imag * b.real;
  13158. return z;
  13159. }
  13160. #if 1
  13161. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  13162. if (b.imag == 0) {
  13163. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  13164. } else if (fabs(b.real) >= fabs(b.imag)) {
  13165. if (b.real == 0 && b.imag == 0) {
  13166. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
  13167. } else {
  13168. double r = b.imag / b.real;
  13169. double s = (double)(1.0) / (b.real + b.imag * r);
  13170. return __pyx_t_double_complex_from_parts(
  13171. (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
  13172. }
  13173. } else {
  13174. double r = b.real / b.imag;
  13175. double s = (double)(1.0) / (b.imag + b.real * r);
  13176. return __pyx_t_double_complex_from_parts(
  13177. (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
  13178. }
  13179. }
  13180. #else
  13181. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  13182. if (b.imag == 0) {
  13183. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  13184. } else {
  13185. double denom = b.real * b.real + b.imag * b.imag;
  13186. return __pyx_t_double_complex_from_parts(
  13187. (a.real * b.real + a.imag * b.imag) / denom,
  13188. (a.imag * b.real - a.real * b.imag) / denom);
  13189. }
  13190. }
  13191. #endif
  13192. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
  13193. __pyx_t_double_complex z;
  13194. z.real = -a.real;
  13195. z.imag = -a.imag;
  13196. return z;
  13197. }
  13198. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
  13199. return (a.real == 0) && (a.imag == 0);
  13200. }
  13201. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
  13202. __pyx_t_double_complex z;
  13203. z.real = a.real;
  13204. z.imag = -a.imag;
  13205. return z;
  13206. }
  13207. #if 1
  13208. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
  13209. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  13210. return sqrt(z.real*z.real + z.imag*z.imag);
  13211. #else
  13212. return hypot(z.real, z.imag);
  13213. #endif
  13214. }
  13215. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  13216. __pyx_t_double_complex z;
  13217. double r, lnr, theta, z_r, z_theta;
  13218. if (b.imag == 0 && b.real == (int)b.real) {
  13219. if (b.real < 0) {
  13220. double denom = a.real * a.real + a.imag * a.imag;
  13221. a.real = a.real / denom;
  13222. a.imag = -a.imag / denom;
  13223. b.real = -b.real;
  13224. }
  13225. switch ((int)b.real) {
  13226. case 0:
  13227. z.real = 1;
  13228. z.imag = 0;
  13229. return z;
  13230. case 1:
  13231. return a;
  13232. case 2:
  13233. return __Pyx_c_prod_double(a, a);
  13234. case 3:
  13235. z = __Pyx_c_prod_double(a, a);
  13236. return __Pyx_c_prod_double(z, a);
  13237. case 4:
  13238. z = __Pyx_c_prod_double(a, a);
  13239. return __Pyx_c_prod_double(z, z);
  13240. }
  13241. }
  13242. if (a.imag == 0) {
  13243. if (a.real == 0) {
  13244. return a;
  13245. } else if ((b.imag == 0) && (a.real >= 0)) {
  13246. z.real = pow(a.real, b.real);
  13247. z.imag = 0;
  13248. return z;
  13249. } else if (a.real > 0) {
  13250. r = a.real;
  13251. theta = 0;
  13252. } else {
  13253. r = -a.real;
  13254. theta = atan2(0.0, -1.0);
  13255. }
  13256. } else {
  13257. r = __Pyx_c_abs_double(a);
  13258. theta = atan2(a.imag, a.real);
  13259. }
  13260. lnr = log(r);
  13261. z_r = exp(lnr * b.real - theta * b.imag);
  13262. z_theta = theta * b.real + lnr * b.imag;
  13263. z.real = z_r * cos(z_theta);
  13264. z.imag = z_r * sin(z_theta);
  13265. return z;
  13266. }
  13267. #endif
  13268. #endif
  13269. /* FromPy */
  13270. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
  13271. #if CYTHON_COMPILING_IN_LIMITED_API
  13272. double real=-1.0, imag=-1.0;
  13273. real = PyComplex_RealAsDouble(o);
  13274. if (unlikely(real == -1.0 && PyErr_Occurred())) goto end;
  13275. imag = PyComplex_ImagAsDouble(o);
  13276. end:
  13277. return __pyx_t_double_complex_from_parts(
  13278. (double)real, (double)imag
  13279. );
  13280. #else
  13281. Py_complex cval;
  13282. #if !CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_GRAAL
  13283. if (PyComplex_CheckExact(o))
  13284. cval = ((PyComplexObject *)o)->cval;
  13285. else
  13286. #endif
  13287. cval = PyComplex_AsCComplex(o);
  13288. return __pyx_t_double_complex_from_parts(
  13289. (double)cval.real,
  13290. (double)cval.imag);
  13291. #endif
  13292. }
  13293. /* CIntFromPyVerify */
  13294. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  13295. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  13296. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  13297. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  13298. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  13299. {\
  13300. func_type value = func_value;\
  13301. if (sizeof(target_type) < sizeof(func_type)) {\
  13302. if (unlikely(value != (func_type) (target_type) value)) {\
  13303. func_type zero = 0;\
  13304. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  13305. return (target_type) -1;\
  13306. if (is_unsigned && unlikely(value < zero))\
  13307. goto raise_neg_overflow;\
  13308. else\
  13309. goto raise_overflow;\
  13310. }\
  13311. }\
  13312. return (target_type) value;\
  13313. }
  13314. /* CIntFromPy */
  13315. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) {
  13316. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13317. #pragma GCC diagnostic push
  13318. #pragma GCC diagnostic ignored "-Wconversion"
  13319. #endif
  13320. const int neg_one = (int) -1, const_zero = (int) 0;
  13321. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13322. #pragma GCC diagnostic pop
  13323. #endif
  13324. const int is_unsigned = neg_one > const_zero;
  13325. if (unlikely(!PyLong_Check(x))) {
  13326. int val;
  13327. PyObject *tmp = __Pyx_PyNumber_Long(x);
  13328. if (!tmp) return (int) -1;
  13329. val = __Pyx_PyLong_As_int(tmp);
  13330. Py_DECREF(tmp);
  13331. return val;
  13332. }
  13333. if (is_unsigned) {
  13334. #if CYTHON_USE_PYLONG_INTERNALS
  13335. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  13336. goto raise_neg_overflow;
  13337. } else if (__Pyx_PyLong_IsCompact(x)) {
  13338. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  13339. } else {
  13340. const digit* digits = __Pyx_PyLong_Digits(x);
  13341. assert(__Pyx_PyLong_DigitCount(x) > 1);
  13342. switch (__Pyx_PyLong_DigitCount(x)) {
  13343. case 2:
  13344. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  13345. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13346. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13347. } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
  13348. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  13349. }
  13350. }
  13351. break;
  13352. case 3:
  13353. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  13354. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13355. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13356. } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
  13357. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  13358. }
  13359. }
  13360. break;
  13361. case 4:
  13362. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  13363. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13364. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13365. } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
  13366. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  13367. }
  13368. }
  13369. break;
  13370. }
  13371. }
  13372. #endif
  13373. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  13374. if (unlikely(Py_SIZE(x) < 0)) {
  13375. goto raise_neg_overflow;
  13376. }
  13377. #else
  13378. {
  13379. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  13380. if (unlikely(result < 0))
  13381. return (int) -1;
  13382. if (unlikely(result == 1))
  13383. goto raise_neg_overflow;
  13384. }
  13385. #endif
  13386. if ((sizeof(int) <= sizeof(unsigned long))) {
  13387. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  13388. } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
  13389. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  13390. }
  13391. } else {
  13392. #if CYTHON_USE_PYLONG_INTERNALS
  13393. if (__Pyx_PyLong_IsCompact(x)) {
  13394. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  13395. } else {
  13396. const digit* digits = __Pyx_PyLong_Digits(x);
  13397. assert(__Pyx_PyLong_DigitCount(x) > 1);
  13398. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  13399. case -2:
  13400. if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
  13401. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13402. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13403. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  13404. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  13405. }
  13406. }
  13407. break;
  13408. case 2:
  13409. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  13410. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13411. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13412. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  13413. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  13414. }
  13415. }
  13416. break;
  13417. case -3:
  13418. if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  13419. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13420. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13421. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  13422. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  13423. }
  13424. }
  13425. break;
  13426. case 3:
  13427. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  13428. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13429. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13430. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  13431. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  13432. }
  13433. }
  13434. break;
  13435. case -4:
  13436. if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  13437. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13438. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13439. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  13440. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  13441. }
  13442. }
  13443. break;
  13444. case 4:
  13445. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  13446. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13447. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13448. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  13449. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  13450. }
  13451. }
  13452. break;
  13453. }
  13454. }
  13455. #endif
  13456. if ((sizeof(int) <= sizeof(long))) {
  13457. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  13458. } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
  13459. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  13460. }
  13461. }
  13462. {
  13463. int val;
  13464. int ret = -1;
  13465. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  13466. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  13467. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  13468. if (unlikely(bytes_copied == -1)) {
  13469. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  13470. goto raise_overflow;
  13471. } else {
  13472. ret = 0;
  13473. }
  13474. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  13475. int one = 1; int is_little = (int)*(unsigned char *)&one;
  13476. unsigned char *bytes = (unsigned char *)&val;
  13477. ret = _PyLong_AsByteArray((PyLongObject *)x,
  13478. bytes, sizeof(val),
  13479. is_little, !is_unsigned);
  13480. #else
  13481. PyObject *v;
  13482. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  13483. int bits, remaining_bits, is_negative = 0;
  13484. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  13485. if (likely(PyLong_CheckExact(x))) {
  13486. v = __Pyx_NewRef(x);
  13487. } else {
  13488. v = PyNumber_Long(x);
  13489. if (unlikely(!v)) return (int) -1;
  13490. assert(PyLong_CheckExact(v));
  13491. }
  13492. {
  13493. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  13494. if (unlikely(result < 0)) {
  13495. Py_DECREF(v);
  13496. return (int) -1;
  13497. }
  13498. is_negative = result == 1;
  13499. }
  13500. if (is_unsigned && unlikely(is_negative)) {
  13501. Py_DECREF(v);
  13502. goto raise_neg_overflow;
  13503. } else if (is_negative) {
  13504. stepval = PyNumber_Invert(v);
  13505. Py_DECREF(v);
  13506. if (unlikely(!stepval))
  13507. return (int) -1;
  13508. } else {
  13509. stepval = v;
  13510. }
  13511. v = NULL;
  13512. val = (int) 0;
  13513. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  13514. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  13515. for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
  13516. PyObject *tmp, *digit;
  13517. long idigit;
  13518. digit = PyNumber_And(stepval, mask);
  13519. if (unlikely(!digit)) goto done;
  13520. idigit = PyLong_AsLong(digit);
  13521. Py_DECREF(digit);
  13522. if (unlikely(idigit < 0)) goto done;
  13523. val |= ((int) idigit) << bits;
  13524. tmp = PyNumber_Rshift(stepval, shift);
  13525. if (unlikely(!tmp)) goto done;
  13526. Py_DECREF(stepval); stepval = tmp;
  13527. }
  13528. Py_DECREF(shift); shift = NULL;
  13529. Py_DECREF(mask); mask = NULL;
  13530. {
  13531. long idigit = PyLong_AsLong(stepval);
  13532. if (unlikely(idigit < 0)) goto done;
  13533. remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
  13534. if (unlikely(idigit >= (1L << remaining_bits)))
  13535. goto raise_overflow;
  13536. val |= ((int) idigit) << bits;
  13537. }
  13538. if (!is_unsigned) {
  13539. if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
  13540. goto raise_overflow;
  13541. if (is_negative)
  13542. val = ~val;
  13543. }
  13544. ret = 0;
  13545. done:
  13546. Py_XDECREF(shift);
  13547. Py_XDECREF(mask);
  13548. Py_XDECREF(stepval);
  13549. #endif
  13550. if (unlikely(ret))
  13551. return (int) -1;
  13552. return val;
  13553. }
  13554. raise_overflow:
  13555. PyErr_SetString(PyExc_OverflowError,
  13556. "value too large to convert to int");
  13557. return (int) -1;
  13558. raise_neg_overflow:
  13559. PyErr_SetString(PyExc_OverflowError,
  13560. "can't convert negative value to int");
  13561. return (int) -1;
  13562. }
  13563. /* PyObjectVectorCallKwBuilder (used by CIntToPy) */
  13564. #if CYTHON_VECTORCALL
  13565. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  13566. (void)__Pyx_PyObject_FastCallDict;
  13567. if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1;
  13568. Py_INCREF(key);
  13569. args[n] = value;
  13570. return 0;
  13571. }
  13572. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  13573. (void)__Pyx_VectorcallBuilder_AddArgStr;
  13574. if (unlikely(!PyUnicode_Check(key))) {
  13575. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  13576. return -1;
  13577. }
  13578. return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n);
  13579. }
  13580. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  13581. PyObject *pyKey = PyUnicode_FromString(key);
  13582. if (!pyKey) return -1;
  13583. return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n);
  13584. }
  13585. #else // CYTHON_VECTORCALL
  13586. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) {
  13587. if (unlikely(!PyUnicode_Check(key))) {
  13588. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  13589. return -1;
  13590. }
  13591. return PyDict_SetItem(builder, key, value);
  13592. }
  13593. #endif
  13594. /* CIntToPy */
  13595. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value) {
  13596. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13597. #pragma GCC diagnostic push
  13598. #pragma GCC diagnostic ignored "-Wconversion"
  13599. #endif
  13600. const int neg_one = (int) -1, const_zero = (int) 0;
  13601. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13602. #pragma GCC diagnostic pop
  13603. #endif
  13604. const int is_unsigned = neg_one > const_zero;
  13605. if (is_unsigned) {
  13606. if (sizeof(int) < sizeof(long)) {
  13607. return PyLong_FromLong((long) value);
  13608. } else if (sizeof(int) <= sizeof(unsigned long)) {
  13609. return PyLong_FromUnsignedLong((unsigned long) value);
  13610. #if !CYTHON_COMPILING_IN_PYPY
  13611. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  13612. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  13613. #endif
  13614. }
  13615. } else {
  13616. if (sizeof(int) <= sizeof(long)) {
  13617. return PyLong_FromLong((long) value);
  13618. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  13619. return PyLong_FromLongLong((PY_LONG_LONG) value);
  13620. }
  13621. }
  13622. {
  13623. unsigned char *bytes = (unsigned char *)&value;
  13624. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  13625. if (is_unsigned) {
  13626. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  13627. } else {
  13628. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  13629. }
  13630. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  13631. int one = 1; int little = (int)*(unsigned char *)&one;
  13632. return _PyLong_FromByteArray(bytes, sizeof(int),
  13633. little, !is_unsigned);
  13634. #else
  13635. int one = 1; int little = (int)*(unsigned char *)&one;
  13636. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  13637. PyObject *py_bytes = NULL, *order_str = NULL;
  13638. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  13639. if (!from_bytes) return NULL;
  13640. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int));
  13641. if (!py_bytes) goto limited_bad;
  13642. order_str = PyUnicode_FromString(little ? "little" : "big");
  13643. if (!order_str) goto limited_bad;
  13644. {
  13645. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  13646. if (!is_unsigned) {
  13647. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  13648. if (!kwds) goto limited_bad;
  13649. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  13650. }
  13651. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  13652. }
  13653. limited_bad:
  13654. Py_XDECREF(kwds);
  13655. Py_XDECREF(order_str);
  13656. Py_XDECREF(py_bytes);
  13657. Py_XDECREF(from_bytes);
  13658. return result;
  13659. #endif
  13660. }
  13661. }
  13662. /* CIntToPy */
  13663. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) {
  13664. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13665. #pragma GCC diagnostic push
  13666. #pragma GCC diagnostic ignored "-Wconversion"
  13667. #endif
  13668. const long neg_one = (long) -1, const_zero = (long) 0;
  13669. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13670. #pragma GCC diagnostic pop
  13671. #endif
  13672. const int is_unsigned = neg_one > const_zero;
  13673. if (is_unsigned) {
  13674. if (sizeof(long) < sizeof(long)) {
  13675. return PyLong_FromLong((long) value);
  13676. } else if (sizeof(long) <= sizeof(unsigned long)) {
  13677. return PyLong_FromUnsignedLong((unsigned long) value);
  13678. #if !CYTHON_COMPILING_IN_PYPY
  13679. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  13680. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  13681. #endif
  13682. }
  13683. } else {
  13684. if (sizeof(long) <= sizeof(long)) {
  13685. return PyLong_FromLong((long) value);
  13686. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  13687. return PyLong_FromLongLong((PY_LONG_LONG) value);
  13688. }
  13689. }
  13690. {
  13691. unsigned char *bytes = (unsigned char *)&value;
  13692. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  13693. if (is_unsigned) {
  13694. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  13695. } else {
  13696. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  13697. }
  13698. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  13699. int one = 1; int little = (int)*(unsigned char *)&one;
  13700. return _PyLong_FromByteArray(bytes, sizeof(long),
  13701. little, !is_unsigned);
  13702. #else
  13703. int one = 1; int little = (int)*(unsigned char *)&one;
  13704. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  13705. PyObject *py_bytes = NULL, *order_str = NULL;
  13706. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  13707. if (!from_bytes) return NULL;
  13708. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long));
  13709. if (!py_bytes) goto limited_bad;
  13710. order_str = PyUnicode_FromString(little ? "little" : "big");
  13711. if (!order_str) goto limited_bad;
  13712. {
  13713. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  13714. if (!is_unsigned) {
  13715. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  13716. if (!kwds) goto limited_bad;
  13717. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  13718. }
  13719. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  13720. }
  13721. limited_bad:
  13722. Py_XDECREF(kwds);
  13723. Py_XDECREF(order_str);
  13724. Py_XDECREF(py_bytes);
  13725. Py_XDECREF(from_bytes);
  13726. return result;
  13727. #endif
  13728. }
  13729. }
  13730. /* FormatTypeName */
  13731. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
  13732. static __Pyx_TypeName
  13733. __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp)
  13734. {
  13735. PyObject *module = NULL, *name = NULL, *result = NULL;
  13736. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  13737. name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  13738. __pyx_mstate_global->__pyx_n_u_qualname);
  13739. #else
  13740. name = PyType_GetQualName(tp);
  13741. #endif
  13742. if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad;
  13743. module = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  13744. __pyx_mstate_global->__pyx_n_u_module);
  13745. if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad;
  13746. if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) {
  13747. result = name;
  13748. name = NULL;
  13749. goto done;
  13750. }
  13751. result = PyUnicode_FromFormat("%U.%U", module, name);
  13752. if (unlikely(result == NULL)) goto bad;
  13753. done:
  13754. Py_XDECREF(name);
  13755. Py_XDECREF(module);
  13756. return result;
  13757. bad:
  13758. PyErr_Clear();
  13759. if (name) {
  13760. result = name;
  13761. name = NULL;
  13762. } else {
  13763. result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2);
  13764. }
  13765. goto done;
  13766. }
  13767. #endif
  13768. /* CIntFromPy */
  13769. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) {
  13770. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13771. #pragma GCC diagnostic push
  13772. #pragma GCC diagnostic ignored "-Wconversion"
  13773. #endif
  13774. const long neg_one = (long) -1, const_zero = (long) 0;
  13775. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  13776. #pragma GCC diagnostic pop
  13777. #endif
  13778. const int is_unsigned = neg_one > const_zero;
  13779. if (unlikely(!PyLong_Check(x))) {
  13780. long val;
  13781. PyObject *tmp = __Pyx_PyNumber_Long(x);
  13782. if (!tmp) return (long) -1;
  13783. val = __Pyx_PyLong_As_long(tmp);
  13784. Py_DECREF(tmp);
  13785. return val;
  13786. }
  13787. if (is_unsigned) {
  13788. #if CYTHON_USE_PYLONG_INTERNALS
  13789. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  13790. goto raise_neg_overflow;
  13791. } else if (__Pyx_PyLong_IsCompact(x)) {
  13792. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  13793. } else {
  13794. const digit* digits = __Pyx_PyLong_Digits(x);
  13795. assert(__Pyx_PyLong_DigitCount(x) > 1);
  13796. switch (__Pyx_PyLong_DigitCount(x)) {
  13797. case 2:
  13798. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  13799. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13800. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13801. } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
  13802. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  13803. }
  13804. }
  13805. break;
  13806. case 3:
  13807. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  13808. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13809. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13810. } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
  13811. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  13812. }
  13813. }
  13814. break;
  13815. case 4:
  13816. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  13817. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13818. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13819. } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
  13820. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  13821. }
  13822. }
  13823. break;
  13824. }
  13825. }
  13826. #endif
  13827. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  13828. if (unlikely(Py_SIZE(x) < 0)) {
  13829. goto raise_neg_overflow;
  13830. }
  13831. #else
  13832. {
  13833. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  13834. if (unlikely(result < 0))
  13835. return (long) -1;
  13836. if (unlikely(result == 1))
  13837. goto raise_neg_overflow;
  13838. }
  13839. #endif
  13840. if ((sizeof(long) <= sizeof(unsigned long))) {
  13841. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  13842. } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
  13843. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  13844. }
  13845. } else {
  13846. #if CYTHON_USE_PYLONG_INTERNALS
  13847. if (__Pyx_PyLong_IsCompact(x)) {
  13848. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  13849. } else {
  13850. const digit* digits = __Pyx_PyLong_Digits(x);
  13851. assert(__Pyx_PyLong_DigitCount(x) > 1);
  13852. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  13853. case -2:
  13854. if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
  13855. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13856. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13857. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13858. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13859. }
  13860. }
  13861. break;
  13862. case 2:
  13863. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  13864. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13865. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13866. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13867. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13868. }
  13869. }
  13870. break;
  13871. case -3:
  13872. if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13873. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13874. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13875. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13876. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13877. }
  13878. }
  13879. break;
  13880. case 3:
  13881. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  13882. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13883. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13884. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13885. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13886. }
  13887. }
  13888. break;
  13889. case -4:
  13890. if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13891. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13892. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13893. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  13894. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13895. }
  13896. }
  13897. break;
  13898. case 4:
  13899. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  13900. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13901. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13902. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  13903. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13904. }
  13905. }
  13906. break;
  13907. }
  13908. }
  13909. #endif
  13910. if ((sizeof(long) <= sizeof(long))) {
  13911. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  13912. } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
  13913. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  13914. }
  13915. }
  13916. {
  13917. long val;
  13918. int ret = -1;
  13919. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  13920. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  13921. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  13922. if (unlikely(bytes_copied == -1)) {
  13923. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  13924. goto raise_overflow;
  13925. } else {
  13926. ret = 0;
  13927. }
  13928. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  13929. int one = 1; int is_little = (int)*(unsigned char *)&one;
  13930. unsigned char *bytes = (unsigned char *)&val;
  13931. ret = _PyLong_AsByteArray((PyLongObject *)x,
  13932. bytes, sizeof(val),
  13933. is_little, !is_unsigned);
  13934. #else
  13935. PyObject *v;
  13936. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  13937. int bits, remaining_bits, is_negative = 0;
  13938. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  13939. if (likely(PyLong_CheckExact(x))) {
  13940. v = __Pyx_NewRef(x);
  13941. } else {
  13942. v = PyNumber_Long(x);
  13943. if (unlikely(!v)) return (long) -1;
  13944. assert(PyLong_CheckExact(v));
  13945. }
  13946. {
  13947. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  13948. if (unlikely(result < 0)) {
  13949. Py_DECREF(v);
  13950. return (long) -1;
  13951. }
  13952. is_negative = result == 1;
  13953. }
  13954. if (is_unsigned && unlikely(is_negative)) {
  13955. Py_DECREF(v);
  13956. goto raise_neg_overflow;
  13957. } else if (is_negative) {
  13958. stepval = PyNumber_Invert(v);
  13959. Py_DECREF(v);
  13960. if (unlikely(!stepval))
  13961. return (long) -1;
  13962. } else {
  13963. stepval = v;
  13964. }
  13965. v = NULL;
  13966. val = (long) 0;
  13967. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  13968. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  13969. for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
  13970. PyObject *tmp, *digit;
  13971. long idigit;
  13972. digit = PyNumber_And(stepval, mask);
  13973. if (unlikely(!digit)) goto done;
  13974. idigit = PyLong_AsLong(digit);
  13975. Py_DECREF(digit);
  13976. if (unlikely(idigit < 0)) goto done;
  13977. val |= ((long) idigit) << bits;
  13978. tmp = PyNumber_Rshift(stepval, shift);
  13979. if (unlikely(!tmp)) goto done;
  13980. Py_DECREF(stepval); stepval = tmp;
  13981. }
  13982. Py_DECREF(shift); shift = NULL;
  13983. Py_DECREF(mask); mask = NULL;
  13984. {
  13985. long idigit = PyLong_AsLong(stepval);
  13986. if (unlikely(idigit < 0)) goto done;
  13987. remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
  13988. if (unlikely(idigit >= (1L << remaining_bits)))
  13989. goto raise_overflow;
  13990. val |= ((long) idigit) << bits;
  13991. }
  13992. if (!is_unsigned) {
  13993. if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
  13994. goto raise_overflow;
  13995. if (is_negative)
  13996. val = ~val;
  13997. }
  13998. ret = 0;
  13999. done:
  14000. Py_XDECREF(shift);
  14001. Py_XDECREF(mask);
  14002. Py_XDECREF(stepval);
  14003. #endif
  14004. if (unlikely(ret))
  14005. return (long) -1;
  14006. return val;
  14007. }
  14008. raise_overflow:
  14009. PyErr_SetString(PyExc_OverflowError,
  14010. "value too large to convert to long");
  14011. return (long) -1;
  14012. raise_neg_overflow:
  14013. PyErr_SetString(PyExc_OverflowError,
  14014. "can't convert negative value to long");
  14015. return (long) -1;
  14016. }
  14017. /* FastTypeChecks */
  14018. #if CYTHON_COMPILING_IN_CPYTHON
  14019. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  14020. while (a) {
  14021. a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
  14022. if (a == b)
  14023. return 1;
  14024. }
  14025. return b == &PyBaseObject_Type;
  14026. }
  14027. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  14028. PyObject *mro;
  14029. if (a == b) return 1;
  14030. mro = a->tp_mro;
  14031. if (likely(mro)) {
  14032. Py_ssize_t i, n;
  14033. n = PyTuple_GET_SIZE(mro);
  14034. for (i = 0; i < n; i++) {
  14035. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  14036. return 1;
  14037. }
  14038. return 0;
  14039. }
  14040. return __Pyx_InBases(a, b);
  14041. }
  14042. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
  14043. PyObject *mro;
  14044. if (cls == a || cls == b) return 1;
  14045. mro = cls->tp_mro;
  14046. if (likely(mro)) {
  14047. Py_ssize_t i, n;
  14048. n = PyTuple_GET_SIZE(mro);
  14049. for (i = 0; i < n; i++) {
  14050. PyObject *base = PyTuple_GET_ITEM(mro, i);
  14051. if (base == (PyObject *)a || base == (PyObject *)b)
  14052. return 1;
  14053. }
  14054. return 0;
  14055. }
  14056. return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
  14057. }
  14058. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  14059. if (exc_type1) {
  14060. return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2);
  14061. } else {
  14062. return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  14063. }
  14064. }
  14065. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  14066. Py_ssize_t i, n;
  14067. assert(PyExceptionClass_Check(exc_type));
  14068. n = PyTuple_GET_SIZE(tuple);
  14069. for (i=0; i<n; i++) {
  14070. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  14071. }
  14072. for (i=0; i<n; i++) {
  14073. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  14074. if (likely(PyExceptionClass_Check(t))) {
  14075. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  14076. } else {
  14077. }
  14078. }
  14079. return 0;
  14080. }
  14081. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  14082. if (likely(err == exc_type)) return 1;
  14083. if (likely(PyExceptionClass_Check(err))) {
  14084. if (likely(PyExceptionClass_Check(exc_type))) {
  14085. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  14086. } else if (likely(PyTuple_Check(exc_type))) {
  14087. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  14088. } else {
  14089. }
  14090. }
  14091. return PyErr_GivenExceptionMatches(err, exc_type);
  14092. }
  14093. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  14094. assert(PyExceptionClass_Check(exc_type1));
  14095. assert(PyExceptionClass_Check(exc_type2));
  14096. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  14097. if (likely(PyExceptionClass_Check(err))) {
  14098. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  14099. }
  14100. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  14101. }
  14102. #endif
  14103. /* GetRuntimeVersion */
  14104. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  14105. void __Pyx_init_runtime_version(void) {
  14106. if (__Pyx_cached_runtime_version == 0) {
  14107. const char* rt_version = Py_GetVersion();
  14108. unsigned long version = 0;
  14109. unsigned long factor = 0x01000000UL;
  14110. unsigned int digit = 0;
  14111. int i = 0;
  14112. while (factor) {
  14113. while ('0' <= rt_version[i] && rt_version[i] <= '9') {
  14114. digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
  14115. ++i;
  14116. }
  14117. version += factor * digit;
  14118. if (rt_version[i] != '.')
  14119. break;
  14120. digit = 0;
  14121. factor >>= 8;
  14122. ++i;
  14123. }
  14124. __Pyx_cached_runtime_version = version;
  14125. }
  14126. }
  14127. #endif
  14128. static unsigned long __Pyx_get_runtime_version(void) {
  14129. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  14130. return Py_Version & ~0xFFUL;
  14131. #else
  14132. return __Pyx_cached_runtime_version;
  14133. #endif
  14134. }
  14135. /* SwapException (used by CoroutineBase) */
  14136. #if CYTHON_FAST_THREAD_STATE
  14137. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  14138. PyObject *tmp_type, *tmp_value, *tmp_tb;
  14139. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  14140. _PyErr_StackItem *exc_info = tstate->exc_info;
  14141. tmp_value = exc_info->exc_value;
  14142. exc_info->exc_value = *value;
  14143. if (tmp_value == NULL || tmp_value == Py_None) {
  14144. Py_XDECREF(tmp_value);
  14145. tmp_value = NULL;
  14146. tmp_type = NULL;
  14147. tmp_tb = NULL;
  14148. } else {
  14149. tmp_type = (PyObject*) Py_TYPE(tmp_value);
  14150. Py_INCREF(tmp_type);
  14151. #if CYTHON_COMPILING_IN_CPYTHON
  14152. tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
  14153. Py_XINCREF(tmp_tb);
  14154. #else
  14155. tmp_tb = PyException_GetTraceback(tmp_value);
  14156. #endif
  14157. }
  14158. #elif CYTHON_USE_EXC_INFO_STACK
  14159. _PyErr_StackItem *exc_info = tstate->exc_info;
  14160. tmp_type = exc_info->exc_type;
  14161. tmp_value = exc_info->exc_value;
  14162. tmp_tb = exc_info->exc_traceback;
  14163. exc_info->exc_type = *type;
  14164. exc_info->exc_value = *value;
  14165. exc_info->exc_traceback = *tb;
  14166. #else
  14167. tmp_type = tstate->exc_type;
  14168. tmp_value = tstate->exc_value;
  14169. tmp_tb = tstate->exc_traceback;
  14170. tstate->exc_type = *type;
  14171. tstate->exc_value = *value;
  14172. tstate->exc_traceback = *tb;
  14173. #endif
  14174. *type = tmp_type;
  14175. *value = tmp_value;
  14176. *tb = tmp_tb;
  14177. }
  14178. #else
  14179. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  14180. PyObject *tmp_type, *tmp_value, *tmp_tb;
  14181. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  14182. PyErr_SetExcInfo(*type, *value, *tb);
  14183. *type = tmp_type;
  14184. *value = tmp_value;
  14185. *tb = tmp_tb;
  14186. }
  14187. #endif
  14188. /* IterNextPlain (used by CoroutineBase) */
  14189. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  14190. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void) {
  14191. if (unlikely(!__pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache))
  14192. __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache = __Pyx_GetBuiltinName(__pyx_mstate_global->__pyx_n_u_next);
  14193. return __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache;
  14194. }
  14195. #endif
  14196. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator) {
  14197. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  14198. PyObject *result;
  14199. PyObject *next = __Pyx_GetBuiltinNext_LimitedAPI();
  14200. if (unlikely(!next)) return NULL;
  14201. result = PyObject_CallFunctionObjArgs(next, iterator, NULL);
  14202. return result;
  14203. #else
  14204. (void)__Pyx_GetBuiltinName; // only for early limited API
  14205. iternextfunc iternext = __Pyx_PyObject_GetIterNextFunc(iterator);
  14206. assert(iternext);
  14207. return iternext(iterator);
  14208. #endif
  14209. }
  14210. /* PyObjectCall2Args (used by PyObjectCallMethod1) */
  14211. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
  14212. PyObject *args[3] = {NULL, arg1, arg2};
  14213. return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  14214. }
  14215. /* PyObjectCallMethod1 (used by CoroutineBase) */
  14216. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  14217. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  14218. PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
  14219. Py_DECREF(method);
  14220. return result;
  14221. }
  14222. #endif
  14223. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  14224. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  14225. PyObject *args[2] = {obj, arg};
  14226. (void) __Pyx_PyObject_CallOneArg;
  14227. (void) __Pyx_PyObject_Call2Args;
  14228. return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  14229. #else
  14230. PyObject *method = NULL, *result;
  14231. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  14232. if (likely(is_method)) {
  14233. result = __Pyx_PyObject_Call2Args(method, obj, arg);
  14234. Py_DECREF(method);
  14235. return result;
  14236. }
  14237. if (unlikely(!method)) return NULL;
  14238. return __Pyx__PyObject_CallMethod1(method, arg);
  14239. #endif
  14240. }
  14241. /* ReturnWithStopIteration (used by CoroutineBase) */
  14242. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async);
  14243. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext) {
  14244. if (value == Py_None) {
  14245. if (async || !iternext)
  14246. PyErr_SetNone(async ? PyExc_StopAsyncIteration : PyExc_StopIteration);
  14247. return;
  14248. }
  14249. __Pyx__ReturnWithStopIteration(value, async);
  14250. }
  14251. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async) {
  14252. #if CYTHON_COMPILING_IN_CPYTHON
  14253. __Pyx_PyThreadState_declare
  14254. #endif
  14255. PyObject *exc;
  14256. PyObject *exc_type = async ? PyExc_StopAsyncIteration : PyExc_StopIteration;
  14257. #if CYTHON_COMPILING_IN_CPYTHON
  14258. if ((PY_VERSION_HEX >= (0x030C00A6)) || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
  14259. if (PY_VERSION_HEX >= (0x030e00A1)) {
  14260. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  14261. } else {
  14262. PyObject *args_tuple = PyTuple_New(1);
  14263. if (unlikely(!args_tuple)) return;
  14264. Py_INCREF(value);
  14265. PyTuple_SET_ITEM(args_tuple, 0, value);
  14266. exc = PyObject_Call(exc_type, args_tuple, NULL);
  14267. Py_DECREF(args_tuple);
  14268. }
  14269. if (unlikely(!exc)) return;
  14270. } else {
  14271. Py_INCREF(value);
  14272. exc = value;
  14273. }
  14274. #if CYTHON_FAST_THREAD_STATE
  14275. __Pyx_PyThreadState_assign
  14276. #if CYTHON_USE_EXC_INFO_STACK
  14277. if (!__pyx_tstate->exc_info->exc_value)
  14278. #else
  14279. if (!__pyx_tstate->exc_type)
  14280. #endif
  14281. {
  14282. Py_INCREF(exc_type);
  14283. __Pyx_ErrRestore(exc_type, exc, NULL);
  14284. return;
  14285. }
  14286. #endif
  14287. #else
  14288. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  14289. if (unlikely(!exc)) return;
  14290. #endif
  14291. PyErr_SetObject(exc_type, exc);
  14292. Py_DECREF(exc);
  14293. }
  14294. /* CoroutineBase (used by Generator) */
  14295. #if !CYTHON_COMPILING_IN_LIMITED_API
  14296. #include <frameobject.h>
  14297. #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
  14298. #ifndef Py_BUILD_CORE
  14299. #define Py_BUILD_CORE 1
  14300. #endif
  14301. #include "internal/pycore_frame.h"
  14302. #endif
  14303. #endif // CYTHON_COMPILING_IN_LIMITED_API
  14304. static CYTHON_INLINE void
  14305. __Pyx_Coroutine_Undelegate(__pyx_CoroutineObject *gen) {
  14306. #if CYTHON_USE_AM_SEND
  14307. gen->yieldfrom_am_send = NULL;
  14308. #endif
  14309. Py_CLEAR(gen->yieldfrom);
  14310. }
  14311. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *__pyx_tstate, PyObject **pvalue) {
  14312. PyObject *et, *ev, *tb;
  14313. PyObject *value = NULL;
  14314. CYTHON_UNUSED_VAR(__pyx_tstate);
  14315. __Pyx_ErrFetch(&et, &ev, &tb);
  14316. if (!et) {
  14317. Py_XDECREF(tb);
  14318. Py_XDECREF(ev);
  14319. Py_INCREF(Py_None);
  14320. *pvalue = Py_None;
  14321. return 0;
  14322. }
  14323. if (likely(et == PyExc_StopIteration)) {
  14324. if (!ev) {
  14325. Py_INCREF(Py_None);
  14326. value = Py_None;
  14327. }
  14328. else if (likely(__Pyx_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) {
  14329. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  14330. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  14331. if (unlikely(!value)) goto limited_api_failure;
  14332. #else
  14333. value = ((PyStopIterationObject *)ev)->value;
  14334. Py_INCREF(value);
  14335. #endif
  14336. Py_DECREF(ev);
  14337. }
  14338. else if (unlikely(PyTuple_Check(ev))) {
  14339. Py_ssize_t tuple_size = __Pyx_PyTuple_GET_SIZE(ev);
  14340. #if !CYTHON_ASSUME_SAFE_SIZE
  14341. if (unlikely(tuple_size < 0)) {
  14342. Py_XDECREF(tb);
  14343. Py_DECREF(ev);
  14344. Py_DECREF(et);
  14345. return -1;
  14346. }
  14347. #endif
  14348. if (tuple_size >= 1) {
  14349. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  14350. value = PyTuple_GET_ITEM(ev, 0);
  14351. Py_INCREF(value);
  14352. #elif CYTHON_ASSUME_SAFE_MACROS
  14353. value = PySequence_ITEM(ev, 0);
  14354. #else
  14355. value = PySequence_GetItem(ev, 0);
  14356. if (!value) goto limited_api_failure;
  14357. #endif
  14358. } else {
  14359. Py_INCREF(Py_None);
  14360. value = Py_None;
  14361. }
  14362. Py_DECREF(ev);
  14363. }
  14364. else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
  14365. value = ev;
  14366. }
  14367. if (likely(value)) {
  14368. Py_XDECREF(tb);
  14369. Py_DECREF(et);
  14370. *pvalue = value;
  14371. return 0;
  14372. }
  14373. } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
  14374. __Pyx_ErrRestore(et, ev, tb);
  14375. return -1;
  14376. }
  14377. PyErr_NormalizeException(&et, &ev, &tb);
  14378. if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
  14379. __Pyx_ErrRestore(et, ev, tb);
  14380. return -1;
  14381. }
  14382. Py_XDECREF(tb);
  14383. Py_DECREF(et);
  14384. #if CYTHON_COMPILING_IN_LIMITED_API
  14385. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  14386. #else
  14387. value = ((PyStopIterationObject *)ev)->value;
  14388. Py_INCREF(value);
  14389. #endif
  14390. Py_DECREF(ev);
  14391. #if CYTHON_COMPILING_IN_LIMITED_API
  14392. if (unlikely(!value)) return -1;
  14393. #endif
  14394. *pvalue = value;
  14395. return 0;
  14396. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL || !CYTHON_ASSUME_SAFE_MACROS
  14397. limited_api_failure:
  14398. Py_XDECREF(et);
  14399. Py_XDECREF(tb);
  14400. Py_XDECREF(ev);
  14401. return -1;
  14402. #endif
  14403. }
  14404. static CYTHON_INLINE
  14405. __Pyx_PySendResult __Pyx_Coroutine_status_from_result(PyObject **retval) {
  14406. if (*retval) {
  14407. return PYGEN_NEXT;
  14408. } else if (likely(__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, retval) == 0)) {
  14409. return PYGEN_RETURN;
  14410. } else {
  14411. return PYGEN_ERROR;
  14412. }
  14413. }
  14414. static CYTHON_INLINE
  14415. void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
  14416. #if PY_VERSION_HEX >= 0x030B00a4
  14417. Py_CLEAR(exc_state->exc_value);
  14418. #else
  14419. PyObject *t, *v, *tb;
  14420. t = exc_state->exc_type;
  14421. v = exc_state->exc_value;
  14422. tb = exc_state->exc_traceback;
  14423. exc_state->exc_type = NULL;
  14424. exc_state->exc_value = NULL;
  14425. exc_state->exc_traceback = NULL;
  14426. Py_XDECREF(t);
  14427. Py_XDECREF(v);
  14428. Py_XDECREF(tb);
  14429. #endif
  14430. }
  14431. #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
  14432. static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) {
  14433. const char *msg;
  14434. CYTHON_MAYBE_UNUSED_VAR(gen);
  14435. if ((0)) {
  14436. #ifdef __Pyx_Coroutine_USED
  14437. } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
  14438. msg = "coroutine already executing";
  14439. #endif
  14440. #ifdef __Pyx_AsyncGen_USED
  14441. } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
  14442. msg = "async generator already executing";
  14443. #endif
  14444. } else {
  14445. msg = "generator already executing";
  14446. }
  14447. PyErr_SetString(PyExc_ValueError, msg);
  14448. }
  14449. static void __Pyx_Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) {
  14450. CYTHON_MAYBE_UNUSED_VAR(gen);
  14451. CYTHON_MAYBE_UNUSED_VAR(closing);
  14452. #ifdef __Pyx_Coroutine_USED
  14453. if (!closing && __Pyx_Coroutine_Check(gen)) {
  14454. PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
  14455. } else
  14456. #endif
  14457. if (value) {
  14458. #ifdef __Pyx_AsyncGen_USED
  14459. if (__Pyx_AsyncGen_CheckExact(gen))
  14460. PyErr_SetNone(PyExc_StopAsyncIteration);
  14461. else
  14462. #endif
  14463. PyErr_SetNone(PyExc_StopIteration);
  14464. }
  14465. }
  14466. static
  14467. __Pyx_PySendResult __Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, PyObject **result, int closing) {
  14468. __Pyx_PyThreadState_declare
  14469. PyThreadState *tstate;
  14470. __Pyx_ExcInfoStruct *exc_state;
  14471. PyObject *retval;
  14472. assert(__Pyx_Coroutine_get_is_running(self)); // Callers should ensure is_running
  14473. if (unlikely(self->resume_label == -1)) {
  14474. __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
  14475. return PYGEN_ERROR;
  14476. }
  14477. #if CYTHON_FAST_THREAD_STATE
  14478. __Pyx_PyThreadState_assign
  14479. tstate = __pyx_tstate;
  14480. #else
  14481. tstate = __Pyx_PyThreadState_Current;
  14482. #endif
  14483. exc_state = &self->gi_exc_state;
  14484. if (exc_state->exc_value) {
  14485. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  14486. #else
  14487. PyObject *exc_tb;
  14488. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  14489. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  14490. #elif PY_VERSION_HEX >= 0x030B00a4
  14491. exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback;
  14492. #else
  14493. exc_tb = exc_state->exc_traceback;
  14494. #endif
  14495. if (exc_tb) {
  14496. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  14497. PyFrameObject *f = tb->tb_frame;
  14498. assert(f->f_back == NULL);
  14499. #if PY_VERSION_HEX >= 0x030B00A1
  14500. f->f_back = PyThreadState_GetFrame(tstate);
  14501. #else
  14502. Py_XINCREF(tstate->frame);
  14503. f->f_back = tstate->frame;
  14504. #endif
  14505. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  14506. Py_DECREF(exc_tb);
  14507. #endif
  14508. }
  14509. #endif
  14510. }
  14511. #if CYTHON_USE_EXC_INFO_STACK
  14512. exc_state->previous_item = tstate->exc_info;
  14513. tstate->exc_info = exc_state;
  14514. #else
  14515. if (exc_state->exc_type) {
  14516. __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  14517. } else {
  14518. __Pyx_Coroutine_ExceptionClear(exc_state);
  14519. __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  14520. }
  14521. #endif
  14522. retval = self->body(self, tstate, value);
  14523. #if CYTHON_USE_EXC_INFO_STACK
  14524. exc_state = &self->gi_exc_state;
  14525. tstate->exc_info = exc_state->previous_item;
  14526. exc_state->previous_item = NULL;
  14527. __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
  14528. #endif
  14529. *result = retval;
  14530. if (self->resume_label == -1) {
  14531. return likely(retval) ? PYGEN_RETURN : PYGEN_ERROR;
  14532. }
  14533. return PYGEN_NEXT;
  14534. }
  14535. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
  14536. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
  14537. CYTHON_UNUSED_VAR(exc_state);
  14538. #else
  14539. PyObject *exc_tb;
  14540. #if PY_VERSION_HEX >= 0x030B00a4
  14541. if (!exc_state->exc_value) return;
  14542. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  14543. #else
  14544. exc_tb = exc_state->exc_traceback;
  14545. #endif
  14546. if (likely(exc_tb)) {
  14547. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  14548. PyFrameObject *f = tb->tb_frame;
  14549. Py_CLEAR(f->f_back);
  14550. #if PY_VERSION_HEX >= 0x030B00a4
  14551. Py_DECREF(exc_tb);
  14552. #endif
  14553. }
  14554. #endif
  14555. }
  14556. #define __Pyx_Coroutine_MethodReturnFromResult(gen, result, retval, iternext)\
  14557. ((result) == PYGEN_NEXT ? (retval) : __Pyx__Coroutine_MethodReturnFromResult(gen, result, retval, iternext))
  14558. static PyObject *
  14559. __Pyx__Coroutine_MethodReturnFromResult(PyObject* gen, __Pyx_PySendResult result, PyObject *retval, int iternext) {
  14560. CYTHON_MAYBE_UNUSED_VAR(gen);
  14561. if (likely(result == PYGEN_RETURN)) {
  14562. int is_async = 0;
  14563. #ifdef __Pyx_AsyncGen_USED
  14564. is_async = __Pyx_AsyncGen_CheckExact(gen);
  14565. #endif
  14566. __Pyx_ReturnWithStopIteration(retval, is_async, iternext);
  14567. Py_XDECREF(retval);
  14568. }
  14569. return NULL;
  14570. }
  14571. #if CYTHON_COMPILING_IN_CPYTHON
  14572. static CYTHON_INLINE
  14573. PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
  14574. #if PY_VERSION_HEX <= 0x030A00A1
  14575. return _PyGen_Send(gen, arg);
  14576. #else
  14577. PyObject *result;
  14578. if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
  14579. if (PyAsyncGen_CheckExact(gen)) {
  14580. assert(result == Py_None);
  14581. PyErr_SetNone(PyExc_StopAsyncIteration);
  14582. }
  14583. else if (result == Py_None) {
  14584. PyErr_SetNone(PyExc_StopIteration);
  14585. }
  14586. else {
  14587. #if PY_VERSION_HEX < 0x030d00A1
  14588. _PyGen_SetStopIterationValue(result);
  14589. #else
  14590. if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) {
  14591. PyErr_SetObject(PyExc_StopIteration, result);
  14592. } else {
  14593. PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result);
  14594. if (likely(exc != NULL)) {
  14595. PyErr_SetObject(PyExc_StopIteration, exc);
  14596. Py_DECREF(exc);
  14597. }
  14598. }
  14599. #endif
  14600. }
  14601. Py_DECREF(result);
  14602. result = NULL;
  14603. }
  14604. return result;
  14605. #endif
  14606. }
  14607. #endif
  14608. static CYTHON_INLINE __Pyx_PySendResult
  14609. __Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen, PyObject** retval) {
  14610. __Pyx_PySendResult result;
  14611. PyObject *val = NULL;
  14612. assert(__Pyx_Coroutine_get_is_running(gen));
  14613. __Pyx_Coroutine_Undelegate(gen);
  14614. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
  14615. result = __Pyx_Coroutine_SendEx(gen, val, retval, 0);
  14616. Py_XDECREF(val);
  14617. return result;
  14618. }
  14619. #if CYTHON_USE_AM_SEND
  14620. static __Pyx_PySendResult
  14621. __Pyx_Coroutine_SendToDelegate(__pyx_CoroutineObject *gen, __Pyx_pyiter_sendfunc gen_am_send, PyObject *value, PyObject **retval) {
  14622. PyObject *ret = NULL;
  14623. __Pyx_PySendResult delegate_result, result;
  14624. assert(__Pyx_Coroutine_get_is_running(gen));
  14625. delegate_result = gen_am_send(gen->yieldfrom, value, &ret);
  14626. if (delegate_result == PYGEN_NEXT) {
  14627. assert (ret != NULL);
  14628. *retval = ret;
  14629. return PYGEN_NEXT;
  14630. }
  14631. assert (delegate_result != PYGEN_ERROR || ret == NULL);
  14632. __Pyx_Coroutine_Undelegate(gen);
  14633. result = __Pyx_Coroutine_SendEx(gen, ret, retval, 0);
  14634. Py_XDECREF(ret);
  14635. return result;
  14636. }
  14637. #endif
  14638. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
  14639. PyObject *retval = NULL;
  14640. __Pyx_PySendResult result = __Pyx_Coroutine_AmSend(self, value, &retval);
  14641. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  14642. }
  14643. static __Pyx_PySendResult
  14644. __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
  14645. __Pyx_PySendResult result;
  14646. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  14647. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  14648. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  14649. return PYGEN_ERROR;
  14650. }
  14651. #if CYTHON_USE_AM_SEND
  14652. if (gen->yieldfrom_am_send) {
  14653. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, value, retval);
  14654. } else
  14655. #endif
  14656. if (gen->yieldfrom) {
  14657. PyObject *yf = gen->yieldfrom;
  14658. PyObject *ret;
  14659. #if !CYTHON_USE_AM_SEND
  14660. #ifdef __Pyx_Generator_USED
  14661. if (__Pyx_Generator_CheckExact(yf)) {
  14662. ret = __Pyx_Coroutine_Send(yf, value);
  14663. } else
  14664. #endif
  14665. #ifdef __Pyx_Coroutine_USED
  14666. if (__Pyx_Coroutine_Check(yf)) {
  14667. ret = __Pyx_Coroutine_Send(yf, value);
  14668. } else
  14669. #endif
  14670. #ifdef __Pyx_AsyncGen_USED
  14671. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  14672. ret = __Pyx_async_gen_asend_send(yf, value);
  14673. } else
  14674. #endif
  14675. #if CYTHON_COMPILING_IN_CPYTHON
  14676. if (PyGen_CheckExact(yf)) {
  14677. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  14678. } else
  14679. if (PyCoro_CheckExact(yf)) {
  14680. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  14681. } else
  14682. #endif
  14683. #endif
  14684. {
  14685. #if !CYTHON_COMPILING_IN_LIMITED_API || __PYX_LIMITED_VERSION_HEX >= 0x03080000
  14686. if (value == Py_None && PyIter_Check(yf))
  14687. ret = __Pyx_PyIter_Next_Plain(yf);
  14688. else
  14689. #endif
  14690. ret = __Pyx_PyObject_CallMethod1(yf, __pyx_mstate_global->__pyx_n_u_send, value);
  14691. }
  14692. if (likely(ret)) {
  14693. __Pyx_Coroutine_unset_is_running(gen);
  14694. *retval = ret;
  14695. return PYGEN_NEXT;
  14696. }
  14697. result = __Pyx_Coroutine_FinishDelegation(gen, retval);
  14698. } else {
  14699. result = __Pyx_Coroutine_SendEx(gen, value, retval, 0);
  14700. }
  14701. __Pyx_Coroutine_unset_is_running(gen);
  14702. return result;
  14703. }
  14704. static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
  14705. __Pyx_PySendResult result;
  14706. PyObject *retval = NULL;
  14707. CYTHON_UNUSED_VAR(gen);
  14708. assert(__Pyx_Coroutine_get_is_running(gen));
  14709. #ifdef __Pyx_Generator_USED
  14710. if (__Pyx_Generator_CheckExact(yf)) {
  14711. result = __Pyx_Coroutine_Close(yf, &retval);
  14712. } else
  14713. #endif
  14714. #ifdef __Pyx_Coroutine_USED
  14715. if (__Pyx_Coroutine_Check(yf)) {
  14716. result = __Pyx_Coroutine_Close(yf, &retval);
  14717. } else
  14718. if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  14719. result = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
  14720. } else
  14721. #endif
  14722. #ifdef __Pyx_AsyncGen_USED
  14723. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  14724. retval = __Pyx_async_gen_asend_close(yf, NULL);
  14725. result = PYGEN_RETURN;
  14726. } else
  14727. if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
  14728. retval = __Pyx_async_gen_athrow_close(yf, NULL);
  14729. result = PYGEN_RETURN;
  14730. } else
  14731. #endif
  14732. {
  14733. PyObject *meth;
  14734. result = PYGEN_RETURN;
  14735. meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_close);
  14736. if (unlikely(!meth)) {
  14737. if (unlikely(PyErr_Occurred())) {
  14738. PyErr_WriteUnraisable(yf);
  14739. }
  14740. } else {
  14741. retval = __Pyx_PyObject_CallNoArg(meth);
  14742. Py_DECREF(meth);
  14743. if (unlikely(!retval)) {
  14744. result = PYGEN_ERROR;
  14745. }
  14746. }
  14747. }
  14748. Py_XDECREF(retval);
  14749. return result == PYGEN_ERROR ? -1 : 0;
  14750. }
  14751. static PyObject *__Pyx_Generator_Next(PyObject *self) {
  14752. __Pyx_PySendResult result;
  14753. PyObject *retval = NULL;
  14754. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  14755. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  14756. return __Pyx_Coroutine_AlreadyRunningError(gen);
  14757. }
  14758. #if CYTHON_USE_AM_SEND
  14759. if (gen->yieldfrom_am_send) {
  14760. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, Py_None, &retval);
  14761. } else
  14762. #endif
  14763. if (gen->yieldfrom) {
  14764. PyObject *yf = gen->yieldfrom;
  14765. PyObject *ret;
  14766. #ifdef __Pyx_Generator_USED
  14767. if (__Pyx_Generator_CheckExact(yf)) {
  14768. ret = __Pyx_Generator_Next(yf);
  14769. } else
  14770. #endif
  14771. #ifdef __Pyx_Coroutine_USED
  14772. if (__Pyx_Coroutine_CheckExact(yf)) {
  14773. ret = __Pyx_Coroutine_Send(yf, Py_None);
  14774. } else
  14775. #endif
  14776. #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX < 0x030A00A3 || !CYTHON_USE_AM_SEND)
  14777. if (PyGen_CheckExact(yf)) {
  14778. ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
  14779. } else
  14780. #endif
  14781. ret = __Pyx_PyIter_Next_Plain(yf);
  14782. if (likely(ret)) {
  14783. __Pyx_Coroutine_unset_is_running(gen);
  14784. return ret;
  14785. }
  14786. result = __Pyx_Coroutine_FinishDelegation(gen, &retval);
  14787. } else {
  14788. result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  14789. }
  14790. __Pyx_Coroutine_unset_is_running(gen);
  14791. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 1);
  14792. }
  14793. static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) {
  14794. PyObject *retval = NULL;
  14795. __Pyx_PySendResult result;
  14796. CYTHON_UNUSED_VAR(arg);
  14797. result = __Pyx_Coroutine_Close(self, &retval);
  14798. if (unlikely(result == PYGEN_ERROR))
  14799. return NULL;
  14800. Py_XDECREF(retval);
  14801. Py_RETURN_NONE;
  14802. }
  14803. static __Pyx_PySendResult
  14804. __Pyx_Coroutine_Close(PyObject *self, PyObject **retval) {
  14805. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14806. __Pyx_PySendResult result;
  14807. PyObject *yf;
  14808. int err = 0;
  14809. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  14810. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  14811. return PYGEN_ERROR;
  14812. }
  14813. yf = gen->yieldfrom;
  14814. if (yf) {
  14815. Py_INCREF(yf);
  14816. err = __Pyx_Coroutine_CloseIter(gen, yf);
  14817. __Pyx_Coroutine_Undelegate(gen);
  14818. Py_DECREF(yf);
  14819. }
  14820. if (err == 0)
  14821. PyErr_SetNone(PyExc_GeneratorExit);
  14822. result = __Pyx_Coroutine_SendEx(gen, NULL, retval, 1);
  14823. if (result == PYGEN_ERROR) {
  14824. __Pyx_PyThreadState_declare
  14825. __Pyx_PyThreadState_assign
  14826. __Pyx_Coroutine_unset_is_running(gen);
  14827. if (!__Pyx_PyErr_Occurred()) {
  14828. return PYGEN_RETURN;
  14829. } else if (likely(__Pyx_PyErr_ExceptionMatches2(PyExc_GeneratorExit, PyExc_StopIteration))) {
  14830. __Pyx_PyErr_Clear();
  14831. return PYGEN_RETURN;
  14832. }
  14833. return PYGEN_ERROR;
  14834. } else if (likely(result == PYGEN_RETURN && *retval == Py_None)) {
  14835. __Pyx_Coroutine_unset_is_running(gen);
  14836. return PYGEN_RETURN;
  14837. } else {
  14838. const char *msg;
  14839. Py_DECREF(*retval);
  14840. *retval = NULL;
  14841. if ((0)) {
  14842. #ifdef __Pyx_Coroutine_USED
  14843. } else if (__Pyx_Coroutine_Check(self)) {
  14844. msg = "coroutine ignored GeneratorExit";
  14845. #endif
  14846. #ifdef __Pyx_AsyncGen_USED
  14847. } else if (__Pyx_AsyncGen_CheckExact(self)) {
  14848. msg = "async generator ignored GeneratorExit";
  14849. #endif
  14850. } else {
  14851. msg = "generator ignored GeneratorExit";
  14852. }
  14853. PyErr_SetString(PyExc_RuntimeError, msg);
  14854. __Pyx_Coroutine_unset_is_running(gen);
  14855. return PYGEN_ERROR;
  14856. }
  14857. }
  14858. static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
  14859. PyObject *args, int close_on_genexit) {
  14860. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14861. PyObject *yf;
  14862. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen)))
  14863. return __Pyx_Coroutine_AlreadyRunningError(gen);
  14864. yf = gen->yieldfrom;
  14865. if (yf) {
  14866. __Pyx_PySendResult result;
  14867. PyObject *ret;
  14868. Py_INCREF(yf);
  14869. if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
  14870. int err = __Pyx_Coroutine_CloseIter(gen, yf);
  14871. Py_DECREF(yf);
  14872. __Pyx_Coroutine_Undelegate(gen);
  14873. if (err < 0)
  14874. goto propagate_exception;
  14875. goto throw_here;
  14876. }
  14877. if (0
  14878. #ifdef __Pyx_Generator_USED
  14879. || __Pyx_Generator_CheckExact(yf)
  14880. #endif
  14881. #ifdef __Pyx_Coroutine_USED
  14882. || __Pyx_Coroutine_Check(yf)
  14883. #endif
  14884. ) {
  14885. ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
  14886. #ifdef __Pyx_Coroutine_USED
  14887. } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  14888. ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
  14889. #endif
  14890. } else {
  14891. PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_throw);
  14892. if (unlikely(!meth)) {
  14893. Py_DECREF(yf);
  14894. if (unlikely(PyErr_Occurred())) {
  14895. __Pyx_Coroutine_unset_is_running(gen);
  14896. return NULL;
  14897. }
  14898. __Pyx_Coroutine_Undelegate(gen);
  14899. goto throw_here;
  14900. }
  14901. if (likely(args)) {
  14902. ret = __Pyx_PyObject_Call(meth, args, NULL);
  14903. } else {
  14904. PyObject *cargs[4] = {NULL, typ, val, tb};
  14905. ret = __Pyx_PyObject_FastCall(meth, cargs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  14906. }
  14907. Py_DECREF(meth);
  14908. }
  14909. Py_DECREF(yf);
  14910. if (ret) {
  14911. __Pyx_Coroutine_unset_is_running(gen);
  14912. return ret;
  14913. }
  14914. result = __Pyx_Coroutine_FinishDelegation(gen, &ret);
  14915. __Pyx_Coroutine_unset_is_running(gen);
  14916. return __Pyx_Coroutine_MethodReturnFromResult(self, result, ret, 0);
  14917. }
  14918. throw_here:
  14919. __Pyx_Raise(typ, val, tb, NULL);
  14920. propagate_exception:
  14921. {
  14922. PyObject *retval = NULL;
  14923. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, NULL, &retval, 0);
  14924. __Pyx_Coroutine_unset_is_running(gen);
  14925. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  14926. }
  14927. }
  14928. static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
  14929. PyObject *typ;
  14930. PyObject *val = NULL;
  14931. PyObject *tb = NULL;
  14932. if (unlikely(!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)))
  14933. return NULL;
  14934. return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
  14935. }
  14936. static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
  14937. #if PY_VERSION_HEX >= 0x030B00a4
  14938. Py_VISIT(exc_state->exc_value);
  14939. #else
  14940. Py_VISIT(exc_state->exc_type);
  14941. Py_VISIT(exc_state->exc_value);
  14942. Py_VISIT(exc_state->exc_traceback);
  14943. #endif
  14944. return 0;
  14945. }
  14946. static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
  14947. {
  14948. int e = __Pyx_call_type_traverse((PyObject*)gen, 1, visit, arg);
  14949. if (e) return e;
  14950. }
  14951. Py_VISIT(gen->closure);
  14952. Py_VISIT(gen->classobj);
  14953. Py_VISIT(gen->yieldfrom);
  14954. return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
  14955. }
  14956. static int __Pyx_Coroutine_clear(PyObject *self) {
  14957. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14958. Py_CLEAR(gen->closure);
  14959. Py_CLEAR(gen->classobj);
  14960. __Pyx_Coroutine_Undelegate(gen);
  14961. __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
  14962. #ifdef __Pyx_AsyncGen_USED
  14963. if (__Pyx_AsyncGen_CheckExact(self)) {
  14964. Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
  14965. }
  14966. #endif
  14967. Py_CLEAR(gen->gi_code);
  14968. Py_CLEAR(gen->gi_frame);
  14969. Py_CLEAR(gen->gi_name);
  14970. Py_CLEAR(gen->gi_qualname);
  14971. Py_CLEAR(gen->gi_modulename);
  14972. return 0;
  14973. }
  14974. static void __Pyx_Coroutine_dealloc(PyObject *self) {
  14975. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14976. PyObject_GC_UnTrack(gen);
  14977. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  14978. if (gen->gi_weakreflist != NULL)
  14979. #endif
  14980. PyObject_ClearWeakRefs(self);
  14981. if (gen->resume_label >= 0) {
  14982. PyObject_GC_Track(self);
  14983. #if CYTHON_USE_TP_FINALIZE
  14984. if (unlikely(PyObject_CallFinalizerFromDealloc(self)))
  14985. #else
  14986. {
  14987. destructor del = __Pyx_PyObject_GetSlot(gen, tp_del, destructor);
  14988. if (del) del(self);
  14989. }
  14990. if (unlikely(Py_REFCNT(self) > 0))
  14991. #endif
  14992. {
  14993. return;
  14994. }
  14995. PyObject_GC_UnTrack(self);
  14996. }
  14997. #ifdef __Pyx_AsyncGen_USED
  14998. if (__Pyx_AsyncGen_CheckExact(self)) {
  14999. /* We have to handle this case for asynchronous generators
  15000. right here, because this code has to be between UNTRACK
  15001. and GC_Del. */
  15002. Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
  15003. }
  15004. #endif
  15005. __Pyx_Coroutine_clear(self);
  15006. __Pyx_PyHeapTypeObject_GC_Del(gen);
  15007. }
  15008. #if CYTHON_USE_TP_FINALIZE
  15009. static void __Pyx_Coroutine_del(PyObject *self) {
  15010. PyObject *error_type, *error_value, *error_traceback;
  15011. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15012. __Pyx_PyThreadState_declare
  15013. if (gen->resume_label < 0) {
  15014. return;
  15015. }
  15016. __Pyx_PyThreadState_assign
  15017. __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
  15018. #ifdef __Pyx_AsyncGen_USED
  15019. if (__Pyx_AsyncGen_CheckExact(self)) {
  15020. __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
  15021. PyObject *finalizer = agen->ag_finalizer;
  15022. if (finalizer && !agen->ag_closed) {
  15023. PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
  15024. if (unlikely(!res)) {
  15025. PyErr_WriteUnraisable(self);
  15026. } else {
  15027. Py_DECREF(res);
  15028. }
  15029. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  15030. return;
  15031. }
  15032. }
  15033. #endif
  15034. if (unlikely(gen->resume_label == 0 && !error_value)) {
  15035. #ifdef __Pyx_Coroutine_USED
  15036. #ifdef __Pyx_Generator_USED
  15037. if (!__Pyx_Generator_CheckExact(self))
  15038. #endif
  15039. {
  15040. PyObject_GC_UnTrack(self);
  15041. if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
  15042. PyErr_WriteUnraisable(self);
  15043. PyObject_GC_Track(self);
  15044. }
  15045. #endif
  15046. } else {
  15047. PyObject *retval = NULL;
  15048. __Pyx_PySendResult result = __Pyx_Coroutine_Close(self, &retval);
  15049. if (result == PYGEN_ERROR) {
  15050. PyErr_WriteUnraisable(self);
  15051. } else {
  15052. Py_XDECREF(retval);
  15053. }
  15054. }
  15055. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  15056. }
  15057. #endif
  15058. static PyObject *
  15059. __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context)
  15060. {
  15061. PyObject *name = self->gi_name;
  15062. CYTHON_UNUSED_VAR(context);
  15063. if (unlikely(!name)) name = Py_None;
  15064. Py_INCREF(name);
  15065. return name;
  15066. }
  15067. static int
  15068. __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context)
  15069. {
  15070. CYTHON_UNUSED_VAR(context);
  15071. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  15072. PyErr_SetString(PyExc_TypeError,
  15073. "__name__ must be set to a string object");
  15074. return -1;
  15075. }
  15076. Py_INCREF(value);
  15077. __Pyx_Py_XDECREF_SET(self->gi_name, value);
  15078. return 0;
  15079. }
  15080. static PyObject *
  15081. __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context)
  15082. {
  15083. PyObject *name = self->gi_qualname;
  15084. CYTHON_UNUSED_VAR(context);
  15085. if (unlikely(!name)) name = Py_None;
  15086. Py_INCREF(name);
  15087. return name;
  15088. }
  15089. static int
  15090. __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context)
  15091. {
  15092. CYTHON_UNUSED_VAR(context);
  15093. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  15094. PyErr_SetString(PyExc_TypeError,
  15095. "__qualname__ must be set to a string object");
  15096. return -1;
  15097. }
  15098. Py_INCREF(value);
  15099. __Pyx_Py_XDECREF_SET(self->gi_qualname, value);
  15100. return 0;
  15101. }
  15102. static PyObject *
  15103. __Pyx__Coroutine_get_frame(__pyx_CoroutineObject *self)
  15104. {
  15105. #if !CYTHON_COMPILING_IN_LIMITED_API
  15106. PyObject *frame;
  15107. #if PY_VERSION_HEX >= 0x030d0000
  15108. Py_BEGIN_CRITICAL_SECTION(self);
  15109. #endif
  15110. frame = self->gi_frame;
  15111. if (!frame) {
  15112. if (unlikely(!self->gi_code)) {
  15113. Py_RETURN_NONE;
  15114. }
  15115. PyObject *globals = PyDict_New();
  15116. if (unlikely(!globals)) return NULL;
  15117. frame = (PyObject *) PyFrame_New(
  15118. PyThreadState_Get(), /*PyThreadState *tstate,*/
  15119. (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/
  15120. globals, /*PyObject *globals,*/
  15121. 0 /*PyObject *locals*/
  15122. );
  15123. Py_DECREF(globals);
  15124. if (unlikely(!frame))
  15125. return NULL;
  15126. if (unlikely(self->gi_frame)) {
  15127. Py_DECREF(frame);
  15128. frame = self->gi_frame;
  15129. } else {
  15130. self->gi_frame = frame;
  15131. }
  15132. }
  15133. Py_INCREF(frame);
  15134. #if PY_VERSION_HEX >= 0x030d0000
  15135. Py_END_CRITICAL_SECTION();
  15136. #endif
  15137. return frame;
  15138. #else
  15139. CYTHON_UNUSED_VAR(self);
  15140. Py_RETURN_NONE;
  15141. #endif
  15142. }
  15143. static PyObject *
  15144. __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) {
  15145. CYTHON_UNUSED_VAR(context);
  15146. PyObject *frame = self->gi_frame;
  15147. if (frame)
  15148. return __Pyx_NewRef(frame);
  15149. return __Pyx__Coroutine_get_frame(self);
  15150. }
  15151. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  15152. PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  15153. PyObject *name, PyObject *qualname, PyObject *module_name) {
  15154. __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
  15155. if (unlikely(!gen))
  15156. return NULL;
  15157. return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
  15158. }
  15159. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  15160. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  15161. PyObject *name, PyObject *qualname, PyObject *module_name) {
  15162. gen->body = body;
  15163. gen->closure = closure;
  15164. Py_XINCREF(closure);
  15165. gen->is_running = 0;
  15166. gen->resume_label = 0;
  15167. gen->classobj = NULL;
  15168. gen->yieldfrom = NULL;
  15169. gen->yieldfrom_am_send = NULL;
  15170. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_LIMITED_API
  15171. gen->gi_exc_state.exc_value = NULL;
  15172. #else
  15173. gen->gi_exc_state.exc_type = NULL;
  15174. gen->gi_exc_state.exc_value = NULL;
  15175. gen->gi_exc_state.exc_traceback = NULL;
  15176. #endif
  15177. #if CYTHON_USE_EXC_INFO_STACK
  15178. gen->gi_exc_state.previous_item = NULL;
  15179. #endif
  15180. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  15181. gen->gi_weakreflist = NULL;
  15182. #endif
  15183. Py_XINCREF(qualname);
  15184. gen->gi_qualname = qualname;
  15185. Py_XINCREF(name);
  15186. gen->gi_name = name;
  15187. Py_XINCREF(module_name);
  15188. gen->gi_modulename = module_name;
  15189. Py_XINCREF(code);
  15190. gen->gi_code = code;
  15191. gen->gi_frame = NULL;
  15192. PyObject_GC_Track(gen);
  15193. return gen;
  15194. }
  15195. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen) {
  15196. char result;
  15197. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  15198. Py_BEGIN_CRITICAL_SECTION(gen);
  15199. #endif
  15200. result = gen->is_running;
  15201. gen->is_running = 1;
  15202. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  15203. Py_END_CRITICAL_SECTION();
  15204. #endif
  15205. return result;
  15206. }
  15207. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen) {
  15208. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  15209. Py_BEGIN_CRITICAL_SECTION(gen);
  15210. #endif
  15211. assert(gen->is_running);
  15212. gen->is_running = 0;
  15213. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  15214. Py_END_CRITICAL_SECTION();
  15215. #endif
  15216. }
  15217. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen) {
  15218. char result;
  15219. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  15220. Py_BEGIN_CRITICAL_SECTION(gen);
  15221. #endif
  15222. result = gen->is_running;
  15223. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  15224. Py_END_CRITICAL_SECTION();
  15225. #endif
  15226. return result;
  15227. }
  15228. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure) {
  15229. CYTHON_UNUSED_VAR(closure);
  15230. char result = __Pyx_Coroutine_get_is_running((__pyx_CoroutineObject*)gen);
  15231. if (result) Py_RETURN_TRUE;
  15232. else Py_RETURN_FALSE;
  15233. }
  15234. #if __PYX_HAS_PY_AM_SEND == 2
  15235. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send) {
  15236. Py_ssize_t ptr_offset = (char*)(type->tp_as_async) - (char*)type;
  15237. if (ptr_offset < 0 || ptr_offset > type->tp_basicsize) {
  15238. return;
  15239. }
  15240. memcpy((void*)static_amsend_methods, (void*)(type->tp_as_async), sizeof(*type->tp_as_async));
  15241. static_amsend_methods->am_send = am_send;
  15242. type->tp_as_async = __Pyx_SlotTpAsAsync(static_amsend_methods);
  15243. }
  15244. #endif
  15245. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg) {
  15246. CYTHON_UNUSED_VAR(arg);
  15247. __Pyx_TypeName self_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE((PyObject*)self));
  15248. PyErr_Format(PyExc_TypeError, "cannot pickle '" __Pyx_FMT_TYPENAME "' object",
  15249. self_type_name);
  15250. __Pyx_DECREF_TypeName(self_type_name);
  15251. return NULL;
  15252. }
  15253. /* Generator */
  15254. static PyMethodDef __pyx_Generator_methods[] = {
  15255. {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
  15256. PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
  15257. {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
  15258. PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
  15259. {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
  15260. PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
  15261. {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
  15262. {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
  15263. {0, 0, 0, 0}
  15264. };
  15265. static PyMemberDef __pyx_Generator_memberlist[] = {
  15266. {"gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
  15267. PyDoc_STR("object being iterated by 'yield from', or None")},
  15268. {"gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
  15269. {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
  15270. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  15271. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
  15272. #endif
  15273. {0, 0, 0, 0, 0}
  15274. };
  15275. static PyGetSetDef __pyx_Generator_getsets[] = {
  15276. {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
  15277. PyDoc_STR("name of the generator"), 0},
  15278. {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
  15279. PyDoc_STR("qualified name of the generator"), 0},
  15280. {"gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
  15281. PyDoc_STR("Frame of the generator"), 0},
  15282. {"gi_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
  15283. {0, 0, 0, 0, 0}
  15284. };
  15285. static PyType_Slot __pyx_GeneratorType_slots[] = {
  15286. {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
  15287. {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
  15288. {Py_tp_iter, (void *)PyObject_SelfIter},
  15289. {Py_tp_iternext, (void *)__Pyx_Generator_Next},
  15290. {Py_tp_methods, (void *)__pyx_Generator_methods},
  15291. {Py_tp_members, (void *)__pyx_Generator_memberlist},
  15292. {Py_tp_getset, (void *)__pyx_Generator_getsets},
  15293. {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
  15294. #if CYTHON_USE_TP_FINALIZE
  15295. {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
  15296. #endif
  15297. #if __PYX_HAS_PY_AM_SEND == 1
  15298. {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
  15299. #endif
  15300. {0, 0},
  15301. };
  15302. static PyType_Spec __pyx_GeneratorType_spec = {
  15303. __PYX_TYPE_MODULE_PREFIX "generator",
  15304. sizeof(__pyx_CoroutineObject),
  15305. 0,
  15306. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  15307. Py_TPFLAGS_MANAGED_WEAKREF |
  15308. #endif
  15309. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  15310. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND,
  15311. __pyx_GeneratorType_slots
  15312. };
  15313. #if __PYX_HAS_PY_AM_SEND == 2
  15314. static __Pyx_PyAsyncMethodsStruct __pyx_Generator_as_async;
  15315. #endif
  15316. static int __pyx_Generator_init(PyObject *module) {
  15317. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  15318. mstate->__pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(
  15319. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_GeneratorType_spec, NULL);
  15320. if (unlikely(!mstate->__pyx_GeneratorType)) {
  15321. return -1;
  15322. }
  15323. #if __PYX_HAS_PY_AM_SEND == 2
  15324. __Pyx_SetBackportTypeAmSend(mstate->__pyx_GeneratorType, &__pyx_Generator_as_async, &__Pyx_Coroutine_AmSend);
  15325. #endif
  15326. return 0;
  15327. }
  15328. static PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self) {
  15329. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15330. PyObject *retval = NULL;
  15331. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  15332. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15333. }
  15334. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  15335. __Pyx_Coroutine_unset_is_running(gen);
  15336. (void) result;
  15337. assert (result == PYGEN_RETURN || result == PYGEN_ERROR);
  15338. assert ((result == PYGEN_RETURN && retval != NULL) || (result == PYGEN_ERROR && retval == NULL));
  15339. return retval;
  15340. }
  15341. /* CheckBinaryVersion */
  15342. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
  15343. const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
  15344. if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
  15345. return 0;
  15346. if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
  15347. return 1;
  15348. {
  15349. char message[200];
  15350. PyOS_snprintf(message, sizeof(message),
  15351. "compile time Python version %d.%d "
  15352. "of module '%.100s' "
  15353. "%s "
  15354. "runtime version %d.%d",
  15355. (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
  15356. __Pyx_MODULE_NAME,
  15357. (allow_newer) ? "was newer than" : "does not match",
  15358. (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
  15359. );
  15360. return PyErr_WarnEx(NULL, message, 1);
  15361. }
  15362. }
  15363. /* NewCodeObj */
  15364. #if CYTHON_COMPILING_IN_LIMITED_API
  15365. static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  15366. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  15367. PyObject *fv, PyObject *cell, PyObject* fn,
  15368. PyObject *name, int fline, PyObject *lnos) {
  15369. PyObject *exception_table = NULL;
  15370. PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
  15371. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  15372. PyObject *version_info;
  15373. PyObject *py_minor_version = NULL;
  15374. #endif
  15375. long minor_version = 0;
  15376. PyObject *type, *value, *traceback;
  15377. PyErr_Fetch(&type, &value, &traceback);
  15378. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  15379. minor_version = 11;
  15380. #else
  15381. if (!(version_info = PySys_GetObject("version_info"))) goto end;
  15382. if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
  15383. minor_version = PyLong_AsLong(py_minor_version);
  15384. Py_DECREF(py_minor_version);
  15385. if (minor_version == -1 && PyErr_Occurred()) goto end;
  15386. #endif
  15387. if (!(types_module = PyImport_ImportModule("types"))) goto end;
  15388. if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
  15389. if (minor_version <= 7) {
  15390. (void)p;
  15391. result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code,
  15392. c, n, v, fn, name, fline, lnos, fv, cell);
  15393. } else if (minor_version <= 10) {
  15394. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code,
  15395. c, n, v, fn, name, fline, lnos, fv, cell);
  15396. } else {
  15397. if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
  15398. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code,
  15399. c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
  15400. }
  15401. end:
  15402. Py_XDECREF(code_type);
  15403. Py_XDECREF(exception_table);
  15404. Py_XDECREF(types_module);
  15405. if (type) {
  15406. PyErr_Restore(type, value, traceback);
  15407. }
  15408. return result;
  15409. }
  15410. #elif PY_VERSION_HEX >= 0x030B0000
  15411. static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  15412. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  15413. PyObject *fv, PyObject *cell, PyObject* fn,
  15414. PyObject *name, int fline, PyObject *lnos) {
  15415. PyCodeObject *result;
  15416. result =
  15417. #if PY_VERSION_HEX >= 0x030C0000
  15418. PyUnstable_Code_NewWithPosOnlyArgs
  15419. #else
  15420. PyCode_NewWithPosOnlyArgs
  15421. #endif
  15422. (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes);
  15423. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1
  15424. if (likely(result))
  15425. result->_co_firsttraceable = 0;
  15426. #endif
  15427. return result;
  15428. }
  15429. #elif !CYTHON_COMPILING_IN_PYPY
  15430. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  15431. PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  15432. #else
  15433. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  15434. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  15435. #endif
  15436. static PyObject* __Pyx_PyCode_New(
  15437. const __Pyx_PyCode_New_function_description descr,
  15438. PyObject * const *varnames,
  15439. PyObject *filename,
  15440. PyObject *funcname,
  15441. PyObject *line_table,
  15442. PyObject *tuple_dedup_map
  15443. ) {
  15444. PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL;
  15445. Py_ssize_t var_count = (Py_ssize_t) descr.nlocals;
  15446. PyObject *varnames_tuple = PyTuple_New(var_count);
  15447. if (unlikely(!varnames_tuple)) return NULL;
  15448. for (Py_ssize_t i=0; i < var_count; i++) {
  15449. Py_INCREF(varnames[i]);
  15450. if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done;
  15451. }
  15452. #if CYTHON_COMPILING_IN_LIMITED_API
  15453. varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple);
  15454. if (!varnames_tuple_dedup) {
  15455. if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done;
  15456. varnames_tuple_dedup = varnames_tuple;
  15457. }
  15458. #else
  15459. varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple);
  15460. if (unlikely(!varnames_tuple_dedup)) goto done;
  15461. #endif
  15462. #if CYTHON_AVOID_BORROWED_REFS
  15463. Py_INCREF(varnames_tuple_dedup);
  15464. #endif
  15465. if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) {
  15466. Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table);
  15467. #if !CYTHON_ASSUME_SAFE_SIZE
  15468. if (unlikely(line_table_length == -1)) goto done;
  15469. #endif
  15470. Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL;
  15471. code_bytes = PyBytes_FromStringAndSize(NULL, code_len);
  15472. if (unlikely(!code_bytes)) goto done;
  15473. char* c_code_bytes = PyBytes_AsString(code_bytes);
  15474. if (unlikely(!c_code_bytes)) goto done;
  15475. memset(c_code_bytes, 0, (size_t) code_len);
  15476. }
  15477. code_obj = (PyObject*) __Pyx__PyCode_New(
  15478. (int) descr.argcount,
  15479. (int) descr.num_posonly_args,
  15480. (int) descr.num_kwonly_args,
  15481. (int) descr.nlocals,
  15482. 0,
  15483. (int) descr.flags,
  15484. code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes,
  15485. __pyx_mstate_global->__pyx_empty_tuple,
  15486. __pyx_mstate_global->__pyx_empty_tuple,
  15487. varnames_tuple_dedup,
  15488. __pyx_mstate_global->__pyx_empty_tuple,
  15489. __pyx_mstate_global->__pyx_empty_tuple,
  15490. filename,
  15491. funcname,
  15492. (int) descr.first_line,
  15493. (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes
  15494. );
  15495. done:
  15496. Py_XDECREF(code_bytes);
  15497. #if CYTHON_AVOID_BORROWED_REFS
  15498. Py_XDECREF(varnames_tuple_dedup);
  15499. #endif
  15500. Py_DECREF(varnames_tuple);
  15501. return code_obj;
  15502. }
  15503. /* DecompressString */
  15504. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) {
  15505. PyObject *module, *decompress, *compressed_bytes, *decompressed;
  15506. const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib";
  15507. PyObject *methodname = PyUnicode_FromString("decompress");
  15508. if (unlikely(!methodname)) return NULL;
  15509. #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000
  15510. if (algo == 3) {
  15511. PyObject *fromlist = Py_BuildValue("[O]", methodname);
  15512. if (unlikely(!fromlist)) return NULL;
  15513. module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0);
  15514. Py_DECREF(fromlist);
  15515. } else
  15516. #endif
  15517. module = PyImport_ImportModule(module_name);
  15518. if (unlikely(!module)) goto import_failed;
  15519. decompress = PyObject_GetAttr(module, methodname);
  15520. if (unlikely(!decompress)) goto import_failed;
  15521. {
  15522. #ifdef __cplusplus
  15523. char *memview_bytes = const_cast<char*>(s);
  15524. #else
  15525. #if defined(__clang__)
  15526. #pragma clang diagnostic push
  15527. #pragma clang diagnostic ignored "-Wcast-qual"
  15528. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  15529. #pragma GCC diagnostic push
  15530. #pragma GCC diagnostic ignored "-Wcast-qual"
  15531. #endif
  15532. char *memview_bytes = (char*) s;
  15533. #if defined(__clang__)
  15534. #pragma clang diagnostic pop
  15535. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  15536. #pragma GCC diagnostic pop
  15537. #endif
  15538. #endif
  15539. #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ)
  15540. int memview_flags = 0x100;
  15541. #else
  15542. int memview_flags = PyBUF_READ;
  15543. #endif
  15544. compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags);
  15545. }
  15546. if (unlikely(!compressed_bytes)) {
  15547. Py_DECREF(decompress);
  15548. goto bad;
  15549. }
  15550. decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL);
  15551. Py_DECREF(compressed_bytes);
  15552. Py_DECREF(decompress);
  15553. Py_DECREF(module);
  15554. Py_DECREF(methodname);
  15555. return decompressed;
  15556. import_failed:
  15557. PyErr_Format(PyExc_ImportError,
  15558. "Failed to import '%.20s.decompress' - cannot initialise module strings. "
  15559. "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.",
  15560. module_name, algo);
  15561. bad:
  15562. Py_XDECREF(module);
  15563. Py_DECREF(methodname);
  15564. return NULL;
  15565. }
  15566. #include <string.h>
  15567. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) {
  15568. size_t len = strlen(s);
  15569. if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) {
  15570. PyErr_SetString(PyExc_OverflowError, "byte string is too long");
  15571. return -1;
  15572. }
  15573. return (Py_ssize_t) len;
  15574. }
  15575. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  15576. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  15577. if (unlikely(len < 0)) return NULL;
  15578. return __Pyx_PyUnicode_FromStringAndSize(c_str, len);
  15579. }
  15580. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) {
  15581. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  15582. if (unlikely(len < 0)) return NULL;
  15583. return PyByteArray_FromStringAndSize(c_str, len);
  15584. }
  15585. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  15586. Py_ssize_t ignore;
  15587. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  15588. }
  15589. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  15590. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  15591. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  15592. #if CYTHON_COMPILING_IN_LIMITED_API
  15593. {
  15594. const char* result;
  15595. Py_ssize_t unicode_length;
  15596. CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  15597. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  15598. if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL;
  15599. #else
  15600. result = PyUnicode_AsUTF8AndSize(o, length);
  15601. #endif
  15602. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  15603. unicode_length = PyUnicode_GetLength(o);
  15604. if (unlikely(unicode_length < 0)) return NULL;
  15605. if (unlikely(unicode_length != *length)) {
  15606. PyUnicode_AsASCIIString(o);
  15607. return NULL;
  15608. }
  15609. #endif
  15610. return result;
  15611. }
  15612. #else
  15613. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  15614. if (likely(PyUnicode_IS_ASCII(o))) {
  15615. *length = PyUnicode_GET_LENGTH(o);
  15616. return PyUnicode_AsUTF8(o);
  15617. } else {
  15618. PyUnicode_AsASCIIString(o);
  15619. return NULL;
  15620. }
  15621. #else
  15622. return PyUnicode_AsUTF8AndSize(o, length);
  15623. #endif
  15624. #endif
  15625. }
  15626. #endif
  15627. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  15628. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  15629. if (PyUnicode_Check(o)) {
  15630. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  15631. } else
  15632. #endif
  15633. if (PyByteArray_Check(o)) {
  15634. #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)))
  15635. *length = PyByteArray_GET_SIZE(o);
  15636. return PyByteArray_AS_STRING(o);
  15637. #else
  15638. *length = PyByteArray_Size(o);
  15639. if (*length == -1) return NULL;
  15640. return PyByteArray_AsString(o);
  15641. #endif
  15642. } else
  15643. {
  15644. char* result;
  15645. int r = PyBytes_AsStringAndSize(o, &result, length);
  15646. if (unlikely(r < 0)) {
  15647. return NULL;
  15648. } else {
  15649. return result;
  15650. }
  15651. }
  15652. }
  15653. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  15654. int is_true = x == Py_True;
  15655. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  15656. else return PyObject_IsTrue(x);
  15657. }
  15658. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  15659. int retval;
  15660. if (unlikely(!x)) return -1;
  15661. retval = __Pyx_PyObject_IsTrue(x);
  15662. Py_DECREF(x);
  15663. return retval;
  15664. }
  15665. static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) {
  15666. __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result));
  15667. if (PyLong_Check(result)) {
  15668. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  15669. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). "
  15670. "The ability to return an instance of a strict subclass of int is deprecated, "
  15671. "and may be removed in a future version of Python.",
  15672. result_type_name)) {
  15673. __Pyx_DECREF_TypeName(result_type_name);
  15674. Py_DECREF(result);
  15675. return NULL;
  15676. }
  15677. __Pyx_DECREF_TypeName(result_type_name);
  15678. return result;
  15679. }
  15680. PyErr_Format(PyExc_TypeError,
  15681. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")",
  15682. result_type_name);
  15683. __Pyx_DECREF_TypeName(result_type_name);
  15684. Py_DECREF(result);
  15685. return NULL;
  15686. }
  15687. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) {
  15688. #if CYTHON_USE_TYPE_SLOTS
  15689. PyNumberMethods *m;
  15690. #endif
  15691. PyObject *res = NULL;
  15692. if (likely(PyLong_Check(x)))
  15693. return __Pyx_NewRef(x);
  15694. #if CYTHON_USE_TYPE_SLOTS
  15695. m = Py_TYPE(x)->tp_as_number;
  15696. if (likely(m && m->nb_int)) {
  15697. res = m->nb_int(x);
  15698. }
  15699. #else
  15700. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  15701. res = PyNumber_Long(x);
  15702. }
  15703. #endif
  15704. if (likely(res)) {
  15705. if (unlikely(!PyLong_CheckExact(res))) {
  15706. return __Pyx_PyNumber_LongWrongResultType(res);
  15707. }
  15708. }
  15709. else if (!PyErr_Occurred()) {
  15710. PyErr_SetString(PyExc_TypeError,
  15711. "an integer is required");
  15712. }
  15713. return res;
  15714. }
  15715. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  15716. Py_ssize_t ival;
  15717. PyObject *x;
  15718. if (likely(PyLong_CheckExact(b))) {
  15719. #if CYTHON_USE_PYLONG_INTERNALS
  15720. if (likely(__Pyx_PyLong_IsCompact(b))) {
  15721. return __Pyx_PyLong_CompactValue(b);
  15722. } else {
  15723. const digit* digits = __Pyx_PyLong_Digits(b);
  15724. const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b);
  15725. switch (size) {
  15726. case 2:
  15727. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  15728. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15729. }
  15730. break;
  15731. case -2:
  15732. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  15733. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15734. }
  15735. break;
  15736. case 3:
  15737. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  15738. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15739. }
  15740. break;
  15741. case -3:
  15742. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  15743. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15744. }
  15745. break;
  15746. case 4:
  15747. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  15748. return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15749. }
  15750. break;
  15751. case -4:
  15752. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  15753. return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  15754. }
  15755. break;
  15756. }
  15757. }
  15758. #endif
  15759. return PyLong_AsSsize_t(b);
  15760. }
  15761. x = PyNumber_Index(b);
  15762. if (!x) return -1;
  15763. ival = PyLong_AsSsize_t(x);
  15764. Py_DECREF(x);
  15765. return ival;
  15766. }
  15767. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  15768. if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
  15769. return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
  15770. } else {
  15771. Py_ssize_t ival;
  15772. PyObject *x;
  15773. x = PyNumber_Index(o);
  15774. if (!x) return -1;
  15775. ival = PyLong_AsLong(x);
  15776. Py_DECREF(x);
  15777. return ival;
  15778. }
  15779. }
  15780. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) {
  15781. CYTHON_UNUSED_VAR(b);
  15782. return __Pyx_NewRef(Py_None);
  15783. }
  15784. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  15785. return __Pyx_NewRef(b ? Py_True: Py_False);
  15786. }
  15787. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) {
  15788. return PyLong_FromSize_t(ival);
  15789. }
  15790. /* MultiPhaseInitModuleState */
  15791. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  15792. #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15793. #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000)
  15794. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1
  15795. #else
  15796. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0
  15797. #endif
  15798. #endif
  15799. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS
  15800. #error "Module state with PEP489 requires atomics. Currently that's one of\
  15801. C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics"
  15802. #endif
  15803. #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15804. #define __Pyx_ModuleStateLookup_Lock()
  15805. #define __Pyx_ModuleStateLookup_Unlock()
  15806. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  15807. static PyMutex __Pyx_ModuleStateLookup_mutex = {0};
  15808. #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex)
  15809. #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex)
  15810. #elif defined(__cplusplus) && __cplusplus >= 201103L
  15811. #include <mutex>
  15812. static std::mutex __Pyx_ModuleStateLookup_mutex;
  15813. #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock()
  15814. #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock()
  15815. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__)
  15816. #include <threads.h>
  15817. static mtx_t __Pyx_ModuleStateLookup_mutex;
  15818. static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT;
  15819. static void __Pyx_ModuleStateLookup_initialize_mutex(void) {
  15820. mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain);
  15821. }
  15822. #define __Pyx_ModuleStateLookup_Lock()\
  15823. call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\
  15824. mtx_lock(&__Pyx_ModuleStateLookup_mutex)
  15825. #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex)
  15826. #elif defined(HAVE_PTHREAD_H)
  15827. #include <pthread.h>
  15828. static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER;
  15829. #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex)
  15830. #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex)
  15831. #elif defined(_WIN32)
  15832. #include <Windows.h> // synchapi.h on its own doesn't work
  15833. static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT;
  15834. #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  15835. #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  15836. #else
  15837. #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\
  15838. Requires C standard >= C11, or C++ standard >= C++11,\
  15839. or pthreads, or the Windows 32 API, or Python >= 3.13."
  15840. #endif
  15841. typedef struct {
  15842. int64_t id;
  15843. PyObject *module;
  15844. } __Pyx_InterpreterIdAndModule;
  15845. typedef struct {
  15846. char interpreter_id_as_index;
  15847. Py_ssize_t count;
  15848. Py_ssize_t allocated;
  15849. __Pyx_InterpreterIdAndModule table[1];
  15850. } __Pyx_ModuleStateLookupData;
  15851. #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32
  15852. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15853. static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0;
  15854. #endif
  15855. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15856. static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0;
  15857. #else
  15858. static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL;
  15859. #endif
  15860. static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound(
  15861. __Pyx_InterpreterIdAndModule* table,
  15862. Py_ssize_t count,
  15863. int64_t interpreterId) {
  15864. __Pyx_InterpreterIdAndModule* begin = table;
  15865. __Pyx_InterpreterIdAndModule* end = begin + count;
  15866. if (begin->id == interpreterId) {
  15867. return begin;
  15868. }
  15869. while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  15870. __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2;
  15871. if (halfway->id == interpreterId) {
  15872. return halfway;
  15873. }
  15874. if (halfway->id < interpreterId) {
  15875. begin = halfway;
  15876. } else {
  15877. end = halfway;
  15878. }
  15879. }
  15880. for (; begin < end; ++begin) {
  15881. if (begin->id >= interpreterId) return begin;
  15882. }
  15883. return begin;
  15884. }
  15885. static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) {
  15886. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15887. if (interpreter_id == -1) return NULL;
  15888. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15889. __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  15890. {
  15891. __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15892. if (likely(data)) {
  15893. __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data);
  15894. if (likely(data == new_data)) {
  15895. goto read_finished;
  15896. }
  15897. }
  15898. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15899. __Pyx_ModuleStateLookup_Lock();
  15900. __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter);
  15901. data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  15902. __Pyx_ModuleStateLookup_Unlock();
  15903. }
  15904. read_finished:;
  15905. #else
  15906. __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data;
  15907. #endif
  15908. __Pyx_InterpreterIdAndModule* found = NULL;
  15909. if (unlikely(!data)) goto end;
  15910. if (data->interpreter_id_as_index) {
  15911. if (interpreter_id < data->count) {
  15912. found = data->table+interpreter_id;
  15913. }
  15914. } else {
  15915. found = __Pyx_State_FindModuleStateLookupTableLowerBound(
  15916. data->table, data->count, interpreter_id);
  15917. }
  15918. end:
  15919. {
  15920. PyObject *result=NULL;
  15921. if (found && found->id == interpreter_id) {
  15922. result = found->module;
  15923. }
  15924. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15925. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15926. #endif
  15927. return result;
  15928. }
  15929. }
  15930. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15931. static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) {
  15932. while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0);
  15933. }
  15934. #else
  15935. #define __Pyx_ModuleStateLookup_wait_until_no_readers()
  15936. #endif
  15937. static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) {
  15938. Py_ssize_t to_allocate = (*old_data)->allocated;
  15939. while (to_allocate <= interpreter_id) {
  15940. if (to_allocate == 0) to_allocate = 1;
  15941. else to_allocate *= 2;
  15942. }
  15943. __Pyx_ModuleStateLookupData *new_data = *old_data;
  15944. if (to_allocate != (*old_data)->allocated) {
  15945. new_data = (__Pyx_ModuleStateLookupData *)realloc(
  15946. *old_data,
  15947. sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  15948. if (!new_data) {
  15949. PyErr_NoMemory();
  15950. return -1;
  15951. }
  15952. for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) {
  15953. new_data->table[i].id = i;
  15954. new_data->table[i].module = NULL;
  15955. }
  15956. new_data->allocated = to_allocate;
  15957. }
  15958. new_data->table[interpreter_id].module = module;
  15959. if (new_data->count < interpreter_id+1) {
  15960. new_data->count = interpreter_id+1;
  15961. }
  15962. *old_data = new_data;
  15963. return 0;
  15964. }
  15965. static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) {
  15966. __Pyx_InterpreterIdAndModule *read = data->table;
  15967. __Pyx_InterpreterIdAndModule *write = data->table;
  15968. __Pyx_InterpreterIdAndModule *end = read + data->count;
  15969. for (; read<end; ++read) {
  15970. if (read->module) {
  15971. write->id = read->id;
  15972. write->module = read->module;
  15973. ++write;
  15974. }
  15975. }
  15976. data->count = write - data->table;
  15977. for (; write<end; ++write) {
  15978. write->id = 0;
  15979. write->module = NULL;
  15980. }
  15981. data->interpreter_id_as_index = 0;
  15982. }
  15983. static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) {
  15984. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15985. if (interpreter_id == -1) return -1;
  15986. int result = 0;
  15987. __Pyx_ModuleStateLookup_Lock();
  15988. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15989. __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *)
  15990. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  15991. #else
  15992. __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data;
  15993. #endif
  15994. __Pyx_ModuleStateLookupData *new_data = old_data;
  15995. if (!new_data) {
  15996. new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData));
  15997. if (!new_data) {
  15998. result = -1;
  15999. PyErr_NoMemory();
  16000. goto end;
  16001. }
  16002. new_data->allocated = 1;
  16003. new_data->interpreter_id_as_index = 1;
  16004. }
  16005. __Pyx_ModuleStateLookup_wait_until_no_readers();
  16006. if (new_data->interpreter_id_as_index) {
  16007. if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  16008. result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id);
  16009. goto end;
  16010. }
  16011. __Pyx_State_ConvertFromInterpIdAsIndex(new_data);
  16012. }
  16013. {
  16014. Py_ssize_t insert_at = 0;
  16015. {
  16016. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  16017. new_data->table, new_data->count, interpreter_id);
  16018. assert(lower_bound);
  16019. insert_at = lower_bound - new_data->table;
  16020. if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) {
  16021. lower_bound->module = module;
  16022. goto end; // already in table, nothing more to do
  16023. }
  16024. }
  16025. if (new_data->count+1 >= new_data->allocated) {
  16026. Py_ssize_t to_allocate = (new_data->count+1)*2;
  16027. new_data =
  16028. (__Pyx_ModuleStateLookupData*)realloc(
  16029. new_data,
  16030. sizeof(__Pyx_ModuleStateLookupData) +
  16031. (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  16032. if (!new_data) {
  16033. result = -1;
  16034. new_data = old_data;
  16035. PyErr_NoMemory();
  16036. goto end;
  16037. }
  16038. new_data->allocated = to_allocate;
  16039. }
  16040. ++new_data->count;
  16041. int64_t last_id = interpreter_id;
  16042. PyObject *last_module = module;
  16043. for (Py_ssize_t i=insert_at; i<new_data->count; ++i) {
  16044. int64_t current_id = new_data->table[i].id;
  16045. new_data->table[i].id = last_id;
  16046. last_id = current_id;
  16047. PyObject *current_module = new_data->table[i].module;
  16048. new_data->table[i].module = last_module;
  16049. last_module = current_module;
  16050. }
  16051. }
  16052. end:
  16053. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16054. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data);
  16055. #else
  16056. __Pyx_ModuleStateLookup_data = new_data;
  16057. #endif
  16058. __Pyx_ModuleStateLookup_Unlock();
  16059. return result;
  16060. }
  16061. static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) {
  16062. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  16063. if (interpreter_id == -1) return -1;
  16064. __Pyx_ModuleStateLookup_Lock();
  16065. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16066. __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *)
  16067. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  16068. #else
  16069. __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data;
  16070. #endif
  16071. if (data->interpreter_id_as_index) {
  16072. if (interpreter_id < data->count) {
  16073. data->table[interpreter_id].module = NULL;
  16074. }
  16075. goto done;
  16076. }
  16077. {
  16078. __Pyx_ModuleStateLookup_wait_until_no_readers();
  16079. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  16080. data->table, data->count, interpreter_id);
  16081. if (!lower_bound) goto done;
  16082. if (lower_bound->id != interpreter_id) goto done;
  16083. __Pyx_InterpreterIdAndModule *end = data->table+data->count;
  16084. for (;lower_bound<end-1; ++lower_bound) {
  16085. lower_bound->id = (lower_bound+1)->id;
  16086. lower_bound->module = (lower_bound+1)->module;
  16087. }
  16088. }
  16089. --data->count;
  16090. if (data->count == 0) {
  16091. free(data);
  16092. data = NULL;
  16093. }
  16094. done:
  16095. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16096. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data);
  16097. #else
  16098. __Pyx_ModuleStateLookup_data = data;
  16099. #endif
  16100. __Pyx_ModuleStateLookup_Unlock();
  16101. return 0;
  16102. }
  16103. #endif
  16104. /* #### Code section: utility_code_pragmas_end ### */
  16105. #ifdef _MSC_VER
  16106. #pragma warning( pop )
  16107. #endif
  16108. /* #### Code section: end ### */
  16109. #endif /* Py_PYTHON_H */