qu2cu.c 717 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598
  1. /* Generated by Cython 3.2.4 */
  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_4"
  41. #define CYTHON_HEX_VERSION 0x030204F0
  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. #ifdef CYTHON_FREETHREADING_COMPATIBLE
  1136. #if CYTHON_FREETHREADING_COMPATIBLE
  1137. #define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_NOT_USED
  1138. #else
  1139. #define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_USED
  1140. #endif
  1141. #else
  1142. #define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_USED
  1143. #endif
  1144. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  1145. #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
  1146. #define __PYX_DEFAULT_STRING_ENCODING ""
  1147. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  1148. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  1149. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  1150. #define __Pyx_long_cast(x) ((long)x)
  1151. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  1152. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  1153. (sizeof(type) > sizeof(Py_ssize_t) &&\
  1154. likely(v < (type)PY_SSIZE_T_MAX ||\
  1155. v == (type)PY_SSIZE_T_MAX) &&\
  1156. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  1157. v == (type)PY_SSIZE_T_MIN))) ||\
  1158. (sizeof(type) == sizeof(Py_ssize_t) &&\
  1159. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  1160. v == (type)PY_SSIZE_T_MAX))) )
  1161. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  1162. return (size_t) i < (size_t) limit;
  1163. }
  1164. #if defined (__cplusplus) && __cplusplus >= 201103L
  1165. #include <cstdlib>
  1166. #define __Pyx_sst_abs(value) std::abs(value)
  1167. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  1168. #define __Pyx_sst_abs(value) abs(value)
  1169. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  1170. #define __Pyx_sst_abs(value) labs(value)
  1171. #elif defined (_MSC_VER)
  1172. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  1173. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  1174. #define __Pyx_sst_abs(value) llabs(value)
  1175. #elif defined (__GNUC__)
  1176. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  1177. #else
  1178. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  1179. #endif
  1180. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s);
  1181. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  1182. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  1183. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*);
  1184. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  1185. #define __Pyx_PyBytes_FromString PyBytes_FromString
  1186. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  1187. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  1188. #if CYTHON_ASSUME_SAFE_MACROS
  1189. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  1190. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  1191. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  1192. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  1193. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  1194. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  1195. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s)
  1196. #else
  1197. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s))
  1198. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s))
  1199. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s))
  1200. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s))
  1201. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s))
  1202. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s))
  1203. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s)
  1204. #endif
  1205. #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1206. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1207. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1208. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  1209. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  1210. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  1211. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  1212. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  1213. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  1214. #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o)
  1215. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  1216. static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) {
  1217. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef)
  1218. return Py_NewRef(obj);
  1219. #else
  1220. Py_INCREF(obj);
  1221. return obj;
  1222. #endif
  1223. }
  1224. static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) {
  1225. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef)
  1226. return Py_XNewRef(obj);
  1227. #else
  1228. Py_XINCREF(obj);
  1229. return obj;
  1230. #endif
  1231. }
  1232. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b);
  1233. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  1234. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  1235. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  1236. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x);
  1237. #define __Pyx_PySequence_Tuple(obj)\
  1238. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  1239. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  1240. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t);
  1241. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
  1242. #if CYTHON_ASSUME_SAFE_MACROS
  1243. #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  1244. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x)
  1245. #else
  1246. #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  1247. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x)
  1248. #endif
  1249. #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x))
  1250. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  1251. #if CYTHON_USE_PYLONG_INTERNALS
  1252. #if PY_VERSION_HEX >= 0x030C00A7
  1253. #ifndef _PyLong_SIGN_MASK
  1254. #define _PyLong_SIGN_MASK 3
  1255. #endif
  1256. #ifndef _PyLong_NON_SIZE_BITS
  1257. #define _PyLong_NON_SIZE_BITS 3
  1258. #endif
  1259. #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK)
  1260. #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0)
  1261. #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x))
  1262. #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1)
  1263. #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0)
  1264. #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0])
  1265. #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS))
  1266. #define __Pyx_PyLong_SignedDigitCount(x)\
  1267. ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x))
  1268. #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue)
  1269. #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x)
  1270. #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x)
  1271. #else
  1272. #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS))
  1273. #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
  1274. #endif
  1275. typedef Py_ssize_t __Pyx_compact_pylong;
  1276. typedef size_t __Pyx_compact_upylong;
  1277. #else
  1278. #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0)
  1279. #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0)
  1280. #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0)
  1281. #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0)
  1282. #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
  1283. #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x))
  1284. #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x)
  1285. #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
  1286. #define __Pyx_PyLong_CompactValue(x)\
  1287. ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
  1288. typedef sdigit __Pyx_compact_pylong;
  1289. typedef digit __Pyx_compact_upylong;
  1290. #endif
  1291. #if PY_VERSION_HEX >= 0x030C00A5
  1292. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit)
  1293. #else
  1294. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit)
  1295. #endif
  1296. #endif
  1297. #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  1298. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  1299. #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  1300. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL)
  1301. #else
  1302. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  1303. #endif
  1304. /* Test for GCC > 2.95 */
  1305. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  1306. #define likely(x) __builtin_expect(!!(x), 1)
  1307. #define unlikely(x) __builtin_expect(!!(x), 0)
  1308. #else /* !__GNUC__ or GCC < 2.95 */
  1309. #define likely(x) (x)
  1310. #define unlikely(x) (x)
  1311. #endif /* __GNUC__ */
  1312. /* PretendToInitialize */
  1313. #ifdef __cplusplus
  1314. #if __cplusplus > 201103L
  1315. #include <type_traits>
  1316. #endif
  1317. template <typename T>
  1318. static void __Pyx_pretend_to_initialize(T* ptr) {
  1319. #if __cplusplus > 201103L
  1320. if ((std::is_trivially_default_constructible<T>::value))
  1321. #endif
  1322. *ptr = T();
  1323. (void)ptr;
  1324. }
  1325. #else
  1326. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  1327. #endif
  1328. #if !CYTHON_USE_MODULE_STATE
  1329. static PyObject *__pyx_m = NULL;
  1330. #endif
  1331. static int __pyx_lineno;
  1332. static int __pyx_clineno = 0;
  1333. static const char * const __pyx_cfilenm = __FILE__;
  1334. static const char *__pyx_filename;
  1335. /* Header.proto */
  1336. #if !defined(CYTHON_CCOMPLEX)
  1337. #if defined(__cplusplus)
  1338. #define CYTHON_CCOMPLEX 1
  1339. #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__) && !defined(_MSC_VER))
  1340. #define CYTHON_CCOMPLEX 1
  1341. #else
  1342. #define CYTHON_CCOMPLEX 0
  1343. #endif
  1344. #endif
  1345. #if CYTHON_CCOMPLEX
  1346. #ifdef __cplusplus
  1347. #include <complex>
  1348. #else
  1349. #include <complex.h>
  1350. #endif
  1351. #endif
  1352. #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  1353. #undef _Complex_I
  1354. #define _Complex_I 1.0fj
  1355. #endif
  1356. /* #### Code section: filename_table ### */
  1357. static const char* const __pyx_f[] = {
  1358. "Lib/fontTools/qu2cu/qu2cu.py",
  1359. };
  1360. /* #### Code section: utility_code_proto_before_types ### */
  1361. /* Atomics.proto (used by UnpackUnboundCMethod) */
  1362. #include <pythread.h>
  1363. #ifndef CYTHON_ATOMICS
  1364. #define CYTHON_ATOMICS 1
  1365. #endif
  1366. #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS
  1367. #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1368. #define __pyx_atomic_int_type int
  1369. #define __pyx_nonatomic_int_type int
  1370. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1371. (__STDC_VERSION__ >= 201112L) &&\
  1372. !defined(__STDC_NO_ATOMICS__))
  1373. #include <stdatomic.h>
  1374. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1375. (__cplusplus >= 201103L) ||\
  1376. (defined(_MSC_VER) && _MSC_VER >= 1700)))
  1377. #include <atomic>
  1378. #endif
  1379. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1380. (__STDC_VERSION__ >= 201112L) &&\
  1381. !defined(__STDC_NO_ATOMICS__) &&\
  1382. ATOMIC_INT_LOCK_FREE == 2)
  1383. #undef __pyx_atomic_int_type
  1384. #define __pyx_atomic_int_type atomic_int
  1385. #define __pyx_atomic_ptr_type atomic_uintptr_t
  1386. #define __pyx_nonatomic_ptr_type uintptr_t
  1387. #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed)
  1388. #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel)
  1389. #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel)
  1390. #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg)
  1391. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1392. #define __pyx_atomic_load(value) atomic_load(value)
  1393. #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value)
  1394. #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed)
  1395. #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire)
  1396. #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1397. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1398. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1399. #pragma message ("Using standard C atomics")
  1400. #elif defined(__PYX_DEBUG_ATOMICS)
  1401. #warning "Using standard C atomics"
  1402. #endif
  1403. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1404. (__cplusplus >= 201103L) ||\
  1405. \
  1406. (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\
  1407. ATOMIC_INT_LOCK_FREE == 2)
  1408. #undef __pyx_atomic_int_type
  1409. #define __pyx_atomic_int_type std::atomic_int
  1410. #define __pyx_atomic_ptr_type std::atomic_uintptr_t
  1411. #define __pyx_nonatomic_ptr_type uintptr_t
  1412. #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed)
  1413. #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel)
  1414. #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel)
  1415. #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg)
  1416. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1417. #define __pyx_atomic_load(value) std::atomic_load(value)
  1418. #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value)
  1419. #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed)
  1420. #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire)
  1421. #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1422. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1423. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1424. #pragma message ("Using standard C++ atomics")
  1425. #elif defined(__PYX_DEBUG_ATOMICS)
  1426. #warning "Using standard C++ atomics"
  1427. #endif
  1428. #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\
  1429. (__GNUC_MINOR__ > 1 ||\
  1430. (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2))))
  1431. #define __pyx_atomic_ptr_type void*
  1432. #define __pyx_nonatomic_ptr_type void*
  1433. #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1)
  1434. #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1)
  1435. #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1)
  1436. #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg)
  1437. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1438. __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1439. int result = old == *expected;
  1440. *expected = old;
  1441. return result;
  1442. }
  1443. #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0)
  1444. #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value)
  1445. #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0)
  1446. #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0)
  1447. #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value)
  1448. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1449. __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1450. int result = old == *expected;
  1451. *expected = old;
  1452. return result;
  1453. }
  1454. #ifdef __PYX_DEBUG_ATOMICS
  1455. #warning "Using GNU atomics"
  1456. #endif
  1457. #elif CYTHON_ATOMICS && defined(_MSC_VER)
  1458. #include <intrin.h>
  1459. #undef __pyx_atomic_int_type
  1460. #define __pyx_atomic_int_type long
  1461. #define __pyx_atomic_ptr_type void*
  1462. #undef __pyx_nonatomic_int_type
  1463. #define __pyx_nonatomic_int_type long
  1464. #define __pyx_nonatomic_ptr_type void*
  1465. #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer)
  1466. #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1)
  1467. #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1)
  1468. #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1)
  1469. #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg)
  1470. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1471. __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected);
  1472. int result = old == *expected;
  1473. *expected = old;
  1474. return result;
  1475. }
  1476. #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0)
  1477. #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value)
  1478. #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value
  1479. #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0)
  1480. #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value)
  1481. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1482. __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected);
  1483. int result = old == *expected;
  1484. *expected = old;
  1485. return result;
  1486. }
  1487. #ifdef __PYX_DEBUG_ATOMICS
  1488. #pragma message ("Using MSVC atomics")
  1489. #endif
  1490. #else
  1491. #undef CYTHON_ATOMICS
  1492. #define CYTHON_ATOMICS 0
  1493. #ifdef __PYX_DEBUG_ATOMICS
  1494. #warning "Not using atomics"
  1495. #endif
  1496. #endif
  1497. /* CriticalSectionsDefinition.proto (used by CriticalSections) */
  1498. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1499. #define __Pyx_PyCriticalSection void*
  1500. #define __Pyx_PyCriticalSection2 void*
  1501. #define __Pyx_PyCriticalSection_End(cs)
  1502. #define __Pyx_PyCriticalSection2_End(cs)
  1503. #else
  1504. #define __Pyx_PyCriticalSection PyCriticalSection
  1505. #define __Pyx_PyCriticalSection2 PyCriticalSection2
  1506. #define __Pyx_PyCriticalSection_End PyCriticalSection_End
  1507. #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End
  1508. #endif
  1509. /* CriticalSections.proto (used by ParseKeywordsImpl) */
  1510. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1511. #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs)
  1512. #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs)
  1513. #else
  1514. #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin
  1515. #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin
  1516. #endif
  1517. #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1518. #define __Pyx_BEGIN_CRITICAL_SECTION(o) {
  1519. #define __Pyx_END_CRITICAL_SECTION() }
  1520. #else
  1521. #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION
  1522. #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION
  1523. #endif
  1524. /* IncludeStructmemberH.proto (used by FixUpExtensionType) */
  1525. #include <structmember.h>
  1526. /* #### Code section: numeric_typedefs ### */
  1527. /* #### Code section: complex_type_declarations ### */
  1528. /* Declarations.proto */
  1529. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  1530. #ifdef __cplusplus
  1531. typedef ::std::complex< double > __pyx_t_double_complex;
  1532. #else
  1533. typedef double _Complex __pyx_t_double_complex;
  1534. #endif
  1535. #else
  1536. typedef struct { double real, imag; } __pyx_t_double_complex;
  1537. #endif
  1538. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
  1539. /* #### Code section: type_declarations ### */
  1540. /*--- Type declarations ---*/
  1541. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  1542. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  1543. /* "fontTools/qu2cu/qu2cu.py":263
  1544. *
  1545. * if not is_complex:
  1546. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves] # <<<<<<<<<<<<<<
  1547. * return curves
  1548. *
  1549. */
  1550. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr {
  1551. PyObject_HEAD
  1552. PyObject *__pyx_genexpr_arg_0;
  1553. PyObject *__pyx_v_c;
  1554. int __pyx_v_cost;
  1555. int __pyx_v_is_complex;
  1556. PyObject *__pyx_t_0;
  1557. Py_ssize_t __pyx_t_1;
  1558. PyObject *(*__pyx_t_2)(PyObject *);
  1559. };
  1560. /* "fontTools/qu2cu/qu2cu.py":368
  1561. * for k, reconst in enumerate(reconstructed):
  1562. * orig = elevated_quadratics[j + k]
  1563. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig)) # <<<<<<<<<<<<<<
  1564. *
  1565. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  1566. */
  1567. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr {
  1568. PyObject_HEAD
  1569. PyObject *__pyx_genexpr_arg_0;
  1570. int __pyx_v_all_cubic;
  1571. int __pyx_v_count;
  1572. double __pyx_v_err;
  1573. double __pyx_v_error;
  1574. int __pyx_v_i;
  1575. int __pyx_v_i_sol_count;
  1576. double __pyx_v_i_sol_error;
  1577. int __pyx_v_is_cubic;
  1578. int __pyx_v_j;
  1579. int __pyx_v_j_sol_count;
  1580. double __pyx_v_j_sol_error;
  1581. int __pyx_v_k;
  1582. __pyx_t_double_complex __pyx_v_p0;
  1583. __pyx_t_double_complex __pyx_v_p1;
  1584. __pyx_t_double_complex __pyx_v_p2;
  1585. __pyx_t_double_complex __pyx_v_p3;
  1586. int __pyx_v_start;
  1587. int __pyx_v_this_sol_count;
  1588. double __pyx_v_tolerance;
  1589. __pyx_t_double_complex __pyx_v_u;
  1590. __pyx_t_double_complex __pyx_v_v;
  1591. PyObject *__pyx_t_0;
  1592. Py_ssize_t __pyx_t_1;
  1593. PyObject *(*__pyx_t_2)(PyObject *);
  1594. };
  1595. /* #### Code section: utility_code_proto ### */
  1596. /* --- Runtime support code (head) --- */
  1597. /* Refnanny.proto */
  1598. #ifndef CYTHON_REFNANNY
  1599. #define CYTHON_REFNANNY 0
  1600. #endif
  1601. #if CYTHON_REFNANNY
  1602. typedef struct {
  1603. void (*INCREF)(void*, PyObject*, Py_ssize_t);
  1604. void (*DECREF)(void*, PyObject*, Py_ssize_t);
  1605. void (*GOTREF)(void*, PyObject*, Py_ssize_t);
  1606. void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
  1607. void* (*SetupContext)(const char*, Py_ssize_t, const char*);
  1608. void (*FinishContext)(void**);
  1609. } __Pyx_RefNannyAPIStruct;
  1610. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1611. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1612. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1613. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1614. if (acquire_gil) {\
  1615. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1616. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1617. PyGILState_Release(__pyx_gilstate_save);\
  1618. } else {\
  1619. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1620. }
  1621. #define __Pyx_RefNannyFinishContextNogil() {\
  1622. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1623. __Pyx_RefNannyFinishContext();\
  1624. PyGILState_Release(__pyx_gilstate_save);\
  1625. }
  1626. #define __Pyx_RefNannyFinishContextNogil() {\
  1627. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1628. __Pyx_RefNannyFinishContext();\
  1629. PyGILState_Release(__pyx_gilstate_save);\
  1630. }
  1631. #define __Pyx_RefNannyFinishContext()\
  1632. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1633. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1634. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1635. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1636. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1637. #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
  1638. #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
  1639. #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
  1640. #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
  1641. #else
  1642. #define __Pyx_RefNannyDeclarations
  1643. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1644. #define __Pyx_RefNannyFinishContextNogil()
  1645. #define __Pyx_RefNannyFinishContext()
  1646. #define __Pyx_INCREF(r) Py_INCREF(r)
  1647. #define __Pyx_DECREF(r) Py_DECREF(r)
  1648. #define __Pyx_GOTREF(r)
  1649. #define __Pyx_GIVEREF(r)
  1650. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1651. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1652. #define __Pyx_XGOTREF(r)
  1653. #define __Pyx_XGIVEREF(r)
  1654. #endif
  1655. #define __Pyx_Py_XDECREF_SET(r, v) do {\
  1656. PyObject *tmp = (PyObject *) r;\
  1657. r = v; Py_XDECREF(tmp);\
  1658. } while (0)
  1659. #define __Pyx_XDECREF_SET(r, v) do {\
  1660. PyObject *tmp = (PyObject *) r;\
  1661. r = v; __Pyx_XDECREF(tmp);\
  1662. } while (0)
  1663. #define __Pyx_DECREF_SET(r, v) do {\
  1664. PyObject *tmp = (PyObject *) r;\
  1665. r = v; __Pyx_DECREF(tmp);\
  1666. } while (0)
  1667. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1668. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1669. /* PyErrExceptionMatches.proto (used by PyObjectGetAttrStrNoError) */
  1670. #if CYTHON_FAST_THREAD_STATE
  1671. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1672. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1673. #else
  1674. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1675. #endif
  1676. /* PyThreadStateGet.proto (used by PyErrFetchRestore) */
  1677. #if CYTHON_FAST_THREAD_STATE
  1678. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1679. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1680. #if PY_VERSION_HEX >= 0x030C00A6
  1681. #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL)
  1682. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL)
  1683. #else
  1684. #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL)
  1685. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type)
  1686. #endif
  1687. #else
  1688. #define __Pyx_PyThreadState_declare
  1689. #define __Pyx_PyThreadState_assign
  1690. #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
  1691. #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
  1692. #endif
  1693. /* PyErrFetchRestore.proto (used by PyObjectGetAttrStrNoError) */
  1694. #if CYTHON_FAST_THREAD_STATE
  1695. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1696. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1697. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1698. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1699. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1700. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1701. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1702. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
  1703. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1704. #else
  1705. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1706. #endif
  1707. #else
  1708. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1709. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1710. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1711. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1712. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1713. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1714. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1715. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1716. #endif
  1717. /* PyObjectGetAttrStr.proto (used by PyObjectGetAttrStrNoError) */
  1718. #if CYTHON_USE_TYPE_SLOTS
  1719. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1720. #else
  1721. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1722. #endif
  1723. /* PyObjectGetAttrStrNoError.proto (used by GetBuiltinName) */
  1724. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
  1725. /* GetBuiltinName.proto */
  1726. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1727. /* TupleAndListFromArray.proto (used by fastcall) */
  1728. #if CYTHON_COMPILING_IN_CPYTHON
  1729. static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
  1730. #endif
  1731. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL
  1732. static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
  1733. #endif
  1734. /* IncludeStringH.proto (used by BytesEquals) */
  1735. #include <string.h>
  1736. /* BytesEquals.proto (used by UnicodeEquals) */
  1737. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
  1738. /* UnicodeEquals.proto (used by fastcall) */
  1739. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
  1740. /* fastcall.proto */
  1741. #if CYTHON_AVOID_BORROWED_REFS
  1742. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i)
  1743. #elif CYTHON_ASSUME_SAFE_MACROS
  1744. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i))
  1745. #else
  1746. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i))
  1747. #endif
  1748. #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
  1749. #define __Pyx_KwValues_VARARGS(args, nargs) NULL
  1750. #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
  1751. #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
  1752. #if CYTHON_METH_FASTCALL
  1753. #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i])
  1754. #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds)
  1755. #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
  1756. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
  1757. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1758. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);
  1759. #else
  1760. #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
  1761. #endif
  1762. #else
  1763. #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS
  1764. #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
  1765. #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
  1766. #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
  1767. #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
  1768. #endif
  1769. #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1770. #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  1771. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start)
  1772. #else
  1773. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1774. #endif
  1775. /* py_dict_items.proto (used by OwnedDictNext) */
  1776. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
  1777. /* CallCFunction.proto (used by CallUnboundCMethod0) */
  1778. #define __Pyx_CallCFunction(cfunc, self, args)\
  1779. ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args)
  1780. #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\
  1781. ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs)
  1782. #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\
  1783. ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs)
  1784. #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\
  1785. ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames)
  1786. /* PyObjectCall.proto (used by PyObjectFastCall) */
  1787. #if CYTHON_COMPILING_IN_CPYTHON
  1788. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1789. #else
  1790. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1791. #endif
  1792. /* PyObjectCallMethO.proto (used by PyObjectFastCall) */
  1793. #if CYTHON_COMPILING_IN_CPYTHON
  1794. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1795. #endif
  1796. /* PyObjectFastCall.proto (used by PyObjectCallOneArg) */
  1797. #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
  1798. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs);
  1799. /* PyObjectCallOneArg.proto (used by CallUnboundCMethod0) */
  1800. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1801. /* UnpackUnboundCMethod.proto (used by CallUnboundCMethod0) */
  1802. typedef struct {
  1803. PyObject *type;
  1804. PyObject **method_name;
  1805. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
  1806. __pyx_atomic_int_type initialized;
  1807. #endif
  1808. PyCFunction func;
  1809. PyObject *method;
  1810. int flag;
  1811. } __Pyx_CachedCFunction;
  1812. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1813. static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) {
  1814. #if !CYTHON_ATOMICS
  1815. return 1;
  1816. #else
  1817. __pyx_nonatomic_int_type expected = 0;
  1818. if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) {
  1819. return 0;
  1820. }
  1821. return expected;
  1822. #endif
  1823. }
  1824. static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) {
  1825. #if CYTHON_ATOMICS
  1826. __pyx_atomic_store(&cfunc->initialized, 2);
  1827. #endif
  1828. }
  1829. #else
  1830. #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2
  1831. #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc)
  1832. #endif
  1833. /* CallUnboundCMethod0.proto */
  1834. CYTHON_UNUSED
  1835. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1836. #if CYTHON_COMPILING_IN_CPYTHON
  1837. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1838. #else
  1839. #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
  1840. #endif
  1841. /* py_dict_values.proto (used by OwnedDictNext) */
  1842. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d);
  1843. /* OwnedDictNext.proto (used by ParseKeywordsImpl) */
  1844. #if CYTHON_AVOID_BORROWED_REFS
  1845. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue);
  1846. #else
  1847. CYTHON_INLINE
  1848. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue);
  1849. #endif
  1850. /* RaiseDoubleKeywords.proto (used by ParseKeywordsImpl) */
  1851. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1852. /* ParseKeywordsImpl.export */
  1853. static int __Pyx_ParseKeywordsTuple(
  1854. PyObject *kwds,
  1855. PyObject * const *kwvalues,
  1856. PyObject ** const argnames[],
  1857. PyObject *kwds2,
  1858. PyObject *values[],
  1859. Py_ssize_t num_pos_args,
  1860. Py_ssize_t num_kwargs,
  1861. const char* function_name,
  1862. int ignore_unknown_kwargs
  1863. );
  1864. static int __Pyx_ParseKeywordDictToDict(
  1865. PyObject *kwds,
  1866. PyObject ** const argnames[],
  1867. PyObject *kwds2,
  1868. PyObject *values[],
  1869. Py_ssize_t num_pos_args,
  1870. const char* function_name
  1871. );
  1872. static int __Pyx_ParseKeywordDict(
  1873. PyObject *kwds,
  1874. PyObject ** const argnames[],
  1875. PyObject *values[],
  1876. Py_ssize_t num_pos_args,
  1877. Py_ssize_t num_kwargs,
  1878. const char* function_name,
  1879. int ignore_unknown_kwargs
  1880. );
  1881. /* CallUnboundCMethod2.proto */
  1882. CYTHON_UNUSED
  1883. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
  1884. #if CYTHON_COMPILING_IN_CPYTHON
  1885. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
  1886. #else
  1887. #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
  1888. #endif
  1889. /* ParseKeywords.proto */
  1890. static CYTHON_INLINE int __Pyx_ParseKeywords(
  1891. PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[],
  1892. PyObject *kwds2, PyObject *values[],
  1893. Py_ssize_t num_pos_args, Py_ssize_t num_kwargs,
  1894. const char* function_name,
  1895. int ignore_unknown_kwargs
  1896. );
  1897. /* RaiseArgTupleInvalid.proto */
  1898. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1899. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1900. /* GetItemInt.proto */
  1901. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1902. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1903. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\
  1904. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
  1905. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  1906. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1907. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1908. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1909. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  1910. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  1911. int wraparound, int boundscheck, int unsafe_shared);
  1912. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1913. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1914. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1915. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  1916. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  1917. int wraparound, int boundscheck, int unsafe_shared);
  1918. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  1919. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  1920. int is_list, int wraparound, int boundscheck, int unsafe_shared);
  1921. /* AssertionsEnabled.proto */
  1922. #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000
  1923. static int __pyx_assertions_enabled_flag;
  1924. #define __pyx_assertions_enabled() (__pyx_assertions_enabled_flag)
  1925. #if __clang__ || __GNUC__
  1926. __attribute__((no_sanitize("thread")))
  1927. #endif
  1928. static int __Pyx_init_assertions_enabled(void) {
  1929. PyObject *builtins, *debug, *debug_str;
  1930. int flag;
  1931. builtins = PyEval_GetBuiltins();
  1932. if (!builtins) goto bad;
  1933. debug_str = PyUnicode_FromStringAndSize("__debug__", 9);
  1934. if (!debug_str) goto bad;
  1935. debug = PyObject_GetItem(builtins, debug_str);
  1936. Py_DECREF(debug_str);
  1937. if (!debug) goto bad;
  1938. flag = PyObject_IsTrue(debug);
  1939. Py_DECREF(debug);
  1940. if (flag == -1) goto bad;
  1941. __pyx_assertions_enabled_flag = flag;
  1942. return 0;
  1943. bad:
  1944. __pyx_assertions_enabled_flag = 1;
  1945. return -1;
  1946. }
  1947. #else
  1948. #define __Pyx_init_assertions_enabled() (0)
  1949. #define __pyx_assertions_enabled() (!Py_OptimizeFlag)
  1950. #endif
  1951. /* PyAssertionError_Check.proto */
  1952. #define __Pyx_PyExc_AssertionError_Check(obj) __Pyx_TypeCheck(obj, PyExc_AssertionError)
  1953. /* RaiseException.export */
  1954. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  1955. /* py_abs.proto */
  1956. #if CYTHON_USE_PYLONG_INTERNALS
  1957. static PyObject *__Pyx_PyLong_AbsNeg(PyObject *num);
  1958. #define __Pyx_PyNumber_Absolute(x)\
  1959. ((likely(PyLong_CheckExact(x))) ?\
  1960. (likely(__Pyx_PyLong_IsNonNeg(x)) ? __Pyx_NewRef(x) : __Pyx_PyLong_AbsNeg(x)) :\
  1961. PyNumber_Absolute(x))
  1962. #else
  1963. #define __Pyx_PyNumber_Absolute(x) PyNumber_Absolute(x)
  1964. #endif
  1965. /* ListAppend.proto */
  1966. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1967. static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
  1968. PyListObject* L = (PyListObject*) list;
  1969. Py_ssize_t len = Py_SIZE(list);
  1970. if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
  1971. Py_INCREF(x);
  1972. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  1973. L->ob_item[len] = x;
  1974. #else
  1975. PyList_SET_ITEM(list, len, x);
  1976. #endif
  1977. __Pyx_SET_SIZE(list, len + 1);
  1978. return 0;
  1979. }
  1980. return PyList_Append(list, x);
  1981. }
  1982. #else
  1983. #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
  1984. #endif
  1985. /* SliceTupleAndList.proto */
  1986. #if CYTHON_COMPILING_IN_CPYTHON
  1987. static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
  1988. static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
  1989. #else
  1990. #define __Pyx_PyList_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
  1991. #define __Pyx_PyTuple_GetSlice(seq, start, stop) PySequence_GetSlice(seq, start, stop)
  1992. #endif
  1993. /* ListCompAppend.proto */
  1994. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1995. static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
  1996. PyListObject* L = (PyListObject*) list;
  1997. Py_ssize_t len = Py_SIZE(list);
  1998. if (likely(L->allocated > len)) {
  1999. Py_INCREF(x);
  2000. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  2001. L->ob_item[len] = x;
  2002. #else
  2003. PyList_SET_ITEM(list, len, x);
  2004. #endif
  2005. __Pyx_SET_SIZE(list, len + 1);
  2006. return 0;
  2007. }
  2008. return PyList_Append(list, x);
  2009. }
  2010. #else
  2011. #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
  2012. #endif
  2013. /* PyLongBinop.proto */
  2014. #if !CYTHON_COMPILING_IN_PYPY
  2015. static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
  2016. #else
  2017. #define __Pyx_PyLong_SubtractCObj(op1, op2, intval, inplace, zerodivision_check)\
  2018. (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
  2019. #endif
  2020. /* PyValueError_Check.proto */
  2021. #define __Pyx_PyExc_ValueError_Check(obj) __Pyx_TypeCheck(obj, PyExc_ValueError)
  2022. /* PyObjectFormatAndDecref.proto */
  2023. static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
  2024. static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);
  2025. /* JoinPyUnicode.export */
  2026. static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength,
  2027. Py_UCS4 max_char);
  2028. /* ArgTypeTestFunc.export */
  2029. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);
  2030. /* ArgTypeTest.proto */
  2031. #define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
  2032. ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\
  2033. __Pyx__ArgTypeTest(obj, type, name, exact))
  2034. /* RaiseUnboundLocalError.proto */
  2035. static void __Pyx_RaiseUnboundLocalError(const char *varname);
  2036. /* GetException.proto (used by pep479) */
  2037. #if CYTHON_FAST_THREAD_STATE
  2038. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  2039. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2040. #else
  2041. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  2042. #endif
  2043. /* pep479.proto */
  2044. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen);
  2045. /* PyDictVersioning.proto (used by GetModuleGlobalName) */
  2046. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  2047. #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
  2048. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  2049. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  2050. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  2051. (cache_var) = (value);
  2052. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  2053. static PY_UINT64_T __pyx_dict_version = 0;\
  2054. static PyObject *__pyx_dict_cached_value = NULL;\
  2055. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  2056. (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\
  2057. } else {\
  2058. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  2059. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  2060. }\
  2061. }
  2062. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
  2063. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
  2064. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
  2065. #else
  2066. #define __PYX_GET_DICT_VERSION(dict) (0)
  2067. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  2068. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  2069. #endif
  2070. /* GetModuleGlobalName.proto */
  2071. #if CYTHON_USE_DICT_VERSIONS
  2072. #define __Pyx_GetModuleGlobalName(var, name) do {\
  2073. static PY_UINT64_T __pyx_dict_version = 0;\
  2074. static PyObject *__pyx_dict_cached_value = NULL;\
  2075. (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\
  2076. (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
  2077. __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  2078. } while(0)
  2079. #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\
  2080. PY_UINT64_T __pyx_dict_version;\
  2081. PyObject *__pyx_dict_cached_value;\
  2082. (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  2083. } while(0)
  2084. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
  2085. #else
  2086. #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  2087. #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  2088. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
  2089. #endif
  2090. /* RaiseTooManyValuesToUnpack.proto */
  2091. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  2092. /* RaiseNeedMoreValuesToUnpack.proto */
  2093. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  2094. /* IterFinish.proto */
  2095. static CYTHON_INLINE int __Pyx_IterFinish(void);
  2096. /* UnpackItemEndCheck.proto */
  2097. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
  2098. /* SliceObject.proto */
  2099. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
  2100. PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
  2101. PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
  2102. int has_cstart, int has_cstop, int wraparound);
  2103. /* PyObjectCallNoArg.proto (used by PyObjectCallMethod0) */
  2104. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  2105. /* PyObjectGetMethod.proto (used by PyObjectCallMethod0) */
  2106. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  2107. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
  2108. #endif
  2109. /* PyObjectCallMethod0.proto (used by pop) */
  2110. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
  2111. /* pop.proto */
  2112. static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L);
  2113. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  2114. static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L);
  2115. #define __Pyx_PyObject_Pop(L) (likely(PyList_CheckExact(L)) ?\
  2116. __Pyx_PyList_Pop(L) : __Pyx__PyObject_Pop(L))
  2117. #else
  2118. #define __Pyx_PyList_Pop(L) __Pyx__PyObject_Pop(L)
  2119. #define __Pyx_PyObject_Pop(L) __Pyx__PyObject_Pop(L)
  2120. #endif
  2121. /* ListExtend.proto */
  2122. static CYTHON_INLINE int __Pyx_PyList_Extend(PyObject* L, PyObject* v) {
  2123. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00a2
  2124. return PyList_Extend(L, v);
  2125. #elif CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
  2126. PyObject* none = _PyList_Extend((PyListObject*)L, v);
  2127. if (unlikely(!none))
  2128. return -1;
  2129. Py_DECREF(none);
  2130. return 0;
  2131. #else
  2132. return PyList_SetSlice(L, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, v);
  2133. #endif
  2134. }
  2135. /* RaiseUnexpectedTypeError.proto */
  2136. static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj);
  2137. /* PyLongBinop.proto */
  2138. #if !CYTHON_COMPILING_IN_PYPY
  2139. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
  2140. #else
  2141. #define __Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
  2142. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  2143. #endif
  2144. /* GetTopmostException.proto (used by SaveResetException) */
  2145. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  2146. static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
  2147. #endif
  2148. /* SaveResetException.proto */
  2149. #if CYTHON_FAST_THREAD_STATE
  2150. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  2151. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2152. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  2153. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  2154. #else
  2155. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  2156. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  2157. #endif
  2158. /* PyZeroDivisionError_Check.proto */
  2159. #define __Pyx_PyExc_ZeroDivisionError_Check(obj) __Pyx_TypeCheck(obj, PyExc_ZeroDivisionError)
  2160. /* pyfrozenset_new.proto (used by PySetContains) */
  2161. static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);
  2162. /* PySetContains.proto */
  2163. static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);
  2164. /* HasAttr.proto (used by ImportImpl) */
  2165. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2166. #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n)
  2167. #else
  2168. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
  2169. #endif
  2170. /* ImportImpl.export */
  2171. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level);
  2172. /* Import.proto */
  2173. static CYTHON_INLINE PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level);
  2174. /* ImportFrom.proto */
  2175. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  2176. /* CheckTypeForFreelists.proto */
  2177. #if CYTHON_USE_FREELISTS
  2178. #if CYTHON_USE_TYPE_SPECS
  2179. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t) == (expected_tp)))
  2180. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS Py_TPFLAGS_IS_ABSTRACT
  2181. #else
  2182. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t)->tp_basicsize == (expected_size)))
  2183. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)
  2184. #endif
  2185. #define __PYX_CHECK_TYPE_FOR_FREELISTS(t, expected_tp, expected_size)\
  2186. (__PYX_CHECK_FINAL_TYPE_FOR_FREELISTS((t), (expected_tp), (expected_size)) &\
  2187. (int) (!__Pyx_PyType_HasFeature((t), __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS)))
  2188. #endif
  2189. /* AllocateExtensionType.proto */
  2190. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final);
  2191. /* CallTypeTraverse.proto */
  2192. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  2193. #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0
  2194. #else
  2195. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg);
  2196. #endif
  2197. /* LimitedApiGetTypeDict.proto (used by SetItemOnTypeDict) */
  2198. #if CYTHON_COMPILING_IN_LIMITED_API
  2199. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp);
  2200. #endif
  2201. /* SetItemOnTypeDict.proto (used by FixUpExtensionType) */
  2202. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v);
  2203. #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v)
  2204. /* FixUpExtensionType.proto */
  2205. static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type);
  2206. /* ValidateBasesTuple.proto (used by PyType_Ready) */
  2207. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  2208. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases);
  2209. #endif
  2210. /* PyType_Ready.proto */
  2211. CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t);
  2212. /* ListPack.proto */
  2213. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...);
  2214. /* dict_setdefault.proto (used by FetchCommonType) */
  2215. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value);
  2216. /* AddModuleRef.proto (used by FetchSharedCythonModule) */
  2217. #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\
  2218. __PYX_LIMITED_VERSION_HEX < 0x030d0000)
  2219. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name);
  2220. #else
  2221. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  2222. #endif
  2223. /* FetchSharedCythonModule.proto (used by FetchCommonType) */
  2224. static PyObject *__Pyx_FetchSharedCythonABIModule(void);
  2225. /* FetchCommonType.proto (used by CommonTypesMetaclass) */
  2226. static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases);
  2227. /* CommonTypesMetaclass.proto (used by CythonFunctionShared) */
  2228. static int __pyx_CommonTypesMetaclass_init(PyObject *module);
  2229. #define __Pyx_CommonTypesMetaclass_USED
  2230. /* PyMethodNew.proto (used by CythonFunctionShared) */
  2231. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ);
  2232. /* PyVectorcallFastCallDict.proto (used by CythonFunctionShared) */
  2233. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  2234. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
  2235. #endif
  2236. /* CythonFunctionShared.proto (used by CythonFunction) */
  2237. #define __Pyx_CyFunction_USED
  2238. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  2239. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  2240. #define __Pyx_CYFUNCTION_CCLASS 0x04
  2241. #define __Pyx_CYFUNCTION_COROUTINE 0x08
  2242. #define __Pyx_CyFunction_GetClosure(f)\
  2243. (((__pyx_CyFunctionObject *) (f))->func_closure)
  2244. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2245. #define __Pyx_CyFunction_GetClassObj(f)\
  2246. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  2247. #else
  2248. #define __Pyx_CyFunction_GetClassObj(f)\
  2249. ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
  2250. #endif
  2251. #define __Pyx_CyFunction_SetClassObj(f, classobj)\
  2252. __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
  2253. #define __Pyx_CyFunction_Defaults(type, f)\
  2254. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  2255. #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
  2256. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  2257. typedef struct {
  2258. #if CYTHON_COMPILING_IN_LIMITED_API
  2259. PyObject_HEAD
  2260. PyObject *func;
  2261. #elif PY_VERSION_HEX < 0x030900B1
  2262. PyCFunctionObject func;
  2263. #else
  2264. PyCMethodObject func;
  2265. #endif
  2266. #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL
  2267. __pyx_vectorcallfunc func_vectorcall;
  2268. #endif
  2269. #if CYTHON_COMPILING_IN_LIMITED_API
  2270. PyObject *func_weakreflist;
  2271. #endif
  2272. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2273. PyObject *func_dict;
  2274. #endif
  2275. PyObject *func_name;
  2276. PyObject *func_qualname;
  2277. PyObject *func_doc;
  2278. PyObject *func_globals;
  2279. PyObject *func_code;
  2280. PyObject *func_closure;
  2281. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2282. PyObject *func_classobj;
  2283. #endif
  2284. PyObject *defaults;
  2285. int flags;
  2286. PyObject *defaults_tuple;
  2287. PyObject *defaults_kwdict;
  2288. PyObject *(*defaults_getter)(PyObject *);
  2289. PyObject *func_annotations;
  2290. PyObject *func_is_coroutine;
  2291. } __pyx_CyFunctionObject;
  2292. #undef __Pyx_CyOrPyCFunction_Check
  2293. #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2294. #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type)
  2295. #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2296. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));
  2297. #undef __Pyx_IsSameCFunction
  2298. #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
  2299. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
  2300. int flags, PyObject* qualname,
  2301. PyObject *closure,
  2302. PyObject *module, PyObject *globals,
  2303. PyObject* code);
  2304. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
  2305. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
  2306. PyTypeObject *defaults_type);
  2307. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  2308. PyObject *tuple);
  2309. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  2310. PyObject *dict);
  2311. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  2312. PyObject *dict);
  2313. static int __pyx_CyFunction_init(PyObject *module);
  2314. #if CYTHON_METH_FASTCALL
  2315. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2316. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2317. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2318. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2319. #if CYTHON_COMPILING_IN_LIMITED_API
  2320. #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
  2321. #else
  2322. #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
  2323. #endif
  2324. #endif
  2325. /* CythonFunction.proto */
  2326. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
  2327. int flags, PyObject* qualname,
  2328. PyObject *closure,
  2329. PyObject *module, PyObject *globals,
  2330. PyObject* code);
  2331. /* ObjectGetItem.proto */
  2332. #if CYTHON_USE_TYPE_SLOTS
  2333. static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key);
  2334. #else
  2335. #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
  2336. #endif
  2337. /* CLineInTraceback.proto (used by AddTraceback) */
  2338. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  2339. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  2340. #else
  2341. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  2342. #endif
  2343. /* CodeObjectCache.proto (used by AddTraceback) */
  2344. #if CYTHON_COMPILING_IN_LIMITED_API
  2345. typedef PyObject __Pyx_CachedCodeObjectType;
  2346. #else
  2347. typedef PyCodeObject __Pyx_CachedCodeObjectType;
  2348. #endif
  2349. typedef struct {
  2350. __Pyx_CachedCodeObjectType* code_object;
  2351. int code_line;
  2352. } __Pyx_CodeObjectCacheEntry;
  2353. struct __Pyx_CodeObjectCache {
  2354. int count;
  2355. int max_count;
  2356. __Pyx_CodeObjectCacheEntry* entries;
  2357. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  2358. __pyx_atomic_int_type accessor_count;
  2359. #endif
  2360. };
  2361. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  2362. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line);
  2363. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object);
  2364. /* AddTraceback.proto */
  2365. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  2366. int py_line, const char *filename);
  2367. /* RealImag.proto */
  2368. #if CYTHON_CCOMPLEX
  2369. #ifdef __cplusplus
  2370. #define __Pyx_CREAL(z) ((z).real())
  2371. #define __Pyx_CIMAG(z) ((z).imag())
  2372. #else
  2373. #define __Pyx_CREAL(z) (__real__(z))
  2374. #define __Pyx_CIMAG(z) (__imag__(z))
  2375. #endif
  2376. #else
  2377. #define __Pyx_CREAL(z) ((z).real)
  2378. #define __Pyx_CIMAG(z) ((z).imag)
  2379. #endif
  2380. #if defined(__cplusplus) && CYTHON_CCOMPLEX\
  2381. && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
  2382. #define __Pyx_SET_CREAL(z,x) ((z).real(x))
  2383. #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
  2384. #else
  2385. #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
  2386. #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
  2387. #endif
  2388. /* Arithmetic.proto */
  2389. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  2390. #define __Pyx_c_eq_double(a, b) ((a)==(b))
  2391. #define __Pyx_c_sum_double(a, b) ((a)+(b))
  2392. #define __Pyx_c_diff_double(a, b) ((a)-(b))
  2393. #define __Pyx_c_prod_double(a, b) ((a)*(b))
  2394. #define __Pyx_c_quot_double(a, b) ((a)/(b))
  2395. #define __Pyx_c_neg_double(a) (-(a))
  2396. #ifdef __cplusplus
  2397. #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
  2398. #define __Pyx_c_conj_double(z) (::std::conj(z))
  2399. #if 1
  2400. #define __Pyx_c_abs_double(z) (::std::abs(z))
  2401. #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
  2402. #endif
  2403. #else
  2404. #define __Pyx_c_is_zero_double(z) ((z)==0)
  2405. #define __Pyx_c_conj_double(z) (conj(z))
  2406. #if 1
  2407. #define __Pyx_c_abs_double(z) (cabs(z))
  2408. #define __Pyx_c_pow_double(a, b) (cpow(a, b))
  2409. #endif
  2410. #endif
  2411. #else
  2412. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2413. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2414. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2415. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2416. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2417. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
  2418. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
  2419. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
  2420. #if 1
  2421. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
  2422. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2423. #endif
  2424. #endif
  2425. /* FromPy.proto */
  2426. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
  2427. /* GCCDiagnostics.proto */
  2428. #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  2429. #define __Pyx_HAS_GCC_DIAGNOSTIC
  2430. #endif
  2431. /* ToPy.proto */
  2432. #define __pyx_PyComplex_FromComplex(z)\
  2433. PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
  2434. (double)__Pyx_CIMAG(z))
  2435. /* CIntFromPy.proto */
  2436. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *);
  2437. /* PyObjectVectorCallKwBuilder.proto (used by CIntToPy) */
  2438. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2439. #if CYTHON_VECTORCALL
  2440. #if PY_VERSION_HEX >= 0x03090000
  2441. #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall
  2442. #else
  2443. #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall
  2444. #endif
  2445. #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n)
  2446. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2447. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2448. #else
  2449. #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict
  2450. #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n)
  2451. #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value)
  2452. #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value)
  2453. #endif
  2454. /* CIntToPy.proto */
  2455. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value);
  2456. /* CIntToPy.proto */
  2457. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value);
  2458. /* FormatTypeName.proto */
  2459. #if CYTHON_COMPILING_IN_LIMITED_API
  2460. typedef PyObject *__Pyx_TypeName;
  2461. #define __Pyx_FMT_TYPENAME "%U"
  2462. #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
  2463. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2464. #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName
  2465. #else
  2466. static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp);
  2467. #endif
  2468. #else // !LIMITED_API
  2469. typedef const char *__Pyx_TypeName;
  2470. #define __Pyx_FMT_TYPENAME "%.200s"
  2471. #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name)
  2472. #define __Pyx_DECREF_TypeName(obj)
  2473. #endif
  2474. /* CIntFromPy.proto */
  2475. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *);
  2476. /* FastTypeChecks.proto */
  2477. #if CYTHON_COMPILING_IN_CPYTHON
  2478. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  2479. #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
  2480. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  2481. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);
  2482. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  2483. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  2484. #else
  2485. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  2486. #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
  2487. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  2488. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) {
  2489. return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2);
  2490. }
  2491. #endif
  2492. #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2)
  2493. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  2494. #ifdef PyExceptionInstance_Check
  2495. #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj)
  2496. #else
  2497. #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException)
  2498. #endif
  2499. /* GetRuntimeVersion.proto */
  2500. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  2501. static unsigned long __Pyx_cached_runtime_version = 0;
  2502. static void __Pyx_init_runtime_version(void);
  2503. #else
  2504. #define __Pyx_init_runtime_version()
  2505. #endif
  2506. static unsigned long __Pyx_get_runtime_version(void);
  2507. /* SwapException.proto (used by CoroutineBase) */
  2508. #if CYTHON_FAST_THREAD_STATE
  2509. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  2510. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2511. #else
  2512. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  2513. #endif
  2514. /* IterNextPlain.proto (used by CoroutineBase) */
  2515. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator);
  2516. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  2517. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void);
  2518. #endif
  2519. /* PyObjectCall2Args.proto (used by PyObjectCallMethod1) */
  2520. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
  2521. /* PyObjectCallMethod1.proto (used by CoroutineBase) */
  2522. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  2523. /* ReturnWithStopIteration.proto (used by CoroutineBase) */
  2524. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext);
  2525. /* CoroutineBase.proto (used by Generator) */
  2526. struct __pyx_CoroutineObject;
  2527. typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *);
  2528. #if CYTHON_USE_EXC_INFO_STACK
  2529. #define __Pyx_ExcInfoStruct _PyErr_StackItem
  2530. #else
  2531. typedef struct {
  2532. PyObject *exc_type;
  2533. PyObject *exc_value;
  2534. PyObject *exc_traceback;
  2535. } __Pyx_ExcInfoStruct;
  2536. #endif
  2537. typedef struct __pyx_CoroutineObject {
  2538. PyObject_HEAD
  2539. __pyx_coroutine_body_t body;
  2540. PyObject *closure;
  2541. __Pyx_ExcInfoStruct gi_exc_state;
  2542. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2543. PyObject *gi_weakreflist;
  2544. #endif
  2545. PyObject *classobj;
  2546. PyObject *yieldfrom;
  2547. __Pyx_pyiter_sendfunc yieldfrom_am_send;
  2548. PyObject *gi_name;
  2549. PyObject *gi_qualname;
  2550. PyObject *gi_modulename;
  2551. PyObject *gi_code;
  2552. PyObject *gi_frame;
  2553. #if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
  2554. PyMonitoringState __pyx_pymonitoring_state[__Pyx_MonitoringEventTypes_CyGen_count];
  2555. uint64_t __pyx_pymonitoring_version;
  2556. #endif
  2557. int resume_label;
  2558. char is_running;
  2559. } __pyx_CoroutineObject;
  2560. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  2561. PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2562. PyObject *name, PyObject *qualname, PyObject *module_name);
  2563. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  2564. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2565. PyObject *name, PyObject *qualname, PyObject *module_name);
  2566. static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
  2567. static int __Pyx_Coroutine_clear(PyObject *self);
  2568. static __Pyx_PySendResult __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval);
  2569. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
  2570. static __Pyx_PySendResult __Pyx_Coroutine_Close(PyObject *self, PyObject **retval);
  2571. static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
  2572. #if CYTHON_USE_EXC_INFO_STACK
  2573. #define __Pyx_Coroutine_SwapException(self)
  2574. #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
  2575. #else
  2576. #define __Pyx_Coroutine_SwapException(self) {\
  2577. __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
  2578. __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
  2579. }
  2580. #define __Pyx_Coroutine_ResetAndClearException(self) {\
  2581. __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
  2582. (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
  2583. }
  2584. #endif
  2585. #if CYTHON_FAST_THREAD_STATE
  2586. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2587. __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
  2588. #else
  2589. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2590. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
  2591. #endif
  2592. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
  2593. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
  2594. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen);
  2595. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen);
  2596. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen);
  2597. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure);
  2598. #if __PYX_HAS_PY_AM_SEND == 2
  2599. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send);
  2600. #endif
  2601. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg);
  2602. /* Generator.proto */
  2603. #define __Pyx_Generator_USED
  2604. #define __Pyx_Generator_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_GeneratorType)
  2605. #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
  2606. __Pyx__Coroutine_New(__pyx_mstate_global->__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
  2607. static PyObject *__Pyx_Generator_Next(PyObject *self);
  2608. static int __pyx_Generator_init(PyObject *module);
  2609. static CYTHON_INLINE PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self);
  2610. /* CheckBinaryVersion.proto */
  2611. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);
  2612. /* DecompressString.proto */
  2613. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo);
  2614. /* MultiPhaseInitModuleState.proto */
  2615. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  2616. static PyObject *__Pyx_State_FindModule(void*);
  2617. static int __Pyx_State_AddModule(PyObject* module, void*);
  2618. static int __Pyx_State_RemoveModule(void*);
  2619. #elif CYTHON_USE_MODULE_STATE
  2620. #define __Pyx_State_FindModule PyState_FindModule
  2621. #define __Pyx_State_AddModule PyState_AddModule
  2622. #define __Pyx_State_RemoveModule PyState_RemoveModule
  2623. #endif
  2624. /* #### Code section: module_declarations ### */
  2625. /* CythonABIVersion.proto */
  2626. #if CYTHON_COMPILING_IN_LIMITED_API
  2627. #if CYTHON_METH_FASTCALL
  2628. #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall"
  2629. #else
  2630. #define __PYX_FASTCALL_ABI_SUFFIX
  2631. #endif
  2632. #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
  2633. #else
  2634. #define __PYX_LIMITED_ABI_SUFFIX
  2635. #endif
  2636. #if __PYX_HAS_PY_AM_SEND == 1
  2637. #define __PYX_AM_SEND_ABI_SUFFIX
  2638. #elif __PYX_HAS_PY_AM_SEND == 2
  2639. #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport"
  2640. #else
  2641. #define __PYX_AM_SEND_ABI_SUFFIX "noamsend"
  2642. #endif
  2643. #ifndef __PYX_MONITORING_ABI_SUFFIX
  2644. #define __PYX_MONITORING_ABI_SUFFIX
  2645. #endif
  2646. #if CYTHON_USE_TP_FINALIZE
  2647. #define __PYX_TP_FINALIZE_ABI_SUFFIX
  2648. #else
  2649. #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize"
  2650. #endif
  2651. #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED)
  2652. #define __PYX_FREELISTS_ABI_SUFFIX
  2653. #else
  2654. #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists"
  2655. #endif
  2656. #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
  2657. #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
  2658. #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
  2659. /* Module declarations from "cython" */
  2660. /* Module declarations from "fontTools.qu2cu.qu2cu" */
  2661. 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*/
  2662. static PyObject *__pyx_f_9fontTools_5qu2cu_5qu2cu_merge_curves(PyObject *, int, int); /*proto*/
  2663. /* #### Code section: typeinfo ### */
  2664. /* #### Code section: before_global_var ### */
  2665. #define __Pyx_MODULE_NAME "fontTools.qu2cu.qu2cu"
  2666. extern int __pyx_module_is_main_fontTools__qu2cu__qu2cu;
  2667. int __pyx_module_is_main_fontTools__qu2cu__qu2cu = 0;
  2668. /* Implementation of "fontTools.qu2cu.qu2cu" */
  2669. /* #### Code section: global_var ### */
  2670. static PyObject *__pyx_builtin_enumerate;
  2671. static PyObject *__pyx_builtin_reversed;
  2672. static PyObject *__pyx_builtin_zip;
  2673. static PyObject *__pyx_builtin_print;
  2674. /* #### Code section: string_decls ### */
  2675. /* #### Code section: decls ### */
  2676. 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 */
  2677. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_p); /* proto */
  2678. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_4_raise_incompatible_point(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_point, PyObject *__pyx_v_previous_point); /* proto */
  2679. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_6_validate_spline_length(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_spline); /* proto */
  2680. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_8_validate_positive_tolerance(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_max_err); /* proto */
  2681. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
  2682. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_10quadratic_to_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_quads, double __pyx_v_max_err, int __pyx_v_all_cubic); /* proto */
  2683. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
  2684. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_12spline_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 */
  2685. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_14main(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
  2686. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2687. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2688. /* #### Code section: late_includes ### */
  2689. /* #### Code section: module_state ### */
  2690. /* SmallCodeConfig */
  2691. #ifndef CYTHON_SMALL_CODE
  2692. #if defined(__clang__)
  2693. #define CYTHON_SMALL_CODE
  2694. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  2695. #define CYTHON_SMALL_CODE __attribute__((cold))
  2696. #else
  2697. #define CYTHON_SMALL_CODE
  2698. #endif
  2699. #endif
  2700. typedef struct {
  2701. PyObject *__pyx_d;
  2702. PyObject *__pyx_b;
  2703. PyObject *__pyx_cython_runtime;
  2704. PyObject *__pyx_empty_tuple;
  2705. PyObject *__pyx_empty_bytes;
  2706. PyObject *__pyx_empty_unicode;
  2707. PyObject *__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  2708. PyObject *__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  2709. PyTypeObject *__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  2710. PyTypeObject *__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  2711. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items;
  2712. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop;
  2713. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values;
  2714. __Pyx_CachedCFunction __pyx_umethod_PyList_Type_pop;
  2715. PyObject *__pyx_slice[1];
  2716. PyObject *__pyx_tuple[1];
  2717. PyObject *__pyx_codeobj_tab[10];
  2718. PyObject *__pyx_string_tab[150];
  2719. PyObject *__pyx_number_tab[3];
  2720. /* #### Code section: module_state_contents ### */
  2721. #if CYTHON_USE_FREELISTS
  2722. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr[8];
  2723. int __pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  2724. #endif
  2725. #if CYTHON_USE_FREELISTS
  2726. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *__pyx_freelist_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr[8];
  2727. int __pyx_freecount_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  2728. #endif
  2729. /* CommonTypesMetaclass.module_state_decls */
  2730. PyTypeObject *__pyx_CommonTypesMetaclassType;
  2731. /* CachedMethodType.module_state_decls */
  2732. #if CYTHON_COMPILING_IN_LIMITED_API
  2733. PyObject *__Pyx_CachedMethodType;
  2734. #endif
  2735. /* CythonFunctionShared.module_state_decls */
  2736. PyTypeObject *__pyx_CyFunctionType;
  2737. /* CodeObjectCache.module_state_decls */
  2738. struct __Pyx_CodeObjectCache __pyx_code_cache;
  2739. /* IterNextPlain.module_state_decls */
  2740. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  2741. PyObject *__Pyx_GetBuiltinNext_LimitedAPI_cache;
  2742. #endif
  2743. /* Generator.module_state_decls */
  2744. PyTypeObject *__pyx_GeneratorType;
  2745. /* #### Code section: module_state_end ### */
  2746. } __pyx_mstatetype;
  2747. #if CYTHON_USE_MODULE_STATE
  2748. #ifdef __cplusplus
  2749. namespace {
  2750. extern struct PyModuleDef __pyx_moduledef;
  2751. } /* anonymous namespace */
  2752. #else
  2753. static struct PyModuleDef __pyx_moduledef;
  2754. #endif
  2755. #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef)))
  2756. #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef))
  2757. #else
  2758. static __pyx_mstatetype __pyx_mstate_global_static =
  2759. #ifdef __cplusplus
  2760. {};
  2761. #else
  2762. {0};
  2763. #endif
  2764. static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static;
  2765. #endif
  2766. /* #### Code section: constant_name_defines ### */
  2767. #define __pyx_kp_u_ __pyx_string_tab[0]
  2768. #define __pyx_kp_u_Lib_fontTools_qu2cu_qu2cu_py __pyx_string_tab[1]
  2769. #define __pyx_kp_u_List_List_Point __pyx_string_tab[2]
  2770. #define __pyx_kp_u_List_Tuple_Point __pyx_string_tab[3]
  2771. #define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[4]
  2772. #define __pyx_kp_u_One_random_cubic_turned_into_d_q __pyx_string_tab[5]
  2773. #define __pyx_kp_u_Original_curve __pyx_string_tab[6]
  2774. #define __pyx_kp_u_Quadratic_splines_must_connect_e __pyx_string_tab[7]
  2775. #define __pyx_kp_u_Quadratic_splines_must_contain_a __pyx_string_tab[8]
  2776. #define __pyx_kp_u_Reconstructed_curve_s __pyx_string_tab[9]
  2777. #define __pyx_kp_u_Those_quadratics_turned_back_int __pyx_string_tab[10]
  2778. #define __pyx_kp_u__2 __pyx_string_tab[11]
  2779. #define __pyx_kp_u_add_note __pyx_string_tab[12]
  2780. #define __pyx_kp_u_cu2qu_tolerance_g_qu2cu_toleranc __pyx_string_tab[13]
  2781. #define __pyx_kp_u_disable __pyx_string_tab[14]
  2782. #define __pyx_kp_u_enable __pyx_string_tab[15]
  2783. #define __pyx_kp_u_gc __pyx_string_tab[16]
  2784. #define __pyx_kp_u_isenabled __pyx_string_tab[17]
  2785. #define __pyx_kp_u_max_err_must_be_greater_than_zer __pyx_string_tab[18]
  2786. #define __pyx_kp_u_quadratic_spline_requires_at_lea __pyx_string_tab[19]
  2787. #define __pyx_kp_u_then __pyx_string_tab[20]
  2788. #define __pyx_n_u_COMPILED __pyx_string_tab[21]
  2789. #define __pyx_n_u_List __pyx_string_tab[22]
  2790. #define __pyx_n_u_Point __pyx_string_tab[23]
  2791. #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[24]
  2792. #define __pyx_n_u_Solution __pyx_string_tab[25]
  2793. #define __pyx_n_u_Tuple __pyx_string_tab[26]
  2794. #define __pyx_n_u_Union __pyx_string_tab[27]
  2795. #define __pyx_n_u_add_implicit_on_curves __pyx_string_tab[28]
  2796. #define __pyx_n_u_all __pyx_string_tab[29]
  2797. #define __pyx_n_u_all_cubic __pyx_string_tab[30]
  2798. #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[31]
  2799. #define __pyx_n_u_best_sol __pyx_string_tab[32]
  2800. #define __pyx_n_u_bool __pyx_string_tab[33]
  2801. #define __pyx_n_u_c __pyx_string_tab[34]
  2802. #define __pyx_n_u_class_getitem __pyx_string_tab[35]
  2803. #define __pyx_n_u_cline_in_traceback __pyx_string_tab[36]
  2804. #define __pyx_n_u_close __pyx_string_tab[37]
  2805. #define __pyx_n_u_collections __pyx_string_tab[38]
  2806. #define __pyx_n_u_cost __pyx_string_tab[39]
  2807. #define __pyx_n_u_costs __pyx_string_tab[40]
  2808. #define __pyx_n_u_count __pyx_string_tab[41]
  2809. #define __pyx_n_u_cubic __pyx_string_tab[42]
  2810. #define __pyx_n_u_curve __pyx_string_tab[43]
  2811. #define __pyx_n_u_curve_to_quadratic __pyx_string_tab[44]
  2812. #define __pyx_n_u_curves __pyx_string_tab[45]
  2813. #define __pyx_n_u_elevate_quadratic __pyx_string_tab[46]
  2814. #define __pyx_n_u_elevated_quadratics __pyx_string_tab[47]
  2815. #define __pyx_n_u_enumerate __pyx_string_tab[48]
  2816. #define __pyx_n_u_err __pyx_string_tab[49]
  2817. #define __pyx_n_u_error __pyx_string_tab[50]
  2818. #define __pyx_n_u_float __pyx_string_tab[51]
  2819. #define __pyx_n_u_fontTools_cu2qu __pyx_string_tab[52]
  2820. #define __pyx_n_u_fontTools_cu2qu_benchmark __pyx_string_tab[53]
  2821. #define __pyx_n_u_fontTools_misc_bezierTools __pyx_string_tab[54]
  2822. #define __pyx_n_u_fontTools_qu2cu_qu2cu __pyx_string_tab[55]
  2823. #define __pyx_n_u_forced __pyx_string_tab[56]
  2824. #define __pyx_n_u_func __pyx_string_tab[57]
  2825. #define __pyx_n_u_generate_curve __pyx_string_tab[58]
  2826. #define __pyx_n_u_genexpr __pyx_string_tab[59]
  2827. #define __pyx_n_u_i __pyx_string_tab[60]
  2828. #define __pyx_n_u_i_sol __pyx_string_tab[61]
  2829. #define __pyx_n_u_i_sol_count __pyx_string_tab[62]
  2830. #define __pyx_n_u_i_sol_error __pyx_string_tab[63]
  2831. #define __pyx_n_u_imag __pyx_string_tab[64]
  2832. #define __pyx_n_u_impossible __pyx_string_tab[65]
  2833. #define __pyx_n_u_is_complex __pyx_string_tab[66]
  2834. #define __pyx_n_u_is_coroutine __pyx_string_tab[67]
  2835. #define __pyx_n_u_is_cubic __pyx_string_tab[68]
  2836. #define __pyx_n_u_items __pyx_string_tab[69]
  2837. #define __pyx_n_u_j __pyx_string_tab[70]
  2838. #define __pyx_n_u_j_sol_count __pyx_string_tab[71]
  2839. #define __pyx_n_u_j_sol_error __pyx_string_tab[72]
  2840. #define __pyx_n_u_k __pyx_string_tab[73]
  2841. #define __pyx_n_u_main __pyx_string_tab[74]
  2842. #define __pyx_n_u_main_2 __pyx_string_tab[75]
  2843. #define __pyx_n_u_math __pyx_string_tab[76]
  2844. #define __pyx_n_u_max_err __pyx_string_tab[77]
  2845. #define __pyx_n_u_module __pyx_string_tab[78]
  2846. #define __pyx_n_u_name __pyx_string_tab[79]
  2847. #define __pyx_n_u_namedtuple __pyx_string_tab[80]
  2848. #define __pyx_n_u_next __pyx_string_tab[81]
  2849. #define __pyx_n_u_num_offcurves __pyx_string_tab[82]
  2850. #define __pyx_n_u_num_points __pyx_string_tab[83]
  2851. #define __pyx_n_u_off1 __pyx_string_tab[84]
  2852. #define __pyx_n_u_off2 __pyx_string_tab[85]
  2853. #define __pyx_n_u_on __pyx_string_tab[86]
  2854. #define __pyx_n_u_orig __pyx_string_tab[87]
  2855. #define __pyx_n_u_p __pyx_string_tab[88]
  2856. #define __pyx_n_u_p0 __pyx_string_tab[89]
  2857. #define __pyx_n_u_p1 __pyx_string_tab[90]
  2858. #define __pyx_n_u_p1_2_3 __pyx_string_tab[91]
  2859. #define __pyx_n_u_p2 __pyx_string_tab[92]
  2860. #define __pyx_n_u_p3 __pyx_string_tab[93]
  2861. #define __pyx_n_u_point __pyx_string_tab[94]
  2862. #define __pyx_n_u_pop __pyx_string_tab[95]
  2863. #define __pyx_n_u_previous_point __pyx_string_tab[96]
  2864. #define __pyx_n_u_print __pyx_string_tab[97]
  2865. #define __pyx_n_u_q __pyx_string_tab[98]
  2866. #define __pyx_n_u_qq __pyx_string_tab[99]
  2867. #define __pyx_n_u_quadratic_to_curves __pyx_string_tab[100]
  2868. #define __pyx_n_u_quadratic_to_curves_locals_genex __pyx_string_tab[101]
  2869. #define __pyx_n_u_quadratics __pyx_string_tab[102]
  2870. #define __pyx_n_u_quads __pyx_string_tab[103]
  2871. #define __pyx_n_u_qualname __pyx_string_tab[104]
  2872. #define __pyx_n_u_raise_incompatible_point __pyx_string_tab[105]
  2873. #define __pyx_n_u_real __pyx_string_tab[106]
  2874. #define __pyx_n_u_reconst __pyx_string_tab[107]
  2875. #define __pyx_n_u_reconstruct_tolerance __pyx_string_tab[108]
  2876. #define __pyx_n_u_reconstructed __pyx_string_tab[109]
  2877. #define __pyx_n_u_reconstructed_iter __pyx_string_tab[110]
  2878. #define __pyx_n_u_return __pyx_string_tab[111]
  2879. #define __pyx_n_u_reversed __pyx_string_tab[112]
  2880. #define __pyx_n_u_send __pyx_string_tab[113]
  2881. #define __pyx_n_u_set_name __pyx_string_tab[114]
  2882. #define __pyx_n_u_setdefault __pyx_string_tab[115]
  2883. #define __pyx_n_u_sols __pyx_string_tab[116]
  2884. #define __pyx_n_u_spline __pyx_string_tab[117]
  2885. #define __pyx_n_u_spline_to_curves __pyx_string_tab[118]
  2886. #define __pyx_n_u_spline_to_curves_locals_genexpr __pyx_string_tab[119]
  2887. #define __pyx_n_u_splitCubicAtTC __pyx_string_tab[120]
  2888. #define __pyx_n_u_splits __pyx_string_tab[121]
  2889. #define __pyx_n_u_start __pyx_string_tab[122]
  2890. #define __pyx_n_u_start_index __pyx_string_tab[123]
  2891. #define __pyx_n_u_test __pyx_string_tab[124]
  2892. #define __pyx_n_u_this_count __pyx_string_tab[125]
  2893. #define __pyx_n_u_this_sol_count __pyx_string_tab[126]
  2894. #define __pyx_n_u_throw __pyx_string_tab[127]
  2895. #define __pyx_n_u_tolerance __pyx_string_tab[128]
  2896. #define __pyx_n_u_ts __pyx_string_tab[129]
  2897. #define __pyx_n_u_typing __pyx_string_tab[130]
  2898. #define __pyx_n_u_u __pyx_string_tab[131]
  2899. #define __pyx_n_u_v __pyx_string_tab[132]
  2900. #define __pyx_n_u_validate_positive_tolerance __pyx_string_tab[133]
  2901. #define __pyx_n_u_validate_spline_length __pyx_string_tab[134]
  2902. #define __pyx_n_u_value __pyx_string_tab[135]
  2903. #define __pyx_n_u_values __pyx_string_tab[136]
  2904. #define __pyx_n_u_x __pyx_string_tab[137]
  2905. #define __pyx_n_u_y __pyx_string_tab[138]
  2906. #define __pyx_n_u_zip __pyx_string_tab[139]
  2907. #define __pyx_kp_b_iso88591_AQ_A_Cq_2Q_U_3a_q_q_2Q_U_U_F_A __pyx_string_tab[140]
  2908. #define __pyx_kp_b_iso88591_A_1_SSTTU __pyx_string_tab[141]
  2909. #define __pyx_kp_b_iso88591_Jb_N_1G1_2_8_Qa_q_Cq_Q_Q __pyx_string_tab[142]
  2910. #define __pyx_kp_b_iso88591_Q_q_t1_q_q_Qe1Bat3a_t1_S_S_c_U __pyx_string_tab[143]
  2911. #define __pyx_kp_b_iso88591_S_2Rq_Cr_3b_Cr_3b __pyx_string_tab[144]
  2912. #define __pyx_kp_b_iso88591__3 __pyx_string_tab[145]
  2913. #define __pyx_kp_b_iso88591__4 __pyx_string_tab[146]
  2914. #define __pyx_kp_b_iso88591_a_3as_S_1AT_2T_U_q_3as_Cq_U_3c __pyx_string_tab[147]
  2915. #define __pyx_kp_b_iso88591_s_82Q_j __pyx_string_tab[148]
  2916. #define __pyx_kp_b_iso88591_xs_j __pyx_string_tab[149]
  2917. #define __pyx_int_0 __pyx_number_tab[0]
  2918. #define __pyx_int_1 __pyx_number_tab[1]
  2919. #define __pyx_int_3 __pyx_number_tab[2]
  2920. /* #### Code section: module_state_clear ### */
  2921. #if CYTHON_USE_MODULE_STATE
  2922. static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) {
  2923. __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m);
  2924. if (!clear_module_state) return 0;
  2925. Py_CLEAR(clear_module_state->__pyx_d);
  2926. Py_CLEAR(clear_module_state->__pyx_b);
  2927. Py_CLEAR(clear_module_state->__pyx_cython_runtime);
  2928. Py_CLEAR(clear_module_state->__pyx_empty_tuple);
  2929. Py_CLEAR(clear_module_state->__pyx_empty_bytes);
  2930. Py_CLEAR(clear_module_state->__pyx_empty_unicode);
  2931. #if CYTHON_PEP489_MULTI_PHASE_INIT
  2932. __Pyx_State_RemoveModule(NULL);
  2933. #endif
  2934. Py_CLEAR(clear_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2935. Py_CLEAR(clear_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2936. Py_CLEAR(clear_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2937. Py_CLEAR(clear_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2938. for (int i=0; i<1; ++i) { Py_CLEAR(clear_module_state->__pyx_slice[i]); }
  2939. for (int i=0; i<1; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); }
  2940. for (int i=0; i<10; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); }
  2941. for (int i=0; i<150; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); }
  2942. for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); }
  2943. /* #### Code section: module_state_clear_contents ### */
  2944. /* CommonTypesMetaclass.module_state_clear */
  2945. Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType);
  2946. /* CythonFunctionShared.module_state_clear */
  2947. Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
  2948. /* Generator.module_state_clear */
  2949. Py_CLEAR(clear_module_state->__pyx_GeneratorType);
  2950. /* #### Code section: module_state_clear_end ### */
  2951. return 0;
  2952. }
  2953. #endif
  2954. /* #### Code section: module_state_traverse ### */
  2955. #if CYTHON_USE_MODULE_STATE
  2956. static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
  2957. __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m);
  2958. if (!traverse_module_state) return 0;
  2959. Py_VISIT(traverse_module_state->__pyx_d);
  2960. Py_VISIT(traverse_module_state->__pyx_b);
  2961. Py_VISIT(traverse_module_state->__pyx_cython_runtime);
  2962. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple);
  2963. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes);
  2964. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode);
  2965. Py_VISIT(traverse_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2966. Py_VISIT(traverse_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  2967. Py_VISIT(traverse_module_state->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2968. Py_VISIT(traverse_module_state->__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  2969. for (int i=0; i<1; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_slice[i]); }
  2970. for (int i=0; i<1; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); }
  2971. for (int i=0; i<10; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); }
  2972. for (int i=0; i<150; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); }
  2973. for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); }
  2974. /* #### Code section: module_state_traverse_contents ### */
  2975. /* CommonTypesMetaclass.module_state_traverse */
  2976. Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType);
  2977. /* CythonFunctionShared.module_state_traverse */
  2978. Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
  2979. /* Generator.module_state_traverse */
  2980. Py_VISIT(traverse_module_state->__pyx_GeneratorType);
  2981. /* #### Code section: module_state_traverse_end ### */
  2982. return 0;
  2983. }
  2984. #endif
  2985. /* #### Code section: module_code ### */
  2986. /* "fontTools/qu2cu/qu2cu.py":40
  2987. *
  2988. * # Copied from cu2qu
  2989. * @cython.cfunc # <<<<<<<<<<<<<<
  2990. * @cython.returns(cython.int)
  2991. * @cython.locals(
  2992. */
  2993. 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) {
  2994. __pyx_t_double_complex __pyx_v_mid;
  2995. __pyx_t_double_complex __pyx_v_deriv3;
  2996. int __pyx_r;
  2997. int __pyx_t_1;
  2998. int __pyx_t_2;
  2999. int __pyx_t_3;
  3000. int __pyx_t_4;
  3001. int __pyx_lineno = 0;
  3002. const char *__pyx_filename = NULL;
  3003. int __pyx_clineno = 0;
  3004. /* "fontTools/qu2cu/qu2cu.py":69
  3005. * """
  3006. * # First check p2 then p1, as p2 has higher error early on.
  3007. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  3008. * return True
  3009. *
  3010. */
  3011. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p2) <= __pyx_v_tolerance);
  3012. if (__pyx_t_2) {
  3013. } else {
  3014. __pyx_t_1 = __pyx_t_2;
  3015. goto __pyx_L4_bool_binop_done;
  3016. }
  3017. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p1) <= __pyx_v_tolerance);
  3018. __pyx_t_1 = __pyx_t_2;
  3019. __pyx_L4_bool_binop_done:;
  3020. if (__pyx_t_1) {
  3021. /* "fontTools/qu2cu/qu2cu.py":70
  3022. * # First check p2 then p1, as p2 has higher error early on.
  3023. * if abs(p2) <= tolerance and abs(p1) <= tolerance:
  3024. * return True # <<<<<<<<<<<<<<
  3025. *
  3026. * # Split.
  3027. */
  3028. __pyx_r = 1;
  3029. goto __pyx_L0;
  3030. /* "fontTools/qu2cu/qu2cu.py":69
  3031. * """
  3032. * # First check p2 then p1, as p2 has higher error early on.
  3033. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  3034. * return True
  3035. *
  3036. */
  3037. }
  3038. /* "fontTools/qu2cu/qu2cu.py":73
  3039. *
  3040. * # Split.
  3041. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<<
  3042. * if abs(mid) > tolerance:
  3043. * return False
  3044. */
  3045. __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));
  3046. /* "fontTools/qu2cu/qu2cu.py":74
  3047. * # Split.
  3048. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  3049. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  3050. * return False
  3051. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3052. */
  3053. __pyx_t_1 = (__Pyx_c_abs_double(__pyx_v_mid) > __pyx_v_tolerance);
  3054. if (__pyx_t_1) {
  3055. /* "fontTools/qu2cu/qu2cu.py":75
  3056. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  3057. * if abs(mid) > tolerance:
  3058. * return False # <<<<<<<<<<<<<<
  3059. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3060. * return cubic_farthest_fit_inside(
  3061. */
  3062. __pyx_r = 0;
  3063. goto __pyx_L0;
  3064. /* "fontTools/qu2cu/qu2cu.py":74
  3065. * # Split.
  3066. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  3067. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  3068. * return False
  3069. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3070. */
  3071. }
  3072. /* "fontTools/qu2cu/qu2cu.py":76
  3073. * if abs(mid) > tolerance:
  3074. * return False
  3075. * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<<
  3076. * return cubic_farthest_fit_inside(
  3077. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  3078. */
  3079. __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));
  3080. /* "fontTools/qu2cu/qu2cu.py":77
  3081. * return False
  3082. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  3083. * return cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  3084. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  3085. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance)
  3086. */
  3087. __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)
  3088. if (__pyx_t_4) {
  3089. } else {
  3090. __pyx_t_3 = __pyx_t_4;
  3091. goto __pyx_L7_bool_binop_done;
  3092. }
  3093. /* "fontTools/qu2cu/qu2cu.py":79
  3094. * return cubic_farthest_fit_inside(
  3095. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  3096. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) # <<<<<<<<<<<<<<
  3097. *
  3098. *
  3099. */
  3100. __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)
  3101. __pyx_t_3 = __pyx_t_4;
  3102. __pyx_L7_bool_binop_done:;
  3103. __pyx_r = __pyx_t_3;
  3104. goto __pyx_L0;
  3105. /* "fontTools/qu2cu/qu2cu.py":40
  3106. *
  3107. * # Copied from cu2qu
  3108. * @cython.cfunc # <<<<<<<<<<<<<<
  3109. * @cython.returns(cython.int)
  3110. * @cython.locals(
  3111. */
  3112. /* function exit code */
  3113. __pyx_L1_error:;
  3114. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.cubic_farthest_fit_inside", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3115. __pyx_r = -1;
  3116. __pyx_L0:;
  3117. return __pyx_r;
  3118. }
  3119. /* "fontTools/qu2cu/qu2cu.py":82
  3120. *
  3121. *
  3122. * @cython.locals( # <<<<<<<<<<<<<<
  3123. * p0=cython.complex,
  3124. * p1=cython.complex,
  3125. */
  3126. /* Python wrapper */
  3127. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_1elevate_quadratic(PyObject *__pyx_self,
  3128. #if CYTHON_METH_FASTCALL
  3129. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3130. #else
  3131. PyObject *__pyx_args, PyObject *__pyx_kwds
  3132. #endif
  3133. ); /*proto*/
  3134. 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.");
  3135. 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};
  3136. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_1elevate_quadratic(PyObject *__pyx_self,
  3137. #if CYTHON_METH_FASTCALL
  3138. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3139. #else
  3140. PyObject *__pyx_args, PyObject *__pyx_kwds
  3141. #endif
  3142. ) {
  3143. __pyx_t_double_complex __pyx_v_p0;
  3144. __pyx_t_double_complex __pyx_v_p1;
  3145. __pyx_t_double_complex __pyx_v_p2;
  3146. #if !CYTHON_METH_FASTCALL
  3147. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  3148. #endif
  3149. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  3150. PyObject* values[3] = {0,0,0};
  3151. int __pyx_lineno = 0;
  3152. const char *__pyx_filename = NULL;
  3153. int __pyx_clineno = 0;
  3154. PyObject *__pyx_r = 0;
  3155. __Pyx_RefNannyDeclarations
  3156. __Pyx_RefNannySetupContext("elevate_quadratic (wrapper)", 0);
  3157. #if !CYTHON_METH_FASTCALL
  3158. #if CYTHON_ASSUME_SAFE_SIZE
  3159. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  3160. #else
  3161. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  3162. #endif
  3163. #endif
  3164. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  3165. {
  3166. 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};
  3167. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  3168. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 82, __pyx_L3_error)
  3169. if (__pyx_kwds_len > 0) {
  3170. switch (__pyx_nargs) {
  3171. case 3:
  3172. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3173. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 82, __pyx_L3_error)
  3174. CYTHON_FALLTHROUGH;
  3175. case 2:
  3176. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  3177. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 82, __pyx_L3_error)
  3178. CYTHON_FALLTHROUGH;
  3179. case 1:
  3180. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3181. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 82, __pyx_L3_error)
  3182. CYTHON_FALLTHROUGH;
  3183. case 0: break;
  3184. default: goto __pyx_L5_argtuple_error;
  3185. }
  3186. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  3187. 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)
  3188. for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
  3189. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("elevate_quadratic", 1, 3, 3, i); __PYX_ERR(0, 82, __pyx_L3_error) }
  3190. }
  3191. } else if (unlikely(__pyx_nargs != 3)) {
  3192. goto __pyx_L5_argtuple_error;
  3193. } else {
  3194. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3195. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 82, __pyx_L3_error)
  3196. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  3197. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 82, __pyx_L3_error)
  3198. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3199. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 82, __pyx_L3_error)
  3200. }
  3201. __pyx_v_p0 = __Pyx_PyComplex_As___pyx_t_double_complex(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L3_error)
  3202. __pyx_v_p1 = __Pyx_PyComplex_As___pyx_t_double_complex(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L3_error)
  3203. __pyx_v_p2 = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L3_error)
  3204. }
  3205. goto __pyx_L6_skip;
  3206. __pyx_L5_argtuple_error:;
  3207. __Pyx_RaiseArgtupleInvalid("elevate_quadratic", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 82, __pyx_L3_error)
  3208. __pyx_L6_skip:;
  3209. goto __pyx_L4_argument_unpacking_done;
  3210. __pyx_L3_error:;
  3211. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3212. Py_XDECREF(values[__pyx_temp]);
  3213. }
  3214. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.elevate_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3215. __Pyx_RefNannyFinishContext();
  3216. return NULL;
  3217. __pyx_L4_argument_unpacking_done:;
  3218. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_elevate_quadratic(__pyx_self, __pyx_v_p0, __pyx_v_p1, __pyx_v_p2);
  3219. /* function exit code */
  3220. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3221. Py_XDECREF(values[__pyx_temp]);
  3222. }
  3223. __Pyx_RefNannyFinishContext();
  3224. return __pyx_r;
  3225. }
  3226. 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) {
  3227. __pyx_t_double_complex __pyx_v_p1_2_3;
  3228. PyObject *__pyx_r = NULL;
  3229. __Pyx_RefNannyDeclarations
  3230. PyObject *__pyx_t_1 = NULL;
  3231. __pyx_t_double_complex __pyx_t_2;
  3232. PyObject *__pyx_t_3 = NULL;
  3233. PyObject *__pyx_t_4 = NULL;
  3234. PyObject *__pyx_t_5 = NULL;
  3235. PyObject *__pyx_t_6 = NULL;
  3236. int __pyx_lineno = 0;
  3237. const char *__pyx_filename = NULL;
  3238. int __pyx_clineno = 0;
  3239. __Pyx_RefNannySetupContext("elevate_quadratic", 0);
  3240. /* "fontTools/qu2cu/qu2cu.py":92
  3241. *
  3242. * # https://pomax.github.io/bezierinfo/#reordering
  3243. * p1_2_3 = p1 * (2 / 3) # <<<<<<<<<<<<<<
  3244. * return (
  3245. * p0,
  3246. */
  3247. __pyx_v_p1_2_3 = __Pyx_c_prod_double(__pyx_v_p1, __pyx_t_double_complex_from_parts((2.0 / 3.0), 0));
  3248. /* "fontTools/qu2cu/qu2cu.py":93
  3249. * # https://pomax.github.io/bezierinfo/#reordering
  3250. * p1_2_3 = p1 * (2 / 3)
  3251. * return ( # <<<<<<<<<<<<<<
  3252. * p0,
  3253. * (p0 * (1 / 3) + p1_2_3),
  3254. */
  3255. __Pyx_XDECREF(__pyx_r);
  3256. /* "fontTools/qu2cu/qu2cu.py":94
  3257. * p1_2_3 = p1 * (2 / 3)
  3258. * return (
  3259. * p0, # <<<<<<<<<<<<<<
  3260. * (p0 * (1 / 3) + p1_2_3),
  3261. * (p2 * (1 / 3) + p1_2_3),
  3262. */
  3263. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error)
  3264. __Pyx_GOTREF(__pyx_t_1);
  3265. /* "fontTools/qu2cu/qu2cu.py":95
  3266. * return (
  3267. * p0,
  3268. * (p0 * (1 / 3) + p1_2_3), # <<<<<<<<<<<<<<
  3269. * (p2 * (1 / 3) + p1_2_3),
  3270. * p2,
  3271. */
  3272. __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);
  3273. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 95, __pyx_L1_error)
  3274. __Pyx_GOTREF(__pyx_t_3);
  3275. /* "fontTools/qu2cu/qu2cu.py":96
  3276. * p0,
  3277. * (p0 * (1 / 3) + p1_2_3),
  3278. * (p2 * (1 / 3) + p1_2_3), # <<<<<<<<<<<<<<
  3279. * p2,
  3280. * )
  3281. */
  3282. __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);
  3283. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error)
  3284. __Pyx_GOTREF(__pyx_t_4);
  3285. /* "fontTools/qu2cu/qu2cu.py":97
  3286. * (p0 * (1 / 3) + p1_2_3),
  3287. * (p2 * (1 / 3) + p1_2_3),
  3288. * p2, # <<<<<<<<<<<<<<
  3289. * )
  3290. *
  3291. */
  3292. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error)
  3293. __Pyx_GOTREF(__pyx_t_5);
  3294. /* "fontTools/qu2cu/qu2cu.py":94
  3295. * p1_2_3 = p1 * (2 / 3)
  3296. * return (
  3297. * p0, # <<<<<<<<<<<<<<
  3298. * (p0 * (1 / 3) + p1_2_3),
  3299. * (p2 * (1 / 3) + p1_2_3),
  3300. */
  3301. __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 94, __pyx_L1_error)
  3302. __Pyx_GOTREF(__pyx_t_6);
  3303. __Pyx_GIVEREF(__pyx_t_1);
  3304. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3305. __Pyx_GIVEREF(__pyx_t_3);
  3306. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3307. __Pyx_GIVEREF(__pyx_t_4);
  3308. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3309. __Pyx_GIVEREF(__pyx_t_5);
  3310. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5) != (0)) __PYX_ERR(0, 94, __pyx_L1_error);
  3311. __pyx_t_1 = 0;
  3312. __pyx_t_3 = 0;
  3313. __pyx_t_4 = 0;
  3314. __pyx_t_5 = 0;
  3315. __pyx_r = __pyx_t_6;
  3316. __pyx_t_6 = 0;
  3317. goto __pyx_L0;
  3318. /* "fontTools/qu2cu/qu2cu.py":82
  3319. *
  3320. *
  3321. * @cython.locals( # <<<<<<<<<<<<<<
  3322. * p0=cython.complex,
  3323. * p1=cython.complex,
  3324. */
  3325. /* function exit code */
  3326. __pyx_L1_error:;
  3327. __Pyx_XDECREF(__pyx_t_1);
  3328. __Pyx_XDECREF(__pyx_t_3);
  3329. __Pyx_XDECREF(__pyx_t_4);
  3330. __Pyx_XDECREF(__pyx_t_5);
  3331. __Pyx_XDECREF(__pyx_t_6);
  3332. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.elevate_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3333. __pyx_r = NULL;
  3334. __pyx_L0:;
  3335. __Pyx_XGIVEREF(__pyx_r);
  3336. __Pyx_RefNannyFinishContext();
  3337. return __pyx_r;
  3338. }
  3339. /* "fontTools/qu2cu/qu2cu.py":101
  3340. *
  3341. *
  3342. * @cython.cfunc # <<<<<<<<<<<<<<
  3343. * @cython.locals(
  3344. * start=cython.int,
  3345. */
  3346. static PyObject *__pyx_f_9fontTools_5qu2cu_5qu2cu_merge_curves(PyObject *__pyx_v_curves, int __pyx_v_start, int __pyx_v_n) {
  3347. int __pyx_v_k;
  3348. double __pyx_v_prod_ratio;
  3349. double __pyx_v_sum_ratio;
  3350. double __pyx_v_ratio;
  3351. __pyx_t_double_complex __pyx_v_p0;
  3352. __pyx_t_double_complex __pyx_v_p1;
  3353. __pyx_t_double_complex __pyx_v_p2;
  3354. __pyx_t_double_complex __pyx_v_p3;
  3355. PyObject *__pyx_v_ts = NULL;
  3356. PyObject *__pyx_v_ck = NULL;
  3357. PyObject *__pyx_v_c_before = NULL;
  3358. PyObject *__pyx_v_curve = NULL;
  3359. double __pyx_7genexpr__pyx_v_t;
  3360. PyObject *__pyx_r = NULL;
  3361. __Pyx_RefNannyDeclarations
  3362. PyObject *__pyx_t_1 = NULL;
  3363. int __pyx_t_2;
  3364. int __pyx_t_3;
  3365. int __pyx_t_4;
  3366. int __pyx_t_5;
  3367. long __pyx_t_6;
  3368. PyObject *__pyx_t_7 = NULL;
  3369. PyObject *__pyx_t_8 = NULL;
  3370. int __pyx_t_9;
  3371. PyObject *__pyx_t_10 = NULL;
  3372. double __pyx_t_11;
  3373. int __pyx_t_12;
  3374. Py_ssize_t __pyx_t_13;
  3375. __pyx_t_double_complex __pyx_t_14;
  3376. PyObject *__pyx_t_15 = NULL;
  3377. int __pyx_lineno = 0;
  3378. const char *__pyx_filename = NULL;
  3379. int __pyx_clineno = 0;
  3380. __Pyx_RefNannySetupContext("merge_curves", 0);
  3381. /* "fontTools/qu2cu/qu2cu.py":121
  3382. *
  3383. * # Reconstruct the t values of the cut segments
  3384. * prod_ratio = 1.0 # <<<<<<<<<<<<<<
  3385. * sum_ratio = 1.0
  3386. * ts = [1]
  3387. */
  3388. __pyx_v_prod_ratio = 1.0;
  3389. /* "fontTools/qu2cu/qu2cu.py":122
  3390. * # Reconstruct the t values of the cut segments
  3391. * prod_ratio = 1.0
  3392. * sum_ratio = 1.0 # <<<<<<<<<<<<<<
  3393. * ts = [1]
  3394. * for k in range(1, n):
  3395. */
  3396. __pyx_v_sum_ratio = 1.0;
  3397. /* "fontTools/qu2cu/qu2cu.py":123
  3398. * prod_ratio = 1.0
  3399. * sum_ratio = 1.0
  3400. * ts = [1] # <<<<<<<<<<<<<<
  3401. * for k in range(1, n):
  3402. * ck = curves[start + k]
  3403. */
  3404. __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
  3405. __Pyx_GOTREF(__pyx_t_1);
  3406. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  3407. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
  3408. if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 123, __pyx_L1_error);
  3409. __pyx_v_ts = ((PyObject*)__pyx_t_1);
  3410. __pyx_t_1 = 0;
  3411. /* "fontTools/qu2cu/qu2cu.py":124
  3412. * sum_ratio = 1.0
  3413. * ts = [1]
  3414. * for k in range(1, n): # <<<<<<<<<<<<<<
  3415. * ck = curves[start + k]
  3416. * c_before = curves[start + k - 1]
  3417. */
  3418. __pyx_t_2 = __pyx_v_n;
  3419. __pyx_t_3 = __pyx_t_2;
  3420. for (__pyx_t_4 = 1; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
  3421. __pyx_v_k = __pyx_t_4;
  3422. /* "fontTools/qu2cu/qu2cu.py":125
  3423. * ts = [1]
  3424. * for k in range(1, n):
  3425. * ck = curves[start + k] # <<<<<<<<<<<<<<
  3426. * c_before = curves[start + k - 1]
  3427. *
  3428. */
  3429. __pyx_t_5 = (__pyx_v_start + __pyx_v_k);
  3430. __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)
  3431. __Pyx_GOTREF(__pyx_t_1);
  3432. __Pyx_XDECREF_SET(__pyx_v_ck, __pyx_t_1);
  3433. __pyx_t_1 = 0;
  3434. /* "fontTools/qu2cu/qu2cu.py":126
  3435. * for k in range(1, n):
  3436. * ck = curves[start + k]
  3437. * c_before = curves[start + k - 1] # <<<<<<<<<<<<<<
  3438. *
  3439. * # |t_(k+1) - t_k| / |t_k - t_(k - 1)| = ratio
  3440. */
  3441. __pyx_t_6 = ((__pyx_v_start + __pyx_v_k) - 1);
  3442. __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)
  3443. __Pyx_GOTREF(__pyx_t_1);
  3444. __Pyx_XDECREF_SET(__pyx_v_c_before, __pyx_t_1);
  3445. __pyx_t_1 = 0;
  3446. /* "fontTools/qu2cu/qu2cu.py":129
  3447. *
  3448. * # |t_(k+1) - t_k| / |t_k - t_(k - 1)| = ratio
  3449. * assert ck[0] == c_before[3] # <<<<<<<<<<<<<<
  3450. * ratio = abs(ck[1] - ck[0]) / abs(c_before[3] - c_before[2])
  3451. *
  3452. */
  3453. #ifndef CYTHON_WITHOUT_ASSERTIONS
  3454. if (unlikely(__pyx_assertions_enabled())) {
  3455. __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)
  3456. __Pyx_GOTREF(__pyx_t_1);
  3457. __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)
  3458. __Pyx_GOTREF(__pyx_t_7);
  3459. __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)
  3460. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3461. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3462. __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 129, __pyx_L1_error)
  3463. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3464. if (unlikely(!__pyx_t_9)) {
  3465. __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_AssertionError))), 0, 0, 0);
  3466. __PYX_ERR(0, 129, __pyx_L1_error)
  3467. }
  3468. }
  3469. #else
  3470. if ((1)); else __PYX_ERR(0, 129, __pyx_L1_error)
  3471. #endif
  3472. /* "fontTools/qu2cu/qu2cu.py":130
  3473. * # |t_(k+1) - t_k| / |t_k - t_(k - 1)| = ratio
  3474. * assert ck[0] == c_before[3]
  3475. * ratio = abs(ck[1] - ck[0]) / abs(c_before[3] - c_before[2]) # <<<<<<<<<<<<<<
  3476. *
  3477. * prod_ratio *= ratio
  3478. */
  3479. __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)
  3480. __Pyx_GOTREF(__pyx_t_8);
  3481. __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)
  3482. __Pyx_GOTREF(__pyx_t_7);
  3483. __pyx_t_1 = PyNumber_Subtract(__pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
  3484. __Pyx_GOTREF(__pyx_t_1);
  3485. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3486. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3487. __pyx_t_7 = __Pyx_PyNumber_Absolute(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 130, __pyx_L1_error)
  3488. __Pyx_GOTREF(__pyx_t_7);
  3489. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3490. __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)
  3491. __Pyx_GOTREF(__pyx_t_1);
  3492. __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)
  3493. __Pyx_GOTREF(__pyx_t_8);
  3494. __pyx_t_10 = PyNumber_Subtract(__pyx_t_1, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 130, __pyx_L1_error)
  3495. __Pyx_GOTREF(__pyx_t_10);
  3496. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3497. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3498. __pyx_t_8 = __Pyx_PyNumber_Absolute(__pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 130, __pyx_L1_error)
  3499. __Pyx_GOTREF(__pyx_t_8);
  3500. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3501. __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 130, __pyx_L1_error)
  3502. __Pyx_GOTREF(__pyx_t_10);
  3503. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3504. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3505. __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)
  3506. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3507. __pyx_v_ratio = __pyx_t_11;
  3508. /* "fontTools/qu2cu/qu2cu.py":132
  3509. * ratio = abs(ck[1] - ck[0]) / abs(c_before[3] - c_before[2])
  3510. *
  3511. * prod_ratio *= ratio # <<<<<<<<<<<<<<
  3512. * sum_ratio += prod_ratio
  3513. * ts.append(sum_ratio)
  3514. */
  3515. __pyx_v_prod_ratio = (__pyx_v_prod_ratio * __pyx_v_ratio);
  3516. /* "fontTools/qu2cu/qu2cu.py":133
  3517. *
  3518. * prod_ratio *= ratio
  3519. * sum_ratio += prod_ratio # <<<<<<<<<<<<<<
  3520. * ts.append(sum_ratio)
  3521. *
  3522. */
  3523. __pyx_v_sum_ratio = (__pyx_v_sum_ratio + __pyx_v_prod_ratio);
  3524. /* "fontTools/qu2cu/qu2cu.py":134
  3525. * prod_ratio *= ratio
  3526. * sum_ratio += prod_ratio
  3527. * ts.append(sum_ratio) # <<<<<<<<<<<<<<
  3528. *
  3529. * # (t(n) - t(n - 1)) / (t_(1) - t(0)) = prod_ratio
  3530. */
  3531. __pyx_t_10 = PyFloat_FromDouble(__pyx_v_sum_ratio); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 134, __pyx_L1_error)
  3532. __Pyx_GOTREF(__pyx_t_10);
  3533. __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)
  3534. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3535. }
  3536. /* "fontTools/qu2cu/qu2cu.py":138
  3537. * # (t(n) - t(n - 1)) / (t_(1) - t(0)) = prod_ratio
  3538. *
  3539. * ts = [t / sum_ratio for t in ts[:-1]] # <<<<<<<<<<<<<<
  3540. *
  3541. * p0 = curves[start][0]
  3542. */
  3543. { /* enter inner scope */
  3544. __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 138, __pyx_L1_error)
  3545. __Pyx_GOTREF(__pyx_t_10);
  3546. __pyx_t_8 = __Pyx_PyList_GetSlice(__pyx_v_ts, 0, -1L); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 138, __pyx_L1_error)
  3547. __Pyx_GOTREF(__pyx_t_8);
  3548. __pyx_t_7 = __pyx_t_8; __Pyx_INCREF(__pyx_t_7);
  3549. __pyx_t_13 = 0;
  3550. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3551. for (;;) {
  3552. {
  3553. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7);
  3554. #if !CYTHON_ASSUME_SAFE_SIZE
  3555. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 138, __pyx_L1_error)
  3556. #endif
  3557. if (__pyx_t_13 >= __pyx_temp) break;
  3558. }
  3559. __pyx_t_8 = __Pyx_PyList_GetItemRefFast(__pyx_t_7, __pyx_t_13, __Pyx_ReferenceSharing_OwnStrongReference);
  3560. ++__pyx_t_13;
  3561. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 138, __pyx_L1_error)
  3562. __Pyx_GOTREF(__pyx_t_8);
  3563. __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)
  3564. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3565. __pyx_7genexpr__pyx_v_t = __pyx_t_11;
  3566. if (unlikely(__pyx_v_sum_ratio == 0)) {
  3567. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  3568. __PYX_ERR(0, 138, __pyx_L1_error)
  3569. }
  3570. __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)
  3571. __Pyx_GOTREF(__pyx_t_8);
  3572. if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_8))) __PYX_ERR(0, 138, __pyx_L1_error)
  3573. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3574. }
  3575. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3576. } /* exit inner scope */
  3577. __Pyx_DECREF_SET(__pyx_v_ts, ((PyObject*)__pyx_t_10));
  3578. __pyx_t_10 = 0;
  3579. /* "fontTools/qu2cu/qu2cu.py":140
  3580. * ts = [t / sum_ratio for t in ts[:-1]]
  3581. *
  3582. * p0 = curves[start][0] # <<<<<<<<<<<<<<
  3583. * p1 = curves[start][1]
  3584. * p2 = curves[start + n - 1][2]
  3585. */
  3586. __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)
  3587. __Pyx_GOTREF(__pyx_t_10);
  3588. __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)
  3589. __Pyx_GOTREF(__pyx_t_7);
  3590. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3591. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 140, __pyx_L1_error)
  3592. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3593. __pyx_v_p0 = __pyx_t_14;
  3594. /* "fontTools/qu2cu/qu2cu.py":141
  3595. *
  3596. * p0 = curves[start][0]
  3597. * p1 = curves[start][1] # <<<<<<<<<<<<<<
  3598. * p2 = curves[start + n - 1][2]
  3599. * p3 = curves[start + n - 1][3]
  3600. */
  3601. __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)
  3602. __Pyx_GOTREF(__pyx_t_7);
  3603. __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)
  3604. __Pyx_GOTREF(__pyx_t_10);
  3605. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3606. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 141, __pyx_L1_error)
  3607. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3608. __pyx_v_p1 = __pyx_t_14;
  3609. /* "fontTools/qu2cu/qu2cu.py":142
  3610. * p0 = curves[start][0]
  3611. * p1 = curves[start][1]
  3612. * p2 = curves[start + n - 1][2] # <<<<<<<<<<<<<<
  3613. * p3 = curves[start + n - 1][3]
  3614. *
  3615. */
  3616. __pyx_t_6 = ((__pyx_v_start + __pyx_v_n) - 1);
  3617. __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)
  3618. __Pyx_GOTREF(__pyx_t_10);
  3619. __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)
  3620. __Pyx_GOTREF(__pyx_t_7);
  3621. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3622. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 142, __pyx_L1_error)
  3623. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3624. __pyx_v_p2 = __pyx_t_14;
  3625. /* "fontTools/qu2cu/qu2cu.py":143
  3626. * p1 = curves[start][1]
  3627. * p2 = curves[start + n - 1][2]
  3628. * p3 = curves[start + n - 1][3] # <<<<<<<<<<<<<<
  3629. *
  3630. * # Build the curve by scaling the control-points.
  3631. */
  3632. __pyx_t_6 = ((__pyx_v_start + __pyx_v_n) - 1);
  3633. __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)
  3634. __Pyx_GOTREF(__pyx_t_7);
  3635. __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)
  3636. __Pyx_GOTREF(__pyx_t_10);
  3637. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3638. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3639. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3640. __pyx_v_p3 = __pyx_t_14;
  3641. /* "fontTools/qu2cu/qu2cu.py":146
  3642. *
  3643. * # Build the curve by scaling the control-points.
  3644. * p1 = p0 + (p1 - p0) / (ts[0] if ts else 1) # <<<<<<<<<<<<<<
  3645. * p2 = p3 + (p2 - p3) / ((1 - ts[-1]) if ts else 1)
  3646. *
  3647. */
  3648. __pyx_t_10 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 146, __pyx_L1_error)
  3649. __Pyx_GOTREF(__pyx_t_10);
  3650. __pyx_t_14 = __Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0);
  3651. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_t_14); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error)
  3652. __Pyx_GOTREF(__pyx_t_7);
  3653. {
  3654. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_ts);
  3655. if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 146, __pyx_L1_error)
  3656. __pyx_t_9 = (__pyx_temp != 0);
  3657. }
  3658. if (__pyx_t_9) {
  3659. __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)
  3660. __Pyx_GOTREF(__pyx_t_1);
  3661. __pyx_t_8 = __pyx_t_1;
  3662. __pyx_t_1 = 0;
  3663. } else {
  3664. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  3665. __pyx_t_8 = __pyx_mstate_global->__pyx_int_1;
  3666. }
  3667. __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
  3668. __Pyx_GOTREF(__pyx_t_1);
  3669. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3670. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3671. __pyx_t_8 = PyNumber_Add(__pyx_t_10, __pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 146, __pyx_L1_error)
  3672. __Pyx_GOTREF(__pyx_t_8);
  3673. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3674. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3675. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 146, __pyx_L1_error)
  3676. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3677. __pyx_v_p1 = __pyx_t_14;
  3678. /* "fontTools/qu2cu/qu2cu.py":147
  3679. * # Build the curve by scaling the control-points.
  3680. * p1 = p0 + (p1 - p0) / (ts[0] if ts else 1)
  3681. * p2 = p3 + (p2 - p3) / ((1 - ts[-1]) if ts else 1) # <<<<<<<<<<<<<<
  3682. *
  3683. * curve = (p0, p1, p2, p3)
  3684. */
  3685. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 147, __pyx_L1_error)
  3686. __Pyx_GOTREF(__pyx_t_8);
  3687. __pyx_t_14 = __Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p3);
  3688. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_t_14); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
  3689. __Pyx_GOTREF(__pyx_t_1);
  3690. {
  3691. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_ts);
  3692. if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 147, __pyx_L1_error)
  3693. __pyx_t_9 = (__pyx_temp != 0);
  3694. }
  3695. if (__pyx_t_9) {
  3696. __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)
  3697. __Pyx_GOTREF(__pyx_t_7);
  3698. __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)
  3699. __Pyx_GOTREF(__pyx_t_15);
  3700. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  3701. __pyx_t_10 = __pyx_t_15;
  3702. __pyx_t_15 = 0;
  3703. } else {
  3704. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  3705. __pyx_t_10 = __pyx_mstate_global->__pyx_int_1;
  3706. }
  3707. __pyx_t_15 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_t_10); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 147, __pyx_L1_error)
  3708. __Pyx_GOTREF(__pyx_t_15);
  3709. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3710. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3711. __pyx_t_10 = PyNumber_Add(__pyx_t_8, __pyx_t_15); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 147, __pyx_L1_error)
  3712. __Pyx_GOTREF(__pyx_t_10);
  3713. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  3714. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  3715. __pyx_t_14 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 147, __pyx_L1_error)
  3716. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  3717. __pyx_v_p2 = __pyx_t_14;
  3718. /* "fontTools/qu2cu/qu2cu.py":149
  3719. * p2 = p3 + (p2 - p3) / ((1 - ts[-1]) if ts else 1)
  3720. *
  3721. * curve = (p0, p1, p2, p3) # <<<<<<<<<<<<<<
  3722. *
  3723. * return curve, ts
  3724. */
  3725. __pyx_t_10 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 149, __pyx_L1_error)
  3726. __Pyx_GOTREF(__pyx_t_10);
  3727. __pyx_t_15 = __pyx_PyComplex_FromComplex(__pyx_v_p1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 149, __pyx_L1_error)
  3728. __Pyx_GOTREF(__pyx_t_15);
  3729. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 149, __pyx_L1_error)
  3730. __Pyx_GOTREF(__pyx_t_8);
  3731. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
  3732. __Pyx_GOTREF(__pyx_t_1);
  3733. __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 149, __pyx_L1_error)
  3734. __Pyx_GOTREF(__pyx_t_7);
  3735. __Pyx_GIVEREF(__pyx_t_10);
  3736. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3737. __Pyx_GIVEREF(__pyx_t_15);
  3738. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_15) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3739. __Pyx_GIVEREF(__pyx_t_8);
  3740. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_8) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3741. __Pyx_GIVEREF(__pyx_t_1);
  3742. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1) != (0)) __PYX_ERR(0, 149, __pyx_L1_error);
  3743. __pyx_t_10 = 0;
  3744. __pyx_t_15 = 0;
  3745. __pyx_t_8 = 0;
  3746. __pyx_t_1 = 0;
  3747. __pyx_v_curve = __pyx_t_7;
  3748. __pyx_t_7 = 0;
  3749. /* "fontTools/qu2cu/qu2cu.py":151
  3750. * curve = (p0, p1, p2, p3)
  3751. *
  3752. * return curve, ts # <<<<<<<<<<<<<<
  3753. *
  3754. *
  3755. */
  3756. __Pyx_XDECREF(__pyx_r);
  3757. __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 151, __pyx_L1_error)
  3758. __Pyx_GOTREF(__pyx_t_7);
  3759. __Pyx_INCREF(__pyx_v_curve);
  3760. __Pyx_GIVEREF(__pyx_v_curve);
  3761. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_curve) != (0)) __PYX_ERR(0, 151, __pyx_L1_error);
  3762. __Pyx_INCREF(__pyx_v_ts);
  3763. __Pyx_GIVEREF(__pyx_v_ts);
  3764. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ts) != (0)) __PYX_ERR(0, 151, __pyx_L1_error);
  3765. __pyx_r = __pyx_t_7;
  3766. __pyx_t_7 = 0;
  3767. goto __pyx_L0;
  3768. /* "fontTools/qu2cu/qu2cu.py":101
  3769. *
  3770. *
  3771. * @cython.cfunc # <<<<<<<<<<<<<<
  3772. * @cython.locals(
  3773. * start=cython.int,
  3774. */
  3775. /* function exit code */
  3776. __pyx_L1_error:;
  3777. __Pyx_XDECREF(__pyx_t_1);
  3778. __Pyx_XDECREF(__pyx_t_7);
  3779. __Pyx_XDECREF(__pyx_t_8);
  3780. __Pyx_XDECREF(__pyx_t_10);
  3781. __Pyx_XDECREF(__pyx_t_15);
  3782. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.merge_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3783. __pyx_r = 0;
  3784. __pyx_L0:;
  3785. __Pyx_XDECREF(__pyx_v_ts);
  3786. __Pyx_XDECREF(__pyx_v_ck);
  3787. __Pyx_XDECREF(__pyx_v_c_before);
  3788. __Pyx_XDECREF(__pyx_v_curve);
  3789. __Pyx_XGIVEREF(__pyx_r);
  3790. __Pyx_RefNannyFinishContext();
  3791. return __pyx_r;
  3792. }
  3793. /* "fontTools/qu2cu/qu2cu.py":154
  3794. *
  3795. *
  3796. * @cython.locals( # <<<<<<<<<<<<<<
  3797. * count=cython.int,
  3798. * num_offcurves=cython.int,
  3799. */
  3800. /* Python wrapper */
  3801. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_3add_implicit_on_curves(PyObject *__pyx_self,
  3802. #if CYTHON_METH_FASTCALL
  3803. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3804. #else
  3805. PyObject *__pyx_args, PyObject *__pyx_kwds
  3806. #endif
  3807. ); /*proto*/
  3808. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves, "add_implicit_on_curves(p)");
  3809. 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};
  3810. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_3add_implicit_on_curves(PyObject *__pyx_self,
  3811. #if CYTHON_METH_FASTCALL
  3812. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3813. #else
  3814. PyObject *__pyx_args, PyObject *__pyx_kwds
  3815. #endif
  3816. ) {
  3817. PyObject *__pyx_v_p = 0;
  3818. #if !CYTHON_METH_FASTCALL
  3819. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  3820. #endif
  3821. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  3822. PyObject* values[1] = {0};
  3823. int __pyx_lineno = 0;
  3824. const char *__pyx_filename = NULL;
  3825. int __pyx_clineno = 0;
  3826. PyObject *__pyx_r = 0;
  3827. __Pyx_RefNannyDeclarations
  3828. __Pyx_RefNannySetupContext("add_implicit_on_curves (wrapper)", 0);
  3829. #if !CYTHON_METH_FASTCALL
  3830. #if CYTHON_ASSUME_SAFE_SIZE
  3831. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  3832. #else
  3833. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  3834. #endif
  3835. #endif
  3836. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  3837. {
  3838. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_p,0};
  3839. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  3840. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 154, __pyx_L3_error)
  3841. if (__pyx_kwds_len > 0) {
  3842. switch (__pyx_nargs) {
  3843. case 1:
  3844. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3845. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 154, __pyx_L3_error)
  3846. CYTHON_FALLTHROUGH;
  3847. case 0: break;
  3848. default: goto __pyx_L5_argtuple_error;
  3849. }
  3850. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  3851. 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)
  3852. for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
  3853. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("add_implicit_on_curves", 1, 1, 1, i); __PYX_ERR(0, 154, __pyx_L3_error) }
  3854. }
  3855. } else if (unlikely(__pyx_nargs != 1)) {
  3856. goto __pyx_L5_argtuple_error;
  3857. } else {
  3858. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3859. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 154, __pyx_L3_error)
  3860. }
  3861. __pyx_v_p = values[0];
  3862. }
  3863. goto __pyx_L6_skip;
  3864. __pyx_L5_argtuple_error:;
  3865. __Pyx_RaiseArgtupleInvalid("add_implicit_on_curves", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 154, __pyx_L3_error)
  3866. __pyx_L6_skip:;
  3867. goto __pyx_L4_argument_unpacking_done;
  3868. __pyx_L3_error:;
  3869. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3870. Py_XDECREF(values[__pyx_temp]);
  3871. }
  3872. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.add_implicit_on_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3873. __Pyx_RefNannyFinishContext();
  3874. return NULL;
  3875. __pyx_L4_argument_unpacking_done:;
  3876. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves(__pyx_self, __pyx_v_p);
  3877. /* function exit code */
  3878. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3879. Py_XDECREF(values[__pyx_temp]);
  3880. }
  3881. __Pyx_RefNannyFinishContext();
  3882. return __pyx_r;
  3883. }
  3884. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_2add_implicit_on_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_p) {
  3885. int __pyx_v_count;
  3886. int __pyx_v_num_offcurves;
  3887. int __pyx_v_i;
  3888. __pyx_t_double_complex __pyx_v_off1;
  3889. __pyx_t_double_complex __pyx_v_off2;
  3890. __pyx_t_double_complex __pyx_v_on;
  3891. PyObject *__pyx_v_q = NULL;
  3892. PyObject *__pyx_r = NULL;
  3893. __Pyx_RefNannyDeclarations
  3894. PyObject *__pyx_t_1 = NULL;
  3895. Py_ssize_t __pyx_t_2;
  3896. int __pyx_t_3;
  3897. int __pyx_t_4;
  3898. int __pyx_t_5;
  3899. __pyx_t_double_complex __pyx_t_6;
  3900. long __pyx_t_7;
  3901. int __pyx_t_8;
  3902. int __pyx_lineno = 0;
  3903. const char *__pyx_filename = NULL;
  3904. int __pyx_clineno = 0;
  3905. __Pyx_RefNannySetupContext("add_implicit_on_curves", 0);
  3906. /* "fontTools/qu2cu/qu2cu.py":163
  3907. * )
  3908. * def add_implicit_on_curves(p):
  3909. * q = list(p) # <<<<<<<<<<<<<<
  3910. * count = 0
  3911. * num_offcurves = len(p) - 2
  3912. */
  3913. __pyx_t_1 = PySequence_List(__pyx_v_p); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
  3914. __Pyx_GOTREF(__pyx_t_1);
  3915. __pyx_v_q = ((PyObject*)__pyx_t_1);
  3916. __pyx_t_1 = 0;
  3917. /* "fontTools/qu2cu/qu2cu.py":164
  3918. * def add_implicit_on_curves(p):
  3919. * q = list(p)
  3920. * count = 0 # <<<<<<<<<<<<<<
  3921. * num_offcurves = len(p) - 2
  3922. * for i in range(1, num_offcurves):
  3923. */
  3924. __pyx_v_count = 0;
  3925. /* "fontTools/qu2cu/qu2cu.py":165
  3926. * q = list(p)
  3927. * count = 0
  3928. * num_offcurves = len(p) - 2 # <<<<<<<<<<<<<<
  3929. * for i in range(1, num_offcurves):
  3930. * off1 = p[i]
  3931. */
  3932. __pyx_t_2 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 165, __pyx_L1_error)
  3933. __pyx_v_num_offcurves = (__pyx_t_2 - 2);
  3934. /* "fontTools/qu2cu/qu2cu.py":166
  3935. * count = 0
  3936. * num_offcurves = len(p) - 2
  3937. * for i in range(1, num_offcurves): # <<<<<<<<<<<<<<
  3938. * off1 = p[i]
  3939. * off2 = p[i + 1]
  3940. */
  3941. __pyx_t_3 = __pyx_v_num_offcurves;
  3942. __pyx_t_4 = __pyx_t_3;
  3943. for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
  3944. __pyx_v_i = __pyx_t_5;
  3945. /* "fontTools/qu2cu/qu2cu.py":167
  3946. * num_offcurves = len(p) - 2
  3947. * for i in range(1, num_offcurves):
  3948. * off1 = p[i] # <<<<<<<<<<<<<<
  3949. * off2 = p[i + 1]
  3950. * on = off1 + (off2 - off1) * 0.5
  3951. */
  3952. __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)
  3953. __Pyx_GOTREF(__pyx_t_1);
  3954. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 167, __pyx_L1_error)
  3955. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3956. __pyx_v_off1 = __pyx_t_6;
  3957. /* "fontTools/qu2cu/qu2cu.py":168
  3958. * for i in range(1, num_offcurves):
  3959. * off1 = p[i]
  3960. * off2 = p[i + 1] # <<<<<<<<<<<<<<
  3961. * on = off1 + (off2 - off1) * 0.5
  3962. * q.insert(i + 1 + count, on)
  3963. */
  3964. __pyx_t_7 = (__pyx_v_i + 1);
  3965. __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)
  3966. __Pyx_GOTREF(__pyx_t_1);
  3967. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 168, __pyx_L1_error)
  3968. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3969. __pyx_v_off2 = __pyx_t_6;
  3970. /* "fontTools/qu2cu/qu2cu.py":169
  3971. * off1 = p[i]
  3972. * off2 = p[i + 1]
  3973. * on = off1 + (off2 - off1) * 0.5 # <<<<<<<<<<<<<<
  3974. * q.insert(i + 1 + count, on)
  3975. * count += 1
  3976. */
  3977. __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)));
  3978. /* "fontTools/qu2cu/qu2cu.py":170
  3979. * off2 = p[i + 1]
  3980. * on = off1 + (off2 - off1) * 0.5
  3981. * q.insert(i + 1 + count, on) # <<<<<<<<<<<<<<
  3982. * count += 1
  3983. * return q
  3984. */
  3985. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_on); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
  3986. __Pyx_GOTREF(__pyx_t_1);
  3987. __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)
  3988. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3989. /* "fontTools/qu2cu/qu2cu.py":171
  3990. * on = off1 + (off2 - off1) * 0.5
  3991. * q.insert(i + 1 + count, on)
  3992. * count += 1 # <<<<<<<<<<<<<<
  3993. * return q
  3994. *
  3995. */
  3996. __pyx_v_count = (__pyx_v_count + 1);
  3997. }
  3998. /* "fontTools/qu2cu/qu2cu.py":172
  3999. * q.insert(i + 1 + count, on)
  4000. * count += 1
  4001. * return q # <<<<<<<<<<<<<<
  4002. *
  4003. *
  4004. */
  4005. __Pyx_XDECREF(__pyx_r);
  4006. __Pyx_INCREF(__pyx_v_q);
  4007. __pyx_r = __pyx_v_q;
  4008. goto __pyx_L0;
  4009. /* "fontTools/qu2cu/qu2cu.py":154
  4010. *
  4011. *
  4012. * @cython.locals( # <<<<<<<<<<<<<<
  4013. * count=cython.int,
  4014. * num_offcurves=cython.int,
  4015. */
  4016. /* function exit code */
  4017. __pyx_L1_error:;
  4018. __Pyx_XDECREF(__pyx_t_1);
  4019. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.add_implicit_on_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4020. __pyx_r = NULL;
  4021. __pyx_L0:;
  4022. __Pyx_XDECREF(__pyx_v_q);
  4023. __Pyx_XGIVEREF(__pyx_r);
  4024. __Pyx_RefNannyFinishContext();
  4025. return __pyx_r;
  4026. }
  4027. /* "fontTools/qu2cu/qu2cu.py":178
  4028. *
  4029. *
  4030. * def _raise_incompatible_point(point, previous_point): # <<<<<<<<<<<<<<
  4031. * raise ValueError(
  4032. * f"Quadratic splines must connect end-to-start; got {previous_point!r} then {point!r}"
  4033. */
  4034. /* Python wrapper */
  4035. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_5_raise_incompatible_point(PyObject *__pyx_self,
  4036. #if CYTHON_METH_FASTCALL
  4037. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4038. #else
  4039. PyObject *__pyx_args, PyObject *__pyx_kwds
  4040. #endif
  4041. ); /*proto*/
  4042. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_4_raise_incompatible_point, "_raise_incompatible_point(point, previous_point)");
  4043. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_5_raise_incompatible_point = {"_raise_incompatible_point", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_5_raise_incompatible_point, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_4_raise_incompatible_point};
  4044. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_5_raise_incompatible_point(PyObject *__pyx_self,
  4045. #if CYTHON_METH_FASTCALL
  4046. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4047. #else
  4048. PyObject *__pyx_args, PyObject *__pyx_kwds
  4049. #endif
  4050. ) {
  4051. PyObject *__pyx_v_point = 0;
  4052. PyObject *__pyx_v_previous_point = 0;
  4053. #if !CYTHON_METH_FASTCALL
  4054. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  4055. #endif
  4056. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  4057. PyObject* values[2] = {0,0};
  4058. int __pyx_lineno = 0;
  4059. const char *__pyx_filename = NULL;
  4060. int __pyx_clineno = 0;
  4061. PyObject *__pyx_r = 0;
  4062. __Pyx_RefNannyDeclarations
  4063. __Pyx_RefNannySetupContext("_raise_incompatible_point (wrapper)", 0);
  4064. #if !CYTHON_METH_FASTCALL
  4065. #if CYTHON_ASSUME_SAFE_SIZE
  4066. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  4067. #else
  4068. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  4069. #endif
  4070. #endif
  4071. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  4072. {
  4073. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_point,&__pyx_mstate_global->__pyx_n_u_previous_point,0};
  4074. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  4075. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 178, __pyx_L3_error)
  4076. if (__pyx_kwds_len > 0) {
  4077. switch (__pyx_nargs) {
  4078. case 2:
  4079. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  4080. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 178, __pyx_L3_error)
  4081. CYTHON_FALLTHROUGH;
  4082. case 1:
  4083. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4084. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 178, __pyx_L3_error)
  4085. CYTHON_FALLTHROUGH;
  4086. case 0: break;
  4087. default: goto __pyx_L5_argtuple_error;
  4088. }
  4089. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  4090. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_raise_incompatible_point", 0) < (0)) __PYX_ERR(0, 178, __pyx_L3_error)
  4091. for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
  4092. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_raise_incompatible_point", 1, 2, 2, i); __PYX_ERR(0, 178, __pyx_L3_error) }
  4093. }
  4094. } else if (unlikely(__pyx_nargs != 2)) {
  4095. goto __pyx_L5_argtuple_error;
  4096. } else {
  4097. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4098. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 178, __pyx_L3_error)
  4099. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  4100. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 178, __pyx_L3_error)
  4101. }
  4102. __pyx_v_point = values[0];
  4103. __pyx_v_previous_point = values[1];
  4104. }
  4105. goto __pyx_L6_skip;
  4106. __pyx_L5_argtuple_error:;
  4107. __Pyx_RaiseArgtupleInvalid("_raise_incompatible_point", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 178, __pyx_L3_error)
  4108. __pyx_L6_skip:;
  4109. goto __pyx_L4_argument_unpacking_done;
  4110. __pyx_L3_error:;
  4111. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4112. Py_XDECREF(values[__pyx_temp]);
  4113. }
  4114. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu._raise_incompatible_point", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4115. __Pyx_RefNannyFinishContext();
  4116. return NULL;
  4117. __pyx_L4_argument_unpacking_done:;
  4118. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_4_raise_incompatible_point(__pyx_self, __pyx_v_point, __pyx_v_previous_point);
  4119. /* function exit code */
  4120. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4121. Py_XDECREF(values[__pyx_temp]);
  4122. }
  4123. __Pyx_RefNannyFinishContext();
  4124. return __pyx_r;
  4125. }
  4126. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_4_raise_incompatible_point(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_point, PyObject *__pyx_v_previous_point) {
  4127. PyObject *__pyx_r = NULL;
  4128. __Pyx_RefNannyDeclarations
  4129. PyObject *__pyx_t_1 = NULL;
  4130. PyObject *__pyx_t_2 = NULL;
  4131. PyObject *__pyx_t_3 = NULL;
  4132. PyObject *__pyx_t_4 = NULL;
  4133. PyObject *__pyx_t_5[4];
  4134. PyObject *__pyx_t_6 = NULL;
  4135. size_t __pyx_t_7;
  4136. int __pyx_lineno = 0;
  4137. const char *__pyx_filename = NULL;
  4138. int __pyx_clineno = 0;
  4139. __Pyx_RefNannySetupContext("_raise_incompatible_point", 0);
  4140. /* "fontTools/qu2cu/qu2cu.py":179
  4141. *
  4142. * def _raise_incompatible_point(point, previous_point):
  4143. * raise ValueError( # <<<<<<<<<<<<<<
  4144. * f"Quadratic splines must connect end-to-start; got {previous_point!r} then {point!r}"
  4145. * )
  4146. */
  4147. __pyx_t_2 = NULL;
  4148. /* "fontTools/qu2cu/qu2cu.py":180
  4149. * def _raise_incompatible_point(point, previous_point):
  4150. * raise ValueError(
  4151. * f"Quadratic splines must connect end-to-start; got {previous_point!r} then {point!r}" # <<<<<<<<<<<<<<
  4152. * )
  4153. *
  4154. */
  4155. __pyx_t_3 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_previous_point), __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
  4156. __Pyx_GOTREF(__pyx_t_3);
  4157. __pyx_t_4 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_point), __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error)
  4158. __Pyx_GOTREF(__pyx_t_4);
  4159. __pyx_t_5[0] = __pyx_mstate_global->__pyx_kp_u_Quadratic_splines_must_connect_e;
  4160. __pyx_t_5[1] = __pyx_t_3;
  4161. __pyx_t_5[2] = __pyx_mstate_global->__pyx_kp_u_then;
  4162. __pyx_t_5[3] = __pyx_t_4;
  4163. __pyx_t_6 = __Pyx_PyUnicode_Join(__pyx_t_5, 4, 49 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 6 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4));
  4164. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 180, __pyx_L1_error)
  4165. __Pyx_GOTREF(__pyx_t_6);
  4166. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4167. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4168. __pyx_t_7 = 1;
  4169. {
  4170. PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_6};
  4171. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4172. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4173. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4174. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error)
  4175. __Pyx_GOTREF(__pyx_t_1);
  4176. }
  4177. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  4178. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4179. __PYX_ERR(0, 179, __pyx_L1_error)
  4180. /* "fontTools/qu2cu/qu2cu.py":178
  4181. *
  4182. *
  4183. * def _raise_incompatible_point(point, previous_point): # <<<<<<<<<<<<<<
  4184. * raise ValueError(
  4185. * f"Quadratic splines must connect end-to-start; got {previous_point!r} then {point!r}"
  4186. */
  4187. /* function exit code */
  4188. __pyx_L1_error:;
  4189. __Pyx_XDECREF(__pyx_t_1);
  4190. __Pyx_XDECREF(__pyx_t_2);
  4191. __Pyx_XDECREF(__pyx_t_3);
  4192. __Pyx_XDECREF(__pyx_t_4);
  4193. __Pyx_XDECREF(__pyx_t_6);
  4194. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu._raise_incompatible_point", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4195. __pyx_r = NULL;
  4196. __Pyx_XGIVEREF(__pyx_r);
  4197. __Pyx_RefNannyFinishContext();
  4198. return __pyx_r;
  4199. }
  4200. /* "fontTools/qu2cu/qu2cu.py":184
  4201. *
  4202. *
  4203. * def _validate_spline_length(spline): # <<<<<<<<<<<<<<
  4204. * if len(spline) < 3:
  4205. * raise ValueError("Quadratic splines must contain at least 3 points")
  4206. */
  4207. /* Python wrapper */
  4208. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_7_validate_spline_length(PyObject *__pyx_self,
  4209. #if CYTHON_METH_FASTCALL
  4210. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4211. #else
  4212. PyObject *__pyx_args, PyObject *__pyx_kwds
  4213. #endif
  4214. ); /*proto*/
  4215. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_6_validate_spline_length, "_validate_spline_length(spline)");
  4216. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_7_validate_spline_length = {"_validate_spline_length", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_7_validate_spline_length, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_6_validate_spline_length};
  4217. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_7_validate_spline_length(PyObject *__pyx_self,
  4218. #if CYTHON_METH_FASTCALL
  4219. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4220. #else
  4221. PyObject *__pyx_args, PyObject *__pyx_kwds
  4222. #endif
  4223. ) {
  4224. PyObject *__pyx_v_spline = 0;
  4225. #if !CYTHON_METH_FASTCALL
  4226. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  4227. #endif
  4228. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  4229. PyObject* values[1] = {0};
  4230. int __pyx_lineno = 0;
  4231. const char *__pyx_filename = NULL;
  4232. int __pyx_clineno = 0;
  4233. PyObject *__pyx_r = 0;
  4234. __Pyx_RefNannyDeclarations
  4235. __Pyx_RefNannySetupContext("_validate_spline_length (wrapper)", 0);
  4236. #if !CYTHON_METH_FASTCALL
  4237. #if CYTHON_ASSUME_SAFE_SIZE
  4238. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  4239. #else
  4240. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  4241. #endif
  4242. #endif
  4243. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  4244. {
  4245. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_spline,0};
  4246. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  4247. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 184, __pyx_L3_error)
  4248. if (__pyx_kwds_len > 0) {
  4249. switch (__pyx_nargs) {
  4250. case 1:
  4251. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4252. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 184, __pyx_L3_error)
  4253. CYTHON_FALLTHROUGH;
  4254. case 0: break;
  4255. default: goto __pyx_L5_argtuple_error;
  4256. }
  4257. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  4258. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_validate_spline_length", 0) < (0)) __PYX_ERR(0, 184, __pyx_L3_error)
  4259. for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
  4260. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_validate_spline_length", 1, 1, 1, i); __PYX_ERR(0, 184, __pyx_L3_error) }
  4261. }
  4262. } else if (unlikely(__pyx_nargs != 1)) {
  4263. goto __pyx_L5_argtuple_error;
  4264. } else {
  4265. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4266. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 184, __pyx_L3_error)
  4267. }
  4268. __pyx_v_spline = values[0];
  4269. }
  4270. goto __pyx_L6_skip;
  4271. __pyx_L5_argtuple_error:;
  4272. __Pyx_RaiseArgtupleInvalid("_validate_spline_length", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 184, __pyx_L3_error)
  4273. __pyx_L6_skip:;
  4274. goto __pyx_L4_argument_unpacking_done;
  4275. __pyx_L3_error:;
  4276. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4277. Py_XDECREF(values[__pyx_temp]);
  4278. }
  4279. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu._validate_spline_length", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4280. __Pyx_RefNannyFinishContext();
  4281. return NULL;
  4282. __pyx_L4_argument_unpacking_done:;
  4283. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_6_validate_spline_length(__pyx_self, __pyx_v_spline);
  4284. /* function exit code */
  4285. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4286. Py_XDECREF(values[__pyx_temp]);
  4287. }
  4288. __Pyx_RefNannyFinishContext();
  4289. return __pyx_r;
  4290. }
  4291. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_6_validate_spline_length(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_spline) {
  4292. PyObject *__pyx_r = NULL;
  4293. __Pyx_RefNannyDeclarations
  4294. Py_ssize_t __pyx_t_1;
  4295. int __pyx_t_2;
  4296. PyObject *__pyx_t_3 = NULL;
  4297. PyObject *__pyx_t_4 = NULL;
  4298. size_t __pyx_t_5;
  4299. int __pyx_lineno = 0;
  4300. const char *__pyx_filename = NULL;
  4301. int __pyx_clineno = 0;
  4302. __Pyx_RefNannySetupContext("_validate_spline_length", 0);
  4303. /* "fontTools/qu2cu/qu2cu.py":185
  4304. *
  4305. * def _validate_spline_length(spline):
  4306. * if len(spline) < 3: # <<<<<<<<<<<<<<
  4307. * raise ValueError("Quadratic splines must contain at least 3 points")
  4308. *
  4309. */
  4310. __pyx_t_1 = PyObject_Length(__pyx_v_spline); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 185, __pyx_L1_error)
  4311. __pyx_t_2 = (__pyx_t_1 < 3);
  4312. if (unlikely(__pyx_t_2)) {
  4313. /* "fontTools/qu2cu/qu2cu.py":186
  4314. * def _validate_spline_length(spline):
  4315. * if len(spline) < 3:
  4316. * raise ValueError("Quadratic splines must contain at least 3 points") # <<<<<<<<<<<<<<
  4317. *
  4318. *
  4319. */
  4320. __pyx_t_4 = NULL;
  4321. __pyx_t_5 = 1;
  4322. {
  4323. PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Quadratic_splines_must_contain_a};
  4324. __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4325. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  4326. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error)
  4327. __Pyx_GOTREF(__pyx_t_3);
  4328. }
  4329. __Pyx_Raise(__pyx_t_3, 0, 0, 0);
  4330. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4331. __PYX_ERR(0, 186, __pyx_L1_error)
  4332. /* "fontTools/qu2cu/qu2cu.py":185
  4333. *
  4334. * def _validate_spline_length(spline):
  4335. * if len(spline) < 3: # <<<<<<<<<<<<<<
  4336. * raise ValueError("Quadratic splines must contain at least 3 points")
  4337. *
  4338. */
  4339. }
  4340. /* "fontTools/qu2cu/qu2cu.py":184
  4341. *
  4342. *
  4343. * def _validate_spline_length(spline): # <<<<<<<<<<<<<<
  4344. * if len(spline) < 3:
  4345. * raise ValueError("Quadratic splines must contain at least 3 points")
  4346. */
  4347. /* function exit code */
  4348. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4349. goto __pyx_L0;
  4350. __pyx_L1_error:;
  4351. __Pyx_XDECREF(__pyx_t_3);
  4352. __Pyx_XDECREF(__pyx_t_4);
  4353. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu._validate_spline_length", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4354. __pyx_r = NULL;
  4355. __pyx_L0:;
  4356. __Pyx_XGIVEREF(__pyx_r);
  4357. __Pyx_RefNannyFinishContext();
  4358. return __pyx_r;
  4359. }
  4360. /* "fontTools/qu2cu/qu2cu.py":189
  4361. *
  4362. *
  4363. * def _validate_positive_tolerance(max_err): # <<<<<<<<<<<<<<
  4364. * if max_err <= 0:
  4365. * raise ValueError("max_err must be greater than zero")
  4366. */
  4367. /* Python wrapper */
  4368. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_9_validate_positive_tolerance(PyObject *__pyx_self,
  4369. #if CYTHON_METH_FASTCALL
  4370. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4371. #else
  4372. PyObject *__pyx_args, PyObject *__pyx_kwds
  4373. #endif
  4374. ); /*proto*/
  4375. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_8_validate_positive_tolerance, "_validate_positive_tolerance(max_err)");
  4376. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_9_validate_positive_tolerance = {"_validate_positive_tolerance", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_9_validate_positive_tolerance, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_8_validate_positive_tolerance};
  4377. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_9_validate_positive_tolerance(PyObject *__pyx_self,
  4378. #if CYTHON_METH_FASTCALL
  4379. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4380. #else
  4381. PyObject *__pyx_args, PyObject *__pyx_kwds
  4382. #endif
  4383. ) {
  4384. PyObject *__pyx_v_max_err = 0;
  4385. #if !CYTHON_METH_FASTCALL
  4386. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  4387. #endif
  4388. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  4389. PyObject* values[1] = {0};
  4390. int __pyx_lineno = 0;
  4391. const char *__pyx_filename = NULL;
  4392. int __pyx_clineno = 0;
  4393. PyObject *__pyx_r = 0;
  4394. __Pyx_RefNannyDeclarations
  4395. __Pyx_RefNannySetupContext("_validate_positive_tolerance (wrapper)", 0);
  4396. #if !CYTHON_METH_FASTCALL
  4397. #if CYTHON_ASSUME_SAFE_SIZE
  4398. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  4399. #else
  4400. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  4401. #endif
  4402. #endif
  4403. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  4404. {
  4405. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_max_err,0};
  4406. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  4407. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 189, __pyx_L3_error)
  4408. if (__pyx_kwds_len > 0) {
  4409. switch (__pyx_nargs) {
  4410. case 1:
  4411. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4412. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 189, __pyx_L3_error)
  4413. CYTHON_FALLTHROUGH;
  4414. case 0: break;
  4415. default: goto __pyx_L5_argtuple_error;
  4416. }
  4417. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  4418. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_validate_positive_tolerance", 0) < (0)) __PYX_ERR(0, 189, __pyx_L3_error)
  4419. for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
  4420. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_validate_positive_tolerance", 1, 1, 1, i); __PYX_ERR(0, 189, __pyx_L3_error) }
  4421. }
  4422. } else if (unlikely(__pyx_nargs != 1)) {
  4423. goto __pyx_L5_argtuple_error;
  4424. } else {
  4425. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4426. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 189, __pyx_L3_error)
  4427. }
  4428. __pyx_v_max_err = values[0];
  4429. }
  4430. goto __pyx_L6_skip;
  4431. __pyx_L5_argtuple_error:;
  4432. __Pyx_RaiseArgtupleInvalid("_validate_positive_tolerance", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 189, __pyx_L3_error)
  4433. __pyx_L6_skip:;
  4434. goto __pyx_L4_argument_unpacking_done;
  4435. __pyx_L3_error:;
  4436. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4437. Py_XDECREF(values[__pyx_temp]);
  4438. }
  4439. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu._validate_positive_tolerance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4440. __Pyx_RefNannyFinishContext();
  4441. return NULL;
  4442. __pyx_L4_argument_unpacking_done:;
  4443. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_8_validate_positive_tolerance(__pyx_self, __pyx_v_max_err);
  4444. /* function exit code */
  4445. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4446. Py_XDECREF(values[__pyx_temp]);
  4447. }
  4448. __Pyx_RefNannyFinishContext();
  4449. return __pyx_r;
  4450. }
  4451. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_8_validate_positive_tolerance(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_max_err) {
  4452. PyObject *__pyx_r = NULL;
  4453. __Pyx_RefNannyDeclarations
  4454. PyObject *__pyx_t_1 = NULL;
  4455. int __pyx_t_2;
  4456. PyObject *__pyx_t_3 = NULL;
  4457. size_t __pyx_t_4;
  4458. int __pyx_lineno = 0;
  4459. const char *__pyx_filename = NULL;
  4460. int __pyx_clineno = 0;
  4461. __Pyx_RefNannySetupContext("_validate_positive_tolerance", 0);
  4462. /* "fontTools/qu2cu/qu2cu.py":190
  4463. *
  4464. * def _validate_positive_tolerance(max_err):
  4465. * if max_err <= 0: # <<<<<<<<<<<<<<
  4466. * raise ValueError("max_err must be greater than zero")
  4467. *
  4468. */
  4469. __pyx_t_1 = PyObject_RichCompare(__pyx_v_max_err, __pyx_mstate_global->__pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
  4470. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 190, __pyx_L1_error)
  4471. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4472. if (unlikely(__pyx_t_2)) {
  4473. /* "fontTools/qu2cu/qu2cu.py":191
  4474. * def _validate_positive_tolerance(max_err):
  4475. * if max_err <= 0:
  4476. * raise ValueError("max_err must be greater than zero") # <<<<<<<<<<<<<<
  4477. *
  4478. *
  4479. */
  4480. __pyx_t_3 = NULL;
  4481. __pyx_t_4 = 1;
  4482. {
  4483. PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_max_err_must_be_greater_than_zer};
  4484. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_ValueError)), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4485. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4486. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error)
  4487. __Pyx_GOTREF(__pyx_t_1);
  4488. }
  4489. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  4490. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4491. __PYX_ERR(0, 191, __pyx_L1_error)
  4492. /* "fontTools/qu2cu/qu2cu.py":190
  4493. *
  4494. * def _validate_positive_tolerance(max_err):
  4495. * if max_err <= 0: # <<<<<<<<<<<<<<
  4496. * raise ValueError("max_err must be greater than zero")
  4497. *
  4498. */
  4499. }
  4500. /* "fontTools/qu2cu/qu2cu.py":189
  4501. *
  4502. *
  4503. * def _validate_positive_tolerance(max_err): # <<<<<<<<<<<<<<
  4504. * if max_err <= 0:
  4505. * raise ValueError("max_err must be greater than zero")
  4506. */
  4507. /* function exit code */
  4508. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4509. goto __pyx_L0;
  4510. __pyx_L1_error:;
  4511. __Pyx_XDECREF(__pyx_t_1);
  4512. __Pyx_XDECREF(__pyx_t_3);
  4513. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu._validate_positive_tolerance", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4514. __pyx_r = NULL;
  4515. __pyx_L0:;
  4516. __Pyx_XGIVEREF(__pyx_r);
  4517. __Pyx_RefNannyFinishContext();
  4518. return __pyx_r;
  4519. }
  4520. /* "fontTools/qu2cu/qu2cu.py":194
  4521. *
  4522. *
  4523. * @cython.locals( # <<<<<<<<<<<<<<
  4524. * cost=cython.int,
  4525. * is_complex=cython.int,
  4526. */
  4527. /* Python wrapper */
  4528. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_11quadratic_to_curves(PyObject *__pyx_self,
  4529. #if CYTHON_METH_FASTCALL
  4530. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4531. #else
  4532. PyObject *__pyx_args, PyObject *__pyx_kwds
  4533. #endif
  4534. ); /*proto*/
  4535. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_10quadratic_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 If ``quads`` is empty, returns an empty list.\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\n\nRaises:\n ValueError: if an input spline has fewer than 3 points, or if adjacent\n splines do not connect end-to-start.");
  4536. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_11quadratic_to_curves = {"quadratic_to_curves", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_11quadratic_to_curves, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_10quadratic_to_curves};
  4537. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_11quadratic_to_curves(PyObject *__pyx_self,
  4538. #if CYTHON_METH_FASTCALL
  4539. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  4540. #else
  4541. PyObject *__pyx_args, PyObject *__pyx_kwds
  4542. #endif
  4543. ) {
  4544. PyObject *__pyx_v_quads = 0;
  4545. double __pyx_v_max_err;
  4546. int __pyx_v_all_cubic;
  4547. #if !CYTHON_METH_FASTCALL
  4548. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  4549. #endif
  4550. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  4551. PyObject* values[3] = {0,0,0};
  4552. int __pyx_lineno = 0;
  4553. const char *__pyx_filename = NULL;
  4554. int __pyx_clineno = 0;
  4555. PyObject *__pyx_r = 0;
  4556. __Pyx_RefNannyDeclarations
  4557. __Pyx_RefNannySetupContext("quadratic_to_curves (wrapper)", 0);
  4558. #if !CYTHON_METH_FASTCALL
  4559. #if CYTHON_ASSUME_SAFE_SIZE
  4560. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  4561. #else
  4562. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  4563. #endif
  4564. #endif
  4565. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  4566. {
  4567. 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};
  4568. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  4569. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 194, __pyx_L3_error)
  4570. if (__pyx_kwds_len > 0) {
  4571. switch (__pyx_nargs) {
  4572. case 3:
  4573. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  4574. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 194, __pyx_L3_error)
  4575. CYTHON_FALLTHROUGH;
  4576. case 2:
  4577. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  4578. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 194, __pyx_L3_error)
  4579. CYTHON_FALLTHROUGH;
  4580. case 1:
  4581. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4582. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 194, __pyx_L3_error)
  4583. CYTHON_FALLTHROUGH;
  4584. case 0: break;
  4585. default: goto __pyx_L5_argtuple_error;
  4586. }
  4587. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  4588. 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, 194, __pyx_L3_error)
  4589. for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
  4590. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("quadratic_to_curves", 0, 1, 3, i); __PYX_ERR(0, 194, __pyx_L3_error) }
  4591. }
  4592. } else {
  4593. switch (__pyx_nargs) {
  4594. case 3:
  4595. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  4596. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 194, __pyx_L3_error)
  4597. CYTHON_FALLTHROUGH;
  4598. case 2:
  4599. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  4600. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 194, __pyx_L3_error)
  4601. CYTHON_FALLTHROUGH;
  4602. case 1:
  4603. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  4604. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 194, __pyx_L3_error)
  4605. break;
  4606. default: goto __pyx_L5_argtuple_error;
  4607. }
  4608. }
  4609. __pyx_v_quads = ((PyObject*)values[0]);
  4610. if (values[1]) {
  4611. __pyx_v_max_err = __Pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_max_err == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L3_error)
  4612. } else {
  4613. __pyx_v_max_err = ((double)((double)0.5));
  4614. }
  4615. if (values[2]) {
  4616. __pyx_v_all_cubic = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_all_cubic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 201, __pyx_L3_error)
  4617. } else {
  4618. /* "fontTools/qu2cu/qu2cu.py":201
  4619. * quads: List[List[Point]],
  4620. * max_err: float = 0.5,
  4621. * all_cubic: bool = False, # <<<<<<<<<<<<<<
  4622. * ) -> List[Tuple[Point, ...]]:
  4623. * """Converts a connecting list of quadratic splines to a list of quadratic
  4624. */
  4625. __pyx_v_all_cubic = ((int)((int)0));
  4626. }
  4627. }
  4628. goto __pyx_L6_skip;
  4629. __pyx_L5_argtuple_error:;
  4630. __Pyx_RaiseArgtupleInvalid("quadratic_to_curves", 0, 1, 3, __pyx_nargs); __PYX_ERR(0, 194, __pyx_L3_error)
  4631. __pyx_L6_skip:;
  4632. goto __pyx_L4_argument_unpacking_done;
  4633. __pyx_L3_error:;
  4634. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4635. Py_XDECREF(values[__pyx_temp]);
  4636. }
  4637. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.quadratic_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4638. __Pyx_RefNannyFinishContext();
  4639. return NULL;
  4640. __pyx_L4_argument_unpacking_done:;
  4641. if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_quads), (&PyList_Type), 0, "quads", 2))) __PYX_ERR(0, 199, __pyx_L1_error)
  4642. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_10quadratic_to_curves(__pyx_self, __pyx_v_quads, __pyx_v_max_err, __pyx_v_all_cubic);
  4643. /* "fontTools/qu2cu/qu2cu.py":194
  4644. *
  4645. *
  4646. * @cython.locals( # <<<<<<<<<<<<<<
  4647. * cost=cython.int,
  4648. * is_complex=cython.int,
  4649. */
  4650. /* function exit code */
  4651. goto __pyx_L0;
  4652. __pyx_L1_error:;
  4653. __pyx_r = NULL;
  4654. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4655. Py_XDECREF(values[__pyx_temp]);
  4656. }
  4657. goto __pyx_L7_cleaned_up;
  4658. __pyx_L0:;
  4659. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  4660. Py_XDECREF(values[__pyx_temp]);
  4661. }
  4662. __pyx_L7_cleaned_up:;
  4663. __Pyx_RefNannyFinishContext();
  4664. return __pyx_r;
  4665. }
  4666. 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 */
  4667. /* "fontTools/qu2cu/qu2cu.py":263
  4668. *
  4669. * if not is_complex:
  4670. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves] # <<<<<<<<<<<<<<
  4671. * return curves
  4672. *
  4673. */
  4674. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  4675. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *__pyx_cur_scope;
  4676. PyObject *__pyx_r = NULL;
  4677. __Pyx_RefNannyDeclarations
  4678. int __pyx_lineno = 0;
  4679. const char *__pyx_filename = NULL;
  4680. int __pyx_clineno = 0;
  4681. __Pyx_RefNannySetupContext("genexpr", 0);
  4682. __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);
  4683. if (unlikely(!__pyx_cur_scope)) {
  4684. __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)Py_None);
  4685. __Pyx_INCREF(Py_None);
  4686. __PYX_ERR(0, 263, __pyx_L1_error)
  4687. } else {
  4688. __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  4689. }
  4690. __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  4691. __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  4692. __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  4693. {
  4694. __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, 263, __pyx_L1_error)
  4695. __Pyx_DECREF(__pyx_cur_scope);
  4696. __Pyx_RefNannyFinishContext();
  4697. return (PyObject *) gen;
  4698. }
  4699. /* function exit code */
  4700. __pyx_L1_error:;
  4701. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.quadratic_to_curves.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4702. __pyx_r = NULL;
  4703. __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  4704. __Pyx_XGIVEREF(__pyx_r);
  4705. __Pyx_RefNannyFinishContext();
  4706. return __pyx_r;
  4707. }
  4708. 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 */
  4709. {
  4710. 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);
  4711. PyObject *__pyx_r = NULL;
  4712. PyObject *__pyx_t_1 = NULL;
  4713. Py_ssize_t __pyx_t_2;
  4714. PyObject *(*__pyx_t_3)(PyObject *);
  4715. PyObject *__pyx_t_4 = NULL;
  4716. PyObject *__pyx_t_5 = NULL;
  4717. PyObject *__pyx_t_6 = NULL;
  4718. int __pyx_lineno = 0;
  4719. const char *__pyx_filename = NULL;
  4720. int __pyx_clineno = 0;
  4721. __Pyx_RefNannyDeclarations
  4722. __Pyx_RefNannySetupContext("genexpr", 0);
  4723. switch (__pyx_generator->resume_label) {
  4724. case 0: goto __pyx_L3_first_run;
  4725. case 1: goto __pyx_L6_resume_from_yield;
  4726. default: /* CPython raises the right error here */
  4727. __Pyx_RefNannyFinishContext();
  4728. return NULL;
  4729. }
  4730. __pyx_L3_first_run:;
  4731. if (unlikely(__pyx_sent_value != Py_None)) {
  4732. if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started generator");
  4733. __PYX_ERR(0, 263, __pyx_L1_error)
  4734. }
  4735. if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 263, __pyx_L1_error) }
  4736. if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
  4737. __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
  4738. __pyx_t_2 = 0;
  4739. __pyx_t_3 = NULL;
  4740. } else {
  4741. __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
  4742. __Pyx_GOTREF(__pyx_t_1);
  4743. __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L1_error)
  4744. }
  4745. for (;;) {
  4746. if (likely(!__pyx_t_3)) {
  4747. if (likely(PyList_CheckExact(__pyx_t_1))) {
  4748. {
  4749. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
  4750. #if !CYTHON_ASSUME_SAFE_SIZE
  4751. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 263, __pyx_L1_error)
  4752. #endif
  4753. if (__pyx_t_2 >= __pyx_temp) break;
  4754. }
  4755. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
  4756. ++__pyx_t_2;
  4757. } else {
  4758. {
  4759. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
  4760. #if !CYTHON_ASSUME_SAFE_SIZE
  4761. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 263, __pyx_L1_error)
  4762. #endif
  4763. if (__pyx_t_2 >= __pyx_temp) break;
  4764. }
  4765. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4766. __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
  4767. #else
  4768. __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
  4769. #endif
  4770. ++__pyx_t_2;
  4771. }
  4772. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 263, __pyx_L1_error)
  4773. } else {
  4774. __pyx_t_4 = __pyx_t_3(__pyx_t_1);
  4775. if (unlikely(!__pyx_t_4)) {
  4776. PyObject* exc_type = PyErr_Occurred();
  4777. if (exc_type) {
  4778. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 263, __pyx_L1_error)
  4779. PyErr_Clear();
  4780. }
  4781. break;
  4782. }
  4783. }
  4784. __Pyx_GOTREF(__pyx_t_4);
  4785. __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_c);
  4786. __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_c, __pyx_t_4);
  4787. __Pyx_GIVEREF(__pyx_t_4);
  4788. __pyx_t_4 = 0;
  4789. __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, 263, __pyx_L1_error)
  4790. __Pyx_GOTREF(__pyx_t_4);
  4791. __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, 263, __pyx_L1_error)
  4792. __Pyx_GOTREF(__pyx_t_5);
  4793. __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 263, __pyx_L1_error)
  4794. __Pyx_GOTREF(__pyx_t_6);
  4795. __Pyx_GIVEREF(__pyx_t_4);
  4796. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 263, __pyx_L1_error);
  4797. __Pyx_GIVEREF(__pyx_t_5);
  4798. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 263, __pyx_L1_error);
  4799. __pyx_t_4 = 0;
  4800. __pyx_t_5 = 0;
  4801. __pyx_r = __pyx_t_6;
  4802. __pyx_t_6 = 0;
  4803. __Pyx_XGIVEREF(__pyx_t_1);
  4804. __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
  4805. __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
  4806. __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
  4807. __Pyx_XGIVEREF(__pyx_r);
  4808. __Pyx_RefNannyFinishContext();
  4809. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4810. /* return from generator, yielding value */
  4811. __pyx_generator->resume_label = 1;
  4812. return __pyx_r;
  4813. __pyx_L6_resume_from_yield:;
  4814. __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
  4815. __pyx_cur_scope->__pyx_t_0 = 0;
  4816. __Pyx_XGOTREF(__pyx_t_1);
  4817. __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
  4818. __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
  4819. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 263, __pyx_L1_error)
  4820. }
  4821. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4822. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  4823. /* function exit code */
  4824. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4825. goto __pyx_L0;
  4826. __pyx_L1_error:;
  4827. __Pyx_XDECREF(__pyx_t_1);
  4828. __Pyx_XDECREF(__pyx_t_4);
  4829. __Pyx_XDECREF(__pyx_t_5);
  4830. __Pyx_XDECREF(__pyx_t_6);
  4831. if (__Pyx_PyErr_Occurred()) {
  4832. __Pyx_Generator_Replace_StopIteration(0);
  4833. __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4834. }
  4835. __pyx_L0:;
  4836. __Pyx_XGIVEREF(__pyx_r);
  4837. #if !CYTHON_USE_EXC_INFO_STACK
  4838. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4839. #endif
  4840. __pyx_generator->resume_label = -1;
  4841. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  4842. __Pyx_RefNannyFinishContext();
  4843. return __pyx_r;
  4844. }
  4845. /* "fontTools/qu2cu/qu2cu.py":194
  4846. *
  4847. *
  4848. * @cython.locals( # <<<<<<<<<<<<<<
  4849. * cost=cython.int,
  4850. * is_complex=cython.int,
  4851. */
  4852. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_10quadratic_to_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_quads, double __pyx_v_max_err, int __pyx_v_all_cubic) {
  4853. int __pyx_v_cost;
  4854. int __pyx_v_is_complex;
  4855. PyObject *__pyx_v_spline = NULL;
  4856. PyObject *__pyx_v_q = NULL;
  4857. PyObject *__pyx_v_costs = NULL;
  4858. PyObject *__pyx_v_p = NULL;
  4859. CYTHON_UNUSED Py_ssize_t __pyx_v_i;
  4860. PyObject *__pyx_v_qq = NULL;
  4861. PyObject *__pyx_v_curves = NULL;
  4862. PyObject *__pyx_8genexpr1__pyx_v_p = NULL;
  4863. PyObject *__pyx_8genexpr2__pyx_v_x = NULL;
  4864. PyObject *__pyx_8genexpr2__pyx_v_y = NULL;
  4865. PyObject *__pyx_8genexpr3__pyx_v_curve = NULL;
  4866. PyObject *__pyx_8genexpr3__pyx_v_0 = NULL;
  4867. PyObject *__pyx_r = NULL;
  4868. __Pyx_RefNannyDeclarations
  4869. int __pyx_t_1;
  4870. int __pyx_t_2;
  4871. PyObject *__pyx_t_3 = NULL;
  4872. PyObject *__pyx_t_4 = NULL;
  4873. PyObject *__pyx_t_5 = NULL;
  4874. PyObject *__pyx_t_6 = NULL;
  4875. size_t __pyx_t_7;
  4876. Py_ssize_t __pyx_t_8;
  4877. Py_ssize_t __pyx_t_9;
  4878. PyObject *(*__pyx_t_10)(PyObject *);
  4879. PyObject *__pyx_t_11 = NULL;
  4880. PyObject *__pyx_t_12 = NULL;
  4881. PyObject *__pyx_t_13 = NULL;
  4882. PyObject *__pyx_t_14 = NULL;
  4883. PyObject *(*__pyx_t_15)(PyObject *);
  4884. Py_ssize_t __pyx_t_16;
  4885. Py_ssize_t __pyx_t_17;
  4886. int __pyx_t_18;
  4887. int __pyx_lineno = 0;
  4888. const char *__pyx_filename = NULL;
  4889. int __pyx_clineno = 0;
  4890. __Pyx_RefNannySetupContext("quadratic_to_curves", 0);
  4891. __Pyx_INCREF(__pyx_v_quads);
  4892. /* "fontTools/qu2cu/qu2cu.py":234
  4893. * splines do not connect end-to-start.
  4894. * """
  4895. * if not quads: # <<<<<<<<<<<<<<
  4896. * return []
  4897. * _validate_positive_tolerance(max_err)
  4898. */
  4899. {
  4900. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_quads);
  4901. if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 234, __pyx_L1_error)
  4902. __pyx_t_1 = (__pyx_temp != 0);
  4903. }
  4904. __pyx_t_2 = (!__pyx_t_1);
  4905. if (__pyx_t_2) {
  4906. /* "fontTools/qu2cu/qu2cu.py":235
  4907. * """
  4908. * if not quads:
  4909. * return [] # <<<<<<<<<<<<<<
  4910. * _validate_positive_tolerance(max_err)
  4911. * for spline in quads:
  4912. */
  4913. __Pyx_XDECREF(__pyx_r);
  4914. __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 235, __pyx_L1_error)
  4915. __Pyx_GOTREF(__pyx_t_3);
  4916. __pyx_r = ((PyObject*)__pyx_t_3);
  4917. __pyx_t_3 = 0;
  4918. goto __pyx_L0;
  4919. /* "fontTools/qu2cu/qu2cu.py":234
  4920. * splines do not connect end-to-start.
  4921. * """
  4922. * if not quads: # <<<<<<<<<<<<<<
  4923. * return []
  4924. * _validate_positive_tolerance(max_err)
  4925. */
  4926. }
  4927. /* "fontTools/qu2cu/qu2cu.py":236
  4928. * if not quads:
  4929. * return []
  4930. * _validate_positive_tolerance(max_err) # <<<<<<<<<<<<<<
  4931. * for spline in quads:
  4932. * _validate_spline_length(spline)
  4933. */
  4934. __pyx_t_4 = NULL;
  4935. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_validate_positive_tolerance); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 236, __pyx_L1_error)
  4936. __Pyx_GOTREF(__pyx_t_5);
  4937. __pyx_t_6 = PyFloat_FromDouble(__pyx_v_max_err); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
  4938. __Pyx_GOTREF(__pyx_t_6);
  4939. __pyx_t_7 = 1;
  4940. #if CYTHON_UNPACK_METHODS
  4941. if (unlikely(PyMethod_Check(__pyx_t_5))) {
  4942. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
  4943. assert(__pyx_t_4);
  4944. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
  4945. __Pyx_INCREF(__pyx_t_4);
  4946. __Pyx_INCREF(__pyx__function);
  4947. __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
  4948. __pyx_t_7 = 0;
  4949. }
  4950. #endif
  4951. {
  4952. PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_6};
  4953. __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4954. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  4955. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4956. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4957. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 236, __pyx_L1_error)
  4958. __Pyx_GOTREF(__pyx_t_3);
  4959. }
  4960. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4961. /* "fontTools/qu2cu/qu2cu.py":237
  4962. * return []
  4963. * _validate_positive_tolerance(max_err)
  4964. * for spline in quads: # <<<<<<<<<<<<<<
  4965. * _validate_spline_length(spline)
  4966. *
  4967. */
  4968. __pyx_t_3 = __pyx_v_quads; __Pyx_INCREF(__pyx_t_3);
  4969. __pyx_t_8 = 0;
  4970. for (;;) {
  4971. {
  4972. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
  4973. #if !CYTHON_ASSUME_SAFE_SIZE
  4974. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 237, __pyx_L1_error)
  4975. #endif
  4976. if (__pyx_t_8 >= __pyx_temp) break;
  4977. }
  4978. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_3, __pyx_t_8, __Pyx_ReferenceSharing_OwnStrongReference);
  4979. ++__pyx_t_8;
  4980. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 237, __pyx_L1_error)
  4981. __Pyx_GOTREF(__pyx_t_5);
  4982. __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_5);
  4983. __pyx_t_5 = 0;
  4984. /* "fontTools/qu2cu/qu2cu.py":238
  4985. * _validate_positive_tolerance(max_err)
  4986. * for spline in quads:
  4987. * _validate_spline_length(spline) # <<<<<<<<<<<<<<
  4988. *
  4989. * is_complex = type(quads[0][0]) is complex
  4990. */
  4991. __pyx_t_6 = NULL;
  4992. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_validate_spline_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 238, __pyx_L1_error)
  4993. __Pyx_GOTREF(__pyx_t_4);
  4994. __pyx_t_7 = 1;
  4995. #if CYTHON_UNPACK_METHODS
  4996. if (unlikely(PyMethod_Check(__pyx_t_4))) {
  4997. __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
  4998. assert(__pyx_t_6);
  4999. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
  5000. __Pyx_INCREF(__pyx_t_6);
  5001. __Pyx_INCREF(__pyx__function);
  5002. __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
  5003. __pyx_t_7 = 0;
  5004. }
  5005. #endif
  5006. {
  5007. PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_spline};
  5008. __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5009. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  5010. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5011. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 238, __pyx_L1_error)
  5012. __Pyx_GOTREF(__pyx_t_5);
  5013. }
  5014. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5015. /* "fontTools/qu2cu/qu2cu.py":237
  5016. * return []
  5017. * _validate_positive_tolerance(max_err)
  5018. * for spline in quads: # <<<<<<<<<<<<<<
  5019. * _validate_spline_length(spline)
  5020. *
  5021. */
  5022. }
  5023. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5024. /* "fontTools/qu2cu/qu2cu.py":240
  5025. * _validate_spline_length(spline)
  5026. *
  5027. * is_complex = type(quads[0][0]) is complex # <<<<<<<<<<<<<<
  5028. * if not is_complex:
  5029. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  5030. */
  5031. __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_quads, 0, long, 1, __Pyx_PyLong_From_long, 1, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 240, __pyx_L1_error)
  5032. __Pyx_GOTREF(__pyx_t_3);
  5033. __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 240, __pyx_L1_error)
  5034. __Pyx_GOTREF(__pyx_t_5);
  5035. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5036. __pyx_t_2 = (((PyObject *)Py_TYPE(__pyx_t_5)) == ((PyObject *)(&PyComplex_Type)));
  5037. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5038. __pyx_v_is_complex = __pyx_t_2;
  5039. /* "fontTools/qu2cu/qu2cu.py":241
  5040. *
  5041. * is_complex = type(quads[0][0]) is complex
  5042. * if not is_complex: # <<<<<<<<<<<<<<
  5043. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  5044. *
  5045. */
  5046. __pyx_t_2 = (!(__pyx_v_is_complex != 0));
  5047. if (__pyx_t_2) {
  5048. /* "fontTools/qu2cu/qu2cu.py":242
  5049. * is_complex = type(quads[0][0]) is complex
  5050. * if not is_complex:
  5051. * quads = [[complex(x, y) for (x, y) in p] for p in quads] # <<<<<<<<<<<<<<
  5052. *
  5053. * q = [quads[0][0]]
  5054. */
  5055. { /* enter inner scope */
  5056. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 242, __pyx_L10_error)
  5057. __Pyx_GOTREF(__pyx_t_5);
  5058. __pyx_t_3 = __pyx_v_quads; __Pyx_INCREF(__pyx_t_3);
  5059. __pyx_t_8 = 0;
  5060. for (;;) {
  5061. {
  5062. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
  5063. #if !CYTHON_ASSUME_SAFE_SIZE
  5064. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 242, __pyx_L10_error)
  5065. #endif
  5066. if (__pyx_t_8 >= __pyx_temp) break;
  5067. }
  5068. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(__pyx_t_3, __pyx_t_8, __Pyx_ReferenceSharing_OwnStrongReference);
  5069. ++__pyx_t_8;
  5070. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L10_error)
  5071. __Pyx_GOTREF(__pyx_t_4);
  5072. __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_p, __pyx_t_4);
  5073. __pyx_t_4 = 0;
  5074. { /* enter inner scope */
  5075. __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 242, __pyx_L15_error)
  5076. __Pyx_GOTREF(__pyx_t_4);
  5077. if (likely(PyList_CheckExact(__pyx_8genexpr1__pyx_v_p)) || PyTuple_CheckExact(__pyx_8genexpr1__pyx_v_p)) {
  5078. __pyx_t_6 = __pyx_8genexpr1__pyx_v_p; __Pyx_INCREF(__pyx_t_6);
  5079. __pyx_t_9 = 0;
  5080. __pyx_t_10 = NULL;
  5081. } else {
  5082. __pyx_t_9 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr1__pyx_v_p); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 242, __pyx_L15_error)
  5083. __Pyx_GOTREF(__pyx_t_6);
  5084. __pyx_t_10 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 242, __pyx_L15_error)
  5085. }
  5086. for (;;) {
  5087. if (likely(!__pyx_t_10)) {
  5088. if (likely(PyList_CheckExact(__pyx_t_6))) {
  5089. {
  5090. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  5091. #if !CYTHON_ASSUME_SAFE_SIZE
  5092. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 242, __pyx_L15_error)
  5093. #endif
  5094. if (__pyx_t_9 >= __pyx_temp) break;
  5095. }
  5096. __pyx_t_11 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_9, __Pyx_ReferenceSharing_OwnStrongReference);
  5097. ++__pyx_t_9;
  5098. } else {
  5099. {
  5100. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  5101. #if !CYTHON_ASSUME_SAFE_SIZE
  5102. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 242, __pyx_L15_error)
  5103. #endif
  5104. if (__pyx_t_9 >= __pyx_temp) break;
  5105. }
  5106. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5107. __pyx_t_11 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9));
  5108. #else
  5109. __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_9);
  5110. #endif
  5111. ++__pyx_t_9;
  5112. }
  5113. if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 242, __pyx_L15_error)
  5114. } else {
  5115. __pyx_t_11 = __pyx_t_10(__pyx_t_6);
  5116. if (unlikely(!__pyx_t_11)) {
  5117. PyObject* exc_type = PyErr_Occurred();
  5118. if (exc_type) {
  5119. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 242, __pyx_L15_error)
  5120. PyErr_Clear();
  5121. }
  5122. break;
  5123. }
  5124. }
  5125. __Pyx_GOTREF(__pyx_t_11);
  5126. if ((likely(PyTuple_CheckExact(__pyx_t_11))) || (PyList_CheckExact(__pyx_t_11))) {
  5127. PyObject* sequence = __pyx_t_11;
  5128. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  5129. if (unlikely(size != 2)) {
  5130. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  5131. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  5132. __PYX_ERR(0, 242, __pyx_L15_error)
  5133. }
  5134. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5135. if (likely(PyTuple_CheckExact(sequence))) {
  5136. __pyx_t_12 = PyTuple_GET_ITEM(sequence, 0);
  5137. __Pyx_INCREF(__pyx_t_12);
  5138. __pyx_t_13 = PyTuple_GET_ITEM(sequence, 1);
  5139. __Pyx_INCREF(__pyx_t_13);
  5140. } else {
  5141. __pyx_t_12 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  5142. if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 242, __pyx_L15_error)
  5143. __Pyx_XGOTREF(__pyx_t_12);
  5144. __pyx_t_13 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  5145. if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L15_error)
  5146. __Pyx_XGOTREF(__pyx_t_13);
  5147. }
  5148. #else
  5149. __pyx_t_12 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 242, __pyx_L15_error)
  5150. __Pyx_GOTREF(__pyx_t_12);
  5151. __pyx_t_13 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 242, __pyx_L15_error)
  5152. __Pyx_GOTREF(__pyx_t_13);
  5153. #endif
  5154. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5155. } else {
  5156. Py_ssize_t index = -1;
  5157. __pyx_t_14 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 242, __pyx_L15_error)
  5158. __Pyx_GOTREF(__pyx_t_14);
  5159. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5160. __pyx_t_15 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_14);
  5161. index = 0; __pyx_t_12 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_12)) goto __pyx_L18_unpacking_failed;
  5162. __Pyx_GOTREF(__pyx_t_12);
  5163. index = 1; __pyx_t_13 = __pyx_t_15(__pyx_t_14); if (unlikely(!__pyx_t_13)) goto __pyx_L18_unpacking_failed;
  5164. __Pyx_GOTREF(__pyx_t_13);
  5165. if (__Pyx_IternextUnpackEndCheck(__pyx_t_15(__pyx_t_14), 2) < (0)) __PYX_ERR(0, 242, __pyx_L15_error)
  5166. __pyx_t_15 = NULL;
  5167. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5168. goto __pyx_L19_unpacking_done;
  5169. __pyx_L18_unpacking_failed:;
  5170. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5171. __pyx_t_15 = NULL;
  5172. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  5173. __PYX_ERR(0, 242, __pyx_L15_error)
  5174. __pyx_L19_unpacking_done:;
  5175. }
  5176. __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_x, __pyx_t_12);
  5177. __pyx_t_12 = 0;
  5178. __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_y, __pyx_t_13);
  5179. __pyx_t_13 = 0;
  5180. __pyx_t_13 = NULL;
  5181. __pyx_t_7 = 1;
  5182. {
  5183. PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_8genexpr2__pyx_v_x, __pyx_8genexpr2__pyx_v_y};
  5184. __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)(&PyComplex_Type), __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5185. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  5186. if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 242, __pyx_L15_error)
  5187. __Pyx_GOTREF(__pyx_t_11);
  5188. }
  5189. if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 242, __pyx_L15_error)
  5190. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5191. }
  5192. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5193. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_x); __pyx_8genexpr2__pyx_v_x = 0;
  5194. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_y); __pyx_8genexpr2__pyx_v_y = 0;
  5195. goto __pyx_L21_exit_scope;
  5196. __pyx_L15_error:;
  5197. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_x); __pyx_8genexpr2__pyx_v_x = 0;
  5198. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_y); __pyx_8genexpr2__pyx_v_y = 0;
  5199. goto __pyx_L10_error;
  5200. __pyx_L21_exit_scope:;
  5201. } /* exit inner scope */
  5202. if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 242, __pyx_L10_error)
  5203. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5204. }
  5205. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5206. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_p); __pyx_8genexpr1__pyx_v_p = 0;
  5207. goto __pyx_L23_exit_scope;
  5208. __pyx_L10_error:;
  5209. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_p); __pyx_8genexpr1__pyx_v_p = 0;
  5210. goto __pyx_L1_error;
  5211. __pyx_L23_exit_scope:;
  5212. } /* exit inner scope */
  5213. __Pyx_DECREF_SET(__pyx_v_quads, ((PyObject*)__pyx_t_5));
  5214. __pyx_t_5 = 0;
  5215. /* "fontTools/qu2cu/qu2cu.py":241
  5216. *
  5217. * is_complex = type(quads[0][0]) is complex
  5218. * if not is_complex: # <<<<<<<<<<<<<<
  5219. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  5220. *
  5221. */
  5222. }
  5223. /* "fontTools/qu2cu/qu2cu.py":244
  5224. * quads = [[complex(x, y) for (x, y) in p] for p in quads]
  5225. *
  5226. * q = [quads[0][0]] # <<<<<<<<<<<<<<
  5227. * costs = [1]
  5228. * cost = 1
  5229. */
  5230. __pyx_t_5 = __Pyx_GetItemInt_List(__pyx_v_quads, 0, long, 1, __Pyx_PyLong_From_long, 1, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 244, __pyx_L1_error)
  5231. __Pyx_GOTREF(__pyx_t_5);
  5232. __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 244, __pyx_L1_error)
  5233. __Pyx_GOTREF(__pyx_t_3);
  5234. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5235. __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 244, __pyx_L1_error)
  5236. __Pyx_GOTREF(__pyx_t_5);
  5237. __Pyx_GIVEREF(__pyx_t_3);
  5238. if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_3) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  5239. __pyx_t_3 = 0;
  5240. __pyx_v_q = ((PyObject*)__pyx_t_5);
  5241. __pyx_t_5 = 0;
  5242. /* "fontTools/qu2cu/qu2cu.py":245
  5243. *
  5244. * q = [quads[0][0]]
  5245. * costs = [1] # <<<<<<<<<<<<<<
  5246. * cost = 1
  5247. * for p in quads:
  5248. */
  5249. __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 245, __pyx_L1_error)
  5250. __Pyx_GOTREF(__pyx_t_5);
  5251. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  5252. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_1);
  5253. if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_mstate_global->__pyx_int_1) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  5254. __pyx_v_costs = ((PyObject*)__pyx_t_5);
  5255. __pyx_t_5 = 0;
  5256. /* "fontTools/qu2cu/qu2cu.py":246
  5257. * q = [quads[0][0]]
  5258. * costs = [1]
  5259. * cost = 1 # <<<<<<<<<<<<<<
  5260. * for p in quads:
  5261. * if q[-1] != p[0]:
  5262. */
  5263. __pyx_v_cost = 1;
  5264. /* "fontTools/qu2cu/qu2cu.py":247
  5265. * costs = [1]
  5266. * cost = 1
  5267. * for p in quads: # <<<<<<<<<<<<<<
  5268. * if q[-1] != p[0]:
  5269. * _raise_incompatible_point(p[0], q[-1])
  5270. */
  5271. __pyx_t_5 = __pyx_v_quads; __Pyx_INCREF(__pyx_t_5);
  5272. __pyx_t_8 = 0;
  5273. for (;;) {
  5274. {
  5275. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
  5276. #if !CYTHON_ASSUME_SAFE_SIZE
  5277. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 247, __pyx_L1_error)
  5278. #endif
  5279. if (__pyx_t_8 >= __pyx_temp) break;
  5280. }
  5281. __pyx_t_3 = __Pyx_PyList_GetItemRefFast(__pyx_t_5, __pyx_t_8, __Pyx_ReferenceSharing_OwnStrongReference);
  5282. ++__pyx_t_8;
  5283. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 247, __pyx_L1_error)
  5284. __Pyx_GOTREF(__pyx_t_3);
  5285. __Pyx_XDECREF_SET(__pyx_v_p, __pyx_t_3);
  5286. __pyx_t_3 = 0;
  5287. /* "fontTools/qu2cu/qu2cu.py":248
  5288. * cost = 1
  5289. * for p in quads:
  5290. * if q[-1] != p[0]: # <<<<<<<<<<<<<<
  5291. * _raise_incompatible_point(p[0], q[-1])
  5292. * for i in range(len(p) - 2):
  5293. */
  5294. __pyx_t_3 = __Pyx_GetItemInt_List(__pyx_v_q, -1L, long, 1, __Pyx_PyLong_From_long, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error)
  5295. __Pyx_GOTREF(__pyx_t_3);
  5296. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_p, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 248, __pyx_L1_error)
  5297. __Pyx_GOTREF(__pyx_t_4);
  5298. __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 248, __pyx_L1_error)
  5299. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5300. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5301. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 248, __pyx_L1_error)
  5302. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5303. if (__pyx_t_2) {
  5304. /* "fontTools/qu2cu/qu2cu.py":249
  5305. * for p in quads:
  5306. * if q[-1] != p[0]:
  5307. * _raise_incompatible_point(p[0], q[-1]) # <<<<<<<<<<<<<<
  5308. * for i in range(len(p) - 2):
  5309. * cost += 1
  5310. */
  5311. __pyx_t_4 = NULL;
  5312. __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_raise_incompatible_point); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error)
  5313. __Pyx_GOTREF(__pyx_t_3);
  5314. __pyx_t_11 = __Pyx_GetItemInt(__pyx_v_p, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 249, __pyx_L1_error)
  5315. __Pyx_GOTREF(__pyx_t_11);
  5316. __pyx_t_13 = __Pyx_GetItemInt_List(__pyx_v_q, -1L, long, 1, __Pyx_PyLong_From_long, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 249, __pyx_L1_error)
  5317. __Pyx_GOTREF(__pyx_t_13);
  5318. __pyx_t_7 = 1;
  5319. #if CYTHON_UNPACK_METHODS
  5320. if (unlikely(PyMethod_Check(__pyx_t_3))) {
  5321. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
  5322. assert(__pyx_t_4);
  5323. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
  5324. __Pyx_INCREF(__pyx_t_4);
  5325. __Pyx_INCREF(__pyx__function);
  5326. __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
  5327. __pyx_t_7 = 0;
  5328. }
  5329. #endif
  5330. {
  5331. PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_t_11, __pyx_t_13};
  5332. __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5333. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  5334. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5335. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  5336. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5337. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 249, __pyx_L1_error)
  5338. __Pyx_GOTREF(__pyx_t_6);
  5339. }
  5340. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5341. /* "fontTools/qu2cu/qu2cu.py":248
  5342. * cost = 1
  5343. * for p in quads:
  5344. * if q[-1] != p[0]: # <<<<<<<<<<<<<<
  5345. * _raise_incompatible_point(p[0], q[-1])
  5346. * for i in range(len(p) - 2):
  5347. */
  5348. }
  5349. /* "fontTools/qu2cu/qu2cu.py":250
  5350. * if q[-1] != p[0]:
  5351. * _raise_incompatible_point(p[0], q[-1])
  5352. * for i in range(len(p) - 2): # <<<<<<<<<<<<<<
  5353. * cost += 1
  5354. * costs.append(cost)
  5355. */
  5356. __pyx_t_9 = PyObject_Length(__pyx_v_p); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 250, __pyx_L1_error)
  5357. __pyx_t_16 = (__pyx_t_9 - 2);
  5358. __pyx_t_9 = __pyx_t_16;
  5359. for (__pyx_t_17 = 0; __pyx_t_17 < __pyx_t_9; __pyx_t_17+=1) {
  5360. __pyx_v_i = __pyx_t_17;
  5361. /* "fontTools/qu2cu/qu2cu.py":251
  5362. * _raise_incompatible_point(p[0], q[-1])
  5363. * for i in range(len(p) - 2):
  5364. * cost += 1 # <<<<<<<<<<<<<<
  5365. * costs.append(cost)
  5366. * costs.append(cost)
  5367. */
  5368. __pyx_v_cost = (__pyx_v_cost + 1);
  5369. /* "fontTools/qu2cu/qu2cu.py":252
  5370. * for i in range(len(p) - 2):
  5371. * cost += 1
  5372. * costs.append(cost) # <<<<<<<<<<<<<<
  5373. * costs.append(cost)
  5374. * qq = add_implicit_on_curves(p)[1:]
  5375. */
  5376. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_cost); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 252, __pyx_L1_error)
  5377. __Pyx_GOTREF(__pyx_t_6);
  5378. __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_costs, __pyx_t_6); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 252, __pyx_L1_error)
  5379. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5380. /* "fontTools/qu2cu/qu2cu.py":253
  5381. * cost += 1
  5382. * costs.append(cost)
  5383. * costs.append(cost) # <<<<<<<<<<<<<<
  5384. * qq = add_implicit_on_curves(p)[1:]
  5385. * costs.pop()
  5386. */
  5387. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_cost); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 253, __pyx_L1_error)
  5388. __Pyx_GOTREF(__pyx_t_6);
  5389. __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_costs, __pyx_t_6); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 253, __pyx_L1_error)
  5390. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5391. }
  5392. /* "fontTools/qu2cu/qu2cu.py":254
  5393. * costs.append(cost)
  5394. * costs.append(cost)
  5395. * qq = add_implicit_on_curves(p)[1:] # <<<<<<<<<<<<<<
  5396. * costs.pop()
  5397. * q.extend(qq)
  5398. */
  5399. __pyx_t_3 = NULL;
  5400. __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_add_implicit_on_curves); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 254, __pyx_L1_error)
  5401. __Pyx_GOTREF(__pyx_t_13);
  5402. __pyx_t_7 = 1;
  5403. #if CYTHON_UNPACK_METHODS
  5404. if (unlikely(PyMethod_Check(__pyx_t_13))) {
  5405. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_13);
  5406. assert(__pyx_t_3);
  5407. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
  5408. __Pyx_INCREF(__pyx_t_3);
  5409. __Pyx_INCREF(__pyx__function);
  5410. __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
  5411. __pyx_t_7 = 0;
  5412. }
  5413. #endif
  5414. {
  5415. PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_p};
  5416. __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5417. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  5418. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  5419. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 254, __pyx_L1_error)
  5420. __Pyx_GOTREF(__pyx_t_6);
  5421. }
  5422. __pyx_t_13 = __Pyx_PyObject_GetSlice(__pyx_t_6, 1, 0, NULL, NULL, &__pyx_mstate_global->__pyx_slice[0], 1, 0, 1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 254, __pyx_L1_error)
  5423. __Pyx_GOTREF(__pyx_t_13);
  5424. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5425. __Pyx_XDECREF_SET(__pyx_v_qq, __pyx_t_13);
  5426. __pyx_t_13 = 0;
  5427. /* "fontTools/qu2cu/qu2cu.py":255
  5428. * costs.append(cost)
  5429. * qq = add_implicit_on_curves(p)[1:]
  5430. * costs.pop() # <<<<<<<<<<<<<<
  5431. * q.extend(qq)
  5432. * cost += 1
  5433. */
  5434. __pyx_t_13 = __Pyx_PyList_Pop(__pyx_v_costs); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 255, __pyx_L1_error)
  5435. __Pyx_GOTREF(__pyx_t_13);
  5436. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  5437. /* "fontTools/qu2cu/qu2cu.py":256
  5438. * qq = add_implicit_on_curves(p)[1:]
  5439. * costs.pop()
  5440. * q.extend(qq) # <<<<<<<<<<<<<<
  5441. * cost += 1
  5442. * costs.append(cost)
  5443. */
  5444. __pyx_t_18 = __Pyx_PyList_Extend(__pyx_v_q, __pyx_v_qq); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 256, __pyx_L1_error)
  5445. /* "fontTools/qu2cu/qu2cu.py":257
  5446. * costs.pop()
  5447. * q.extend(qq)
  5448. * cost += 1 # <<<<<<<<<<<<<<
  5449. * costs.append(cost)
  5450. *
  5451. */
  5452. __pyx_v_cost = (__pyx_v_cost + 1);
  5453. /* "fontTools/qu2cu/qu2cu.py":258
  5454. * q.extend(qq)
  5455. * cost += 1
  5456. * costs.append(cost) # <<<<<<<<<<<<<<
  5457. *
  5458. * curves = spline_to_curves(q, costs, max_err, all_cubic)
  5459. */
  5460. __pyx_t_13 = __Pyx_PyLong_From_int(__pyx_v_cost); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 258, __pyx_L1_error)
  5461. __Pyx_GOTREF(__pyx_t_13);
  5462. __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_costs, __pyx_t_13); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 258, __pyx_L1_error)
  5463. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  5464. /* "fontTools/qu2cu/qu2cu.py":247
  5465. * costs = [1]
  5466. * cost = 1
  5467. * for p in quads: # <<<<<<<<<<<<<<
  5468. * if q[-1] != p[0]:
  5469. * _raise_incompatible_point(p[0], q[-1])
  5470. */
  5471. }
  5472. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5473. /* "fontTools/qu2cu/qu2cu.py":260
  5474. * costs.append(cost)
  5475. *
  5476. * curves = spline_to_curves(q, costs, max_err, all_cubic) # <<<<<<<<<<<<<<
  5477. *
  5478. * if not is_complex:
  5479. */
  5480. __pyx_t_13 = NULL;
  5481. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_spline_to_curves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 260, __pyx_L1_error)
  5482. __Pyx_GOTREF(__pyx_t_6);
  5483. __pyx_t_3 = PyFloat_FromDouble(__pyx_v_max_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error)
  5484. __Pyx_GOTREF(__pyx_t_3);
  5485. __pyx_t_11 = __Pyx_PyBool_FromLong(__pyx_v_all_cubic); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 260, __pyx_L1_error)
  5486. __Pyx_GOTREF(__pyx_t_11);
  5487. __pyx_t_7 = 1;
  5488. #if CYTHON_UNPACK_METHODS
  5489. if (unlikely(PyMethod_Check(__pyx_t_6))) {
  5490. __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6);
  5491. assert(__pyx_t_13);
  5492. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
  5493. __Pyx_INCREF(__pyx_t_13);
  5494. __Pyx_INCREF(__pyx__function);
  5495. __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
  5496. __pyx_t_7 = 0;
  5497. }
  5498. #endif
  5499. {
  5500. PyObject *__pyx_callargs[5] = {__pyx_t_13, __pyx_v_q, __pyx_v_costs, __pyx_t_3, __pyx_t_11};
  5501. __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5502. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  5503. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5504. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5505. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5506. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 260, __pyx_L1_error)
  5507. __Pyx_GOTREF(__pyx_t_5);
  5508. }
  5509. __pyx_v_curves = __pyx_t_5;
  5510. __pyx_t_5 = 0;
  5511. /* "fontTools/qu2cu/qu2cu.py":262
  5512. * curves = spline_to_curves(q, costs, max_err, all_cubic)
  5513. *
  5514. * if not is_complex: # <<<<<<<<<<<<<<
  5515. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves]
  5516. * return curves
  5517. */
  5518. __pyx_t_2 = (!(__pyx_v_is_complex != 0));
  5519. if (__pyx_t_2) {
  5520. /* "fontTools/qu2cu/qu2cu.py":263
  5521. *
  5522. * if not is_complex:
  5523. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves] # <<<<<<<<<<<<<<
  5524. * return curves
  5525. *
  5526. */
  5527. { /* enter inner scope */
  5528. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 263, __pyx_L33_error)
  5529. __Pyx_GOTREF(__pyx_t_5);
  5530. if (likely(PyList_CheckExact(__pyx_v_curves)) || PyTuple_CheckExact(__pyx_v_curves)) {
  5531. __pyx_t_6 = __pyx_v_curves; __Pyx_INCREF(__pyx_t_6);
  5532. __pyx_t_8 = 0;
  5533. __pyx_t_10 = NULL;
  5534. } else {
  5535. __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_curves); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 263, __pyx_L33_error)
  5536. __Pyx_GOTREF(__pyx_t_6);
  5537. __pyx_t_10 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 263, __pyx_L33_error)
  5538. }
  5539. for (;;) {
  5540. if (likely(!__pyx_t_10)) {
  5541. if (likely(PyList_CheckExact(__pyx_t_6))) {
  5542. {
  5543. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  5544. #if !CYTHON_ASSUME_SAFE_SIZE
  5545. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 263, __pyx_L33_error)
  5546. #endif
  5547. if (__pyx_t_8 >= __pyx_temp) break;
  5548. }
  5549. __pyx_t_11 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_8, __Pyx_ReferenceSharing_OwnStrongReference);
  5550. ++__pyx_t_8;
  5551. } else {
  5552. {
  5553. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  5554. #if !CYTHON_ASSUME_SAFE_SIZE
  5555. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 263, __pyx_L33_error)
  5556. #endif
  5557. if (__pyx_t_8 >= __pyx_temp) break;
  5558. }
  5559. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5560. __pyx_t_11 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8));
  5561. #else
  5562. __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_8);
  5563. #endif
  5564. ++__pyx_t_8;
  5565. }
  5566. if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 263, __pyx_L33_error)
  5567. } else {
  5568. __pyx_t_11 = __pyx_t_10(__pyx_t_6);
  5569. if (unlikely(!__pyx_t_11)) {
  5570. PyObject* exc_type = PyErr_Occurred();
  5571. if (exc_type) {
  5572. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 263, __pyx_L33_error)
  5573. PyErr_Clear();
  5574. }
  5575. break;
  5576. }
  5577. }
  5578. __Pyx_GOTREF(__pyx_t_11);
  5579. __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_curve, __pyx_t_11);
  5580. __pyx_t_11 = 0;
  5581. __pyx_t_11 = __pyx_pf_9fontTools_5qu2cu_5qu2cu_19quadratic_to_curves_8genexpr3_genexpr(NULL, __pyx_8genexpr3__pyx_v_curve); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 263, __pyx_L33_error)
  5582. __Pyx_GOTREF(__pyx_t_11);
  5583. __pyx_t_3 = __Pyx_PySequence_Tuple(__pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 263, __pyx_L33_error)
  5584. __Pyx_GOTREF(__pyx_t_3);
  5585. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  5586. if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 263, __pyx_L33_error)
  5587. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  5588. }
  5589. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5590. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_curve); __pyx_8genexpr3__pyx_v_curve = 0;
  5591. goto __pyx_L37_exit_scope;
  5592. __pyx_L33_error:;
  5593. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_curve); __pyx_8genexpr3__pyx_v_curve = 0;
  5594. goto __pyx_L1_error;
  5595. __pyx_L37_exit_scope:;
  5596. } /* exit inner scope */
  5597. __Pyx_DECREF_SET(__pyx_v_curves, __pyx_t_5);
  5598. __pyx_t_5 = 0;
  5599. /* "fontTools/qu2cu/qu2cu.py":262
  5600. * curves = spline_to_curves(q, costs, max_err, all_cubic)
  5601. *
  5602. * if not is_complex: # <<<<<<<<<<<<<<
  5603. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves]
  5604. * return curves
  5605. */
  5606. }
  5607. /* "fontTools/qu2cu/qu2cu.py":264
  5608. * if not is_complex:
  5609. * curves = [tuple((c.real, c.imag) for c in curve) for curve in curves]
  5610. * return curves # <<<<<<<<<<<<<<
  5611. *
  5612. *
  5613. */
  5614. __Pyx_XDECREF(__pyx_r);
  5615. __pyx_t_5 = __pyx_v_curves;
  5616. __Pyx_INCREF(__pyx_t_5);
  5617. if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None) || __Pyx_RaiseUnexpectedTypeError("list", __pyx_t_5))) __PYX_ERR(0, 264, __pyx_L1_error)
  5618. __pyx_r = ((PyObject*)__pyx_t_5);
  5619. __pyx_t_5 = 0;
  5620. goto __pyx_L0;
  5621. /* "fontTools/qu2cu/qu2cu.py":194
  5622. *
  5623. *
  5624. * @cython.locals( # <<<<<<<<<<<<<<
  5625. * cost=cython.int,
  5626. * is_complex=cython.int,
  5627. */
  5628. /* function exit code */
  5629. __pyx_L1_error:;
  5630. __Pyx_XDECREF(__pyx_t_3);
  5631. __Pyx_XDECREF(__pyx_t_4);
  5632. __Pyx_XDECREF(__pyx_t_5);
  5633. __Pyx_XDECREF(__pyx_t_6);
  5634. __Pyx_XDECREF(__pyx_t_11);
  5635. __Pyx_XDECREF(__pyx_t_12);
  5636. __Pyx_XDECREF(__pyx_t_13);
  5637. __Pyx_XDECREF(__pyx_t_14);
  5638. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.quadratic_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5639. __pyx_r = NULL;
  5640. __pyx_L0:;
  5641. __Pyx_XDECREF(__pyx_v_spline);
  5642. __Pyx_XDECREF(__pyx_v_q);
  5643. __Pyx_XDECREF(__pyx_v_costs);
  5644. __Pyx_XDECREF(__pyx_v_p);
  5645. __Pyx_XDECREF(__pyx_v_qq);
  5646. __Pyx_XDECREF(__pyx_v_curves);
  5647. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_p);
  5648. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_x);
  5649. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_y);
  5650. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_curve);
  5651. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_0);
  5652. __Pyx_XDECREF(__pyx_v_quads);
  5653. __Pyx_XGIVEREF(__pyx_r);
  5654. __Pyx_RefNannyFinishContext();
  5655. return __pyx_r;
  5656. }
  5657. /* "fontTools/qu2cu/qu2cu.py":270
  5658. *
  5659. *
  5660. * @cython.locals( # <<<<<<<<<<<<<<
  5661. * i=cython.int,
  5662. * j=cython.int,
  5663. */
  5664. /* Python wrapper */
  5665. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_13spline_to_curves(PyObject *__pyx_self,
  5666. #if CYTHON_METH_FASTCALL
  5667. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  5668. #else
  5669. PyObject *__pyx_args, PyObject *__pyx_kwds
  5670. #endif
  5671. ); /*proto*/
  5672. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_12spline_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).");
  5673. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_13spline_to_curves = {"spline_to_curves", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5qu2cu_5qu2cu_13spline_to_curves, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_12spline_to_curves};
  5674. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_13spline_to_curves(PyObject *__pyx_self,
  5675. #if CYTHON_METH_FASTCALL
  5676. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  5677. #else
  5678. PyObject *__pyx_args, PyObject *__pyx_kwds
  5679. #endif
  5680. ) {
  5681. PyObject *__pyx_v_q = 0;
  5682. PyObject *__pyx_v_costs = 0;
  5683. double __pyx_v_tolerance;
  5684. int __pyx_v_all_cubic;
  5685. #if !CYTHON_METH_FASTCALL
  5686. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  5687. #endif
  5688. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  5689. PyObject* values[4] = {0,0,0,0};
  5690. int __pyx_lineno = 0;
  5691. const char *__pyx_filename = NULL;
  5692. int __pyx_clineno = 0;
  5693. PyObject *__pyx_r = 0;
  5694. __Pyx_RefNannyDeclarations
  5695. __Pyx_RefNannySetupContext("spline_to_curves (wrapper)", 0);
  5696. #if !CYTHON_METH_FASTCALL
  5697. #if CYTHON_ASSUME_SAFE_SIZE
  5698. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  5699. #else
  5700. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  5701. #endif
  5702. #endif
  5703. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  5704. {
  5705. 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};
  5706. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  5707. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 270, __pyx_L3_error)
  5708. if (__pyx_kwds_len > 0) {
  5709. switch (__pyx_nargs) {
  5710. case 4:
  5711. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  5712. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 270, __pyx_L3_error)
  5713. CYTHON_FALLTHROUGH;
  5714. case 3:
  5715. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5716. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 270, __pyx_L3_error)
  5717. CYTHON_FALLTHROUGH;
  5718. case 2:
  5719. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5720. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 270, __pyx_L3_error)
  5721. CYTHON_FALLTHROUGH;
  5722. case 1:
  5723. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  5724. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 270, __pyx_L3_error)
  5725. CYTHON_FALLTHROUGH;
  5726. case 0: break;
  5727. default: goto __pyx_L5_argtuple_error;
  5728. }
  5729. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  5730. 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, 270, __pyx_L3_error)
  5731. for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
  5732. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("spline_to_curves", 0, 2, 4, i); __PYX_ERR(0, 270, __pyx_L3_error) }
  5733. }
  5734. } else {
  5735. switch (__pyx_nargs) {
  5736. case 4:
  5737. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  5738. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 270, __pyx_L3_error)
  5739. CYTHON_FALLTHROUGH;
  5740. case 3:
  5741. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5742. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 270, __pyx_L3_error)
  5743. CYTHON_FALLTHROUGH;
  5744. case 2:
  5745. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5746. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 270, __pyx_L3_error)
  5747. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  5748. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 270, __pyx_L3_error)
  5749. break;
  5750. default: goto __pyx_L5_argtuple_error;
  5751. }
  5752. }
  5753. __pyx_v_q = values[0];
  5754. __pyx_v_costs = values[1];
  5755. if (values[2]) {
  5756. __pyx_v_tolerance = __Pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_tolerance == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 293, __pyx_L3_error)
  5757. } else {
  5758. __pyx_v_tolerance = ((double)((double)0.5));
  5759. }
  5760. if (values[3]) {
  5761. __pyx_v_all_cubic = __Pyx_PyLong_As_int(values[3]); if (unlikely((__pyx_v_all_cubic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 293, __pyx_L3_error)
  5762. } else {
  5763. /* "fontTools/qu2cu/qu2cu.py":293
  5764. * u=cython.complex,
  5765. * )
  5766. * def spline_to_curves(q, costs, tolerance=0.5, all_cubic=False): # <<<<<<<<<<<<<<
  5767. * """
  5768. * q: quadratic spline with alternating on-curve / off-curve points.
  5769. */
  5770. __pyx_v_all_cubic = ((int)((int)0));
  5771. }
  5772. }
  5773. goto __pyx_L6_skip;
  5774. __pyx_L5_argtuple_error:;
  5775. __Pyx_RaiseArgtupleInvalid("spline_to_curves", 0, 2, 4, __pyx_nargs); __PYX_ERR(0, 270, __pyx_L3_error)
  5776. __pyx_L6_skip:;
  5777. goto __pyx_L4_argument_unpacking_done;
  5778. __pyx_L3_error:;
  5779. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5780. Py_XDECREF(values[__pyx_temp]);
  5781. }
  5782. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5783. __Pyx_RefNannyFinishContext();
  5784. return NULL;
  5785. __pyx_L4_argument_unpacking_done:;
  5786. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_12spline_to_curves(__pyx_self, __pyx_v_q, __pyx_v_costs, __pyx_v_tolerance, __pyx_v_all_cubic);
  5787. /* "fontTools/qu2cu/qu2cu.py":270
  5788. *
  5789. *
  5790. * @cython.locals( # <<<<<<<<<<<<<<
  5791. * i=cython.int,
  5792. * j=cython.int,
  5793. */
  5794. /* function exit code */
  5795. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5796. Py_XDECREF(values[__pyx_temp]);
  5797. }
  5798. __Pyx_RefNannyFinishContext();
  5799. return __pyx_r;
  5800. }
  5801. 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 */
  5802. /* "fontTools/qu2cu/qu2cu.py":368
  5803. * for k, reconst in enumerate(reconstructed):
  5804. * orig = elevated_quadratics[j + k]
  5805. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig)) # <<<<<<<<<<<<<<
  5806. *
  5807. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  5808. */
  5809. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  5810. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *__pyx_cur_scope;
  5811. PyObject *__pyx_r = NULL;
  5812. __Pyx_RefNannyDeclarations
  5813. int __pyx_lineno = 0;
  5814. const char *__pyx_filename = NULL;
  5815. int __pyx_clineno = 0;
  5816. __Pyx_RefNannySetupContext("genexpr", 0);
  5817. __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);
  5818. if (unlikely(!__pyx_cur_scope)) {
  5819. __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)Py_None);
  5820. __Pyx_INCREF(Py_None);
  5821. __PYX_ERR(0, 368, __pyx_L1_error)
  5822. } else {
  5823. __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  5824. }
  5825. __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  5826. __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  5827. __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  5828. {
  5829. __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, 368, __pyx_L1_error)
  5830. __Pyx_DECREF(__pyx_cur_scope);
  5831. __Pyx_RefNannyFinishContext();
  5832. return (PyObject *) gen;
  5833. }
  5834. /* function exit code */
  5835. __pyx_L1_error:;
  5836. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5837. __pyx_r = NULL;
  5838. __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  5839. __Pyx_XGIVEREF(__pyx_r);
  5840. __Pyx_RefNannyFinishContext();
  5841. return __pyx_r;
  5842. }
  5843. 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 */
  5844. {
  5845. 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);
  5846. PyObject *__pyx_r = NULL;
  5847. PyObject *__pyx_t_1 = NULL;
  5848. Py_ssize_t __pyx_t_2;
  5849. PyObject *(*__pyx_t_3)(PyObject *);
  5850. PyObject *__pyx_t_4 = NULL;
  5851. PyObject *__pyx_t_5 = NULL;
  5852. PyObject *__pyx_t_6 = NULL;
  5853. PyObject *__pyx_t_7 = NULL;
  5854. PyObject *(*__pyx_t_8)(PyObject *);
  5855. __pyx_t_double_complex __pyx_t_9;
  5856. __pyx_t_double_complex __pyx_t_10;
  5857. int __pyx_lineno = 0;
  5858. const char *__pyx_filename = NULL;
  5859. int __pyx_clineno = 0;
  5860. __Pyx_RefNannyDeclarations
  5861. __Pyx_RefNannySetupContext("genexpr", 0);
  5862. switch (__pyx_generator->resume_label) {
  5863. case 0: goto __pyx_L3_first_run;
  5864. case 1: goto __pyx_L8_resume_from_yield;
  5865. default: /* CPython raises the right error here */
  5866. __Pyx_RefNannyFinishContext();
  5867. return NULL;
  5868. }
  5869. __pyx_L3_first_run:;
  5870. if (unlikely(__pyx_sent_value != Py_None)) {
  5871. if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started generator");
  5872. __PYX_ERR(0, 368, __pyx_L1_error)
  5873. }
  5874. if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 368, __pyx_L1_error) }
  5875. if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
  5876. __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
  5877. __pyx_t_2 = 0;
  5878. __pyx_t_3 = NULL;
  5879. } else {
  5880. __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 368, __pyx_L1_error)
  5881. __Pyx_GOTREF(__pyx_t_1);
  5882. __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 368, __pyx_L1_error)
  5883. }
  5884. for (;;) {
  5885. if (likely(!__pyx_t_3)) {
  5886. if (likely(PyList_CheckExact(__pyx_t_1))) {
  5887. {
  5888. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
  5889. #if !CYTHON_ASSUME_SAFE_SIZE
  5890. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 368, __pyx_L1_error)
  5891. #endif
  5892. if (__pyx_t_2 >= __pyx_temp) break;
  5893. }
  5894. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
  5895. ++__pyx_t_2;
  5896. } else {
  5897. {
  5898. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
  5899. #if !CYTHON_ASSUME_SAFE_SIZE
  5900. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 368, __pyx_L1_error)
  5901. #endif
  5902. if (__pyx_t_2 >= __pyx_temp) break;
  5903. }
  5904. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5905. __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
  5906. #else
  5907. __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
  5908. #endif
  5909. ++__pyx_t_2;
  5910. }
  5911. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 368, __pyx_L1_error)
  5912. } else {
  5913. __pyx_t_4 = __pyx_t_3(__pyx_t_1);
  5914. if (unlikely(!__pyx_t_4)) {
  5915. PyObject* exc_type = PyErr_Occurred();
  5916. if (exc_type) {
  5917. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 368, __pyx_L1_error)
  5918. PyErr_Clear();
  5919. }
  5920. break;
  5921. }
  5922. }
  5923. __Pyx_GOTREF(__pyx_t_4);
  5924. if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
  5925. PyObject* sequence = __pyx_t_4;
  5926. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  5927. if (unlikely(size != 2)) {
  5928. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  5929. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  5930. __PYX_ERR(0, 368, __pyx_L1_error)
  5931. }
  5932. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5933. if (likely(PyTuple_CheckExact(sequence))) {
  5934. __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
  5935. __Pyx_INCREF(__pyx_t_5);
  5936. __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
  5937. __Pyx_INCREF(__pyx_t_6);
  5938. } else {
  5939. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  5940. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 368, __pyx_L1_error)
  5941. __Pyx_XGOTREF(__pyx_t_5);
  5942. __pyx_t_6 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  5943. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
  5944. __Pyx_XGOTREF(__pyx_t_6);
  5945. }
  5946. #else
  5947. __pyx_t_5 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 368, __pyx_L1_error)
  5948. __Pyx_GOTREF(__pyx_t_5);
  5949. __pyx_t_6 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 368, __pyx_L1_error)
  5950. __Pyx_GOTREF(__pyx_t_6);
  5951. #endif
  5952. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5953. } else {
  5954. Py_ssize_t index = -1;
  5955. __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 368, __pyx_L1_error)
  5956. __Pyx_GOTREF(__pyx_t_7);
  5957. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  5958. __pyx_t_8 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7);
  5959. index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
  5960. __Pyx_GOTREF(__pyx_t_5);
  5961. index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
  5962. __Pyx_GOTREF(__pyx_t_6);
  5963. if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < (0)) __PYX_ERR(0, 368, __pyx_L1_error)
  5964. __pyx_t_8 = NULL;
  5965. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5966. goto __pyx_L7_unpacking_done;
  5967. __pyx_L6_unpacking_failed:;
  5968. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  5969. __pyx_t_8 = NULL;
  5970. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  5971. __PYX_ERR(0, 368, __pyx_L1_error)
  5972. __pyx_L7_unpacking_done:;
  5973. }
  5974. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
  5975. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  5976. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_6); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
  5977. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  5978. __pyx_cur_scope->__pyx_v_v = __pyx_t_9;
  5979. __pyx_cur_scope->__pyx_v_u = __pyx_t_10;
  5980. __pyx_t_10 = __Pyx_c_diff_double(__pyx_cur_scope->__pyx_v_v, __pyx_cur_scope->__pyx_v_u);
  5981. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 368, __pyx_L1_error)
  5982. __Pyx_GOTREF(__pyx_t_4);
  5983. __pyx_r = __pyx_t_4;
  5984. __pyx_t_4 = 0;
  5985. __Pyx_XGIVEREF(__pyx_t_1);
  5986. __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
  5987. __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
  5988. __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
  5989. __Pyx_XGIVEREF(__pyx_r);
  5990. __Pyx_RefNannyFinishContext();
  5991. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  5992. /* return from generator, yielding value */
  5993. __pyx_generator->resume_label = 1;
  5994. return __pyx_r;
  5995. __pyx_L8_resume_from_yield:;
  5996. __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
  5997. __pyx_cur_scope->__pyx_t_0 = 0;
  5998. __Pyx_XGOTREF(__pyx_t_1);
  5999. __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
  6000. __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
  6001. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 368, __pyx_L1_error)
  6002. }
  6003. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6004. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  6005. /* function exit code */
  6006. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  6007. goto __pyx_L0;
  6008. __pyx_L1_error:;
  6009. __Pyx_XDECREF(__pyx_t_1);
  6010. __Pyx_XDECREF(__pyx_t_4);
  6011. __Pyx_XDECREF(__pyx_t_5);
  6012. __Pyx_XDECREF(__pyx_t_6);
  6013. __Pyx_XDECREF(__pyx_t_7);
  6014. if (__Pyx_PyErr_Occurred()) {
  6015. __Pyx_Generator_Replace_StopIteration(0);
  6016. __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6017. }
  6018. __pyx_L0:;
  6019. __Pyx_XGIVEREF(__pyx_r);
  6020. #if !CYTHON_USE_EXC_INFO_STACK
  6021. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  6022. #endif
  6023. __pyx_generator->resume_label = -1;
  6024. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  6025. __Pyx_RefNannyFinishContext();
  6026. return __pyx_r;
  6027. }
  6028. /* "fontTools/qu2cu/qu2cu.py":270
  6029. *
  6030. *
  6031. * @cython.locals( # <<<<<<<<<<<<<<
  6032. * i=cython.int,
  6033. * j=cython.int,
  6034. */
  6035. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_12spline_to_curves(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_q, PyObject *__pyx_v_costs, double __pyx_v_tolerance, int __pyx_v_all_cubic) {
  6036. int __pyx_v_i;
  6037. int __pyx_v_j;
  6038. int __pyx_v_k;
  6039. int __pyx_v_start;
  6040. int __pyx_v_i_sol_count;
  6041. int __pyx_v_j_sol_count;
  6042. double __pyx_v_err;
  6043. double __pyx_v_error;
  6044. double __pyx_v_i_sol_error;
  6045. double __pyx_v_j_sol_error;
  6046. int __pyx_v_is_cubic;
  6047. int __pyx_v_count;
  6048. __pyx_t_double_complex __pyx_v_p0;
  6049. __pyx_t_double_complex __pyx_v_p1;
  6050. __pyx_t_double_complex __pyx_v_p2;
  6051. __pyx_t_double_complex __pyx_v_p3;
  6052. PyObject *__pyx_v_elevated_quadratics = NULL;
  6053. PyObject *__pyx_v_forced = NULL;
  6054. PyObject *__pyx_v_sols = NULL;
  6055. PyObject *__pyx_v_impossible = NULL;
  6056. PyObject *__pyx_v_best_sol = NULL;
  6057. PyObject *__pyx_v_this_count = NULL;
  6058. PyObject *__pyx_v_i_sol = NULL;
  6059. PyObject *__pyx_v_curve = NULL;
  6060. PyObject *__pyx_v_ts = NULL;
  6061. PyObject *__pyx_v_reconstructed_iter = NULL;
  6062. PyObject *__pyx_v_reconstructed = NULL;
  6063. PyObject *__pyx_v_reconst = NULL;
  6064. PyObject *__pyx_v_orig = NULL;
  6065. PyObject *__pyx_v_splits = NULL;
  6066. PyObject *__pyx_v_cubic = NULL;
  6067. PyObject *__pyx_v_curves = NULL;
  6068. int __pyx_8genexpr5__pyx_v_i;
  6069. PyObject *__pyx_gb_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_2generator1 = 0;
  6070. PyObject *__pyx_r = NULL;
  6071. __Pyx_RefNannyDeclarations
  6072. Py_ssize_t __pyx_t_1;
  6073. int __pyx_t_2;
  6074. PyObject *__pyx_t_3 = NULL;
  6075. Py_ssize_t __pyx_t_4;
  6076. int __pyx_t_5;
  6077. PyObject *__pyx_t_6 = NULL;
  6078. PyObject *__pyx_t_7 = NULL;
  6079. PyObject *__pyx_t_8 = NULL;
  6080. long __pyx_t_9;
  6081. __pyx_t_double_complex __pyx_t_10;
  6082. int __pyx_t_11;
  6083. size_t __pyx_t_12;
  6084. int __pyx_t_13;
  6085. int __pyx_t_14;
  6086. int __pyx_t_15;
  6087. int __pyx_t_16;
  6088. double __pyx_t_17;
  6089. PyObject *__pyx_t_18 = NULL;
  6090. PyObject *__pyx_t_19 = NULL;
  6091. PyObject *__pyx_t_20 = NULL;
  6092. PyObject *__pyx_t_21 = NULL;
  6093. PyObject *__pyx_t_22 = NULL;
  6094. PyObject *(*__pyx_t_23)(PyObject *);
  6095. Py_ssize_t __pyx_t_24;
  6096. PyObject *(*__pyx_t_25)(PyObject *);
  6097. int __pyx_t_26;
  6098. double __pyx_t_27;
  6099. double __pyx_t_28;
  6100. __pyx_t_double_complex __pyx_t_29;
  6101. __pyx_t_double_complex __pyx_t_30;
  6102. __pyx_t_double_complex __pyx_t_31;
  6103. int __pyx_lineno = 0;
  6104. const char *__pyx_filename = NULL;
  6105. int __pyx_clineno = 0;
  6106. __Pyx_RefNannySetupContext("spline_to_curves", 0);
  6107. /* "fontTools/qu2cu/qu2cu.py":303
  6108. * """
  6109. *
  6110. * assert len(q) >= 3, "quadratic spline requires at least 3 points" # <<<<<<<<<<<<<<
  6111. *
  6112. * # Elevate quadratic segments to cubic
  6113. */
  6114. #ifndef CYTHON_WITHOUT_ASSERTIONS
  6115. if (unlikely(__pyx_assertions_enabled())) {
  6116. __pyx_t_1 = PyObject_Length(__pyx_v_q); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 303, __pyx_L1_error)
  6117. __pyx_t_2 = (__pyx_t_1 >= 3);
  6118. if (unlikely(!__pyx_t_2)) {
  6119. __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_AssertionError))), __pyx_mstate_global->__pyx_kp_u_quadratic_spline_requires_at_lea, 0, 0);
  6120. __PYX_ERR(0, 303, __pyx_L1_error)
  6121. }
  6122. }
  6123. #else
  6124. if ((1)); else __PYX_ERR(0, 303, __pyx_L1_error)
  6125. #endif
  6126. /* "fontTools/qu2cu/qu2cu.py":306
  6127. *
  6128. * # Elevate quadratic segments to cubic
  6129. * elevated_quadratics = [ # <<<<<<<<<<<<<<
  6130. * elevate_quadratic(*q[i : i + 3]) for i in range(0, len(q) - 2, 2)
  6131. * ]
  6132. */
  6133. { /* enter inner scope */
  6134. __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 306, __pyx_L1_error)
  6135. __Pyx_GOTREF(__pyx_t_3);
  6136. /* "fontTools/qu2cu/qu2cu.py":307
  6137. * # Elevate quadratic segments to cubic
  6138. * elevated_quadratics = [
  6139. * elevate_quadratic(*q[i : i + 3]) for i in range(0, len(q) - 2, 2) # <<<<<<<<<<<<<<
  6140. * ]
  6141. *
  6142. */
  6143. __pyx_t_1 = PyObject_Length(__pyx_v_q); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 307, __pyx_L1_error)
  6144. __pyx_t_4 = (__pyx_t_1 - 2);
  6145. __pyx_t_1 = __pyx_t_4;
  6146. for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=2) {
  6147. __pyx_8genexpr5__pyx_v_i = __pyx_t_5;
  6148. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_elevate_quadratic); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 307, __pyx_L1_error)
  6149. __Pyx_GOTREF(__pyx_t_6);
  6150. __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, 307, __pyx_L1_error)
  6151. __Pyx_GOTREF(__pyx_t_7);
  6152. __pyx_t_8 = __Pyx_PySequence_Tuple(__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 307, __pyx_L1_error)
  6153. __Pyx_GOTREF(__pyx_t_8);
  6154. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6155. __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 307, __pyx_L1_error)
  6156. __Pyx_GOTREF(__pyx_t_7);
  6157. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6158. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6159. if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 306, __pyx_L1_error)
  6160. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6161. }
  6162. } /* exit inner scope */
  6163. __pyx_v_elevated_quadratics = ((PyObject*)__pyx_t_3);
  6164. __pyx_t_3 = 0;
  6165. /* "fontTools/qu2cu/qu2cu.py":311
  6166. *
  6167. * # Find sharp corners; they have to be oncurves for sure.
  6168. * forced = set() # <<<<<<<<<<<<<<
  6169. * for i in range(1, len(elevated_quadratics)):
  6170. * p0 = elevated_quadratics[i - 1][2]
  6171. */
  6172. __pyx_t_3 = PySet_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 311, __pyx_L1_error)
  6173. __Pyx_GOTREF(__pyx_t_3);
  6174. __pyx_v_forced = ((PyObject*)__pyx_t_3);
  6175. __pyx_t_3 = 0;
  6176. /* "fontTools/qu2cu/qu2cu.py":312
  6177. * # Find sharp corners; they have to be oncurves for sure.
  6178. * forced = set()
  6179. * for i in range(1, len(elevated_quadratics)): # <<<<<<<<<<<<<<
  6180. * p0 = elevated_quadratics[i - 1][2]
  6181. * p1 = elevated_quadratics[i][0]
  6182. */
  6183. __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_elevated_quadratics); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 312, __pyx_L1_error)
  6184. __pyx_t_1 = __pyx_t_4;
  6185. for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_1; __pyx_t_5+=1) {
  6186. __pyx_v_i = __pyx_t_5;
  6187. /* "fontTools/qu2cu/qu2cu.py":313
  6188. * forced = set()
  6189. * for i in range(1, len(elevated_quadratics)):
  6190. * p0 = elevated_quadratics[i - 1][2] # <<<<<<<<<<<<<<
  6191. * p1 = elevated_quadratics[i][0]
  6192. * p2 = elevated_quadratics[i][1]
  6193. */
  6194. __pyx_t_9 = (__pyx_v_i - 1);
  6195. __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, 313, __pyx_L1_error)
  6196. __Pyx_GOTREF(__pyx_t_3);
  6197. __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, 313, __pyx_L1_error)
  6198. __Pyx_GOTREF(__pyx_t_7);
  6199. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6200. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 313, __pyx_L1_error)
  6201. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6202. __pyx_v_p0 = __pyx_t_10;
  6203. /* "fontTools/qu2cu/qu2cu.py":314
  6204. * for i in range(1, len(elevated_quadratics)):
  6205. * p0 = elevated_quadratics[i - 1][2]
  6206. * p1 = elevated_quadratics[i][0] # <<<<<<<<<<<<<<
  6207. * p2 = elevated_quadratics[i][1]
  6208. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0):
  6209. */
  6210. __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, 314, __pyx_L1_error)
  6211. __Pyx_GOTREF(__pyx_t_7);
  6212. __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, 314, __pyx_L1_error)
  6213. __Pyx_GOTREF(__pyx_t_3);
  6214. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6215. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 314, __pyx_L1_error)
  6216. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6217. __pyx_v_p1 = __pyx_t_10;
  6218. /* "fontTools/qu2cu/qu2cu.py":315
  6219. * p0 = elevated_quadratics[i - 1][2]
  6220. * p1 = elevated_quadratics[i][0]
  6221. * p2 = elevated_quadratics[i][1] # <<<<<<<<<<<<<<
  6222. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0):
  6223. * forced.add(i)
  6224. */
  6225. __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, 315, __pyx_L1_error)
  6226. __Pyx_GOTREF(__pyx_t_3);
  6227. __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, 315, __pyx_L1_error)
  6228. __Pyx_GOTREF(__pyx_t_7);
  6229. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6230. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_7); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 315, __pyx_L1_error)
  6231. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6232. __pyx_v_p2 = __pyx_t_10;
  6233. /* "fontTools/qu2cu/qu2cu.py":316
  6234. * p1 = elevated_quadratics[i][0]
  6235. * p2 = elevated_quadratics[i][1]
  6236. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0): # <<<<<<<<<<<<<<
  6237. * forced.add(i)
  6238. *
  6239. */
  6240. __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))));
  6241. if (__pyx_t_2) {
  6242. /* "fontTools/qu2cu/qu2cu.py":317
  6243. * p2 = elevated_quadratics[i][1]
  6244. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0):
  6245. * forced.add(i) # <<<<<<<<<<<<<<
  6246. *
  6247. * # Dynamic-Programming to find the solution with fewest number of
  6248. */
  6249. __pyx_t_7 = __Pyx_PyLong_From_int(__pyx_v_i); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 317, __pyx_L1_error)
  6250. __Pyx_GOTREF(__pyx_t_7);
  6251. __pyx_t_11 = PySet_Add(__pyx_v_forced, __pyx_t_7); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 317, __pyx_L1_error)
  6252. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6253. /* "fontTools/qu2cu/qu2cu.py":316
  6254. * p1 = elevated_quadratics[i][0]
  6255. * p2 = elevated_quadratics[i][1]
  6256. * if abs(p1 - p0) + abs(p2 - p1) > tolerance + abs(p2 - p0): # <<<<<<<<<<<<<<
  6257. * forced.add(i)
  6258. *
  6259. */
  6260. }
  6261. }
  6262. /* "fontTools/qu2cu/qu2cu.py":321
  6263. * # Dynamic-Programming to find the solution with fewest number of
  6264. * # cubic curves, and within those the one with smallest error.
  6265. * sols = [Solution(0, 0, 0, False)] # <<<<<<<<<<<<<<
  6266. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  6267. * start = 0
  6268. */
  6269. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 321, __pyx_L1_error)
  6270. __Pyx_GOTREF(__pyx_t_7);
  6271. __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[0], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 321, __pyx_L1_error)
  6272. __Pyx_GOTREF(__pyx_t_3);
  6273. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6274. __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 321, __pyx_L1_error)
  6275. __Pyx_GOTREF(__pyx_t_7);
  6276. __Pyx_GIVEREF(__pyx_t_3);
  6277. if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_3) != (0)) __PYX_ERR(0, 321, __pyx_L1_error);
  6278. __pyx_t_3 = 0;
  6279. __pyx_v_sols = ((PyObject*)__pyx_t_7);
  6280. __pyx_t_7 = 0;
  6281. /* "fontTools/qu2cu/qu2cu.py":322
  6282. * # cubic curves, and within those the one with smallest error.
  6283. * sols = [Solution(0, 0, 0, False)]
  6284. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False) # <<<<<<<<<<<<<<
  6285. * start = 0
  6286. * for i in range(1, len(elevated_quadratics) + 1):
  6287. */
  6288. __pyx_t_3 = NULL;
  6289. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 322, __pyx_L1_error)
  6290. __Pyx_GOTREF(__pyx_t_8);
  6291. __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_elevated_quadratics); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 322, __pyx_L1_error)
  6292. __pyx_t_6 = PyLong_FromSsize_t(((__pyx_t_4 * 3) + 1)); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 322, __pyx_L1_error)
  6293. __Pyx_GOTREF(__pyx_t_6);
  6294. __pyx_t_12 = 1;
  6295. #if CYTHON_UNPACK_METHODS
  6296. if (unlikely(PyMethod_Check(__pyx_t_8))) {
  6297. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
  6298. assert(__pyx_t_3);
  6299. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
  6300. __Pyx_INCREF(__pyx_t_3);
  6301. __Pyx_INCREF(__pyx__function);
  6302. __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
  6303. __pyx_t_12 = 0;
  6304. }
  6305. #endif
  6306. {
  6307. PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_t_6, __pyx_mstate_global->__pyx_int_0, __pyx_mstate_global->__pyx_int_1, Py_False};
  6308. __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));
  6309. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6310. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6311. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6312. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 322, __pyx_L1_error)
  6313. __Pyx_GOTREF(__pyx_t_7);
  6314. }
  6315. __pyx_v_impossible = __pyx_t_7;
  6316. __pyx_t_7 = 0;
  6317. /* "fontTools/qu2cu/qu2cu.py":323
  6318. * sols = [Solution(0, 0, 0, False)]
  6319. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  6320. * start = 0 # <<<<<<<<<<<<<<
  6321. * for i in range(1, len(elevated_quadratics) + 1):
  6322. * best_sol = impossible
  6323. */
  6324. __pyx_v_start = 0;
  6325. /* "fontTools/qu2cu/qu2cu.py":324
  6326. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  6327. * start = 0
  6328. * for i in range(1, len(elevated_quadratics) + 1): # <<<<<<<<<<<<<<
  6329. * best_sol = impossible
  6330. * for j in range(start, i):
  6331. */
  6332. __pyx_t_4 = __Pyx_PyList_GET_SIZE(__pyx_v_elevated_quadratics); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 324, __pyx_L1_error)
  6333. __pyx_t_1 = (__pyx_t_4 + 1);
  6334. __pyx_t_4 = __pyx_t_1;
  6335. for (__pyx_t_5 = 1; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
  6336. __pyx_v_i = __pyx_t_5;
  6337. /* "fontTools/qu2cu/qu2cu.py":325
  6338. * start = 0
  6339. * for i in range(1, len(elevated_quadratics) + 1):
  6340. * best_sol = impossible # <<<<<<<<<<<<<<
  6341. * for j in range(start, i):
  6342. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  6343. */
  6344. __Pyx_INCREF(__pyx_v_impossible);
  6345. __Pyx_XDECREF_SET(__pyx_v_best_sol, __pyx_v_impossible);
  6346. /* "fontTools/qu2cu/qu2cu.py":326
  6347. * for i in range(1, len(elevated_quadratics) + 1):
  6348. * best_sol = impossible
  6349. * for j in range(start, i): # <<<<<<<<<<<<<<
  6350. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  6351. *
  6352. */
  6353. __pyx_t_13 = __pyx_v_i;
  6354. __pyx_t_14 = __pyx_t_13;
  6355. for (__pyx_t_15 = __pyx_v_start; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
  6356. __pyx_v_j = __pyx_t_15;
  6357. /* "fontTools/qu2cu/qu2cu.py":327
  6358. * best_sol = impossible
  6359. * for j in range(start, i):
  6360. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error # <<<<<<<<<<<<<<
  6361. *
  6362. * if not all_cubic:
  6363. */
  6364. __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, 327, __pyx_L1_error)
  6365. __Pyx_GOTREF(__pyx_t_7);
  6366. __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, 327, __pyx_L1_error)
  6367. __Pyx_GOTREF(__pyx_t_8);
  6368. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6369. __pyx_t_16 = __Pyx_PyLong_As_int(__pyx_t_8); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 327, __pyx_L1_error)
  6370. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6371. __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, 327, __pyx_L1_error)
  6372. __Pyx_GOTREF(__pyx_t_8);
  6373. __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 327, __pyx_L1_error)
  6374. __Pyx_GOTREF(__pyx_t_7);
  6375. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6376. __pyx_t_17 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_17 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 327, __pyx_L1_error)
  6377. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6378. __pyx_v_j_sol_count = __pyx_t_16;
  6379. __pyx_v_j_sol_error = __pyx_t_17;
  6380. /* "fontTools/qu2cu/qu2cu.py":329
  6381. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  6382. *
  6383. * if not all_cubic: # <<<<<<<<<<<<<<
  6384. * # Solution with quadratics between j:i
  6385. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  6386. */
  6387. __pyx_t_2 = (!(__pyx_v_all_cubic != 0));
  6388. if (__pyx_t_2) {
  6389. /* "fontTools/qu2cu/qu2cu.py":331
  6390. * if not all_cubic:
  6391. * # Solution with quadratics between j:i
  6392. * this_count = costs[2 * i - 1] - costs[2 * j] + 1 # <<<<<<<<<<<<<<
  6393. * i_sol_count = j_sol_count + this_count
  6394. * i_sol_error = j_sol_error
  6395. */
  6396. __pyx_t_9 = ((2 * __pyx_v_i) - 1);
  6397. __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, 331, __pyx_L1_error)
  6398. __Pyx_GOTREF(__pyx_t_7);
  6399. __pyx_t_9 = (2 * __pyx_v_j);
  6400. __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, 331, __pyx_L1_error)
  6401. __Pyx_GOTREF(__pyx_t_8);
  6402. __pyx_t_6 = PyNumber_Subtract(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 331, __pyx_L1_error)
  6403. __Pyx_GOTREF(__pyx_t_6);
  6404. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6405. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6406. __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, 331, __pyx_L1_error)
  6407. __Pyx_GOTREF(__pyx_t_8);
  6408. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6409. __Pyx_XDECREF_SET(__pyx_v_this_count, __pyx_t_8);
  6410. __pyx_t_8 = 0;
  6411. /* "fontTools/qu2cu/qu2cu.py":332
  6412. * # Solution with quadratics between j:i
  6413. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  6414. * i_sol_count = j_sol_count + this_count # <<<<<<<<<<<<<<
  6415. * i_sol_error = j_sol_error
  6416. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  6417. */
  6418. __pyx_t_8 = __Pyx_PyLong_From_int(__pyx_v_j_sol_count); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 332, __pyx_L1_error)
  6419. __Pyx_GOTREF(__pyx_t_8);
  6420. __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_v_this_count); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 332, __pyx_L1_error)
  6421. __Pyx_GOTREF(__pyx_t_6);
  6422. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  6423. __pyx_t_16 = __Pyx_PyLong_As_int(__pyx_t_6); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 332, __pyx_L1_error)
  6424. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6425. __pyx_v_i_sol_count = __pyx_t_16;
  6426. /* "fontTools/qu2cu/qu2cu.py":333
  6427. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  6428. * i_sol_count = j_sol_count + this_count
  6429. * i_sol_error = j_sol_error # <<<<<<<<<<<<<<
  6430. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  6431. * if i_sol < best_sol:
  6432. */
  6433. __pyx_v_i_sol_error = __pyx_v_j_sol_error;
  6434. /* "fontTools/qu2cu/qu2cu.py":334
  6435. * i_sol_count = j_sol_count + this_count
  6436. * i_sol_error = j_sol_error
  6437. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False) # <<<<<<<<<<<<<<
  6438. * if i_sol < best_sol:
  6439. * best_sol = i_sol
  6440. */
  6441. __pyx_t_8 = NULL;
  6442. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 334, __pyx_L1_error)
  6443. __Pyx_GOTREF(__pyx_t_7);
  6444. __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_i_sol_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 334, __pyx_L1_error)
  6445. __Pyx_GOTREF(__pyx_t_3);
  6446. __pyx_t_18 = PyFloat_FromDouble(__pyx_v_i_sol_error); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 334, __pyx_L1_error)
  6447. __Pyx_GOTREF(__pyx_t_18);
  6448. __pyx_t_19 = __Pyx_PyLong_From_int((__pyx_v_i - __pyx_v_j)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 334, __pyx_L1_error)
  6449. __Pyx_GOTREF(__pyx_t_19);
  6450. __pyx_t_12 = 1;
  6451. #if CYTHON_UNPACK_METHODS
  6452. if (unlikely(PyMethod_Check(__pyx_t_7))) {
  6453. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
  6454. assert(__pyx_t_8);
  6455. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
  6456. __Pyx_INCREF(__pyx_t_8);
  6457. __Pyx_INCREF(__pyx__function);
  6458. __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
  6459. __pyx_t_12 = 0;
  6460. }
  6461. #endif
  6462. {
  6463. PyObject *__pyx_callargs[5] = {__pyx_t_8, __pyx_t_3, __pyx_t_18, __pyx_t_19, Py_False};
  6464. __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));
  6465. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  6466. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  6467. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6468. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6469. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6470. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 334, __pyx_L1_error)
  6471. __Pyx_GOTREF(__pyx_t_6);
  6472. }
  6473. __Pyx_XDECREF_SET(__pyx_v_i_sol, __pyx_t_6);
  6474. __pyx_t_6 = 0;
  6475. /* "fontTools/qu2cu/qu2cu.py":335
  6476. * i_sol_error = j_sol_error
  6477. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  6478. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  6479. * best_sol = i_sol
  6480. *
  6481. */
  6482. __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, 335, __pyx_L1_error)
  6483. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 335, __pyx_L1_error)
  6484. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6485. if (__pyx_t_2) {
  6486. /* "fontTools/qu2cu/qu2cu.py":336
  6487. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  6488. * if i_sol < best_sol:
  6489. * best_sol = i_sol # <<<<<<<<<<<<<<
  6490. *
  6491. * if this_count <= 3:
  6492. */
  6493. __Pyx_INCREF(__pyx_v_i_sol);
  6494. __Pyx_DECREF_SET(__pyx_v_best_sol, __pyx_v_i_sol);
  6495. /* "fontTools/qu2cu/qu2cu.py":335
  6496. * i_sol_error = j_sol_error
  6497. * i_sol = Solution(i_sol_count, i_sol_error, i - j, False)
  6498. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  6499. * best_sol = i_sol
  6500. *
  6501. */
  6502. }
  6503. /* "fontTools/qu2cu/qu2cu.py":338
  6504. * best_sol = i_sol
  6505. *
  6506. * if this_count <= 3: # <<<<<<<<<<<<<<
  6507. * # Can't get any better than this in the path below
  6508. * continue
  6509. */
  6510. __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, 338, __pyx_L1_error)
  6511. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 338, __pyx_L1_error)
  6512. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6513. if (__pyx_t_2) {
  6514. /* "fontTools/qu2cu/qu2cu.py":340
  6515. * if this_count <= 3:
  6516. * # Can't get any better than this in the path below
  6517. * continue # <<<<<<<<<<<<<<
  6518. *
  6519. * # Fit elevated_quadratics[j:i] into one cubic
  6520. */
  6521. goto __pyx_L10_continue;
  6522. /* "fontTools/qu2cu/qu2cu.py":338
  6523. * best_sol = i_sol
  6524. *
  6525. * if this_count <= 3: # <<<<<<<<<<<<<<
  6526. * # Can't get any better than this in the path below
  6527. * continue
  6528. */
  6529. }
  6530. /* "fontTools/qu2cu/qu2cu.py":329
  6531. * j_sol_count, j_sol_error = sols[j].num_points, sols[j].error
  6532. *
  6533. * if not all_cubic: # <<<<<<<<<<<<<<
  6534. * # Solution with quadratics between j:i
  6535. * this_count = costs[2 * i - 1] - costs[2 * j] + 1
  6536. */
  6537. }
  6538. /* "fontTools/qu2cu/qu2cu.py":343
  6539. *
  6540. * # Fit elevated_quadratics[j:i] into one cubic
  6541. * try: # <<<<<<<<<<<<<<
  6542. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  6543. * except ZeroDivisionError:
  6544. */
  6545. {
  6546. __Pyx_PyThreadState_declare
  6547. __Pyx_PyThreadState_assign
  6548. __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
  6549. __Pyx_XGOTREF(__pyx_t_20);
  6550. __Pyx_XGOTREF(__pyx_t_21);
  6551. __Pyx_XGOTREF(__pyx_t_22);
  6552. /*try:*/ {
  6553. /* "fontTools/qu2cu/qu2cu.py":344
  6554. * # Fit elevated_quadratics[j:i] into one cubic
  6555. * try:
  6556. * curve, ts = merge_curves(elevated_quadratics, j, i - j) # <<<<<<<<<<<<<<
  6557. * except ZeroDivisionError:
  6558. * continue
  6559. */
  6560. __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, 344, __pyx_L15_error)
  6561. __Pyx_GOTREF(__pyx_t_6);
  6562. if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) {
  6563. PyObject* sequence = __pyx_t_6;
  6564. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  6565. if (unlikely(size != 2)) {
  6566. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  6567. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  6568. __PYX_ERR(0, 344, __pyx_L15_error)
  6569. }
  6570. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6571. if (likely(PyTuple_CheckExact(sequence))) {
  6572. __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0);
  6573. __Pyx_INCREF(__pyx_t_7);
  6574. __pyx_t_19 = PyTuple_GET_ITEM(sequence, 1);
  6575. __Pyx_INCREF(__pyx_t_19);
  6576. } else {
  6577. __pyx_t_7 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  6578. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 344, __pyx_L15_error)
  6579. __Pyx_XGOTREF(__pyx_t_7);
  6580. __pyx_t_19 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  6581. if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 344, __pyx_L15_error)
  6582. __Pyx_XGOTREF(__pyx_t_19);
  6583. }
  6584. #else
  6585. __pyx_t_7 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 344, __pyx_L15_error)
  6586. __Pyx_GOTREF(__pyx_t_7);
  6587. __pyx_t_19 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 344, __pyx_L15_error)
  6588. __Pyx_GOTREF(__pyx_t_19);
  6589. #endif
  6590. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6591. } else {
  6592. Py_ssize_t index = -1;
  6593. __pyx_t_18 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 344, __pyx_L15_error)
  6594. __Pyx_GOTREF(__pyx_t_18);
  6595. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6596. __pyx_t_23 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_18);
  6597. index = 0; __pyx_t_7 = __pyx_t_23(__pyx_t_18); if (unlikely(!__pyx_t_7)) goto __pyx_L23_unpacking_failed;
  6598. __Pyx_GOTREF(__pyx_t_7);
  6599. index = 1; __pyx_t_19 = __pyx_t_23(__pyx_t_18); if (unlikely(!__pyx_t_19)) goto __pyx_L23_unpacking_failed;
  6600. __Pyx_GOTREF(__pyx_t_19);
  6601. if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_18), 2) < (0)) __PYX_ERR(0, 344, __pyx_L15_error)
  6602. __pyx_t_23 = NULL;
  6603. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6604. goto __pyx_L24_unpacking_done;
  6605. __pyx_L23_unpacking_failed:;
  6606. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6607. __pyx_t_23 = NULL;
  6608. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  6609. __PYX_ERR(0, 344, __pyx_L15_error)
  6610. __pyx_L24_unpacking_done:;
  6611. }
  6612. __Pyx_XDECREF_SET(__pyx_v_curve, __pyx_t_7);
  6613. __pyx_t_7 = 0;
  6614. __Pyx_XDECREF_SET(__pyx_v_ts, __pyx_t_19);
  6615. __pyx_t_19 = 0;
  6616. /* "fontTools/qu2cu/qu2cu.py":343
  6617. *
  6618. * # Fit elevated_quadratics[j:i] into one cubic
  6619. * try: # <<<<<<<<<<<<<<
  6620. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  6621. * except ZeroDivisionError:
  6622. */
  6623. }
  6624. __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
  6625. __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
  6626. __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
  6627. goto __pyx_L22_try_end;
  6628. __pyx_L15_error:;
  6629. __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
  6630. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  6631. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  6632. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  6633. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6634. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  6635. /* "fontTools/qu2cu/qu2cu.py":345
  6636. * try:
  6637. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  6638. * except ZeroDivisionError: # <<<<<<<<<<<<<<
  6639. * continue
  6640. *
  6641. */
  6642. __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ZeroDivisionError))));
  6643. if (__pyx_t_16) {
  6644. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6645. if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_19, &__pyx_t_7) < 0) __PYX_ERR(0, 345, __pyx_L17_except_error)
  6646. __Pyx_XGOTREF(__pyx_t_6);
  6647. __Pyx_XGOTREF(__pyx_t_19);
  6648. __Pyx_XGOTREF(__pyx_t_7);
  6649. /* "fontTools/qu2cu/qu2cu.py":346
  6650. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  6651. * except ZeroDivisionError:
  6652. * continue # <<<<<<<<<<<<<<
  6653. *
  6654. * # Now reconstruct the segments from the fitted curve
  6655. */
  6656. goto __pyx_L25_except_continue;
  6657. __pyx_L25_except_continue:;
  6658. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6659. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6660. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  6661. goto __pyx_L21_try_continue;
  6662. }
  6663. goto __pyx_L17_except_error;
  6664. /* "fontTools/qu2cu/qu2cu.py":343
  6665. *
  6666. * # Fit elevated_quadratics[j:i] into one cubic
  6667. * try: # <<<<<<<<<<<<<<
  6668. * curve, ts = merge_curves(elevated_quadratics, j, i - j)
  6669. * except ZeroDivisionError:
  6670. */
  6671. __pyx_L17_except_error:;
  6672. __Pyx_XGIVEREF(__pyx_t_20);
  6673. __Pyx_XGIVEREF(__pyx_t_21);
  6674. __Pyx_XGIVEREF(__pyx_t_22);
  6675. __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
  6676. goto __pyx_L1_error;
  6677. __pyx_L21_try_continue:;
  6678. __Pyx_XGIVEREF(__pyx_t_20);
  6679. __Pyx_XGIVEREF(__pyx_t_21);
  6680. __Pyx_XGIVEREF(__pyx_t_22);
  6681. __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
  6682. goto __pyx_L10_continue;
  6683. __pyx_L22_try_end:;
  6684. }
  6685. /* "fontTools/qu2cu/qu2cu.py":349
  6686. *
  6687. * # Now reconstruct the segments from the fitted curve
  6688. * reconstructed_iter = splitCubicAtTC(*curve, *ts) # <<<<<<<<<<<<<<
  6689. * reconstructed = []
  6690. *
  6691. */
  6692. __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_splitCubicAtTC); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 349, __pyx_L1_error)
  6693. __Pyx_GOTREF(__pyx_t_7);
  6694. __pyx_t_19 = __Pyx_PySequence_Tuple(__pyx_v_curve); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 349, __pyx_L1_error)
  6695. __Pyx_GOTREF(__pyx_t_19);
  6696. __pyx_t_6 = __Pyx_PySequence_Tuple(__pyx_v_ts); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L1_error)
  6697. __Pyx_GOTREF(__pyx_t_6);
  6698. __pyx_t_18 = PyNumber_Add(__pyx_t_19, __pyx_t_6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 349, __pyx_L1_error)
  6699. __Pyx_GOTREF(__pyx_t_18);
  6700. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6701. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6702. __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_18, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 349, __pyx_L1_error)
  6703. __Pyx_GOTREF(__pyx_t_6);
  6704. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6705. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6706. __Pyx_XDECREF_SET(__pyx_v_reconstructed_iter, __pyx_t_6);
  6707. __pyx_t_6 = 0;
  6708. /* "fontTools/qu2cu/qu2cu.py":350
  6709. * # Now reconstruct the segments from the fitted curve
  6710. * reconstructed_iter = splitCubicAtTC(*curve, *ts)
  6711. * reconstructed = [] # <<<<<<<<<<<<<<
  6712. *
  6713. * # Knot errors
  6714. */
  6715. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 350, __pyx_L1_error)
  6716. __Pyx_GOTREF(__pyx_t_6);
  6717. __Pyx_XDECREF_SET(__pyx_v_reconstructed, ((PyObject*)__pyx_t_6));
  6718. __pyx_t_6 = 0;
  6719. /* "fontTools/qu2cu/qu2cu.py":353
  6720. *
  6721. * # Knot errors
  6722. * error = 0 # <<<<<<<<<<<<<<
  6723. * for k, reconst in enumerate(reconstructed_iter):
  6724. * orig = elevated_quadratics[j + k]
  6725. */
  6726. __pyx_v_error = 0.0;
  6727. /* "fontTools/qu2cu/qu2cu.py":354
  6728. * # Knot errors
  6729. * error = 0
  6730. * for k, reconst in enumerate(reconstructed_iter): # <<<<<<<<<<<<<<
  6731. * orig = elevated_quadratics[j + k]
  6732. * err = abs(reconst[3] - orig[3])
  6733. */
  6734. __pyx_t_16 = 0;
  6735. if (likely(PyList_CheckExact(__pyx_v_reconstructed_iter)) || PyTuple_CheckExact(__pyx_v_reconstructed_iter)) {
  6736. __pyx_t_6 = __pyx_v_reconstructed_iter; __Pyx_INCREF(__pyx_t_6);
  6737. __pyx_t_24 = 0;
  6738. __pyx_t_25 = NULL;
  6739. } else {
  6740. __pyx_t_24 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_reconstructed_iter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 354, __pyx_L1_error)
  6741. __Pyx_GOTREF(__pyx_t_6);
  6742. __pyx_t_25 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 354, __pyx_L1_error)
  6743. }
  6744. for (;;) {
  6745. if (likely(!__pyx_t_25)) {
  6746. if (likely(PyList_CheckExact(__pyx_t_6))) {
  6747. {
  6748. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6749. #if !CYTHON_ASSUME_SAFE_SIZE
  6750. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 354, __pyx_L1_error)
  6751. #endif
  6752. if (__pyx_t_24 >= __pyx_temp) break;
  6753. }
  6754. __pyx_t_18 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_24, __Pyx_ReferenceSharing_OwnStrongReference);
  6755. ++__pyx_t_24;
  6756. } else {
  6757. {
  6758. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  6759. #if !CYTHON_ASSUME_SAFE_SIZE
  6760. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 354, __pyx_L1_error)
  6761. #endif
  6762. if (__pyx_t_24 >= __pyx_temp) break;
  6763. }
  6764. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6765. __pyx_t_18 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_24));
  6766. #else
  6767. __pyx_t_18 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_24);
  6768. #endif
  6769. ++__pyx_t_24;
  6770. }
  6771. if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 354, __pyx_L1_error)
  6772. } else {
  6773. __pyx_t_18 = __pyx_t_25(__pyx_t_6);
  6774. if (unlikely(!__pyx_t_18)) {
  6775. PyObject* exc_type = PyErr_Occurred();
  6776. if (exc_type) {
  6777. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 354, __pyx_L1_error)
  6778. PyErr_Clear();
  6779. }
  6780. break;
  6781. }
  6782. }
  6783. __Pyx_GOTREF(__pyx_t_18);
  6784. __Pyx_XDECREF_SET(__pyx_v_reconst, __pyx_t_18);
  6785. __pyx_t_18 = 0;
  6786. __pyx_v_k = __pyx_t_16;
  6787. __pyx_t_16 = (__pyx_t_16 + 1);
  6788. /* "fontTools/qu2cu/qu2cu.py":355
  6789. * error = 0
  6790. * for k, reconst in enumerate(reconstructed_iter):
  6791. * orig = elevated_quadratics[j + k] # <<<<<<<<<<<<<<
  6792. * err = abs(reconst[3] - orig[3])
  6793. * error = max(error, err)
  6794. */
  6795. __pyx_t_26 = (__pyx_v_j + __pyx_v_k);
  6796. __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, 355, __pyx_L1_error)
  6797. __Pyx_GOTREF(__pyx_t_18);
  6798. __Pyx_XDECREF_SET(__pyx_v_orig, __pyx_t_18);
  6799. __pyx_t_18 = 0;
  6800. /* "fontTools/qu2cu/qu2cu.py":356
  6801. * for k, reconst in enumerate(reconstructed_iter):
  6802. * orig = elevated_quadratics[j + k]
  6803. * err = abs(reconst[3] - orig[3]) # <<<<<<<<<<<<<<
  6804. * error = max(error, err)
  6805. * if error > tolerance:
  6806. */
  6807. __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, 356, __pyx_L1_error)
  6808. __Pyx_GOTREF(__pyx_t_18);
  6809. __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, 356, __pyx_L1_error)
  6810. __Pyx_GOTREF(__pyx_t_7);
  6811. __pyx_t_19 = PyNumber_Subtract(__pyx_t_18, __pyx_t_7); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 356, __pyx_L1_error)
  6812. __Pyx_GOTREF(__pyx_t_19);
  6813. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  6814. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6815. __pyx_t_7 = __Pyx_PyNumber_Absolute(__pyx_t_19); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L1_error)
  6816. __Pyx_GOTREF(__pyx_t_7);
  6817. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6818. __pyx_t_17 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_17 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 356, __pyx_L1_error)
  6819. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6820. __pyx_v_err = __pyx_t_17;
  6821. /* "fontTools/qu2cu/qu2cu.py":357
  6822. * orig = elevated_quadratics[j + k]
  6823. * err = abs(reconst[3] - orig[3])
  6824. * error = max(error, err) # <<<<<<<<<<<<<<
  6825. * if error > tolerance:
  6826. * break
  6827. */
  6828. __pyx_t_17 = __pyx_v_err;
  6829. __pyx_t_27 = __pyx_v_error;
  6830. __pyx_t_2 = (__pyx_t_17 > __pyx_t_27);
  6831. if (__pyx_t_2) {
  6832. __pyx_t_28 = __pyx_t_17;
  6833. } else {
  6834. __pyx_t_28 = __pyx_t_27;
  6835. }
  6836. __pyx_v_error = __pyx_t_28;
  6837. /* "fontTools/qu2cu/qu2cu.py":358
  6838. * err = abs(reconst[3] - orig[3])
  6839. * error = max(error, err)
  6840. * if error > tolerance: # <<<<<<<<<<<<<<
  6841. * break
  6842. * reconstructed.append(reconst)
  6843. */
  6844. __pyx_t_2 = (__pyx_v_error > __pyx_v_tolerance);
  6845. if (__pyx_t_2) {
  6846. /* "fontTools/qu2cu/qu2cu.py":359
  6847. * error = max(error, err)
  6848. * if error > tolerance:
  6849. * break # <<<<<<<<<<<<<<
  6850. * reconstructed.append(reconst)
  6851. * if error > tolerance:
  6852. */
  6853. goto __pyx_L28_break;
  6854. /* "fontTools/qu2cu/qu2cu.py":358
  6855. * err = abs(reconst[3] - orig[3])
  6856. * error = max(error, err)
  6857. * if error > tolerance: # <<<<<<<<<<<<<<
  6858. * break
  6859. * reconstructed.append(reconst)
  6860. */
  6861. }
  6862. /* "fontTools/qu2cu/qu2cu.py":360
  6863. * if error > tolerance:
  6864. * break
  6865. * reconstructed.append(reconst) # <<<<<<<<<<<<<<
  6866. * if error > tolerance:
  6867. * # Not feasible
  6868. */
  6869. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_reconstructed, __pyx_v_reconst); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 360, __pyx_L1_error)
  6870. /* "fontTools/qu2cu/qu2cu.py":354
  6871. * # Knot errors
  6872. * error = 0
  6873. * for k, reconst in enumerate(reconstructed_iter): # <<<<<<<<<<<<<<
  6874. * orig = elevated_quadratics[j + k]
  6875. * err = abs(reconst[3] - orig[3])
  6876. */
  6877. }
  6878. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6879. goto __pyx_L30_for_end;
  6880. __pyx_L28_break:;
  6881. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6882. goto __pyx_L30_for_end;
  6883. __pyx_L30_for_end:;
  6884. /* "fontTools/qu2cu/qu2cu.py":361
  6885. * break
  6886. * reconstructed.append(reconst)
  6887. * if error > tolerance: # <<<<<<<<<<<<<<
  6888. * # Not feasible
  6889. * continue
  6890. */
  6891. __pyx_t_2 = (__pyx_v_error > __pyx_v_tolerance);
  6892. if (__pyx_t_2) {
  6893. /* "fontTools/qu2cu/qu2cu.py":363
  6894. * if error > tolerance:
  6895. * # Not feasible
  6896. * continue # <<<<<<<<<<<<<<
  6897. *
  6898. * # Interior errors
  6899. */
  6900. goto __pyx_L10_continue;
  6901. /* "fontTools/qu2cu/qu2cu.py":361
  6902. * break
  6903. * reconstructed.append(reconst)
  6904. * if error > tolerance: # <<<<<<<<<<<<<<
  6905. * # Not feasible
  6906. * continue
  6907. */
  6908. }
  6909. /* "fontTools/qu2cu/qu2cu.py":366
  6910. *
  6911. * # Interior errors
  6912. * for k, reconst in enumerate(reconstructed): # <<<<<<<<<<<<<<
  6913. * orig = elevated_quadratics[j + k]
  6914. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  6915. */
  6916. __pyx_t_16 = 0;
  6917. __pyx_t_6 = __pyx_v_reconstructed; __Pyx_INCREF(__pyx_t_6);
  6918. __pyx_t_24 = 0;
  6919. for (;;) {
  6920. {
  6921. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6922. #if !CYTHON_ASSUME_SAFE_SIZE
  6923. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 366, __pyx_L1_error)
  6924. #endif
  6925. if (__pyx_t_24 >= __pyx_temp) break;
  6926. }
  6927. __pyx_t_7 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_24, __Pyx_ReferenceSharing_OwnStrongReference);
  6928. ++__pyx_t_24;
  6929. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 366, __pyx_L1_error)
  6930. __Pyx_GOTREF(__pyx_t_7);
  6931. __Pyx_XDECREF_SET(__pyx_v_reconst, __pyx_t_7);
  6932. __pyx_t_7 = 0;
  6933. __pyx_v_k = __pyx_t_16;
  6934. __pyx_t_16 = (__pyx_t_16 + 1);
  6935. /* "fontTools/qu2cu/qu2cu.py":367
  6936. * # Interior errors
  6937. * for k, reconst in enumerate(reconstructed):
  6938. * orig = elevated_quadratics[j + k] # <<<<<<<<<<<<<<
  6939. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  6940. *
  6941. */
  6942. __pyx_t_26 = (__pyx_v_j + __pyx_v_k);
  6943. __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, 367, __pyx_L1_error)
  6944. __Pyx_GOTREF(__pyx_t_7);
  6945. __Pyx_XDECREF_SET(__pyx_v_orig, __pyx_t_7);
  6946. __pyx_t_7 = 0;
  6947. /* "fontTools/qu2cu/qu2cu.py":368
  6948. * for k, reconst in enumerate(reconstructed):
  6949. * orig = elevated_quadratics[j + k]
  6950. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig)) # <<<<<<<<<<<<<<
  6951. *
  6952. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  6953. */
  6954. __pyx_t_19 = NULL;
  6955. __pyx_t_12 = 1;
  6956. {
  6957. PyObject *__pyx_callargs[3] = {__pyx_t_19, __pyx_v_reconst, __pyx_v_orig};
  6958. __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));
  6959. __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
  6960. if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 368, __pyx_L1_error)
  6961. __Pyx_GOTREF(__pyx_t_7);
  6962. }
  6963. __pyx_t_19 = __pyx_pf_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_genexpr(NULL, __pyx_t_7); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 368, __pyx_L1_error)
  6964. __Pyx_GOTREF(__pyx_t_19);
  6965. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6966. __pyx_t_7 = __Pyx_PySequence_Tuple(__pyx_t_19); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 368, __pyx_L1_error)
  6967. __Pyx_GOTREF(__pyx_t_7);
  6968. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  6969. if (1) {
  6970. PyObject* sequence = __pyx_t_7;
  6971. Py_ssize_t size = __Pyx_PyTuple_GET_SIZE(sequence);
  6972. if (unlikely(size != 4)) {
  6973. if (size > 4) __Pyx_RaiseTooManyValuesError(4);
  6974. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  6975. __PYX_ERR(0, 368, __pyx_L1_error)
  6976. }
  6977. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6978. __pyx_t_19 = PyTuple_GET_ITEM(sequence, 0);
  6979. __Pyx_INCREF(__pyx_t_19);
  6980. __pyx_t_18 = PyTuple_GET_ITEM(sequence, 1);
  6981. __Pyx_INCREF(__pyx_t_18);
  6982. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2);
  6983. __Pyx_INCREF(__pyx_t_3);
  6984. __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3);
  6985. __Pyx_INCREF(__pyx_t_8);
  6986. #else
  6987. {
  6988. Py_ssize_t i;
  6989. PyObject** temps[4] = {&__pyx_t_19,&__pyx_t_18,&__pyx_t_3,&__pyx_t_8};
  6990. for (i=0; i < 4; i++) {
  6991. PyObject* item = __Pyx_PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 368, __pyx_L1_error)
  6992. __Pyx_GOTREF(item);
  6993. *(temps[i]) = item;
  6994. }
  6995. }
  6996. #endif
  6997. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  6998. }
  6999. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_19); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
  7000. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  7001. __pyx_t_29 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_18); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
  7002. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  7003. __pyx_t_30 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
  7004. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7005. __pyx_t_31 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 368, __pyx_L1_error)
  7006. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7007. __pyx_v_p0 = __pyx_t_10;
  7008. __pyx_v_p1 = __pyx_t_29;
  7009. __pyx_v_p2 = __pyx_t_30;
  7010. __pyx_v_p3 = __pyx_t_31;
  7011. /* "fontTools/qu2cu/qu2cu.py":370
  7012. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  7013. *
  7014. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): # <<<<<<<<<<<<<<
  7015. * error = tolerance + 1
  7016. * break
  7017. */
  7018. __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, 370, __pyx_L1_error)
  7019. __pyx_t_2 = (!(__pyx_t_26 != 0));
  7020. if (__pyx_t_2) {
  7021. /* "fontTools/qu2cu/qu2cu.py":371
  7022. *
  7023. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  7024. * error = tolerance + 1 # <<<<<<<<<<<<<<
  7025. * break
  7026. * if error > tolerance:
  7027. */
  7028. __pyx_v_error = (__pyx_v_tolerance + 1.0);
  7029. /* "fontTools/qu2cu/qu2cu.py":372
  7030. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance):
  7031. * error = tolerance + 1
  7032. * break # <<<<<<<<<<<<<<
  7033. * if error > tolerance:
  7034. * # Not feasible
  7035. */
  7036. goto __pyx_L33_break;
  7037. /* "fontTools/qu2cu/qu2cu.py":370
  7038. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  7039. *
  7040. * if not cubic_farthest_fit_inside(p0, p1, p2, p3, tolerance): # <<<<<<<<<<<<<<
  7041. * error = tolerance + 1
  7042. * break
  7043. */
  7044. }
  7045. /* "fontTools/qu2cu/qu2cu.py":366
  7046. *
  7047. * # Interior errors
  7048. * for k, reconst in enumerate(reconstructed): # <<<<<<<<<<<<<<
  7049. * orig = elevated_quadratics[j + k]
  7050. * p0, p1, p2, p3 = tuple(v - u for v, u in zip(reconst, orig))
  7051. */
  7052. }
  7053. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7054. goto __pyx_L35_for_end;
  7055. __pyx_L33_break:;
  7056. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7057. goto __pyx_L35_for_end;
  7058. __pyx_L35_for_end:;
  7059. /* "fontTools/qu2cu/qu2cu.py":373
  7060. * error = tolerance + 1
  7061. * break
  7062. * if error > tolerance: # <<<<<<<<<<<<<<
  7063. * # Not feasible
  7064. * continue
  7065. */
  7066. __pyx_t_2 = (__pyx_v_error > __pyx_v_tolerance);
  7067. if (__pyx_t_2) {
  7068. /* "fontTools/qu2cu/qu2cu.py":375
  7069. * if error > tolerance:
  7070. * # Not feasible
  7071. * continue # <<<<<<<<<<<<<<
  7072. *
  7073. * # Save best solution
  7074. */
  7075. goto __pyx_L10_continue;
  7076. /* "fontTools/qu2cu/qu2cu.py":373
  7077. * error = tolerance + 1
  7078. * break
  7079. * if error > tolerance: # <<<<<<<<<<<<<<
  7080. * # Not feasible
  7081. * continue
  7082. */
  7083. }
  7084. /* "fontTools/qu2cu/qu2cu.py":378
  7085. *
  7086. * # Save best solution
  7087. * i_sol_count = j_sol_count + 3 # <<<<<<<<<<<<<<
  7088. * i_sol_error = max(j_sol_error, error)
  7089. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  7090. */
  7091. __pyx_v_i_sol_count = (__pyx_v_j_sol_count + 3);
  7092. /* "fontTools/qu2cu/qu2cu.py":379
  7093. * # Save best solution
  7094. * i_sol_count = j_sol_count + 3
  7095. * i_sol_error = max(j_sol_error, error) # <<<<<<<<<<<<<<
  7096. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  7097. * if i_sol < best_sol:
  7098. */
  7099. __pyx_t_28 = __pyx_v_error;
  7100. __pyx_t_17 = __pyx_v_j_sol_error;
  7101. __pyx_t_2 = (__pyx_t_28 > __pyx_t_17);
  7102. if (__pyx_t_2) {
  7103. __pyx_t_27 = __pyx_t_28;
  7104. } else {
  7105. __pyx_t_27 = __pyx_t_17;
  7106. }
  7107. __pyx_v_i_sol_error = __pyx_t_27;
  7108. /* "fontTools/qu2cu/qu2cu.py":380
  7109. * i_sol_count = j_sol_count + 3
  7110. * i_sol_error = max(j_sol_error, error)
  7111. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True) # <<<<<<<<<<<<<<
  7112. * if i_sol < best_sol:
  7113. * best_sol = i_sol
  7114. */
  7115. __pyx_t_7 = NULL;
  7116. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Solution); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 380, __pyx_L1_error)
  7117. __Pyx_GOTREF(__pyx_t_8);
  7118. __pyx_t_3 = __Pyx_PyLong_From_int(__pyx_v_i_sol_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 380, __pyx_L1_error)
  7119. __Pyx_GOTREF(__pyx_t_3);
  7120. __pyx_t_18 = PyFloat_FromDouble(__pyx_v_i_sol_error); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 380, __pyx_L1_error)
  7121. __Pyx_GOTREF(__pyx_t_18);
  7122. __pyx_t_19 = __Pyx_PyLong_From_int((__pyx_v_i - __pyx_v_j)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 380, __pyx_L1_error)
  7123. __Pyx_GOTREF(__pyx_t_19);
  7124. __pyx_t_12 = 1;
  7125. #if CYTHON_UNPACK_METHODS
  7126. if (unlikely(PyMethod_Check(__pyx_t_8))) {
  7127. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
  7128. assert(__pyx_t_7);
  7129. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
  7130. __Pyx_INCREF(__pyx_t_7);
  7131. __Pyx_INCREF(__pyx__function);
  7132. __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
  7133. __pyx_t_12 = 0;
  7134. }
  7135. #endif
  7136. {
  7137. PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_t_3, __pyx_t_18, __pyx_t_19, Py_True};
  7138. __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));
  7139. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  7140. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7141. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  7142. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  7143. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7144. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 380, __pyx_L1_error)
  7145. __Pyx_GOTREF(__pyx_t_6);
  7146. }
  7147. __Pyx_XDECREF_SET(__pyx_v_i_sol, __pyx_t_6);
  7148. __pyx_t_6 = 0;
  7149. /* "fontTools/qu2cu/qu2cu.py":381
  7150. * i_sol_error = max(j_sol_error, error)
  7151. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  7152. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  7153. * best_sol = i_sol
  7154. *
  7155. */
  7156. __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, 381, __pyx_L1_error)
  7157. __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 381, __pyx_L1_error)
  7158. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7159. if (__pyx_t_2) {
  7160. /* "fontTools/qu2cu/qu2cu.py":382
  7161. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  7162. * if i_sol < best_sol:
  7163. * best_sol = i_sol # <<<<<<<<<<<<<<
  7164. *
  7165. * if i_sol_count == 3:
  7166. */
  7167. __Pyx_INCREF(__pyx_v_i_sol);
  7168. __Pyx_DECREF_SET(__pyx_v_best_sol, __pyx_v_i_sol);
  7169. /* "fontTools/qu2cu/qu2cu.py":381
  7170. * i_sol_error = max(j_sol_error, error)
  7171. * i_sol = Solution(i_sol_count, i_sol_error, i - j, True)
  7172. * if i_sol < best_sol: # <<<<<<<<<<<<<<
  7173. * best_sol = i_sol
  7174. *
  7175. */
  7176. }
  7177. /* "fontTools/qu2cu/qu2cu.py":384
  7178. * best_sol = i_sol
  7179. *
  7180. * if i_sol_count == 3: # <<<<<<<<<<<<<<
  7181. * # Can't get any better than this
  7182. * break
  7183. */
  7184. __pyx_t_2 = (__pyx_v_i_sol_count == 3);
  7185. if (__pyx_t_2) {
  7186. /* "fontTools/qu2cu/qu2cu.py":386
  7187. * if i_sol_count == 3:
  7188. * # Can't get any better than this
  7189. * break # <<<<<<<<<<<<<<
  7190. *
  7191. * sols.append(best_sol)
  7192. */
  7193. goto __pyx_L11_break;
  7194. /* "fontTools/qu2cu/qu2cu.py":384
  7195. * best_sol = i_sol
  7196. *
  7197. * if i_sol_count == 3: # <<<<<<<<<<<<<<
  7198. * # Can't get any better than this
  7199. * break
  7200. */
  7201. }
  7202. __pyx_L10_continue:;
  7203. }
  7204. __pyx_L11_break:;
  7205. /* "fontTools/qu2cu/qu2cu.py":388
  7206. * break
  7207. *
  7208. * sols.append(best_sol) # <<<<<<<<<<<<<<
  7209. * if i in forced:
  7210. * start = i
  7211. */
  7212. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_sols, __pyx_v_best_sol); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 388, __pyx_L1_error)
  7213. /* "fontTools/qu2cu/qu2cu.py":389
  7214. *
  7215. * sols.append(best_sol)
  7216. * if i in forced: # <<<<<<<<<<<<<<
  7217. * start = i
  7218. *
  7219. */
  7220. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 389, __pyx_L1_error)
  7221. __Pyx_GOTREF(__pyx_t_6);
  7222. __pyx_t_2 = (__Pyx_PySet_ContainsTF(__pyx_t_6, __pyx_v_forced, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 389, __pyx_L1_error)
  7223. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7224. if (__pyx_t_2) {
  7225. /* "fontTools/qu2cu/qu2cu.py":390
  7226. * sols.append(best_sol)
  7227. * if i in forced:
  7228. * start = i # <<<<<<<<<<<<<<
  7229. *
  7230. * # Reconstruct solution
  7231. */
  7232. __pyx_v_start = __pyx_v_i;
  7233. /* "fontTools/qu2cu/qu2cu.py":389
  7234. *
  7235. * sols.append(best_sol)
  7236. * if i in forced: # <<<<<<<<<<<<<<
  7237. * start = i
  7238. *
  7239. */
  7240. }
  7241. }
  7242. /* "fontTools/qu2cu/qu2cu.py":393
  7243. *
  7244. * # Reconstruct solution
  7245. * splits = [] # <<<<<<<<<<<<<<
  7246. * cubic = []
  7247. * i = len(sols) - 1
  7248. */
  7249. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __pyx_L1_error)
  7250. __Pyx_GOTREF(__pyx_t_6);
  7251. __pyx_v_splits = ((PyObject*)__pyx_t_6);
  7252. __pyx_t_6 = 0;
  7253. /* "fontTools/qu2cu/qu2cu.py":394
  7254. * # Reconstruct solution
  7255. * splits = []
  7256. * cubic = [] # <<<<<<<<<<<<<<
  7257. * i = len(sols) - 1
  7258. * while i:
  7259. */
  7260. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 394, __pyx_L1_error)
  7261. __Pyx_GOTREF(__pyx_t_6);
  7262. __pyx_v_cubic = ((PyObject*)__pyx_t_6);
  7263. __pyx_t_6 = 0;
  7264. /* "fontTools/qu2cu/qu2cu.py":395
  7265. * splits = []
  7266. * cubic = []
  7267. * i = len(sols) - 1 # <<<<<<<<<<<<<<
  7268. * while i:
  7269. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  7270. */
  7271. __pyx_t_1 = __Pyx_PyList_GET_SIZE(__pyx_v_sols); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 395, __pyx_L1_error)
  7272. __pyx_v_i = (__pyx_t_1 - 1);
  7273. /* "fontTools/qu2cu/qu2cu.py":396
  7274. * cubic = []
  7275. * i = len(sols) - 1
  7276. * while i: # <<<<<<<<<<<<<<
  7277. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  7278. * splits.append(i)
  7279. */
  7280. while (1) {
  7281. __pyx_t_2 = (__pyx_v_i != 0);
  7282. if (!__pyx_t_2) break;
  7283. /* "fontTools/qu2cu/qu2cu.py":397
  7284. * i = len(sols) - 1
  7285. * while i:
  7286. * count, is_cubic = sols[i].start_index, sols[i].is_cubic # <<<<<<<<<<<<<<
  7287. * splits.append(i)
  7288. * cubic.append(is_cubic)
  7289. */
  7290. __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, 397, __pyx_L1_error)
  7291. __Pyx_GOTREF(__pyx_t_6);
  7292. __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, 397, __pyx_L1_error)
  7293. __Pyx_GOTREF(__pyx_t_8);
  7294. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7295. __pyx_t_5 = __Pyx_PyLong_As_int(__pyx_t_8); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 397, __pyx_L1_error)
  7296. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7297. __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, 397, __pyx_L1_error)
  7298. __Pyx_GOTREF(__pyx_t_8);
  7299. __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, 397, __pyx_L1_error)
  7300. __Pyx_GOTREF(__pyx_t_6);
  7301. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7302. __pyx_t_13 = __Pyx_PyLong_As_int(__pyx_t_6); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 397, __pyx_L1_error)
  7303. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7304. __pyx_v_count = __pyx_t_5;
  7305. __pyx_v_is_cubic = __pyx_t_13;
  7306. /* "fontTools/qu2cu/qu2cu.py":398
  7307. * while i:
  7308. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  7309. * splits.append(i) # <<<<<<<<<<<<<<
  7310. * cubic.append(is_cubic)
  7311. * i -= count
  7312. */
  7313. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_i); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 398, __pyx_L1_error)
  7314. __Pyx_GOTREF(__pyx_t_6);
  7315. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_splits, __pyx_t_6); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 398, __pyx_L1_error)
  7316. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7317. /* "fontTools/qu2cu/qu2cu.py":399
  7318. * count, is_cubic = sols[i].start_index, sols[i].is_cubic
  7319. * splits.append(i)
  7320. * cubic.append(is_cubic) # <<<<<<<<<<<<<<
  7321. * i -= count
  7322. * curves = []
  7323. */
  7324. __pyx_t_6 = __Pyx_PyLong_From_int(__pyx_v_is_cubic); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 399, __pyx_L1_error)
  7325. __Pyx_GOTREF(__pyx_t_6);
  7326. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_cubic, __pyx_t_6); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 399, __pyx_L1_error)
  7327. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7328. /* "fontTools/qu2cu/qu2cu.py":400
  7329. * splits.append(i)
  7330. * cubic.append(is_cubic)
  7331. * i -= count # <<<<<<<<<<<<<<
  7332. * curves = []
  7333. * j = 0
  7334. */
  7335. __pyx_v_i = (__pyx_v_i - __pyx_v_count);
  7336. }
  7337. /* "fontTools/qu2cu/qu2cu.py":401
  7338. * cubic.append(is_cubic)
  7339. * i -= count
  7340. * curves = [] # <<<<<<<<<<<<<<
  7341. * j = 0
  7342. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  7343. */
  7344. __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 401, __pyx_L1_error)
  7345. __Pyx_GOTREF(__pyx_t_6);
  7346. __pyx_v_curves = ((PyObject*)__pyx_t_6);
  7347. __pyx_t_6 = 0;
  7348. /* "fontTools/qu2cu/qu2cu.py":402
  7349. * i -= count
  7350. * curves = []
  7351. * j = 0 # <<<<<<<<<<<<<<
  7352. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  7353. * if is_cubic:
  7354. */
  7355. __pyx_v_j = 0;
  7356. /* "fontTools/qu2cu/qu2cu.py":403
  7357. * curves = []
  7358. * j = 0
  7359. * for i, is_cubic in reversed(list(zip(splits, cubic))): # <<<<<<<<<<<<<<
  7360. * if is_cubic:
  7361. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  7362. */
  7363. __pyx_t_8 = NULL;
  7364. __pyx_t_12 = 1;
  7365. {
  7366. PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_v_splits, __pyx_v_cubic};
  7367. __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));
  7368. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  7369. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 403, __pyx_L1_error)
  7370. __Pyx_GOTREF(__pyx_t_6);
  7371. }
  7372. __pyx_t_8 = __Pyx_PySequence_ListKeepNew(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 403, __pyx_L1_error)
  7373. __Pyx_GOTREF(__pyx_t_8);
  7374. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7375. __pyx_t_6 = __pyx_t_8; __Pyx_INCREF(__pyx_t_6);
  7376. __pyx_t_1 = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  7377. #if !CYTHON_ASSUME_SAFE_SIZE
  7378. if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 403, __pyx_L1_error)
  7379. #endif
  7380. --__pyx_t_1;
  7381. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7382. for (;;) {
  7383. if (__pyx_t_1 < 0) break;
  7384. {
  7385. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  7386. #if !CYTHON_ASSUME_SAFE_SIZE
  7387. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 403, __pyx_L1_error)
  7388. #endif
  7389. if (__pyx_t_1 >= __pyx_temp) break;
  7390. }
  7391. __pyx_t_8 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_1, __Pyx_ReferenceSharing_OwnStrongReference);
  7392. --__pyx_t_1;
  7393. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 403, __pyx_L1_error)
  7394. __Pyx_GOTREF(__pyx_t_8);
  7395. if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) {
  7396. PyObject* sequence = __pyx_t_8;
  7397. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  7398. if (unlikely(size != 2)) {
  7399. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  7400. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  7401. __PYX_ERR(0, 403, __pyx_L1_error)
  7402. }
  7403. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  7404. if (likely(PyTuple_CheckExact(sequence))) {
  7405. __pyx_t_19 = PyTuple_GET_ITEM(sequence, 0);
  7406. __Pyx_INCREF(__pyx_t_19);
  7407. __pyx_t_18 = PyTuple_GET_ITEM(sequence, 1);
  7408. __Pyx_INCREF(__pyx_t_18);
  7409. } else {
  7410. __pyx_t_19 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  7411. if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 403, __pyx_L1_error)
  7412. __Pyx_XGOTREF(__pyx_t_19);
  7413. __pyx_t_18 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  7414. if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 403, __pyx_L1_error)
  7415. __Pyx_XGOTREF(__pyx_t_18);
  7416. }
  7417. #else
  7418. __pyx_t_19 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 403, __pyx_L1_error)
  7419. __Pyx_GOTREF(__pyx_t_19);
  7420. __pyx_t_18 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 403, __pyx_L1_error)
  7421. __Pyx_GOTREF(__pyx_t_18);
  7422. #endif
  7423. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7424. } else {
  7425. Py_ssize_t index = -1;
  7426. __pyx_t_3 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error)
  7427. __Pyx_GOTREF(__pyx_t_3);
  7428. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7429. __pyx_t_23 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3);
  7430. index = 0; __pyx_t_19 = __pyx_t_23(__pyx_t_3); if (unlikely(!__pyx_t_19)) goto __pyx_L44_unpacking_failed;
  7431. __Pyx_GOTREF(__pyx_t_19);
  7432. index = 1; __pyx_t_18 = __pyx_t_23(__pyx_t_3); if (unlikely(!__pyx_t_18)) goto __pyx_L44_unpacking_failed;
  7433. __Pyx_GOTREF(__pyx_t_18);
  7434. if (__Pyx_IternextUnpackEndCheck(__pyx_t_23(__pyx_t_3), 2) < (0)) __PYX_ERR(0, 403, __pyx_L1_error)
  7435. __pyx_t_23 = NULL;
  7436. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7437. goto __pyx_L45_unpacking_done;
  7438. __pyx_L44_unpacking_failed:;
  7439. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  7440. __pyx_t_23 = NULL;
  7441. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  7442. __PYX_ERR(0, 403, __pyx_L1_error)
  7443. __pyx_L45_unpacking_done:;
  7444. }
  7445. __pyx_t_13 = __Pyx_PyLong_As_int(__pyx_t_19); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 403, __pyx_L1_error)
  7446. __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
  7447. __pyx_t_5 = __Pyx_PyLong_As_int(__pyx_t_18); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 403, __pyx_L1_error)
  7448. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  7449. __pyx_v_i = __pyx_t_13;
  7450. __pyx_v_is_cubic = __pyx_t_5;
  7451. /* "fontTools/qu2cu/qu2cu.py":404
  7452. * j = 0
  7453. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  7454. * if is_cubic: # <<<<<<<<<<<<<<
  7455. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  7456. * else:
  7457. */
  7458. __pyx_t_2 = (__pyx_v_is_cubic != 0);
  7459. if (__pyx_t_2) {
  7460. /* "fontTools/qu2cu/qu2cu.py":405
  7461. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  7462. * if is_cubic:
  7463. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0]) # <<<<<<<<<<<<<<
  7464. * else:
  7465. * for k in range(j, i):
  7466. */
  7467. __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, 405, __pyx_L1_error)
  7468. __Pyx_GOTREF(__pyx_t_8);
  7469. __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, 405, __pyx_L1_error)
  7470. __Pyx_GOTREF(__pyx_t_18);
  7471. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7472. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_curves, __pyx_t_18); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 405, __pyx_L1_error)
  7473. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  7474. /* "fontTools/qu2cu/qu2cu.py":404
  7475. * j = 0
  7476. * for i, is_cubic in reversed(list(zip(splits, cubic))):
  7477. * if is_cubic: # <<<<<<<<<<<<<<
  7478. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  7479. * else:
  7480. */
  7481. goto __pyx_L46;
  7482. }
  7483. /* "fontTools/qu2cu/qu2cu.py":407
  7484. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  7485. * else:
  7486. * for k in range(j, i): # <<<<<<<<<<<<<<
  7487. * curves.append(q[k * 2 : k * 2 + 3])
  7488. * j = i
  7489. */
  7490. /*else*/ {
  7491. __pyx_t_5 = __pyx_v_i;
  7492. __pyx_t_13 = __pyx_t_5;
  7493. for (__pyx_t_14 = __pyx_v_j; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
  7494. __pyx_v_k = __pyx_t_14;
  7495. /* "fontTools/qu2cu/qu2cu.py":408
  7496. * else:
  7497. * for k in range(j, i):
  7498. * curves.append(q[k * 2 : k * 2 + 3]) # <<<<<<<<<<<<<<
  7499. * j = i
  7500. *
  7501. */
  7502. __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, 408, __pyx_L1_error)
  7503. __Pyx_GOTREF(__pyx_t_18);
  7504. __pyx_t_11 = __Pyx_PyList_Append(__pyx_v_curves, __pyx_t_18); if (unlikely(__pyx_t_11 == ((int)-1))) __PYX_ERR(0, 408, __pyx_L1_error)
  7505. __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
  7506. }
  7507. }
  7508. __pyx_L46:;
  7509. /* "fontTools/qu2cu/qu2cu.py":409
  7510. * for k in range(j, i):
  7511. * curves.append(q[k * 2 : k * 2 + 3])
  7512. * j = i # <<<<<<<<<<<<<<
  7513. *
  7514. * return curves
  7515. */
  7516. __pyx_v_j = __pyx_v_i;
  7517. /* "fontTools/qu2cu/qu2cu.py":403
  7518. * curves = []
  7519. * j = 0
  7520. * for i, is_cubic in reversed(list(zip(splits, cubic))): # <<<<<<<<<<<<<<
  7521. * if is_cubic:
  7522. * curves.append(merge_curves(elevated_quadratics, j, i - j)[0])
  7523. */
  7524. }
  7525. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7526. /* "fontTools/qu2cu/qu2cu.py":411
  7527. * j = i
  7528. *
  7529. * return curves # <<<<<<<<<<<<<<
  7530. *
  7531. *
  7532. */
  7533. __Pyx_XDECREF(__pyx_r);
  7534. __Pyx_INCREF(__pyx_v_curves);
  7535. __pyx_r = __pyx_v_curves;
  7536. goto __pyx_L0;
  7537. /* "fontTools/qu2cu/qu2cu.py":270
  7538. *
  7539. *
  7540. * @cython.locals( # <<<<<<<<<<<<<<
  7541. * i=cython.int,
  7542. * j=cython.int,
  7543. */
  7544. /* function exit code */
  7545. __pyx_L1_error:;
  7546. __Pyx_XDECREF(__pyx_t_3);
  7547. __Pyx_XDECREF(__pyx_t_6);
  7548. __Pyx_XDECREF(__pyx_t_7);
  7549. __Pyx_XDECREF(__pyx_t_8);
  7550. __Pyx_XDECREF(__pyx_t_18);
  7551. __Pyx_XDECREF(__pyx_t_19);
  7552. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.spline_to_curves", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7553. __pyx_r = NULL;
  7554. __pyx_L0:;
  7555. __Pyx_XDECREF(__pyx_v_elevated_quadratics);
  7556. __Pyx_XDECREF(__pyx_v_forced);
  7557. __Pyx_XDECREF(__pyx_v_sols);
  7558. __Pyx_XDECREF(__pyx_v_impossible);
  7559. __Pyx_XDECREF(__pyx_v_best_sol);
  7560. __Pyx_XDECREF(__pyx_v_this_count);
  7561. __Pyx_XDECREF(__pyx_v_i_sol);
  7562. __Pyx_XDECREF(__pyx_v_curve);
  7563. __Pyx_XDECREF(__pyx_v_ts);
  7564. __Pyx_XDECREF(__pyx_v_reconstructed_iter);
  7565. __Pyx_XDECREF(__pyx_v_reconstructed);
  7566. __Pyx_XDECREF(__pyx_v_reconst);
  7567. __Pyx_XDECREF(__pyx_v_orig);
  7568. __Pyx_XDECREF(__pyx_v_splits);
  7569. __Pyx_XDECREF(__pyx_v_cubic);
  7570. __Pyx_XDECREF(__pyx_v_curves);
  7571. __Pyx_XDECREF(__pyx_gb_9fontTools_5qu2cu_5qu2cu_16spline_to_curves_2generator1);
  7572. __Pyx_XGIVEREF(__pyx_r);
  7573. __Pyx_RefNannyFinishContext();
  7574. return __pyx_r;
  7575. }
  7576. /* "fontTools/qu2cu/qu2cu.py":414
  7577. *
  7578. *
  7579. * def main(): # <<<<<<<<<<<<<<
  7580. * from fontTools.cu2qu.benchmark import generate_curve
  7581. * from fontTools.cu2qu import curve_to_quadratic
  7582. */
  7583. /* Python wrapper */
  7584. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_15main(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
  7585. PyDoc_STRVAR(__pyx_doc_9fontTools_5qu2cu_5qu2cu_14main, "main()");
  7586. static PyMethodDef __pyx_mdef_9fontTools_5qu2cu_5qu2cu_15main = {"main", (PyCFunction)__pyx_pw_9fontTools_5qu2cu_5qu2cu_15main, METH_NOARGS, __pyx_doc_9fontTools_5qu2cu_5qu2cu_14main};
  7587. static PyObject *__pyx_pw_9fontTools_5qu2cu_5qu2cu_15main(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  7588. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  7589. PyObject *__pyx_r = 0;
  7590. __Pyx_RefNannyDeclarations
  7591. __Pyx_RefNannySetupContext("main (wrapper)", 0);
  7592. __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  7593. __pyx_r = __pyx_pf_9fontTools_5qu2cu_5qu2cu_14main(__pyx_self);
  7594. /* function exit code */
  7595. __Pyx_RefNannyFinishContext();
  7596. return __pyx_r;
  7597. }
  7598. static PyObject *__pyx_pf_9fontTools_5qu2cu_5qu2cu_14main(CYTHON_UNUSED PyObject *__pyx_self) {
  7599. PyObject *__pyx_v_generate_curve = NULL;
  7600. PyObject *__pyx_v_curve_to_quadratic = NULL;
  7601. double __pyx_v_tolerance;
  7602. double __pyx_v_reconstruct_tolerance;
  7603. PyObject *__pyx_v_curve = NULL;
  7604. PyObject *__pyx_v_quadratics = NULL;
  7605. PyObject *__pyx_v_curves = NULL;
  7606. PyObject *__pyx_r = NULL;
  7607. __Pyx_RefNannyDeclarations
  7608. PyObject *__pyx_t_1 = NULL;
  7609. PyObject *__pyx_t_2 = NULL;
  7610. Py_ssize_t __pyx_t_3;
  7611. PyObject *__pyx_t_4 = NULL;
  7612. PyObject *__pyx_t_5 = NULL;
  7613. size_t __pyx_t_6;
  7614. PyObject *__pyx_t_7 = NULL;
  7615. PyObject *__pyx_t_8 = NULL;
  7616. int __pyx_lineno = 0;
  7617. const char *__pyx_filename = NULL;
  7618. int __pyx_clineno = 0;
  7619. __Pyx_RefNannySetupContext("main", 0);
  7620. /* "fontTools/qu2cu/qu2cu.py":415
  7621. *
  7622. * def main():
  7623. * from fontTools.cu2qu.benchmark import generate_curve # <<<<<<<<<<<<<<
  7624. * from fontTools.cu2qu import curve_to_quadratic
  7625. *
  7626. */
  7627. {
  7628. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_generate_curve};
  7629. __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, 415, __pyx_L1_error)
  7630. }
  7631. __pyx_t_1 = __pyx_t_2;
  7632. __Pyx_GOTREF(__pyx_t_1);
  7633. {
  7634. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_generate_curve};
  7635. __pyx_t_3 = 0; {
  7636. __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_1, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 415, __pyx_L1_error)
  7637. __Pyx_GOTREF(__pyx_t_4);
  7638. switch (__pyx_t_3) {
  7639. case 0:
  7640. __Pyx_INCREF(__pyx_t_4);
  7641. __pyx_v_generate_curve = __pyx_t_4;
  7642. break;
  7643. default:;
  7644. }
  7645. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7646. }
  7647. }
  7648. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7649. /* "fontTools/qu2cu/qu2cu.py":416
  7650. * def main():
  7651. * from fontTools.cu2qu.benchmark import generate_curve
  7652. * from fontTools.cu2qu import curve_to_quadratic # <<<<<<<<<<<<<<
  7653. *
  7654. * tolerance = 0.05
  7655. */
  7656. {
  7657. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_curve_to_quadratic};
  7658. __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, 416, __pyx_L1_error)
  7659. }
  7660. __pyx_t_1 = __pyx_t_2;
  7661. __Pyx_GOTREF(__pyx_t_1);
  7662. {
  7663. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_curve_to_quadratic};
  7664. __pyx_t_3 = 0; {
  7665. __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_1, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 416, __pyx_L1_error)
  7666. __Pyx_GOTREF(__pyx_t_4);
  7667. switch (__pyx_t_3) {
  7668. case 0:
  7669. __Pyx_INCREF(__pyx_t_4);
  7670. __pyx_v_curve_to_quadratic = __pyx_t_4;
  7671. break;
  7672. default:;
  7673. }
  7674. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7675. }
  7676. }
  7677. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7678. /* "fontTools/qu2cu/qu2cu.py":418
  7679. * from fontTools.cu2qu import curve_to_quadratic
  7680. *
  7681. * tolerance = 0.05 # <<<<<<<<<<<<<<
  7682. * reconstruct_tolerance = tolerance * 1
  7683. * curve = generate_curve()
  7684. */
  7685. __pyx_v_tolerance = 0.05;
  7686. /* "fontTools/qu2cu/qu2cu.py":419
  7687. *
  7688. * tolerance = 0.05
  7689. * reconstruct_tolerance = tolerance * 1 # <<<<<<<<<<<<<<
  7690. * curve = generate_curve()
  7691. * quadratics = curve_to_quadratic(curve, tolerance)
  7692. */
  7693. __pyx_v_reconstruct_tolerance = (__pyx_v_tolerance * 1.0);
  7694. /* "fontTools/qu2cu/qu2cu.py":420
  7695. * tolerance = 0.05
  7696. * reconstruct_tolerance = tolerance * 1
  7697. * curve = generate_curve() # <<<<<<<<<<<<<<
  7698. * quadratics = curve_to_quadratic(curve, tolerance)
  7699. * print(
  7700. */
  7701. __pyx_t_4 = NULL;
  7702. __Pyx_INCREF(__pyx_v_generate_curve);
  7703. __pyx_t_5 = __pyx_v_generate_curve;
  7704. __pyx_t_6 = 1;
  7705. #if CYTHON_UNPACK_METHODS
  7706. if (unlikely(PyMethod_Check(__pyx_t_5))) {
  7707. __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
  7708. assert(__pyx_t_4);
  7709. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
  7710. __Pyx_INCREF(__pyx_t_4);
  7711. __Pyx_INCREF(__pyx__function);
  7712. __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
  7713. __pyx_t_6 = 0;
  7714. }
  7715. #endif
  7716. {
  7717. PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
  7718. __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));
  7719. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7720. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7721. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error)
  7722. __Pyx_GOTREF(__pyx_t_1);
  7723. }
  7724. __pyx_v_curve = __pyx_t_1;
  7725. __pyx_t_1 = 0;
  7726. /* "fontTools/qu2cu/qu2cu.py":421
  7727. * reconstruct_tolerance = tolerance * 1
  7728. * curve = generate_curve()
  7729. * quadratics = curve_to_quadratic(curve, tolerance) # <<<<<<<<<<<<<<
  7730. * print(
  7731. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance)
  7732. */
  7733. __pyx_t_5 = NULL;
  7734. __Pyx_INCREF(__pyx_v_curve_to_quadratic);
  7735. __pyx_t_4 = __pyx_v_curve_to_quadratic;
  7736. __pyx_t_7 = PyFloat_FromDouble(__pyx_v_tolerance); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 421, __pyx_L1_error)
  7737. __Pyx_GOTREF(__pyx_t_7);
  7738. __pyx_t_6 = 1;
  7739. #if CYTHON_UNPACK_METHODS
  7740. if (unlikely(PyMethod_Check(__pyx_t_4))) {
  7741. __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
  7742. assert(__pyx_t_5);
  7743. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
  7744. __Pyx_INCREF(__pyx_t_5);
  7745. __Pyx_INCREF(__pyx__function);
  7746. __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
  7747. __pyx_t_6 = 0;
  7748. }
  7749. #endif
  7750. {
  7751. PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_v_curve, __pyx_t_7};
  7752. __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));
  7753. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7754. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7755. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7756. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error)
  7757. __Pyx_GOTREF(__pyx_t_1);
  7758. }
  7759. __pyx_v_quadratics = __pyx_t_1;
  7760. __pyx_t_1 = 0;
  7761. /* "fontTools/qu2cu/qu2cu.py":422
  7762. * curve = generate_curve()
  7763. * quadratics = curve_to_quadratic(curve, tolerance)
  7764. * print( # <<<<<<<<<<<<<<
  7765. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance)
  7766. * )
  7767. */
  7768. __pyx_t_4 = NULL;
  7769. /* "fontTools/qu2cu/qu2cu.py":423
  7770. * quadratics = curve_to_quadratic(curve, tolerance)
  7771. * print(
  7772. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance) # <<<<<<<<<<<<<<
  7773. * )
  7774. * print("One random cubic turned into %d quadratics." % len(quadratics))
  7775. */
  7776. __pyx_t_7 = PyFloat_FromDouble(__pyx_v_tolerance); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 423, __pyx_L1_error)
  7777. __Pyx_GOTREF(__pyx_t_7);
  7778. __pyx_t_5 = PyFloat_FromDouble(__pyx_v_reconstruct_tolerance); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L1_error)
  7779. __Pyx_GOTREF(__pyx_t_5);
  7780. __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 423, __pyx_L1_error)
  7781. __Pyx_GOTREF(__pyx_t_8);
  7782. __Pyx_GIVEREF(__pyx_t_7);
  7783. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 423, __pyx_L1_error);
  7784. __Pyx_GIVEREF(__pyx_t_5);
  7785. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 423, __pyx_L1_error);
  7786. __pyx_t_7 = 0;
  7787. __pyx_t_5 = 0;
  7788. __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, 423, __pyx_L1_error)
  7789. __Pyx_GOTREF(__pyx_t_5);
  7790. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7791. __pyx_t_6 = 1;
  7792. {
  7793. PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_5};
  7794. __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));
  7795. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7796. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7797. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 422, __pyx_L1_error)
  7798. __Pyx_GOTREF(__pyx_t_1);
  7799. }
  7800. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7801. /* "fontTools/qu2cu/qu2cu.py":425
  7802. * "cu2qu tolerance %g. qu2cu tolerance %g." % (tolerance, reconstruct_tolerance)
  7803. * )
  7804. * print("One random cubic turned into %d quadratics." % len(quadratics)) # <<<<<<<<<<<<<<
  7805. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance)
  7806. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7807. */
  7808. __pyx_t_5 = NULL;
  7809. __pyx_t_3 = PyObject_Length(__pyx_v_quadratics); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 425, __pyx_L1_error)
  7810. __pyx_t_4 = PyLong_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 425, __pyx_L1_error)
  7811. __Pyx_GOTREF(__pyx_t_4);
  7812. __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, 425, __pyx_L1_error)
  7813. __Pyx_GOTREF(__pyx_t_8);
  7814. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7815. __pyx_t_6 = 1;
  7816. {
  7817. PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_8};
  7818. __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));
  7819. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7820. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  7821. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 425, __pyx_L1_error)
  7822. __Pyx_GOTREF(__pyx_t_1);
  7823. }
  7824. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7825. /* "fontTools/qu2cu/qu2cu.py":426
  7826. * )
  7827. * print("One random cubic turned into %d quadratics." % len(quadratics))
  7828. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance) # <<<<<<<<<<<<<<
  7829. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7830. * print("Original curve:", curve)
  7831. */
  7832. __pyx_t_8 = NULL;
  7833. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_quadratic_to_curves); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 426, __pyx_L1_error)
  7834. __Pyx_GOTREF(__pyx_t_5);
  7835. __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 426, __pyx_L1_error)
  7836. __Pyx_GOTREF(__pyx_t_4);
  7837. __Pyx_INCREF(__pyx_v_quadratics);
  7838. __Pyx_GIVEREF(__pyx_v_quadratics);
  7839. if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_quadratics) != (0)) __PYX_ERR(0, 426, __pyx_L1_error);
  7840. __pyx_t_7 = PyFloat_FromDouble(__pyx_v_reconstruct_tolerance); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 426, __pyx_L1_error)
  7841. __Pyx_GOTREF(__pyx_t_7);
  7842. __pyx_t_6 = 1;
  7843. #if CYTHON_UNPACK_METHODS
  7844. if (unlikely(PyMethod_Check(__pyx_t_5))) {
  7845. __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
  7846. assert(__pyx_t_8);
  7847. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
  7848. __Pyx_INCREF(__pyx_t_8);
  7849. __Pyx_INCREF(__pyx__function);
  7850. __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
  7851. __pyx_t_6 = 0;
  7852. }
  7853. #endif
  7854. {
  7855. PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_t_4, __pyx_t_7};
  7856. __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));
  7857. __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
  7858. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7859. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7860. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  7861. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 426, __pyx_L1_error)
  7862. __Pyx_GOTREF(__pyx_t_1);
  7863. }
  7864. __pyx_v_curves = __pyx_t_1;
  7865. __pyx_t_1 = 0;
  7866. /* "fontTools/qu2cu/qu2cu.py":427
  7867. * print("One random cubic turned into %d quadratics." % len(quadratics))
  7868. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance)
  7869. * print("Those quadratics turned back into %d cubics. " % len(curves)) # <<<<<<<<<<<<<<
  7870. * print("Original curve:", curve)
  7871. * print("Reconstructed curve(s):", curves)
  7872. */
  7873. __pyx_t_5 = NULL;
  7874. __pyx_t_3 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 427, __pyx_L1_error)
  7875. __pyx_t_7 = PyLong_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 427, __pyx_L1_error)
  7876. __Pyx_GOTREF(__pyx_t_7);
  7877. __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, 427, __pyx_L1_error)
  7878. __Pyx_GOTREF(__pyx_t_4);
  7879. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  7880. __pyx_t_6 = 1;
  7881. {
  7882. PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4};
  7883. __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));
  7884. __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
  7885. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7886. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 427, __pyx_L1_error)
  7887. __Pyx_GOTREF(__pyx_t_1);
  7888. }
  7889. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7890. /* "fontTools/qu2cu/qu2cu.py":428
  7891. * curves = quadratic_to_curves([quadratics], reconstruct_tolerance)
  7892. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7893. * print("Original curve:", curve) # <<<<<<<<<<<<<<
  7894. * print("Reconstructed curve(s):", curves)
  7895. *
  7896. */
  7897. __pyx_t_4 = NULL;
  7898. __pyx_t_6 = 1;
  7899. {
  7900. PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Original_curve, __pyx_v_curve};
  7901. __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));
  7902. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7903. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 428, __pyx_L1_error)
  7904. __Pyx_GOTREF(__pyx_t_1);
  7905. }
  7906. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7907. /* "fontTools/qu2cu/qu2cu.py":429
  7908. * print("Those quadratics turned back into %d cubics. " % len(curves))
  7909. * print("Original curve:", curve)
  7910. * print("Reconstructed curve(s):", curves) # <<<<<<<<<<<<<<
  7911. *
  7912. *
  7913. */
  7914. __pyx_t_4 = NULL;
  7915. __pyx_t_6 = 1;
  7916. {
  7917. PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Reconstructed_curve_s, __pyx_v_curves};
  7918. __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));
  7919. __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
  7920. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 429, __pyx_L1_error)
  7921. __Pyx_GOTREF(__pyx_t_1);
  7922. }
  7923. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  7924. /* "fontTools/qu2cu/qu2cu.py":414
  7925. *
  7926. *
  7927. * def main(): # <<<<<<<<<<<<<<
  7928. * from fontTools.cu2qu.benchmark import generate_curve
  7929. * from fontTools.cu2qu import curve_to_quadratic
  7930. */
  7931. /* function exit code */
  7932. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  7933. goto __pyx_L0;
  7934. __pyx_L1_error:;
  7935. __Pyx_XDECREF(__pyx_t_1);
  7936. __Pyx_XDECREF(__pyx_t_4);
  7937. __Pyx_XDECREF(__pyx_t_5);
  7938. __Pyx_XDECREF(__pyx_t_7);
  7939. __Pyx_XDECREF(__pyx_t_8);
  7940. __Pyx_AddTraceback("fontTools.qu2cu.qu2cu.main", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7941. __pyx_r = NULL;
  7942. __pyx_L0:;
  7943. __Pyx_XDECREF(__pyx_v_generate_curve);
  7944. __Pyx_XDECREF(__pyx_v_curve_to_quadratic);
  7945. __Pyx_XDECREF(__pyx_v_curve);
  7946. __Pyx_XDECREF(__pyx_v_quadratics);
  7947. __Pyx_XDECREF(__pyx_v_curves);
  7948. __Pyx_XGIVEREF(__pyx_r);
  7949. __Pyx_RefNannyFinishContext();
  7950. return __pyx_r;
  7951. }
  7952. /* #### Code section: module_exttypes ### */
  7953. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  7954. PyObject *o;
  7955. #if CYTHON_USE_FREELISTS
  7956. 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))))
  7957. {
  7958. 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];
  7959. #if CYTHON_USE_TYPE_SPECS
  7960. Py_DECREF(Py_TYPE(o));
  7961. #endif
  7962. memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr));
  7963. #if CYTHON_COMPILING_IN_LIMITED_API
  7964. (void) PyObject_Init(o, t);
  7965. #else
  7966. (void) PyObject_INIT(o, t);
  7967. #endif
  7968. PyObject_GC_Track(o);
  7969. } else
  7970. #endif
  7971. {
  7972. o = __Pyx_AllocateExtensionType(t, 1);
  7973. if (unlikely(!o)) return 0;
  7974. }
  7975. return o;
  7976. }
  7977. static void __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyObject *o) {
  7978. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)o;
  7979. #if CYTHON_USE_TP_FINALIZE
  7980. if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
  7981. if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr) {
  7982. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7983. }
  7984. }
  7985. #endif
  7986. PyObject_GC_UnTrack(o);
  7987. Py_CLEAR(p->__pyx_genexpr_arg_0);
  7988. Py_CLEAR(p->__pyx_v_c);
  7989. Py_CLEAR(p->__pyx_t_0);
  7990. #if CYTHON_USE_FREELISTS
  7991. 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))))
  7992. {
  7993. __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);
  7994. } else
  7995. #endif
  7996. {
  7997. PyTypeObject *tp = Py_TYPE(o);
  7998. #if CYTHON_USE_TYPE_SLOTS
  7999. (*tp->tp_free)(o);
  8000. #else
  8001. {
  8002. freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
  8003. if (tp_free) tp_free(o);
  8004. }
  8005. #endif
  8006. #if CYTHON_USE_TYPE_SPECS
  8007. Py_DECREF(tp);
  8008. #endif
  8009. }
  8010. }
  8011. static int __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr(PyObject *o, visitproc v, void *a) {
  8012. int e;
  8013. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr *)o;
  8014. {
  8015. e = __Pyx_call_type_traverse(o, 1, v, a);
  8016. if (e) return e;
  8017. }
  8018. if (p->__pyx_genexpr_arg_0) {
  8019. e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  8020. }
  8021. if (p->__pyx_v_c) {
  8022. e = (*v)(p->__pyx_v_c, a); if (e) return e;
  8023. }
  8024. if (p->__pyx_t_0) {
  8025. e = (*v)(p->__pyx_t_0, a); if (e) return e;
  8026. }
  8027. return 0;
  8028. }
  8029. #if CYTHON_USE_TYPE_SPECS
  8030. static PyType_Slot __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_slots[] = {
  8031. {Py_tp_dealloc, (void *)__pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr},
  8032. {Py_tp_traverse, (void *)__pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr},
  8033. {Py_tp_new, (void *)__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr},
  8034. {0, 0},
  8035. };
  8036. static PyType_Spec __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_spec = {
  8037. "fontTools.qu2cu.qu2cu.__pyx_scope_struct__genexpr",
  8038. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr),
  8039. 0,
  8040. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  8041. __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr_slots,
  8042. };
  8043. #else
  8044. static PyTypeObject __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr = {
  8045. PyVarObject_HEAD_INIT(0, 0)
  8046. "fontTools.qu2cu.qu2cu.""__pyx_scope_struct__genexpr", /*tp_name*/
  8047. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr), /*tp_basicsize*/
  8048. 0, /*tp_itemsize*/
  8049. __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, /*tp_dealloc*/
  8050. 0, /*tp_vectorcall_offset*/
  8051. 0, /*tp_getattr*/
  8052. 0, /*tp_setattr*/
  8053. 0, /*tp_as_async*/
  8054. 0, /*tp_repr*/
  8055. 0, /*tp_as_number*/
  8056. 0, /*tp_as_sequence*/
  8057. 0, /*tp_as_mapping*/
  8058. 0, /*tp_hash*/
  8059. 0, /*tp_call*/
  8060. 0, /*tp_str*/
  8061. 0, /*tp_getattro*/
  8062. 0, /*tp_setattro*/
  8063. 0, /*tp_as_buffer*/
  8064. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  8065. 0, /*tp_doc*/
  8066. __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, /*tp_traverse*/
  8067. 0, /*tp_clear*/
  8068. 0, /*tp_richcompare*/
  8069. 0, /*tp_weaklistoffset*/
  8070. 0, /*tp_iter*/
  8071. 0, /*tp_iternext*/
  8072. 0, /*tp_methods*/
  8073. 0, /*tp_members*/
  8074. 0, /*tp_getset*/
  8075. 0, /*tp_base*/
  8076. 0, /*tp_dict*/
  8077. 0, /*tp_descr_get*/
  8078. 0, /*tp_descr_set*/
  8079. #if !CYTHON_USE_TYPE_SPECS
  8080. 0, /*tp_dictoffset*/
  8081. #endif
  8082. 0, /*tp_init*/
  8083. 0, /*tp_alloc*/
  8084. __pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr, /*tp_new*/
  8085. 0, /*tp_free*/
  8086. 0, /*tp_is_gc*/
  8087. 0, /*tp_bases*/
  8088. 0, /*tp_mro*/
  8089. 0, /*tp_cache*/
  8090. 0, /*tp_subclasses*/
  8091. 0, /*tp_weaklist*/
  8092. 0, /*tp_del*/
  8093. 0, /*tp_version_tag*/
  8094. #if CYTHON_USE_TP_FINALIZE
  8095. 0, /*tp_finalize*/
  8096. #else
  8097. NULL, /*tp_finalize*/
  8098. #endif
  8099. #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  8100. 0, /*tp_vectorcall*/
  8101. #endif
  8102. #if __PYX_NEED_TP_PRINT_SLOT == 1
  8103. 0, /*tp_print*/
  8104. #endif
  8105. #if PY_VERSION_HEX >= 0x030C0000
  8106. 0, /*tp_watched*/
  8107. #endif
  8108. #if PY_VERSION_HEX >= 0x030d00A4
  8109. 0, /*tp_versions_used*/
  8110. #endif
  8111. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  8112. 0, /*tp_pypy_flags*/
  8113. #endif
  8114. };
  8115. #endif
  8116. static PyObject *__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  8117. PyObject *o;
  8118. #if CYTHON_USE_FREELISTS
  8119. 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))))
  8120. {
  8121. 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];
  8122. #if CYTHON_USE_TYPE_SPECS
  8123. Py_DECREF(Py_TYPE(o));
  8124. #endif
  8125. memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr));
  8126. #if CYTHON_COMPILING_IN_LIMITED_API
  8127. (void) PyObject_Init(o, t);
  8128. #else
  8129. (void) PyObject_INIT(o, t);
  8130. #endif
  8131. PyObject_GC_Track(o);
  8132. } else
  8133. #endif
  8134. {
  8135. o = __Pyx_AllocateExtensionType(t, 1);
  8136. if (unlikely(!o)) return 0;
  8137. }
  8138. return o;
  8139. }
  8140. static void __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyObject *o) {
  8141. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)o;
  8142. #if CYTHON_USE_TP_FINALIZE
  8143. if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
  8144. if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr) {
  8145. if (PyObject_CallFinalizerFromDealloc(o)) return;
  8146. }
  8147. }
  8148. #endif
  8149. PyObject_GC_UnTrack(o);
  8150. Py_CLEAR(p->__pyx_genexpr_arg_0);
  8151. Py_CLEAR(p->__pyx_t_0);
  8152. #if CYTHON_USE_FREELISTS
  8153. 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))))
  8154. {
  8155. __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);
  8156. } else
  8157. #endif
  8158. {
  8159. PyTypeObject *tp = Py_TYPE(o);
  8160. #if CYTHON_USE_TYPE_SLOTS
  8161. (*tp->tp_free)(o);
  8162. #else
  8163. {
  8164. freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
  8165. if (tp_free) tp_free(o);
  8166. }
  8167. #endif
  8168. #if CYTHON_USE_TYPE_SPECS
  8169. Py_DECREF(tp);
  8170. #endif
  8171. }
  8172. }
  8173. static int __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) {
  8174. int e;
  8175. struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr *)o;
  8176. {
  8177. e = __Pyx_call_type_traverse(o, 1, v, a);
  8178. if (e) return e;
  8179. }
  8180. if (p->__pyx_genexpr_arg_0) {
  8181. e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  8182. }
  8183. if (p->__pyx_t_0) {
  8184. e = (*v)(p->__pyx_t_0, a); if (e) return e;
  8185. }
  8186. return 0;
  8187. }
  8188. #if CYTHON_USE_TYPE_SPECS
  8189. static PyType_Slot __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_slots[] = {
  8190. {Py_tp_dealloc, (void *)__pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr},
  8191. {Py_tp_traverse, (void *)__pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr},
  8192. {Py_tp_new, (void *)__pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr},
  8193. {0, 0},
  8194. };
  8195. static PyType_Spec __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_spec = {
  8196. "fontTools.qu2cu.qu2cu.__pyx_scope_struct_1_genexpr",
  8197. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr),
  8198. 0,
  8199. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  8200. __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr_slots,
  8201. };
  8202. #else
  8203. static PyTypeObject __pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr = {
  8204. PyVarObject_HEAD_INIT(0, 0)
  8205. "fontTools.qu2cu.qu2cu.""__pyx_scope_struct_1_genexpr", /*tp_name*/
  8206. sizeof(struct __pyx_obj_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr), /*tp_basicsize*/
  8207. 0, /*tp_itemsize*/
  8208. __pyx_tp_dealloc_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, /*tp_dealloc*/
  8209. 0, /*tp_vectorcall_offset*/
  8210. 0, /*tp_getattr*/
  8211. 0, /*tp_setattr*/
  8212. 0, /*tp_as_async*/
  8213. 0, /*tp_repr*/
  8214. 0, /*tp_as_number*/
  8215. 0, /*tp_as_sequence*/
  8216. 0, /*tp_as_mapping*/
  8217. 0, /*tp_hash*/
  8218. 0, /*tp_call*/
  8219. 0, /*tp_str*/
  8220. 0, /*tp_getattro*/
  8221. 0, /*tp_setattro*/
  8222. 0, /*tp_as_buffer*/
  8223. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  8224. 0, /*tp_doc*/
  8225. __pyx_tp_traverse_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, /*tp_traverse*/
  8226. 0, /*tp_clear*/
  8227. 0, /*tp_richcompare*/
  8228. 0, /*tp_weaklistoffset*/
  8229. 0, /*tp_iter*/
  8230. 0, /*tp_iternext*/
  8231. 0, /*tp_methods*/
  8232. 0, /*tp_members*/
  8233. 0, /*tp_getset*/
  8234. 0, /*tp_base*/
  8235. 0, /*tp_dict*/
  8236. 0, /*tp_descr_get*/
  8237. 0, /*tp_descr_set*/
  8238. #if !CYTHON_USE_TYPE_SPECS
  8239. 0, /*tp_dictoffset*/
  8240. #endif
  8241. 0, /*tp_init*/
  8242. 0, /*tp_alloc*/
  8243. __pyx_tp_new_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr, /*tp_new*/
  8244. 0, /*tp_free*/
  8245. 0, /*tp_is_gc*/
  8246. 0, /*tp_bases*/
  8247. 0, /*tp_mro*/
  8248. 0, /*tp_cache*/
  8249. 0, /*tp_subclasses*/
  8250. 0, /*tp_weaklist*/
  8251. 0, /*tp_del*/
  8252. 0, /*tp_version_tag*/
  8253. #if CYTHON_USE_TP_FINALIZE
  8254. 0, /*tp_finalize*/
  8255. #else
  8256. NULL, /*tp_finalize*/
  8257. #endif
  8258. #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  8259. 0, /*tp_vectorcall*/
  8260. #endif
  8261. #if __PYX_NEED_TP_PRINT_SLOT == 1
  8262. 0, /*tp_print*/
  8263. #endif
  8264. #if PY_VERSION_HEX >= 0x030C0000
  8265. 0, /*tp_watched*/
  8266. #endif
  8267. #if PY_VERSION_HEX >= 0x030d00A4
  8268. 0, /*tp_versions_used*/
  8269. #endif
  8270. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  8271. 0, /*tp_pypy_flags*/
  8272. #endif
  8273. };
  8274. #endif
  8275. static PyMethodDef __pyx_methods[] = {
  8276. {0, 0, 0, 0}
  8277. };
  8278. /* #### Code section: initfunc_declarations ### */
  8279. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8280. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8281. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/
  8282. static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8283. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8284. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8285. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8286. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8287. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8288. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8289. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8290. static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/
  8291. /* #### Code section: init_module ### */
  8292. static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) {
  8293. __Pyx_RefNannyDeclarations
  8294. CYTHON_UNUSED_VAR(__pyx_mstate);
  8295. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  8296. /*--- Global init code ---*/
  8297. __Pyx_RefNannyFinishContext();
  8298. return 0;
  8299. }
  8300. static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) {
  8301. __Pyx_RefNannyDeclarations
  8302. CYTHON_UNUSED_VAR(__pyx_mstate);
  8303. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  8304. /*--- Variable export code ---*/
  8305. __Pyx_RefNannyFinishContext();
  8306. return 0;
  8307. }
  8308. static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) {
  8309. __Pyx_RefNannyDeclarations
  8310. CYTHON_UNUSED_VAR(__pyx_mstate);
  8311. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  8312. /*--- Function export code ---*/
  8313. __Pyx_RefNannyFinishContext();
  8314. return 0;
  8315. }
  8316. static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) {
  8317. __Pyx_RefNannyDeclarations
  8318. CYTHON_UNUSED_VAR(__pyx_mstate);
  8319. int __pyx_lineno = 0;
  8320. const char *__pyx_filename = NULL;
  8321. int __pyx_clineno = 0;
  8322. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  8323. /*--- Type init code ---*/
  8324. #if CYTHON_USE_TYPE_SPECS
  8325. __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, 263, __pyx_L1_error)
  8326. 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, 263, __pyx_L1_error)
  8327. #else
  8328. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr = &__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr;
  8329. #endif
  8330. #if !CYTHON_COMPILING_IN_LIMITED_API
  8331. #endif
  8332. #if !CYTHON_USE_TYPE_SPECS
  8333. if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr) < (0)) __PYX_ERR(0, 263, __pyx_L1_error)
  8334. #endif
  8335. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8336. PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr);
  8337. #endif
  8338. #if !CYTHON_COMPILING_IN_LIMITED_API
  8339. 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)) {
  8340. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct__genexpr->tp_getattro = PyObject_GenericGetAttr;
  8341. }
  8342. #endif
  8343. #if CYTHON_USE_TYPE_SPECS
  8344. __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, 368, __pyx_L1_error)
  8345. 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, 368, __pyx_L1_error)
  8346. #else
  8347. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr = &__pyx_type_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr;
  8348. #endif
  8349. #if !CYTHON_COMPILING_IN_LIMITED_API
  8350. #endif
  8351. #if !CYTHON_USE_TYPE_SPECS
  8352. if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr) < (0)) __PYX_ERR(0, 368, __pyx_L1_error)
  8353. #endif
  8354. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8355. PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr);
  8356. #endif
  8357. #if !CYTHON_COMPILING_IN_LIMITED_API
  8358. 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)) {
  8359. __pyx_mstate->__pyx_ptype_9fontTools_5qu2cu_5qu2cu___pyx_scope_struct_1_genexpr->tp_getattro = PyObject_GenericGetAttr;
  8360. }
  8361. #endif
  8362. __Pyx_RefNannyFinishContext();
  8363. return 0;
  8364. __pyx_L1_error:;
  8365. __Pyx_RefNannyFinishContext();
  8366. return -1;
  8367. }
  8368. static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) {
  8369. __Pyx_RefNannyDeclarations
  8370. CYTHON_UNUSED_VAR(__pyx_mstate);
  8371. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  8372. /*--- Type import code ---*/
  8373. __Pyx_RefNannyFinishContext();
  8374. return 0;
  8375. }
  8376. static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) {
  8377. __Pyx_RefNannyDeclarations
  8378. CYTHON_UNUSED_VAR(__pyx_mstate);
  8379. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  8380. /*--- Variable import code ---*/
  8381. __Pyx_RefNannyFinishContext();
  8382. return 0;
  8383. }
  8384. static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) {
  8385. __Pyx_RefNannyDeclarations
  8386. CYTHON_UNUSED_VAR(__pyx_mstate);
  8387. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  8388. /*--- Function import code ---*/
  8389. __Pyx_RefNannyFinishContext();
  8390. return 0;
  8391. }
  8392. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8393. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  8394. static int __pyx_pymod_exec_qu2cu(PyObject* module); /*proto*/
  8395. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  8396. {Py_mod_create, (void*)__pyx_pymod_create},
  8397. {Py_mod_exec, (void*)__pyx_pymod_exec_qu2cu},
  8398. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8399. {Py_mod_gil, __Pyx_FREETHREADING_COMPATIBLE},
  8400. #endif
  8401. #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE
  8402. {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
  8403. #endif
  8404. {0, NULL}
  8405. };
  8406. #endif
  8407. #ifdef __cplusplus
  8408. namespace {
  8409. struct PyModuleDef __pyx_moduledef =
  8410. #else
  8411. static struct PyModuleDef __pyx_moduledef =
  8412. #endif
  8413. {
  8414. PyModuleDef_HEAD_INIT,
  8415. "qu2cu",
  8416. 0, /* m_doc */
  8417. #if CYTHON_USE_MODULE_STATE
  8418. sizeof(__pyx_mstatetype), /* m_size */
  8419. #else
  8420. (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */
  8421. #endif
  8422. __pyx_methods /* m_methods */,
  8423. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8424. __pyx_moduledef_slots, /* m_slots */
  8425. #else
  8426. NULL, /* m_reload */
  8427. #endif
  8428. #if CYTHON_USE_MODULE_STATE
  8429. __pyx_m_traverse, /* m_traverse */
  8430. __pyx_m_clear, /* m_clear */
  8431. NULL /* m_free */
  8432. #else
  8433. NULL, /* m_traverse */
  8434. NULL, /* m_clear */
  8435. NULL /* m_free */
  8436. #endif
  8437. };
  8438. #ifdef __cplusplus
  8439. } /* anonymous namespace */
  8440. #endif
  8441. /* PyModInitFuncType */
  8442. #ifndef CYTHON_NO_PYINIT_EXPORT
  8443. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  8444. #else
  8445. #ifdef __cplusplus
  8446. #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
  8447. #else
  8448. #define __Pyx_PyMODINIT_FUNC PyObject *
  8449. #endif
  8450. #endif
  8451. __Pyx_PyMODINIT_FUNC PyInit_qu2cu(void) CYTHON_SMALL_CODE; /*proto*/
  8452. __Pyx_PyMODINIT_FUNC PyInit_qu2cu(void)
  8453. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8454. {
  8455. return PyModuleDef_Init(&__pyx_moduledef);
  8456. }
  8457. /* ModuleCreationPEP489 */
  8458. #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  8459. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  8460. static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) {
  8461. {
  8462. PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think
  8463. if (!module) {
  8464. PyErr_Clear(); // just try the 3.8-3.12 version
  8465. module = PyImport_ImportModule("_xxsubinterpreters");
  8466. if (!module) goto bad;
  8467. }
  8468. PyObject *current = PyObject_CallMethod(module, "get_current", NULL);
  8469. Py_DECREF(module);
  8470. if (!current) goto bad;
  8471. if (PyTuple_Check(current)) {
  8472. PyObject *new_current = PySequence_GetItem(current, 0);
  8473. Py_DECREF(current);
  8474. current = new_current;
  8475. if (!new_current) goto bad;
  8476. }
  8477. long long as_c_int = PyLong_AsLongLong(current);
  8478. Py_DECREF(current);
  8479. return as_c_int;
  8480. }
  8481. bad:
  8482. PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n");
  8483. return -1;
  8484. }
  8485. #endif
  8486. #if !CYTHON_USE_MODULE_STATE
  8487. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  8488. static PY_INT64_T main_interpreter_id = -1;
  8489. #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  8490. PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  8491. #elif CYTHON_COMPILING_IN_GRAAL
  8492. PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  8493. #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  8494. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  8495. PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId();
  8496. #elif CYTHON_COMPILING_IN_LIMITED_API
  8497. PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get());
  8498. #else
  8499. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  8500. #endif
  8501. if (unlikely(current_id == -1)) {
  8502. return -1;
  8503. }
  8504. if (main_interpreter_id == -1) {
  8505. main_interpreter_id = current_id;
  8506. return 0;
  8507. } else if (unlikely(main_interpreter_id != current_id)) {
  8508. PyErr_SetString(
  8509. PyExc_ImportError,
  8510. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  8511. return -1;
  8512. }
  8513. return 0;
  8514. }
  8515. #endif
  8516. 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)
  8517. {
  8518. PyObject *value = PyObject_GetAttrString(spec, from_name);
  8519. int result = 0;
  8520. if (likely(value)) {
  8521. if (allow_none || value != Py_None) {
  8522. result = PyDict_SetItemString(moddict, to_name, value);
  8523. }
  8524. Py_DECREF(value);
  8525. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  8526. PyErr_Clear();
  8527. } else {
  8528. result = -1;
  8529. }
  8530. return result;
  8531. }
  8532. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) {
  8533. PyObject *module = NULL, *moddict, *modname;
  8534. CYTHON_UNUSED_VAR(def);
  8535. #if !CYTHON_USE_MODULE_STATE
  8536. if (__Pyx_check_single_interpreter())
  8537. return NULL;
  8538. #endif
  8539. if (__pyx_m)
  8540. return __Pyx_NewRef(__pyx_m);
  8541. modname = PyObject_GetAttrString(spec, "name");
  8542. if (unlikely(!modname)) goto bad;
  8543. module = PyModule_NewObject(modname);
  8544. Py_DECREF(modname);
  8545. if (unlikely(!module)) goto bad;
  8546. moddict = PyModule_GetDict(module);
  8547. if (unlikely(!moddict)) goto bad;
  8548. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  8549. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  8550. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  8551. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  8552. return module;
  8553. bad:
  8554. Py_XDECREF(module);
  8555. return NULL;
  8556. }
  8557. static CYTHON_SMALL_CODE int __pyx_pymod_exec_qu2cu(PyObject *__pyx_pyinit_module)
  8558. #endif
  8559. {
  8560. int stringtab_initialized = 0;
  8561. #if CYTHON_USE_MODULE_STATE
  8562. int pystate_addmodule_run = 0;
  8563. #endif
  8564. __pyx_mstatetype *__pyx_mstate = NULL;
  8565. PyObject *__pyx_t_1 = NULL;
  8566. PyObject *__pyx_t_2 = NULL;
  8567. PyObject *__pyx_t_3 = NULL;
  8568. PyObject *__pyx_t_4 = NULL;
  8569. Py_ssize_t __pyx_t_5;
  8570. PyObject *__pyx_t_6 = NULL;
  8571. PyObject *__pyx_t_7 = NULL;
  8572. PyObject *__pyx_t_8 = NULL;
  8573. size_t __pyx_t_9;
  8574. int __pyx_t_10;
  8575. int __pyx_lineno = 0;
  8576. const char *__pyx_filename = NULL;
  8577. int __pyx_clineno = 0;
  8578. __Pyx_RefNannyDeclarations
  8579. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8580. if (__pyx_m) {
  8581. if (__pyx_m == __pyx_pyinit_module) return 0;
  8582. PyErr_SetString(PyExc_RuntimeError, "Module 'qu2cu' has already been imported. Re-initialisation is not supported.");
  8583. return -1;
  8584. }
  8585. #else
  8586. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  8587. #endif
  8588. /*--- Module creation code ---*/
  8589. #if CYTHON_PEP489_MULTI_PHASE_INIT
  8590. __pyx_t_1 = __pyx_pyinit_module;
  8591. Py_INCREF(__pyx_t_1);
  8592. #else
  8593. __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  8594. #endif
  8595. #if CYTHON_USE_MODULE_STATE
  8596. {
  8597. int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef);
  8598. __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "qu2cu" pseudovariable */
  8599. if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  8600. pystate_addmodule_run = 1;
  8601. }
  8602. #else
  8603. __pyx_m = __pyx_t_1;
  8604. #endif
  8605. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8606. PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED);
  8607. #endif
  8608. __pyx_mstate = __pyx_mstate_global;
  8609. CYTHON_UNUSED_VAR(__pyx_t_1);
  8610. __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  8611. Py_INCREF(__pyx_mstate->__pyx_d);
  8612. __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  8613. __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  8614. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  8615. /* ImportRefnannyAPI */
  8616. #if CYTHON_REFNANNY
  8617. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  8618. if (!__Pyx_RefNanny) {
  8619. PyErr_Clear();
  8620. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  8621. if (!__Pyx_RefNanny)
  8622. Py_FatalError("failed to import 'refnanny' module");
  8623. }
  8624. #endif
  8625. __Pyx_RefNannySetupContext("PyInit_qu2cu", 0);
  8626. __Pyx_init_runtime_version();
  8627. 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)
  8628. __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  8629. __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  8630. __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  8631. /*--- Library function declarations ---*/
  8632. /*--- Initialize various global constants etc. ---*/
  8633. if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  8634. stringtab_initialized = 1;
  8635. if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  8636. if (__pyx_module_is_main_fontTools__qu2cu__qu2cu) {
  8637. 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)
  8638. }
  8639. {
  8640. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  8641. if (!PyDict_GetItemString(modules, "fontTools.qu2cu.qu2cu")) {
  8642. if (unlikely((PyDict_SetItemString(modules, "fontTools.qu2cu.qu2cu", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  8643. }
  8644. }
  8645. /*--- Builtin init code ---*/
  8646. if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  8647. /*--- Constants init code ---*/
  8648. if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  8649. if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  8650. /*--- Global type/function init code ---*/
  8651. (void)__Pyx_modinit_global_init_code(__pyx_mstate);
  8652. (void)__Pyx_modinit_variable_export_code(__pyx_mstate);
  8653. (void)__Pyx_modinit_function_export_code(__pyx_mstate);
  8654. if (unlikely((__Pyx_modinit_type_init_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  8655. (void)__Pyx_modinit_type_import_code(__pyx_mstate);
  8656. (void)__Pyx_modinit_variable_import_code(__pyx_mstate);
  8657. (void)__Pyx_modinit_function_import_code(__pyx_mstate);
  8658. /*--- Execution code ---*/
  8659. /* "fontTools/qu2cu/qu2cu.py":19
  8660. * # limitations under the License.
  8661. *
  8662. * try: # <<<<<<<<<<<<<<
  8663. * import cython
  8664. * except (AttributeError, ImportError):
  8665. */
  8666. {
  8667. (void)__pyx_t_1; (void)__pyx_t_2; (void)__pyx_t_3; /* mark used */
  8668. /*try:*/ {
  8669. /* "fontTools/qu2cu/qu2cu.py":20
  8670. *
  8671. * try:
  8672. * import cython # <<<<<<<<<<<<<<
  8673. * except (AttributeError, ImportError):
  8674. * # if cython not installed, use mock module with no-op decorators and types
  8675. */
  8676. }
  8677. }
  8678. /* "fontTools/qu2cu/qu2cu.py":24
  8679. * # if cython not installed, use mock module with no-op decorators and types
  8680. * from fontTools.misc import cython
  8681. * COMPILED = cython.compiled # <<<<<<<<<<<<<<
  8682. *
  8683. * from fontTools.misc.bezierTools import splitCubicAtTC
  8684. */
  8685. 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)
  8686. /* "fontTools/qu2cu/qu2cu.py":26
  8687. * COMPILED = cython.compiled
  8688. *
  8689. * from fontTools.misc.bezierTools import splitCubicAtTC # <<<<<<<<<<<<<<
  8690. * from collections import namedtuple
  8691. * import math
  8692. */
  8693. {
  8694. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_splitCubicAtTC};
  8695. __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)
  8696. }
  8697. __pyx_t_4 = __pyx_t_3;
  8698. __Pyx_GOTREF(__pyx_t_4);
  8699. {
  8700. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_splitCubicAtTC};
  8701. __pyx_t_5 = 0; {
  8702. __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)
  8703. __Pyx_GOTREF(__pyx_t_6);
  8704. 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)
  8705. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8706. }
  8707. }
  8708. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8709. /* "fontTools/qu2cu/qu2cu.py":27
  8710. *
  8711. * from fontTools.misc.bezierTools import splitCubicAtTC
  8712. * from collections import namedtuple # <<<<<<<<<<<<<<
  8713. * import math
  8714. * from typing import (
  8715. */
  8716. {
  8717. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_namedtuple};
  8718. __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)
  8719. }
  8720. __pyx_t_4 = __pyx_t_3;
  8721. __Pyx_GOTREF(__pyx_t_4);
  8722. {
  8723. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_namedtuple};
  8724. __pyx_t_5 = 0; {
  8725. __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)
  8726. __Pyx_GOTREF(__pyx_t_6);
  8727. 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)
  8728. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8729. }
  8730. }
  8731. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8732. /* "fontTools/qu2cu/qu2cu.py":28
  8733. * from fontTools.misc.bezierTools import splitCubicAtTC
  8734. * from collections import namedtuple
  8735. * import math # <<<<<<<<<<<<<<
  8736. * from typing import (
  8737. * List,
  8738. */
  8739. __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)
  8740. __pyx_t_4 = __pyx_t_3;
  8741. __Pyx_GOTREF(__pyx_t_4);
  8742. 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)
  8743. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8744. /* "fontTools/qu2cu/qu2cu.py":29
  8745. * from collections import namedtuple
  8746. * import math
  8747. * from typing import ( # <<<<<<<<<<<<<<
  8748. * List,
  8749. * Tuple,
  8750. */
  8751. {
  8752. 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};
  8753. __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)
  8754. }
  8755. __pyx_t_4 = __pyx_t_3;
  8756. __Pyx_GOTREF(__pyx_t_4);
  8757. {
  8758. 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};
  8759. for (__pyx_t_5=0; __pyx_t_5 < 3; __pyx_t_5++) {
  8760. __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)
  8761. __Pyx_GOTREF(__pyx_t_6);
  8762. 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)
  8763. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8764. }
  8765. }
  8766. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8767. /* "fontTools/qu2cu/qu2cu.py":36
  8768. *
  8769. *
  8770. * __all__ = ["quadratic_to_curves"] # <<<<<<<<<<<<<<
  8771. *
  8772. *
  8773. */
  8774. __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)
  8775. __Pyx_GOTREF(__pyx_t_4);
  8776. 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)
  8777. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8778. /* "fontTools/qu2cu/qu2cu.py":82
  8779. *
  8780. *
  8781. * @cython.locals( # <<<<<<<<<<<<<<
  8782. * p0=cython.complex,
  8783. * p1=cython.complex,
  8784. */
  8785. __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)
  8786. __Pyx_GOTREF(__pyx_t_4);
  8787. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8788. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8789. #endif
  8790. 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)
  8791. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8792. /* "fontTools/qu2cu/qu2cu.py":154
  8793. *
  8794. *
  8795. * @cython.locals( # <<<<<<<<<<<<<<
  8796. * count=cython.int,
  8797. * num_offcurves=cython.int,
  8798. */
  8799. __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)
  8800. __Pyx_GOTREF(__pyx_t_4);
  8801. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8802. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8803. #endif
  8804. 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)
  8805. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8806. /* "fontTools/qu2cu/qu2cu.py":175
  8807. *
  8808. *
  8809. * Point = Union[Tuple[float, float], complex] # <<<<<<<<<<<<<<
  8810. *
  8811. *
  8812. */
  8813. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_Union); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 175, __pyx_L1_error)
  8814. __Pyx_GOTREF(__pyx_t_4);
  8815. __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_Tuple); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 175, __pyx_L1_error)
  8816. __Pyx_GOTREF(__pyx_t_6);
  8817. __pyx_t_7 = PyTuple_Pack(2, ((PyObject *)(&PyFloat_Type)), ((PyObject *)(&PyFloat_Type))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 175, __pyx_L1_error)
  8818. __Pyx_GOTREF(__pyx_t_7);
  8819. __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 175, __pyx_L1_error)
  8820. __Pyx_GOTREF(__pyx_t_8);
  8821. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8822. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8823. __pyx_t_7 = PyTuple_Pack(2, __pyx_t_8, ((PyObject *)(&PyComplex_Type))); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 175, __pyx_L1_error)
  8824. __Pyx_GOTREF(__pyx_t_7);
  8825. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8826. __pyx_t_8 = __Pyx_PyObject_GetItem(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 175, __pyx_L1_error)
  8827. __Pyx_GOTREF(__pyx_t_8);
  8828. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8829. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8830. 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)
  8831. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8832. /* "fontTools/qu2cu/qu2cu.py":178
  8833. *
  8834. *
  8835. * def _raise_incompatible_point(point, previous_point): # <<<<<<<<<<<<<<
  8836. * raise ValueError(
  8837. * f"Quadratic splines must connect end-to-start; got {previous_point!r} then {point!r}"
  8838. */
  8839. __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_5_raise_incompatible_point, 0, __pyx_mstate_global->__pyx_n_u_raise_incompatible_point, 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)
  8840. __Pyx_GOTREF(__pyx_t_8);
  8841. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8842. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  8843. #endif
  8844. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_raise_incompatible_point, __pyx_t_8) < (0)) __PYX_ERR(0, 178, __pyx_L1_error)
  8845. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8846. /* "fontTools/qu2cu/qu2cu.py":184
  8847. *
  8848. *
  8849. * def _validate_spline_length(spline): # <<<<<<<<<<<<<<
  8850. * if len(spline) < 3:
  8851. * raise ValueError("Quadratic splines must contain at least 3 points")
  8852. */
  8853. __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_7_validate_spline_length, 0, __pyx_mstate_global->__pyx_n_u_validate_spline_length, 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_8)) __PYX_ERR(0, 184, __pyx_L1_error)
  8854. __Pyx_GOTREF(__pyx_t_8);
  8855. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8856. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  8857. #endif
  8858. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_validate_spline_length, __pyx_t_8) < (0)) __PYX_ERR(0, 184, __pyx_L1_error)
  8859. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8860. /* "fontTools/qu2cu/qu2cu.py":189
  8861. *
  8862. *
  8863. * def _validate_positive_tolerance(max_err): # <<<<<<<<<<<<<<
  8864. * if max_err <= 0:
  8865. * raise ValueError("max_err must be greater than zero")
  8866. */
  8867. __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_9_validate_positive_tolerance, 0, __pyx_mstate_global->__pyx_n_u_validate_positive_tolerance, 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_8)) __PYX_ERR(0, 189, __pyx_L1_error)
  8868. __Pyx_GOTREF(__pyx_t_8);
  8869. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8870. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  8871. #endif
  8872. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_validate_positive_tolerance, __pyx_t_8) < (0)) __PYX_ERR(0, 189, __pyx_L1_error)
  8873. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8874. /* "fontTools/qu2cu/qu2cu.py":200
  8875. * def quadratic_to_curves(
  8876. * quads: List[List[Point]],
  8877. * max_err: float = 0.5, # <<<<<<<<<<<<<<
  8878. * all_cubic: bool = False,
  8879. * ) -> List[Tuple[Point, ...]]:
  8880. */
  8881. __pyx_t_8 = PyFloat_FromDouble(((double)0.5)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 200, __pyx_L1_error)
  8882. __Pyx_GOTREF(__pyx_t_8);
  8883. /* "fontTools/qu2cu/qu2cu.py":201
  8884. * quads: List[List[Point]],
  8885. * max_err: float = 0.5,
  8886. * all_cubic: bool = False, # <<<<<<<<<<<<<<
  8887. * ) -> List[Tuple[Point, ...]]:
  8888. * """Converts a connecting list of quadratic splines to a list of quadratic
  8889. */
  8890. __pyx_t_7 = __Pyx_PyBool_FromLong(((int)0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 201, __pyx_L1_error)
  8891. __Pyx_GOTREF(__pyx_t_7);
  8892. /* "fontTools/qu2cu/qu2cu.py":194
  8893. *
  8894. *
  8895. * @cython.locals( # <<<<<<<<<<<<<<
  8896. * cost=cython.int,
  8897. * is_complex=cython.int,
  8898. */
  8899. __pyx_t_4 = PyTuple_Pack(2, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 194, __pyx_L1_error)
  8900. __Pyx_GOTREF(__pyx_t_4);
  8901. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8902. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8903. __pyx_t_7 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 194, __pyx_L1_error)
  8904. __Pyx_GOTREF(__pyx_t_7);
  8905. 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, 194, __pyx_L1_error)
  8906. 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, 194, __pyx_L1_error)
  8907. 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, 194, __pyx_L1_error)
  8908. 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, 194, __pyx_L1_error)
  8909. __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_11quadratic_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[7])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 194, __pyx_L1_error)
  8910. __Pyx_GOTREF(__pyx_t_8);
  8911. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8912. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  8913. #endif
  8914. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_t_4);
  8915. __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_7);
  8916. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8917. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  8918. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_quadratic_to_curves, __pyx_t_8) < (0)) __PYX_ERR(0, 194, __pyx_L1_error)
  8919. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8920. /* "fontTools/qu2cu/qu2cu.py":267
  8921. *
  8922. *
  8923. * Solution = namedtuple("Solution", ["num_points", "error", "start_index", "is_cubic"]) # <<<<<<<<<<<<<<
  8924. *
  8925. *
  8926. */
  8927. __pyx_t_7 = NULL;
  8928. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_namedtuple); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error)
  8929. __Pyx_GOTREF(__pyx_t_4);
  8930. __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, 267, __pyx_L1_error)
  8931. __Pyx_GOTREF(__pyx_t_6);
  8932. __pyx_t_9 = 1;
  8933. {
  8934. PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Solution, __pyx_t_6};
  8935. __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));
  8936. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  8937. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8938. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8939. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 267, __pyx_L1_error)
  8940. __Pyx_GOTREF(__pyx_t_8);
  8941. }
  8942. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Solution, __pyx_t_8) < (0)) __PYX_ERR(0, 267, __pyx_L1_error)
  8943. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8944. /* "fontTools/qu2cu/qu2cu.py":293
  8945. * u=cython.complex,
  8946. * )
  8947. * def spline_to_curves(q, costs, tolerance=0.5, all_cubic=False): # <<<<<<<<<<<<<<
  8948. * """
  8949. * q: quadratic spline with alternating on-curve / off-curve points.
  8950. */
  8951. __pyx_t_8 = PyFloat_FromDouble(((double)0.5)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 293, __pyx_L1_error)
  8952. __Pyx_GOTREF(__pyx_t_8);
  8953. __pyx_t_4 = __Pyx_PyBool_FromLong(((int)0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 293, __pyx_L1_error)
  8954. __Pyx_GOTREF(__pyx_t_4);
  8955. /* "fontTools/qu2cu/qu2cu.py":270
  8956. *
  8957. *
  8958. * @cython.locals( # <<<<<<<<<<<<<<
  8959. * i=cython.int,
  8960. * j=cython.int,
  8961. */
  8962. __pyx_t_6 = PyTuple_Pack(2, __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 270, __pyx_L1_error)
  8963. __Pyx_GOTREF(__pyx_t_6);
  8964. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  8965. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8966. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_13spline_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[8])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 270, __pyx_L1_error)
  8967. __Pyx_GOTREF(__pyx_t_4);
  8968. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8969. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8970. #endif
  8971. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_6);
  8972. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  8973. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_spline_to_curves, __pyx_t_4) < (0)) __PYX_ERR(0, 270, __pyx_L1_error)
  8974. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8975. /* "fontTools/qu2cu/qu2cu.py":414
  8976. *
  8977. *
  8978. * def main(): # <<<<<<<<<<<<<<
  8979. * from fontTools.cu2qu.benchmark import generate_curve
  8980. * from fontTools.cu2qu import curve_to_quadratic
  8981. */
  8982. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5qu2cu_5qu2cu_15main, 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[9])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 414, __pyx_L1_error)
  8983. __Pyx_GOTREF(__pyx_t_4);
  8984. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  8985. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  8986. #endif
  8987. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_main_2, __pyx_t_4) < (0)) __PYX_ERR(0, 414, __pyx_L1_error)
  8988. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8989. /* "fontTools/qu2cu/qu2cu.py":432
  8990. *
  8991. *
  8992. * if __name__ == "__main__": # <<<<<<<<<<<<<<
  8993. * main()
  8994. */
  8995. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_name); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 432, __pyx_L1_error)
  8996. __Pyx_GOTREF(__pyx_t_4);
  8997. __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, 432, __pyx_L1_error)
  8998. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  8999. if (__pyx_t_10) {
  9000. /* "fontTools/qu2cu/qu2cu.py":433
  9001. *
  9002. * if __name__ == "__main__":
  9003. * main() # <<<<<<<<<<<<<<
  9004. */
  9005. __pyx_t_6 = NULL;
  9006. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_main_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 433, __pyx_L1_error)
  9007. __Pyx_GOTREF(__pyx_t_8);
  9008. __pyx_t_9 = 1;
  9009. {
  9010. PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
  9011. __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));
  9012. __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
  9013. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  9014. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L1_error)
  9015. __Pyx_GOTREF(__pyx_t_4);
  9016. }
  9017. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9018. /* "fontTools/qu2cu/qu2cu.py":432
  9019. *
  9020. *
  9021. * if __name__ == "__main__": # <<<<<<<<<<<<<<
  9022. * main()
  9023. */
  9024. }
  9025. /* "fontTools/qu2cu/qu2cu.py":1
  9026. * # cython: language_level=3 # <<<<<<<<<<<<<<
  9027. * # distutils: define_macros=CYTHON_TRACE_NOGIL=1
  9028. *
  9029. */
  9030. __pyx_t_4 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  9031. __Pyx_GOTREF(__pyx_t_4);
  9032. 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)
  9033. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  9034. /*--- Wrapped vars code ---*/
  9035. goto __pyx_L0;
  9036. __pyx_L1_error:;
  9037. __Pyx_XDECREF(__pyx_t_4);
  9038. __Pyx_XDECREF(__pyx_t_6);
  9039. __Pyx_XDECREF(__pyx_t_7);
  9040. __Pyx_XDECREF(__pyx_t_8);
  9041. if (__pyx_m) {
  9042. if (__pyx_mstate->__pyx_d && stringtab_initialized) {
  9043. __Pyx_AddTraceback("init fontTools.qu2cu.qu2cu", __pyx_clineno, __pyx_lineno, __pyx_filename);
  9044. }
  9045. #if !CYTHON_USE_MODULE_STATE
  9046. Py_CLEAR(__pyx_m);
  9047. #else
  9048. Py_DECREF(__pyx_m);
  9049. if (pystate_addmodule_run) {
  9050. PyObject *tp, *value, *tb;
  9051. PyErr_Fetch(&tp, &value, &tb);
  9052. PyState_RemoveModule(&__pyx_moduledef);
  9053. PyErr_Restore(tp, value, tb);
  9054. }
  9055. #endif
  9056. } else if (!PyErr_Occurred()) {
  9057. PyErr_SetString(PyExc_ImportError, "init fontTools.qu2cu.qu2cu");
  9058. }
  9059. __pyx_L0:;
  9060. __Pyx_RefNannyFinishContext();
  9061. #if CYTHON_PEP489_MULTI_PHASE_INIT
  9062. return (__pyx_m != NULL) ? 0 : -1;
  9063. #else
  9064. return __pyx_m;
  9065. #endif
  9066. }
  9067. /* #### Code section: pystring_table ### */
  9068. /* #### Code section: cached_builtins ### */
  9069. static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) {
  9070. CYTHON_UNUSED_VAR(__pyx_mstate);
  9071. __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 354, __pyx_L1_error)
  9072. __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_reversed); if (!__pyx_builtin_reversed) __PYX_ERR(0, 403, __pyx_L1_error)
  9073. __pyx_builtin_zip = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_zip); if (!__pyx_builtin_zip) __PYX_ERR(0, 403, __pyx_L1_error)
  9074. __pyx_builtin_print = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_print); if (!__pyx_builtin_print) __PYX_ERR(0, 422, __pyx_L1_error)
  9075. /* Cached unbound methods */
  9076. __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  9077. __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items;
  9078. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  9079. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop;
  9080. __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type;
  9081. __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values;
  9082. __pyx_mstate->__pyx_umethod_PyList_Type_pop.type = (PyObject*)&PyList_Type;
  9083. __pyx_mstate->__pyx_umethod_PyList_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop;
  9084. return 0;
  9085. __pyx_L1_error:;
  9086. return -1;
  9087. }
  9088. /* #### Code section: cached_constants ### */
  9089. static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) {
  9090. __Pyx_RefNannyDeclarations
  9091. CYTHON_UNUSED_VAR(__pyx_mstate);
  9092. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  9093. /* "fontTools/qu2cu/qu2cu.py":254
  9094. * costs.append(cost)
  9095. * costs.append(cost)
  9096. * qq = add_implicit_on_curves(p)[1:] # <<<<<<<<<<<<<<
  9097. * costs.pop()
  9098. * q.extend(qq)
  9099. */
  9100. __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, 254, __pyx_L1_error)
  9101. __Pyx_GOTREF(__pyx_mstate_global->__pyx_slice[0]);
  9102. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_slice[0]);
  9103. /* "fontTools/qu2cu/qu2cu.py":321
  9104. * # Dynamic-Programming to find the solution with fewest number of
  9105. * # cubic curves, and within those the one with smallest error.
  9106. * sols = [Solution(0, 0, 0, False)] # <<<<<<<<<<<<<<
  9107. * impossible = Solution(len(elevated_quadratics) * 3 + 1, 0, 1, False)
  9108. * start = 0
  9109. */
  9110. __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, 321, __pyx_L1_error)
  9111. __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]);
  9112. __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]);
  9113. #if CYTHON_IMMORTAL_CONSTANTS
  9114. {
  9115. PyObject **table = __pyx_mstate->__pyx_tuple;
  9116. for (Py_ssize_t i=0; i<1; ++i) {
  9117. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9118. #if PY_VERSION_HEX < 0x030E0000
  9119. if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
  9120. #else
  9121. if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
  9122. #endif
  9123. {
  9124. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  9125. }
  9126. #else
  9127. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  9128. #endif
  9129. }
  9130. }
  9131. #endif
  9132. #if CYTHON_IMMORTAL_CONSTANTS
  9133. {
  9134. PyObject **table = __pyx_mstate->__pyx_slice;
  9135. for (Py_ssize_t i=0; i<1; ++i) {
  9136. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9137. #if PY_VERSION_HEX < 0x030E0000
  9138. if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
  9139. #else
  9140. if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
  9141. #endif
  9142. {
  9143. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  9144. }
  9145. #else
  9146. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  9147. #endif
  9148. }
  9149. }
  9150. #endif
  9151. __Pyx_RefNannyFinishContext();
  9152. return 0;
  9153. __pyx_L1_error:;
  9154. __Pyx_RefNannyFinishContext();
  9155. return -1;
  9156. }
  9157. /* #### Code section: init_constants ### */
  9158. static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) {
  9159. CYTHON_UNUSED_VAR(__pyx_mstate);
  9160. {
  9161. const struct { const unsigned int length: 10; } index[] = {{1},{28},{17},{23},{179},{43},{15},{49},{48},{23},{45},{1},{8},{39},{7},{6},{2},{9},{33},{43},{6},{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},{5},{3},{14},{5},{1},{2},{19},{36},{10},{5},{12},{25},{4},{7},{21},{13},{18},{6},{8},{4},{12},{10},{4},{6},{16},{33},{14},{6},{5},{11},{8},{10},{14},{5},{9},{2},{6},{1},{1},{28},{23},{5},{6},{1},{1},{3},{112},{23},{131},{313},{56},{2},{2},{914},{24},{20}};
  9162. #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (2007 bytes) */
  9163. const char* const cstring = "BZh91AY&SY\322\r\372Z\000\001D\377\377\377\377\377\377\376\367\375}\377\367\376\252\277\377\377\374@@@@@@@@@\000@@@\000@\000`\007M\3075F\231\264l\312\n\202W\000\373\300jz)\t\250\320\r\2244\365=\032l&\2322S\324\030\215\244\365<\211\246\200\014\215\036\246\215\006\206\324\0031\242OH4 \032@&\025=S\364\311\223B\217(?T\003\322h\0004\003@\006\200\0324\001\243\322h\000jz\004\324\202\2322\033(\332\231\r2\000\0004\r\000\000\000\000\000\000\032h\000%4I\243D&&\230\024\336\242\233F\2203Q\210\036\240\000\000\000\032\001\243F\201\352\000=CC\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\021S\322&\004\302z\006\247\251\223\002h\300\004\365\014\023&\000\207\244\323\000\000F\231\r4\030\t\203\315\227\225,\242d\226\n\233\033\2667\370\030/\001|3\004xS\010\225+\022\206\227\"R.CET\010P\320\001F\220\362+H\r\374\247\364\222(\t\024$P\022\0104\016\3232\334\002\240\262\253\264\366\231\254\327\001\005\031\213\223\003JL\027A\332%&3\265\216=\225\004\030\023I&\303m\031$\231\212\025\005[\242g\230X\302O\t\002\020oLv\337M)\003\2525\022\022`I\242JExL4\244\312\353\016\302\201\013\001\324\003Q\215\0261\0029\226\334\335\264\305\0134\302\201\"q\007\312B\312T\010\270(p\264\304\305PH-\"C\212\273\036+\336%\031\211\341\034.{\t\223\234-\245\033\022\344\207\302\272\313\214\342\345\210.\250\267?A\353\247\006\366x\307\372\244*\257'=}\315\357#9Fs\374\307{\025s\301\\?x\216\321\327\324\026,\214\316_\251\177q\n\0356\004\204\303!\033ON\243.\\\234\232`\0305t]{\004tE\313(\026j*\" E#{\\\272\210\2168\t\225\227\031\332\327\274C,\035g\216.\317\001\366\357\350\273\035\324\013,\337`\306\324f\23544G\341\010\343>sE\363\177\214\017a\344\013>%x\027\216\333K\330\364\001\034\362o5D\025P\242\340\037\002\210\3351=\202\261M\023\023!0'?EG\301\355\271\220-\322\341\351\351\366\231\266\005\177\026\261-\333\302X\355\340xP3\231L\362$\241\320\232\010y:\224\215y\251\311\221\354)Sl\353\364\244]\331\356,1Z\356f\344{\234\341\327\303\254\277\267;\377.\026Q\327\220\262\217\305E\362\035g]qT\002e\216-\254\301\202y=\251\2754 \322""\316R\220\325\310\242\002q\020\372\3265!\016\217F\351\252\255=\216=p\002\261:)`\263vH}0K\361\213\346\363\277\355\202\033\005\354\335g\02313o_\231\262\253n\333\000\342\330$\027\314\026\021P\342\004MD\302\253\321\212\334Xu2^\000\374~j\211)\025\030\235&\226\003\226\036\305\213\303\037\357\343\006\332\242'U\013\211\333q\311Q0\345,c\267?\006t\027\215\211P(\224\204\257\240\315\003\360\232\264\210O\221\243Yp\026\222\342\034\0069Q\215\332pC\242K\235\273\227\036\241\370%{\310h\345e\252w\026\342k\214U\205\312\315\216g\023;]\271\020\036K\222/\337\027\006\335q\222\030O\267\207R\200\265\211\254\300\235\271\300\253,\235\211\352E[\322\005\261\315z[Ki\323\256\235\224,\256\222\336t\262\031\314\230\346\262\316\036\224\010H\277\2062/b\324Z\310\nq\251\217Fw,\264@\342p8)\010>\344C\247\024b\344:d\301\003\222\275\255[\231#t\343'\304\251\r\2356\263|\t\204X\214\315!Er\247\374\336\024\311X,I\n\006\326\223\014\031\207\256\267\225tI\265\004\027\"\227h\345\253.n\330\312(kn\332\340\307\311,\330o.\205x\367\353\330\225g\006\\@hGE\032\025\234q\031\023h\020\204C\272M\341nH\275\3332\311\314\313b\210ElI\t^U\251\263\010D\300\266\002\363\325N\252\245\320\253Z\033\265\325F\000Z\224\234\260kG\030\332\224;@\215\346s\226fH\223#p\313\247l\233\204\266\246\306\002\035\336\202\242\001\311-\376\251TI\204\310\331\202\010\263+\274\212\2553\352\320\364\t\337:\026\024\310\327p\221J\247\017\020\351(\023\345\365\250][\025\361\327\020;\361\273\030\363\230\242h\020$\277\265\206\305]\326@\325&\020\256g`F\275v\273\022Lm6\356\031\365.\361\033`\322\033\005\030}P3\367\372\344k\305j#\211\335\215\326\025\374#a\334\251gD\313sL\203\237>\355s$\306\n5xv:\226t3\251h$\031\020\017\300<\036su\271\351\346y\215\266\365I\265\211\367\2173\225T\207\005\267\017^\367@\350\364\033\250\035^\251.\346b\251\021$Mw\330(\313&\010c\022n{1\216\254\266#]\214\004\220\365\347X\362\243\014\317\223Q,I\243\205\355\000\033\312 @\002\304\256\315\210\304d2t\3552\\\346\233\177CB<\210\232\314\240\004+@\323\305\367\305\251\203\331%Q\226q&K\\\246\362#\202=\254""\t?)\253\220\n\311\253EeP\016\0357N6R`#X\037.\256r\277\002P\351!V\301\031\333S\366\363\270\203\010\342h\370A\216r\024\215\034\311\000n\010f\036\021\022\364\254\022X\3164\326\255\000\260\300\221h9\276\303\024\014) \200\317\366L\353\030\3268\353\0052]#U\244*Y\241\264_y~\216\034i2a2\345\027M\001i+\320d\r\262\250\342|\272s7K\013\034F\350P\0329\254\213\257\346\357j6p\230\323\230\214\302\031\021\350%\216\306\334\014\026Z]W}\333\273]\345\241\333Z\264T7{>\002l\245\033\365zI\220{i\204\307]\031=S\260\035\217}\367\0313\376R~\262\014(\022K\255\323\373\022\r\316\313J\254,\336\323\030$2\350\r\320\031\250\0243\345\325\367\0239F\250D\024\322q\256\200(\256\326\320,m\20733\316\201\255\351\000\307\364\242\273\231\311D\202$\000\240\360\214W\234\216\205\3264F\223\310^\004\354\260\340W\3229b\2752Y\276Q\037\333\001\363q)\037V\320Q\256 \271U\023\202\240\201=\350t\021\241\366\302+%J\273p\337j\372\214d5\016\242 0\210\270\215Xp\245\230\221G\226\264\030\201\211\022$\006\010l\303\354?\322/I\004*p\303m\020x\2305\342\211bdU`\025\013-\245\262\275:\264\355AL>'\213H\361\264l\322\311\244\302t\003n\216:X\\\32709\215\017n\306\310p%\362\376u\327\\$\0354j\224\366\350\272\342j\263a\317\333a\333\217\007\235q\320[\242;\327[o\375\330]\332\014\223@~(\rl\275i\323\327\227\324\313\346G2\031\"`\213**\323f\275\344\230\374\336t\302\3669\267\236\032N\352:4\366E\214@\022Hr\222.M~]*\206\001\024Nq\021\307\314X\020%\000\234p\334:.\200(\002\260\030\027X\304\320-p\365:\354\254M\0339\215\262UQe\026\037p\320b\265rK\033\254\205\241\344UWaV`\317c\241\226s5dtZ\261B\350\240\302\341Ew\357\005\246\240\243*j\032\313A\273\220\022Z\304KO6\211\261a\3203<\212\206*\225\211U!\303\010#s\377\027rE8P\220\322\r\372Z";
  9164. PyObject *data = __Pyx_DecompressString(cstring, 2007, 2);
  9165. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  9166. const char* const bytes = __Pyx_PyBytes_AsString(data);
  9167. #if !CYTHON_ASSUME_SAFE_MACROS
  9168. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  9169. #endif
  9170. #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1954 bytes) */
  9171. const char* const cstring = "x\332uT\317s\032G\026\02628\310A\016Hhe\307\261w\220\242\322&e\341\000\252-\257\355\312.\222\177$[^[H\250R[)\325T3\264\320\310\303\014L\367(\222w\017>\316q\216s\234\343\0349\316\221?\201\343\034\371\023\364'\354\327=\010deCA\323\375\272\373\365{\337\367\275W~\253\267\236\034[&oZ\226\301\236\364\235\252\346$c\271w\361Vg\374W9\354Y\272\311\217\216\344\274\351\364\014\232X\036+\345r\371\350\350\235\305\251\302O\010Wv/\370\211e*:S\332\324\320[\324&\234\032\027\n\343\266\256qj\213C\246\262\367jok\373\351\266B\314\266b\323S\252q\2460\247\245\031\2041\312\024\353Xi9\272\301uS\341\027=\312\312\312\317\307\312\205\345(&\245m\205[J\017\347\256_\340'\324T\030\345b\242l\022\323\2648\341\272e\252\270\256\233\235M\245\255\333xD?\243\342\366kb0Z~oR\305F\000VW\321\234\226\256)\334\261M\270GR\226\262\321V\372\016i#x]c\345\367\266\336\321Mb\340\240}F\2375\256v\024\3263t\023\357w\035\306\025\3152M<\242P\263\275\305\255-\306\211\315\237+\035\213+\177|\201\023\344\010\324\014J`\250)=\201)\333\247\330\002b\016\020k'\217\376\205}\367\254yb1z-\256\253\210[D\3730\r[\346\002\304\376N\332m\0258P\315\251\366\035\244m\200\nS\243\312F\247\254Hz?\267\265uFZ\006\245\246\030;\232\316\222Y\273K\316Uj\333I\304-\252tlJ\246<~\244\266\325\277\221\034\010\355;\200\233\375>\257\204\247\335\367\377\332\373\371\355\253\227BJRC\252\272wq\216\337K(D}G\317\371>=>\260\014G0(\245vhb&\362\321\273xB\323\271\nj%,LU\211a$\203\314\234\260\013S\323\255\262f\331\026\034\000\353\026e\\e\226\321\202\2745U\225\222Q;\224\353\234v\305\022gT\035J\261\211F\005\222\232\001\2245\3130\204`@\203f1.~\2308&\227\217\310\247\345\240rK\235\002\220DD\rz\006\204f\346\211\241=\263\000[\247++\003\310\342k\331\307\206E\370\264\010\313\222\263\033\313r\213\232\332I\227\330\037f\033]\235i\260\177\324\251-\r\263\235\244\200\345xl\331\032^W\217\035\023\371w\250)_N\360\023\253\363\236\255\353\002!9\2502\315d*C\323\273\244\003\334-\306t\350Ag8\000\026\350\271*\247\023\224\305\\ #@e\247\2473G\2473G\037T\265\013\271'c\227\360\223\211\264`\260\332""\216AU|L\322\245\311\330\346\202yD\307\201\225j\035\037'\350\212E\"&\230*\370U-\0231vz\275\037z\225^E\255\252\265^\265W\223GzV\257g\3233\335rXr\007\211\232\274\217\317\025\021\202\276\304\357\3771\225_\030\226\206V\361cy\202\322\214?1\203\364\360g$\021\2536A\305@G\002\034\034\001R\311\223\250\026\303\236\224\363\254\252\325i\351\331\327K\375\263\205\n,\241\016Q\343H\202\332\214\266\241\033\360\210>7\301\t\2636=&\216\0014\0146\351-r\234eqs\375\273\254\304\001\276+\310\253\363\346\256\\1\331\273\344\200\224\332\340Z\345\242\212T~\"I\007\257r6e\231\237\330\326o\323\234pS\266]\347L=#\206\336\026j\203~t\321\177g\231\317\366&!\202\355\016?\201\325\241r`\347\027\037\365\336\247\324\345\322\\f\301M\273u\267\021\247sn=N\027\275]\257\357\337\362\253>,Y7\343\036z%\257\346\2218\373\225\333\367R^\341j\262\344U\275F\234]\304\201u\357\320_\363_\007kA=\316.\270\253\223\335}\317\366W\203T\234-\340V\372K\267\362)\025\247\357\270\337{8\365<\252\214^\034\214\016\232\243\346\2410/\214\026\276\017K\362_\tR\343t\336\203\361\033\377\237A+L\211\310\336\371\330,\214\n\353A%x\023Vp\320E$\325\301\372\340\327!\216c5\272\3634\232\217\326\243FD\342\364\342h\021n\202B\260\025\366\343d\367Y\264\026\355F\375aj\262~(\022\224\263\215\240\001$\356\314\345\026qQ\000\201\004\343\314\355\313\177\244\3462\331O\334\255\310\224\343\264\364(@\271\343\225\342\354\237\375\276\010\264\340\025\275\206G\375\212\277\343\023\237\007\265\000\317\177\221\334\312\013\274\274M\277\340\257\373\007A&8\010o\207\332\24088\214Jc\270I\271+.qm\034)I\360\305\323@)\201\035\320b\356\356\270\232\267\354\325\361\004\211s\0104 A?L\207\365p\037\211es\356+o\305#\036\363K~\315o\001\353\\\021\350\346\n\336\252\237\362\013\263I\026\200\010\350v\304}AZS\020\231PU\220\201\n\343/\342\241\261\000\017\340\370Z\260\032.\014\n\343\253l\300\242\267\341\331\243\373\177\213\212\321\277\207dB\351eq.s\327=\360nI\306\001S\006\216\343\205\234\273\213\324\226 \235\226\237\272\271\314.\370\205\260\200\273\3459\345IH\204\213\234[\003\030\014Z:\360S\227""\267\3472\017\300x\366\276\277\004d\353~3X\n\252A3,\206\207\203\215A?\272\025\325\"\022\261\341\332pw\330\277\314\316e\nB/3\271j\300\274$\263\026\244\211\273\373\300-u\315R\021Z\375|\365\345$\2045\357\245?\017\312\004\004K\301v`\207_\017\252\203\203(\025-G;PWn\311\373\026\240\313ws\340\350'\300v\200\222\251\371\300\244\340\335\223|7F\217j\270\265?\260qk\027\241\226&\005\366Y\220\243\257\237\204\366\000\014,{\225\031\235\277\301Q\356\276\377(\340a%\334\t\273\3216t;?,\215s_\271\334\253\214\363\017\375\303\240$\223\262\303\245\260\026\266\006\231Ac\320\222\372\337\217\372q\376\221o\204ka]LH\234\277\347g\221\345C8\252b[\204\222_\366\376*\240\215\213\220\361\030\253\347\310\2650.\256\000\371\305\273q~\325s\374\267aj\364\335\217\2216\\\032V\207\215x\271\030\347\013b{-x\204\230\357E\220\3277~]XV\204\346\362P\300s_\2270\347WG\253(\347\260*e\232\377\223\344c\023\345\270\216\220ER\210\354\001\210}\023T\256\205\262\022#\261_\202z\320\210\221\350\231P\3238y\262\360\307\276\213 +\355\277\nV\002-,\210L\266G\253?\014R\250\262&d\332\034\026\342\342U\033\301\0037\374>\360\037\313\235\234\320{\027m\005\345\363\023\344v\024n\201\267%!\262\351\025\031\261`\340\277\202h8\030\203\2577^\305\223\312\251\242\002\222\352\023\332\275;m\247Y\367\026\024\362\032\232\252\213\336W\022\255\344?\376\267h\0256`\344\203\312`g\200\336z\327\355\310\022\277*B1iL\272\021\032E\342\347\205w\216\236\223\006@\007a*\274'd#\332\005\344(Z\314\343\200\2146_@jvB\330\220\214\301I\006\255\271$\225\t\026:\310\222\300\305<:\365\313p\036\n\331\201tRBx\365\361U\203\376\342\023sK\356\323\244\273\337uOE\377H\354\347\250\215\322\324\366?\260\362\370\237";
  9172. PyObject *data = __Pyx_DecompressString(cstring, 1954, 1);
  9173. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  9174. const char* const bytes = __Pyx_PyBytes_AsString(data);
  9175. #if !CYTHON_ASSUME_SAFE_MACROS
  9176. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  9177. #endif
  9178. #else /* compression: none (3292 bytes) */
  9179. 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:Quadratic splines must connect end-to-start; got Quadratic splines must contain at least 3 pointsReconstructed curve(s):Those quadratics turned back into %d cubics. ?add_notecu2qu tolerance %g. qu2cu tolerance %g.disableenablegcisenabledmax_err must be greater than zeroquadratic spline requires at least 3 points then COMPILEDListPoint__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_3p2p3pointpopprevious_pointprintqqqquadratic_to_curvesquadratic_to_curves.<locals>.genexprquadraticsquads__qualname___raise_incompatible_pointrealreconstreconstruct_tolerancereconstructedreconstructed_iterreturnreversedsend__set_name__setdefaultsolssplinespline_to_curvesspline_to_curves.<locals>.genexprsplitCubicAtTCsplitsstartstart_index__test__this_countthis_sol_countthrowtolerancetstypinguv_validate_positive_tolerance_validate_spline_lengthvaluevaluesxyzip\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\n\210*\220A\330\010;\2701\320<S\320ST\320TU\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\360@\001\000\005\010\200t\2101\330\010\017\210q\330\004 \240\001\240\021\330\004\010\210\n\220!\330\010\037\230q\240\001\340\004\021\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\013\2101\210B\210c\220\023\220A\220Q\220a\330\014%\240Q\240a\240q\250\004\250A\250R\250q\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\200\001\330\004\007\200s\210!\2108\2202\220Q\330\010\016\210j\230\001\230\021\200\001\330\004\007\200x\210s\220!\330\010\016\210j\230\001\230\021";
  9180. PyObject *data = NULL;
  9181. CYTHON_UNUSED_VAR(__Pyx_DecompressString);
  9182. #endif
  9183. PyObject **stringtab = __pyx_mstate->__pyx_string_tab;
  9184. Py_ssize_t pos = 0;
  9185. for (int i = 0; i < 140; i++) {
  9186. Py_ssize_t bytes_length = index[i].length;
  9187. PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL);
  9188. if (likely(string) && i >= 21) PyUnicode_InternInPlace(&string);
  9189. if (unlikely(!string)) {
  9190. Py_XDECREF(data);
  9191. __PYX_ERR(0, 1, __pyx_L1_error)
  9192. }
  9193. stringtab[i] = string;
  9194. pos += bytes_length;
  9195. }
  9196. for (int i = 140; i < 150; i++) {
  9197. Py_ssize_t bytes_length = index[i].length;
  9198. PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length);
  9199. stringtab[i] = string;
  9200. pos += bytes_length;
  9201. if (unlikely(!string)) {
  9202. Py_XDECREF(data);
  9203. __PYX_ERR(0, 1, __pyx_L1_error)
  9204. }
  9205. }
  9206. Py_XDECREF(data);
  9207. for (Py_ssize_t i = 0; i < 150; i++) {
  9208. if (unlikely(PyObject_Hash(stringtab[i]) == -1)) {
  9209. __PYX_ERR(0, 1, __pyx_L1_error)
  9210. }
  9211. }
  9212. #if CYTHON_IMMORTAL_CONSTANTS
  9213. {
  9214. PyObject **table = stringtab + 140;
  9215. for (Py_ssize_t i=0; i<10; ++i) {
  9216. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9217. #if PY_VERSION_HEX < 0x030E0000
  9218. if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
  9219. #else
  9220. if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
  9221. #endif
  9222. {
  9223. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  9224. }
  9225. #else
  9226. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  9227. #endif
  9228. }
  9229. }
  9230. #endif
  9231. }
  9232. {
  9233. PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0;
  9234. int8_t const cint_constants_1[] = {0,1,3};
  9235. for (int i = 0; i < 3; i++) {
  9236. numbertab[i] = PyLong_FromLong(cint_constants_1[i - 0]);
  9237. if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error)
  9238. }
  9239. }
  9240. #if CYTHON_IMMORTAL_CONSTANTS
  9241. {
  9242. PyObject **table = __pyx_mstate->__pyx_number_tab;
  9243. for (Py_ssize_t i=0; i<3; ++i) {
  9244. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9245. #if PY_VERSION_HEX < 0x030E0000
  9246. if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
  9247. #else
  9248. if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
  9249. #endif
  9250. {
  9251. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  9252. }
  9253. #else
  9254. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  9255. #endif
  9256. }
  9257. }
  9258. #endif
  9259. return 0;
  9260. __pyx_L1_error:;
  9261. return -1;
  9262. }
  9263. /* #### Code section: init_codeobjects ### */
  9264. typedef struct {
  9265. unsigned int argcount : 3;
  9266. unsigned int num_posonly_args : 1;
  9267. unsigned int num_kwonly_args : 1;
  9268. unsigned int nlocals : 6;
  9269. unsigned int flags : 10;
  9270. unsigned int first_line : 9;
  9271. } __Pyx_PyCode_New_function_description;
  9272. /* NewCodeObj.proto */
  9273. static PyObject* __Pyx_PyCode_New(
  9274. const __Pyx_PyCode_New_function_description descr,
  9275. PyObject * const *varnames,
  9276. PyObject *filename,
  9277. PyObject *funcname,
  9278. PyObject *line_table,
  9279. PyObject *tuple_dedup_map
  9280. );
  9281. static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) {
  9282. PyObject* tuple_dedup_map = PyDict_New();
  9283. if (unlikely(!tuple_dedup_map)) return -1;
  9284. {
  9285. const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 263};
  9286. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_cost, __pyx_mstate->__pyx_n_u_is_complex, __pyx_mstate->__pyx_n_u_c};
  9287. __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;
  9288. }
  9289. {
  9290. const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 21, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 368};
  9291. 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};
  9292. __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;
  9293. }
  9294. {
  9295. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 82};
  9296. 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};
  9297. __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;
  9298. }
  9299. {
  9300. const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 154};
  9301. 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};
  9302. __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;
  9303. }
  9304. {
  9305. const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 178};
  9306. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_point, __pyx_mstate->__pyx_n_u_previous_point};
  9307. __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_raise_incompatible_point, __pyx_mstate->__pyx_kp_b_iso88591_A_1_SSTTU, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad;
  9308. }
  9309. {
  9310. const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 184};
  9311. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_spline};
  9312. __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_validate_spline_length, __pyx_mstate->__pyx_kp_b_iso88591_s_82Q_j, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad;
  9313. }
  9314. {
  9315. const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 189};
  9316. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_max_err};
  9317. __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_validate_positive_tolerance, __pyx_mstate->__pyx_kp_b_iso88591_xs_j, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad;
  9318. }
  9319. {
  9320. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 18, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 194};
  9321. 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_spline, __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};
  9322. __pyx_mstate_global->__pyx_codeobj_tab[7] = __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_t1_q_q_Qe1Bat3a_t1_S_S_c_U, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad;
  9323. }
  9324. {
  9325. const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 42, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 270};
  9326. 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};
  9327. __pyx_mstate_global->__pyx_codeobj_tab[8] = __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[8])) goto bad;
  9328. }
  9329. {
  9330. const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 414};
  9331. 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};
  9332. __pyx_mstate_global->__pyx_codeobj_tab[9] = __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[9])) goto bad;
  9333. }
  9334. Py_DECREF(tuple_dedup_map);
  9335. return 0;
  9336. bad:
  9337. Py_DECREF(tuple_dedup_map);
  9338. return -1;
  9339. }
  9340. /* #### Code section: init_globals ### */
  9341. static int __Pyx_InitGlobals(void) {
  9342. /* PythonCompatibility.init */
  9343. if (likely(__Pyx_init_co_variables() == 0)); else
  9344. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  9345. /* AssertionsEnabled.init */
  9346. if (likely(__Pyx_init_assertions_enabled() == 0)); else
  9347. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  9348. /* CommonTypesMetaclass.init */
  9349. if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else
  9350. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  9351. /* CachedMethodType.init */
  9352. #if CYTHON_COMPILING_IN_LIMITED_API
  9353. {
  9354. PyObject *typesModule=NULL;
  9355. typesModule = PyImport_ImportModule("types");
  9356. if (typesModule) {
  9357. __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType");
  9358. Py_DECREF(typesModule);
  9359. }
  9360. } // error handling follows
  9361. #endif
  9362. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  9363. /* CythonFunctionShared.init */
  9364. if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else
  9365. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  9366. /* Generator.init */
  9367. if (likely(__pyx_Generator_init(__pyx_m) == 0)); else
  9368. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  9369. return 0;
  9370. __pyx_L1_error:;
  9371. return -1;
  9372. }
  9373. /* #### Code section: cleanup_globals ### */
  9374. /* #### Code section: cleanup_module ### */
  9375. /* #### Code section: main_method ### */
  9376. /* #### Code section: utility_code_pragmas ### */
  9377. #ifdef _MSC_VER
  9378. #pragma warning( push )
  9379. /* Warning 4127: conditional expression is constant
  9380. * Cython uses constant conditional expressions to allow in inline functions to be optimized at
  9381. * compile-time, so this warning is not useful
  9382. */
  9383. #pragma warning( disable : 4127 )
  9384. #endif
  9385. /* #### Code section: utility_code_def ### */
  9386. /* --- Runtime support code --- */
  9387. /* Refnanny */
  9388. #if CYTHON_REFNANNY
  9389. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  9390. PyObject *m = NULL, *p = NULL;
  9391. void *r = NULL;
  9392. m = PyImport_ImportModule(modname);
  9393. if (!m) goto end;
  9394. p = PyObject_GetAttrString(m, "RefNannyAPI");
  9395. if (!p) goto end;
  9396. r = PyLong_AsVoidPtr(p);
  9397. end:
  9398. Py_XDECREF(p);
  9399. Py_XDECREF(m);
  9400. return (__Pyx_RefNannyAPIStruct *)r;
  9401. }
  9402. #endif
  9403. /* PyErrExceptionMatches (used by PyObjectGetAttrStrNoError) */
  9404. #if CYTHON_FAST_THREAD_STATE
  9405. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  9406. Py_ssize_t i, n;
  9407. n = PyTuple_GET_SIZE(tuple);
  9408. for (i=0; i<n; i++) {
  9409. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  9410. }
  9411. for (i=0; i<n; i++) {
  9412. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  9413. }
  9414. return 0;
  9415. }
  9416. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  9417. int result;
  9418. PyObject *exc_type;
  9419. #if PY_VERSION_HEX >= 0x030C00A6
  9420. PyObject *current_exception = tstate->current_exception;
  9421. if (unlikely(!current_exception)) return 0;
  9422. exc_type = (PyObject*) Py_TYPE(current_exception);
  9423. if (exc_type == err) return 1;
  9424. #else
  9425. exc_type = tstate->curexc_type;
  9426. if (exc_type == err) return 1;
  9427. if (unlikely(!exc_type)) return 0;
  9428. #endif
  9429. #if CYTHON_AVOID_BORROWED_REFS
  9430. Py_INCREF(exc_type);
  9431. #endif
  9432. if (unlikely(PyTuple_Check(err))) {
  9433. result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  9434. } else {
  9435. result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  9436. }
  9437. #if CYTHON_AVOID_BORROWED_REFS
  9438. Py_DECREF(exc_type);
  9439. #endif
  9440. return result;
  9441. }
  9442. #endif
  9443. /* PyErrFetchRestore (used by PyObjectGetAttrStrNoError) */
  9444. #if CYTHON_FAST_THREAD_STATE
  9445. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  9446. #if PY_VERSION_HEX >= 0x030C00A6
  9447. PyObject *tmp_value;
  9448. assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
  9449. if (value) {
  9450. #if CYTHON_COMPILING_IN_CPYTHON
  9451. if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
  9452. #endif
  9453. PyException_SetTraceback(value, tb);
  9454. }
  9455. tmp_value = tstate->current_exception;
  9456. tstate->current_exception = value;
  9457. Py_XDECREF(tmp_value);
  9458. Py_XDECREF(type);
  9459. Py_XDECREF(tb);
  9460. #else
  9461. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9462. tmp_type = tstate->curexc_type;
  9463. tmp_value = tstate->curexc_value;
  9464. tmp_tb = tstate->curexc_traceback;
  9465. tstate->curexc_type = type;
  9466. tstate->curexc_value = value;
  9467. tstate->curexc_traceback = tb;
  9468. Py_XDECREF(tmp_type);
  9469. Py_XDECREF(tmp_value);
  9470. Py_XDECREF(tmp_tb);
  9471. #endif
  9472. }
  9473. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  9474. #if PY_VERSION_HEX >= 0x030C00A6
  9475. PyObject* exc_value;
  9476. exc_value = tstate->current_exception;
  9477. tstate->current_exception = 0;
  9478. *value = exc_value;
  9479. *type = NULL;
  9480. *tb = NULL;
  9481. if (exc_value) {
  9482. *type = (PyObject*) Py_TYPE(exc_value);
  9483. Py_INCREF(*type);
  9484. #if CYTHON_COMPILING_IN_CPYTHON
  9485. *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
  9486. Py_XINCREF(*tb);
  9487. #else
  9488. *tb = PyException_GetTraceback(exc_value);
  9489. #endif
  9490. }
  9491. #else
  9492. *type = tstate->curexc_type;
  9493. *value = tstate->curexc_value;
  9494. *tb = tstate->curexc_traceback;
  9495. tstate->curexc_type = 0;
  9496. tstate->curexc_value = 0;
  9497. tstate->curexc_traceback = 0;
  9498. #endif
  9499. }
  9500. #endif
  9501. /* PyObjectGetAttrStr (used by PyObjectGetAttrStrNoError) */
  9502. #if CYTHON_USE_TYPE_SLOTS
  9503. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  9504. PyTypeObject* tp = Py_TYPE(obj);
  9505. if (likely(tp->tp_getattro))
  9506. return tp->tp_getattro(obj, attr_name);
  9507. return PyObject_GetAttr(obj, attr_name);
  9508. }
  9509. #endif
  9510. /* PyObjectGetAttrStrNoError (used by GetBuiltinName) */
  9511. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  9512. static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
  9513. __Pyx_PyThreadState_declare
  9514. __Pyx_PyThreadState_assign
  9515. if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  9516. __Pyx_PyErr_Clear();
  9517. }
  9518. #endif
  9519. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
  9520. PyObject *result;
  9521. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  9522. (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
  9523. return result;
  9524. #else
  9525. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS
  9526. PyTypeObject* tp = Py_TYPE(obj);
  9527. if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
  9528. return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
  9529. }
  9530. #endif
  9531. result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
  9532. if (unlikely(!result)) {
  9533. __Pyx_PyObject_GetAttrStr_ClearAttributeError();
  9534. }
  9535. return result;
  9536. #endif
  9537. }
  9538. /* GetBuiltinName */
  9539. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  9540. PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name);
  9541. if (unlikely(!result) && !PyErr_Occurred()) {
  9542. PyErr_Format(PyExc_NameError,
  9543. "name '%U' is not defined", name);
  9544. }
  9545. return result;
  9546. }
  9547. /* TupleAndListFromArray (used by fastcall) */
  9548. #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL
  9549. static CYTHON_INLINE PyObject *
  9550. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  9551. {
  9552. PyObject *res;
  9553. Py_ssize_t i;
  9554. if (n <= 0) {
  9555. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  9556. }
  9557. res = PyTuple_New(n);
  9558. if (unlikely(res == NULL)) return NULL;
  9559. for (i = 0; i < n; i++) {
  9560. if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) {
  9561. Py_DECREF(res);
  9562. return NULL;
  9563. }
  9564. Py_INCREF(src[i]);
  9565. }
  9566. return res;
  9567. }
  9568. #elif CYTHON_COMPILING_IN_CPYTHON
  9569. static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
  9570. PyObject *v;
  9571. Py_ssize_t i;
  9572. for (i = 0; i < length; i++) {
  9573. v = dest[i] = src[i];
  9574. Py_INCREF(v);
  9575. }
  9576. }
  9577. static CYTHON_INLINE PyObject *
  9578. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  9579. {
  9580. PyObject *res;
  9581. if (n <= 0) {
  9582. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  9583. }
  9584. res = PyTuple_New(n);
  9585. if (unlikely(res == NULL)) return NULL;
  9586. __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
  9587. return res;
  9588. }
  9589. static CYTHON_INLINE PyObject *
  9590. __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
  9591. {
  9592. PyObject *res;
  9593. if (n <= 0) {
  9594. return PyList_New(0);
  9595. }
  9596. res = PyList_New(n);
  9597. if (unlikely(res == NULL)) return NULL;
  9598. __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
  9599. return res;
  9600. }
  9601. #endif
  9602. /* BytesEquals (used by UnicodeEquals) */
  9603. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  9604. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\
  9605. !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS)
  9606. return PyObject_RichCompareBool(s1, s2, equals);
  9607. #else
  9608. if (s1 == s2) {
  9609. return (equals == Py_EQ);
  9610. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  9611. const char *ps1, *ps2;
  9612. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  9613. if (length != PyBytes_GET_SIZE(s2))
  9614. return (equals == Py_NE);
  9615. ps1 = PyBytes_AS_STRING(s1);
  9616. ps2 = PyBytes_AS_STRING(s2);
  9617. if (ps1[0] != ps2[0]) {
  9618. return (equals == Py_NE);
  9619. } else if (length == 1) {
  9620. return (equals == Py_EQ);
  9621. } else {
  9622. int result;
  9623. #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
  9624. Py_hash_t hash1, hash2;
  9625. hash1 = ((PyBytesObject*)s1)->ob_shash;
  9626. hash2 = ((PyBytesObject*)s2)->ob_shash;
  9627. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  9628. return (equals == Py_NE);
  9629. }
  9630. #endif
  9631. result = memcmp(ps1, ps2, (size_t)length);
  9632. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  9633. }
  9634. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  9635. return (equals == Py_NE);
  9636. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  9637. return (equals == Py_NE);
  9638. } else {
  9639. int result;
  9640. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  9641. if (!py_result)
  9642. return -1;
  9643. result = __Pyx_PyObject_IsTrue(py_result);
  9644. Py_DECREF(py_result);
  9645. return result;
  9646. }
  9647. #endif
  9648. }
  9649. /* UnicodeEquals (used by fastcall) */
  9650. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  9651. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  9652. return PyObject_RichCompareBool(s1, s2, equals);
  9653. #else
  9654. int s1_is_unicode, s2_is_unicode;
  9655. if (s1 == s2) {
  9656. goto return_eq;
  9657. }
  9658. s1_is_unicode = PyUnicode_CheckExact(s1);
  9659. s2_is_unicode = PyUnicode_CheckExact(s2);
  9660. if (s1_is_unicode & s2_is_unicode) {
  9661. Py_ssize_t length, length2;
  9662. int kind;
  9663. void *data1, *data2;
  9664. #if !CYTHON_COMPILING_IN_LIMITED_API
  9665. if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
  9666. return -1;
  9667. #endif
  9668. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  9669. #if !CYTHON_ASSUME_SAFE_SIZE
  9670. if (unlikely(length < 0)) return -1;
  9671. #endif
  9672. length2 = __Pyx_PyUnicode_GET_LENGTH(s2);
  9673. #if !CYTHON_ASSUME_SAFE_SIZE
  9674. if (unlikely(length2 < 0)) return -1;
  9675. #endif
  9676. if (length != length2) {
  9677. goto return_ne;
  9678. }
  9679. #if CYTHON_USE_UNICODE_INTERNALS
  9680. {
  9681. Py_hash_t hash1, hash2;
  9682. hash1 = ((PyASCIIObject*)s1)->hash;
  9683. hash2 = ((PyASCIIObject*)s2)->hash;
  9684. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  9685. goto return_ne;
  9686. }
  9687. }
  9688. #endif
  9689. kind = __Pyx_PyUnicode_KIND(s1);
  9690. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  9691. goto return_ne;
  9692. }
  9693. data1 = __Pyx_PyUnicode_DATA(s1);
  9694. data2 = __Pyx_PyUnicode_DATA(s2);
  9695. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  9696. goto return_ne;
  9697. } else if (length == 1) {
  9698. goto return_eq;
  9699. } else {
  9700. int result = memcmp(data1, data2, (size_t)(length * kind));
  9701. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  9702. }
  9703. } else if ((s1 == Py_None) & s2_is_unicode) {
  9704. goto return_ne;
  9705. } else if ((s2 == Py_None) & s1_is_unicode) {
  9706. goto return_ne;
  9707. } else {
  9708. int result;
  9709. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  9710. if (!py_result)
  9711. return -1;
  9712. result = __Pyx_PyObject_IsTrue(py_result);
  9713. Py_DECREF(py_result);
  9714. return result;
  9715. }
  9716. return_eq:
  9717. return (equals == Py_EQ);
  9718. return_ne:
  9719. return (equals == Py_NE);
  9720. #endif
  9721. }
  9722. /* fastcall */
  9723. #if CYTHON_METH_FASTCALL
  9724. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
  9725. {
  9726. Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames);
  9727. #if !CYTHON_ASSUME_SAFE_SIZE
  9728. if (unlikely(n == -1)) return NULL;
  9729. #endif
  9730. for (i = 0; i < n; i++)
  9731. {
  9732. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  9733. #if !CYTHON_ASSUME_SAFE_MACROS
  9734. if (unlikely(!namei)) return NULL;
  9735. #endif
  9736. if (s == namei) return kwvalues[i];
  9737. }
  9738. for (i = 0; i < n; i++)
  9739. {
  9740. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  9741. #if !CYTHON_ASSUME_SAFE_MACROS
  9742. if (unlikely(!namei)) return NULL;
  9743. #endif
  9744. int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ);
  9745. if (unlikely(eq != 0)) {
  9746. if (unlikely(eq < 0)) return NULL;
  9747. return kwvalues[i];
  9748. }
  9749. }
  9750. return NULL;
  9751. }
  9752. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  9753. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
  9754. Py_ssize_t i, nkwargs;
  9755. PyObject *dict;
  9756. #if !CYTHON_ASSUME_SAFE_SIZE
  9757. nkwargs = PyTuple_Size(kwnames);
  9758. if (unlikely(nkwargs < 0)) return NULL;
  9759. #else
  9760. nkwargs = PyTuple_GET_SIZE(kwnames);
  9761. #endif
  9762. dict = PyDict_New();
  9763. if (unlikely(!dict))
  9764. return NULL;
  9765. for (i=0; i<nkwargs; i++) {
  9766. #if !CYTHON_ASSUME_SAFE_MACROS
  9767. PyObject *key = PyTuple_GetItem(kwnames, i);
  9768. if (!key) goto bad;
  9769. #else
  9770. PyObject *key = PyTuple_GET_ITEM(kwnames, i);
  9771. #endif
  9772. if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
  9773. goto bad;
  9774. }
  9775. return dict;
  9776. bad:
  9777. Py_DECREF(dict);
  9778. return NULL;
  9779. }
  9780. #endif
  9781. #endif
  9782. /* PyObjectCall (used by PyObjectFastCall) */
  9783. #if CYTHON_COMPILING_IN_CPYTHON
  9784. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  9785. PyObject *result;
  9786. ternaryfunc call = Py_TYPE(func)->tp_call;
  9787. if (unlikely(!call))
  9788. return PyObject_Call(func, arg, kw);
  9789. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  9790. return NULL;
  9791. result = (*call)(func, arg, kw);
  9792. Py_LeaveRecursiveCall();
  9793. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  9794. PyErr_SetString(
  9795. PyExc_SystemError,
  9796. "NULL result without error in PyObject_Call");
  9797. }
  9798. return result;
  9799. }
  9800. #endif
  9801. /* PyObjectCallMethO (used by PyObjectFastCall) */
  9802. #if CYTHON_COMPILING_IN_CPYTHON
  9803. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  9804. PyObject *self, *result;
  9805. PyCFunction cfunc;
  9806. cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func);
  9807. self = __Pyx_CyOrPyCFunction_GET_SELF(func);
  9808. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  9809. return NULL;
  9810. result = cfunc(self, arg);
  9811. Py_LeaveRecursiveCall();
  9812. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  9813. PyErr_SetString(
  9814. PyExc_SystemError,
  9815. "NULL result without error in PyObject_Call");
  9816. }
  9817. return result;
  9818. }
  9819. #endif
  9820. /* PyObjectFastCall (used by PyObjectCallOneArg) */
  9821. #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
  9822. static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) {
  9823. PyObject *argstuple;
  9824. PyObject *result = 0;
  9825. size_t i;
  9826. argstuple = PyTuple_New((Py_ssize_t)nargs);
  9827. if (unlikely(!argstuple)) return NULL;
  9828. for (i = 0; i < nargs; i++) {
  9829. Py_INCREF(args[i]);
  9830. if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad;
  9831. }
  9832. result = __Pyx_PyObject_Call(func, argstuple, kwargs);
  9833. bad:
  9834. Py_DECREF(argstuple);
  9835. return result;
  9836. }
  9837. #endif
  9838. #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API
  9839. #if PY_VERSION_HEX < 0x03090000
  9840. #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable)
  9841. #elif CYTHON_COMPILING_IN_CPYTHON
  9842. static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) {
  9843. PyTypeObject *tp = Py_TYPE(callable);
  9844. #if defined(__Pyx_CyFunction_USED)
  9845. if (__Pyx_CyFunction_CheckExact(callable)) {
  9846. return __Pyx_CyFunction_func_vectorcall(callable);
  9847. }
  9848. #endif
  9849. if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) {
  9850. return NULL;
  9851. }
  9852. assert(PyCallable_Check(callable));
  9853. Py_ssize_t offset = tp->tp_vectorcall_offset;
  9854. assert(offset > 0);
  9855. vectorcallfunc ptr;
  9856. memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
  9857. return ptr;
  9858. }
  9859. #else
  9860. #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable)
  9861. #endif
  9862. #endif
  9863. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) {
  9864. Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
  9865. #if CYTHON_COMPILING_IN_CPYTHON
  9866. if (nargs == 0 && kwargs == NULL) {
  9867. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
  9868. return __Pyx_PyObject_CallMethO(func, NULL);
  9869. }
  9870. else if (nargs == 1 && kwargs == NULL) {
  9871. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O))
  9872. return __Pyx_PyObject_CallMethO(func, args[0]);
  9873. }
  9874. #endif
  9875. if (kwargs == NULL) {
  9876. #if CYTHON_VECTORCALL
  9877. #if CYTHON_COMPILING_IN_LIMITED_API
  9878. return PyObject_Vectorcall(func, args, _nargs, NULL);
  9879. #else
  9880. vectorcallfunc f = __Pyx_PyVectorcall_Function(func);
  9881. if (f) {
  9882. return f(func, args, _nargs, NULL);
  9883. }
  9884. #endif
  9885. #endif
  9886. }
  9887. if (nargs == 0) {
  9888. return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs);
  9889. }
  9890. #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
  9891. return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
  9892. #else
  9893. return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
  9894. #endif
  9895. }
  9896. /* PyObjectCallOneArg (used by CallUnboundCMethod0) */
  9897. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  9898. PyObject *args[2] = {NULL, arg};
  9899. return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  9900. }
  9901. /* UnpackUnboundCMethod (used by CallUnboundCMethod0) */
  9902. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  9903. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) {
  9904. PyObject *result;
  9905. PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
  9906. if (unlikely(!selfless_args)) return NULL;
  9907. result = PyObject_Call(method, selfless_args, kwargs);
  9908. Py_DECREF(selfless_args);
  9909. return result;
  9910. }
  9911. #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000
  9912. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) {
  9913. return _PyObject_Vectorcall
  9914. (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames);
  9915. }
  9916. #else
  9917. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) {
  9918. return
  9919. #if PY_VERSION_HEX < 0x03090000
  9920. _PyObject_Vectorcall
  9921. #else
  9922. PyObject_Vectorcall
  9923. #endif
  9924. (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames);
  9925. }
  9926. #endif
  9927. static PyMethodDef __Pyx_UnboundCMethod_Def = {
  9928. "CythonUnboundCMethod",
  9929. __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall),
  9930. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  9931. METH_VARARGS | METH_KEYWORDS,
  9932. #else
  9933. METH_FASTCALL | METH_KEYWORDS,
  9934. #endif
  9935. NULL
  9936. };
  9937. static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
  9938. PyObject *method, *result=NULL;
  9939. method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
  9940. if (unlikely(!method))
  9941. return -1;
  9942. result = method;
  9943. #if CYTHON_COMPILING_IN_CPYTHON
  9944. if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
  9945. {
  9946. PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
  9947. target->func = descr->d_method->ml_meth;
  9948. target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
  9949. } else
  9950. #endif
  9951. #if CYTHON_COMPILING_IN_PYPY
  9952. #else
  9953. if (PyCFunction_Check(method))
  9954. #endif
  9955. {
  9956. PyObject *self;
  9957. int self_found;
  9958. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  9959. self = PyObject_GetAttrString(method, "__self__");
  9960. if (!self) {
  9961. PyErr_Clear();
  9962. }
  9963. #else
  9964. self = PyCFunction_GET_SELF(method);
  9965. #endif
  9966. self_found = (self && self != Py_None);
  9967. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  9968. Py_XDECREF(self);
  9969. #endif
  9970. if (self_found) {
  9971. PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method);
  9972. if (unlikely(!unbound_method)) return -1;
  9973. Py_DECREF(method);
  9974. result = unbound_method;
  9975. }
  9976. }
  9977. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  9978. if (unlikely(target->method)) {
  9979. Py_DECREF(result);
  9980. } else
  9981. #endif
  9982. target->method = result;
  9983. return 0;
  9984. }
  9985. /* CallUnboundCMethod0 */
  9986. #if CYTHON_COMPILING_IN_CPYTHON
  9987. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  9988. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  9989. if (likely(was_initialized == 2 && cfunc->func)) {
  9990. if (likely(cfunc->flag == METH_NOARGS))
  9991. return __Pyx_CallCFunction(cfunc, self, NULL);
  9992. if (likely(cfunc->flag == METH_FASTCALL))
  9993. return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0);
  9994. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  9995. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL);
  9996. if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS)))
  9997. return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  9998. if (cfunc->flag == METH_VARARGS)
  9999. return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple);
  10000. return __Pyx__CallUnboundCMethod0(cfunc, self);
  10001. }
  10002. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  10003. else if (unlikely(was_initialized == 1)) {
  10004. __Pyx_CachedCFunction tmp_cfunc = {
  10005. #ifndef __cplusplus
  10006. 0
  10007. #endif
  10008. };
  10009. tmp_cfunc.type = cfunc->type;
  10010. tmp_cfunc.method_name = cfunc->method_name;
  10011. return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self);
  10012. }
  10013. #endif
  10014. PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self);
  10015. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  10016. return result;
  10017. }
  10018. #endif
  10019. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  10020. PyObject *result;
  10021. if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  10022. result = __Pyx_PyObject_CallOneArg(cfunc->method, self);
  10023. return result;
  10024. }
  10025. /* py_dict_items (used by OwnedDictNext) */
  10026. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
  10027. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d);
  10028. }
  10029. /* py_dict_values (used by OwnedDictNext) */
  10030. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
  10031. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d);
  10032. }
  10033. /* OwnedDictNext (used by ParseKeywordsImpl) */
  10034. #if CYTHON_AVOID_BORROWED_REFS
  10035. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) {
  10036. PyObject *next = NULL;
  10037. if (!*ppos) {
  10038. if (pvalue) {
  10039. PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p);
  10040. if (unlikely(!dictview)) goto bad;
  10041. *ppos = PyObject_GetIter(dictview);
  10042. Py_DECREF(dictview);
  10043. } else {
  10044. *ppos = PyObject_GetIter(p);
  10045. }
  10046. if (unlikely(!*ppos)) goto bad;
  10047. }
  10048. next = PyIter_Next(*ppos);
  10049. if (!next) {
  10050. if (PyErr_Occurred()) goto bad;
  10051. return 0;
  10052. }
  10053. if (pkey && pvalue) {
  10054. *pkey = __Pyx_PySequence_ITEM(next, 0);
  10055. if (unlikely(*pkey)) goto bad;
  10056. *pvalue = __Pyx_PySequence_ITEM(next, 1);
  10057. if (unlikely(*pvalue)) goto bad;
  10058. Py_DECREF(next);
  10059. } else if (pkey) {
  10060. *pkey = next;
  10061. } else {
  10062. assert(pvalue);
  10063. *pvalue = next;
  10064. }
  10065. return 1;
  10066. bad:
  10067. Py_XDECREF(next);
  10068. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  10069. PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef");
  10070. #else
  10071. PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef);
  10072. #endif
  10073. if (pkey) *pkey = NULL;
  10074. if (pvalue) *pvalue = NULL;
  10075. return 0;
  10076. }
  10077. #else // !CYTHON_AVOID_BORROWED_REFS
  10078. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) {
  10079. int result = PyDict_Next(p, ppos, pkey, pvalue);
  10080. if (likely(result == 1)) {
  10081. if (pkey) Py_INCREF(*pkey);
  10082. if (pvalue) Py_INCREF(*pvalue);
  10083. }
  10084. return result;
  10085. }
  10086. #endif
  10087. /* RaiseDoubleKeywords (used by ParseKeywordsImpl) */
  10088. static void __Pyx_RaiseDoubleKeywordsError(
  10089. const char* func_name,
  10090. PyObject* kw_name)
  10091. {
  10092. PyErr_Format(PyExc_TypeError,
  10093. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  10094. }
  10095. /* CallUnboundCMethod2 */
  10096. #if CYTHON_COMPILING_IN_CPYTHON
  10097. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
  10098. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  10099. if (likely(was_initialized == 2 && cfunc->func)) {
  10100. PyObject *args[2] = {arg1, arg2};
  10101. if (cfunc->flag == METH_FASTCALL) {
  10102. return __Pyx_CallCFunctionFast(cfunc, self, args, 2);
  10103. }
  10104. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  10105. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL);
  10106. }
  10107. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  10108. else if (unlikely(was_initialized == 1)) {
  10109. __Pyx_CachedCFunction tmp_cfunc = {
  10110. #ifndef __cplusplus
  10111. 0
  10112. #endif
  10113. };
  10114. tmp_cfunc.type = cfunc->type;
  10115. tmp_cfunc.method_name = cfunc->method_name;
  10116. return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2);
  10117. }
  10118. #endif
  10119. PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
  10120. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  10121. return result;
  10122. }
  10123. #endif
  10124. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
  10125. if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  10126. #if CYTHON_COMPILING_IN_CPYTHON
  10127. if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
  10128. PyObject *result = NULL;
  10129. PyObject *args = PyTuple_New(2);
  10130. if (unlikely(!args)) return NULL;
  10131. Py_INCREF(arg1);
  10132. PyTuple_SET_ITEM(args, 0, arg1);
  10133. Py_INCREF(arg2);
  10134. PyTuple_SET_ITEM(args, 1, arg2);
  10135. if (cfunc->flag & METH_KEYWORDS)
  10136. result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL);
  10137. else
  10138. result = __Pyx_CallCFunction(cfunc, self, args);
  10139. Py_DECREF(args);
  10140. return result;
  10141. }
  10142. #endif
  10143. {
  10144. PyObject *args[4] = {NULL, self, arg1, arg2};
  10145. return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  10146. }
  10147. }
  10148. /* ParseKeywordsImpl (used by ParseKeywords) */
  10149. static int __Pyx_ValidateDuplicatePosArgs(
  10150. PyObject *kwds,
  10151. PyObject ** const argnames[],
  10152. PyObject ** const *first_kw_arg,
  10153. const char* function_name)
  10154. {
  10155. PyObject ** const *name = argnames;
  10156. while (name != first_kw_arg) {
  10157. PyObject *key = **name;
  10158. int found = PyDict_Contains(kwds, key);
  10159. if (unlikely(found)) {
  10160. if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key);
  10161. goto bad;
  10162. }
  10163. name++;
  10164. }
  10165. return 0;
  10166. bad:
  10167. return -1;
  10168. }
  10169. #if CYTHON_USE_UNICODE_INTERNALS
  10170. static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) {
  10171. int kind;
  10172. Py_ssize_t len = PyUnicode_GET_LENGTH(s1);
  10173. if (len != PyUnicode_GET_LENGTH(s2)) return 0;
  10174. kind = PyUnicode_KIND(s1);
  10175. if (kind != PyUnicode_KIND(s2)) return 0;
  10176. const void *data1 = PyUnicode_DATA(s1);
  10177. const void *data2 = PyUnicode_DATA(s2);
  10178. return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0);
  10179. }
  10180. #endif
  10181. static int __Pyx_MatchKeywordArg_str(
  10182. PyObject *key,
  10183. PyObject ** const argnames[],
  10184. PyObject ** const *first_kw_arg,
  10185. size_t *index_found,
  10186. const char *function_name)
  10187. {
  10188. PyObject ** const *name;
  10189. #if CYTHON_USE_UNICODE_INTERNALS
  10190. Py_hash_t key_hash = ((PyASCIIObject*)key)->hash;
  10191. if (unlikely(key_hash == -1)) {
  10192. key_hash = PyObject_Hash(key);
  10193. if (unlikely(key_hash == -1))
  10194. goto bad;
  10195. }
  10196. #endif
  10197. name = first_kw_arg;
  10198. while (*name) {
  10199. PyObject *name_str = **name;
  10200. #if CYTHON_USE_UNICODE_INTERNALS
  10201. if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) {
  10202. *index_found = (size_t) (name - argnames);
  10203. return 1;
  10204. }
  10205. #else
  10206. #if CYTHON_ASSUME_SAFE_SIZE
  10207. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  10208. #endif
  10209. {
  10210. int cmp = PyUnicode_Compare(name_str, key);
  10211. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  10212. if (cmp == 0) {
  10213. *index_found = (size_t) (name - argnames);
  10214. return 1;
  10215. }
  10216. }
  10217. #endif
  10218. name++;
  10219. }
  10220. name = argnames;
  10221. while (name != first_kw_arg) {
  10222. PyObject *name_str = **name;
  10223. #if CYTHON_USE_UNICODE_INTERNALS
  10224. if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) {
  10225. if (__Pyx_UnicodeKeywordsEqual(name_str, key))
  10226. goto arg_passed_twice;
  10227. }
  10228. #else
  10229. #if CYTHON_ASSUME_SAFE_SIZE
  10230. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  10231. #endif
  10232. {
  10233. if (unlikely(name_str == key)) goto arg_passed_twice;
  10234. int cmp = PyUnicode_Compare(name_str, key);
  10235. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  10236. if (cmp == 0) goto arg_passed_twice;
  10237. }
  10238. #endif
  10239. name++;
  10240. }
  10241. return 0;
  10242. arg_passed_twice:
  10243. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  10244. goto bad;
  10245. bad:
  10246. return -1;
  10247. }
  10248. static int __Pyx_MatchKeywordArg_nostr(
  10249. PyObject *key,
  10250. PyObject ** const argnames[],
  10251. PyObject ** const *first_kw_arg,
  10252. size_t *index_found,
  10253. const char *function_name)
  10254. {
  10255. PyObject ** const *name;
  10256. if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type;
  10257. name = first_kw_arg;
  10258. while (*name) {
  10259. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  10260. if (cmp == 1) {
  10261. *index_found = (size_t) (name - argnames);
  10262. return 1;
  10263. }
  10264. if (unlikely(cmp == -1)) goto bad;
  10265. name++;
  10266. }
  10267. name = argnames;
  10268. while (name != first_kw_arg) {
  10269. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  10270. if (unlikely(cmp != 0)) {
  10271. if (cmp == 1) goto arg_passed_twice;
  10272. else goto bad;
  10273. }
  10274. name++;
  10275. }
  10276. return 0;
  10277. arg_passed_twice:
  10278. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  10279. goto bad;
  10280. invalid_keyword_type:
  10281. PyErr_Format(PyExc_TypeError,
  10282. "%.200s() keywords must be strings", function_name);
  10283. goto bad;
  10284. bad:
  10285. return -1;
  10286. }
  10287. static CYTHON_INLINE int __Pyx_MatchKeywordArg(
  10288. PyObject *key,
  10289. PyObject ** const argnames[],
  10290. PyObject ** const *first_kw_arg,
  10291. size_t *index_found,
  10292. const char *function_name)
  10293. {
  10294. return likely(PyUnicode_CheckExact(key)) ?
  10295. __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) :
  10296. __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name);
  10297. }
  10298. static void __Pyx_RejectUnknownKeyword(
  10299. PyObject *kwds,
  10300. PyObject ** const argnames[],
  10301. PyObject ** const *first_kw_arg,
  10302. const char *function_name)
  10303. {
  10304. #if CYTHON_AVOID_BORROWED_REFS
  10305. PyObject *pos = NULL;
  10306. #else
  10307. Py_ssize_t pos = 0;
  10308. #endif
  10309. PyObject *key = NULL;
  10310. __Pyx_BEGIN_CRITICAL_SECTION(kwds);
  10311. while (
  10312. #if CYTHON_AVOID_BORROWED_REFS
  10313. __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL)
  10314. #else
  10315. PyDict_Next(kwds, &pos, &key, NULL)
  10316. #endif
  10317. ) {
  10318. PyObject** const *name = first_kw_arg;
  10319. while (*name && (**name != key)) name++;
  10320. if (!*name) {
  10321. size_t index_found = 0;
  10322. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  10323. if (cmp != 1) {
  10324. if (cmp == 0) {
  10325. PyErr_Format(PyExc_TypeError,
  10326. "%s() got an unexpected keyword argument '%U'",
  10327. function_name, key);
  10328. }
  10329. #if CYTHON_AVOID_BORROWED_REFS
  10330. Py_DECREF(key);
  10331. #endif
  10332. break;
  10333. }
  10334. }
  10335. #if CYTHON_AVOID_BORROWED_REFS
  10336. Py_DECREF(key);
  10337. #endif
  10338. }
  10339. __Pyx_END_CRITICAL_SECTION();
  10340. #if CYTHON_AVOID_BORROWED_REFS
  10341. Py_XDECREF(pos);
  10342. #endif
  10343. assert(PyErr_Occurred());
  10344. }
  10345. static int __Pyx_ParseKeywordDict(
  10346. PyObject *kwds,
  10347. PyObject ** const argnames[],
  10348. PyObject *values[],
  10349. Py_ssize_t num_pos_args,
  10350. Py_ssize_t num_kwargs,
  10351. const char* function_name,
  10352. int ignore_unknown_kwargs)
  10353. {
  10354. PyObject** const *name;
  10355. PyObject** const *first_kw_arg = argnames + num_pos_args;
  10356. Py_ssize_t extracted = 0;
  10357. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  10358. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  10359. #endif
  10360. name = first_kw_arg;
  10361. while (*name && num_kwargs > extracted) {
  10362. PyObject * key = **name;
  10363. PyObject *value;
  10364. int found = 0;
  10365. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  10366. found = PyDict_GetItemRef(kwds, key, &value);
  10367. #else
  10368. value = PyDict_GetItemWithError(kwds, key);
  10369. if (value) {
  10370. Py_INCREF(value);
  10371. found = 1;
  10372. } else {
  10373. if (unlikely(PyErr_Occurred())) goto bad;
  10374. }
  10375. #endif
  10376. if (found) {
  10377. if (unlikely(found < 0)) goto bad;
  10378. values[name-argnames] = value;
  10379. extracted++;
  10380. }
  10381. name++;
  10382. }
  10383. if (num_kwargs > extracted) {
  10384. if (ignore_unknown_kwargs) {
  10385. if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1))
  10386. goto bad;
  10387. } else {
  10388. __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name);
  10389. goto bad;
  10390. }
  10391. }
  10392. return 0;
  10393. bad:
  10394. return -1;
  10395. }
  10396. static int __Pyx_ParseKeywordDictToDict(
  10397. PyObject *kwds,
  10398. PyObject ** const argnames[],
  10399. PyObject *kwds2,
  10400. PyObject *values[],
  10401. Py_ssize_t num_pos_args,
  10402. const char* function_name)
  10403. {
  10404. PyObject** const *name;
  10405. PyObject** const *first_kw_arg = argnames + num_pos_args;
  10406. Py_ssize_t len;
  10407. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  10408. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  10409. #endif
  10410. if (PyDict_Update(kwds2, kwds) < 0) goto bad;
  10411. name = first_kw_arg;
  10412. while (*name) {
  10413. PyObject *key = **name;
  10414. PyObject *value;
  10415. #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop))
  10416. int found = PyDict_Pop(kwds2, key, &value);
  10417. if (found) {
  10418. if (unlikely(found < 0)) goto bad;
  10419. values[name-argnames] = value;
  10420. }
  10421. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  10422. int found = PyDict_GetItemRef(kwds2, key, &value);
  10423. if (found) {
  10424. if (unlikely(found < 0)) goto bad;
  10425. values[name-argnames] = value;
  10426. if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad;
  10427. }
  10428. #else
  10429. #if CYTHON_COMPILING_IN_CPYTHON
  10430. value = _PyDict_Pop(kwds2, key, kwds2);
  10431. #else
  10432. value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2);
  10433. #endif
  10434. if (value == kwds2) {
  10435. Py_DECREF(value);
  10436. } else {
  10437. if (unlikely(!value)) goto bad;
  10438. values[name-argnames] = value;
  10439. }
  10440. #endif
  10441. name++;
  10442. }
  10443. len = PyDict_Size(kwds2);
  10444. if (len > 0) {
  10445. return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name);
  10446. } else if (unlikely(len == -1)) {
  10447. goto bad;
  10448. }
  10449. return 0;
  10450. bad:
  10451. return -1;
  10452. }
  10453. static int __Pyx_ParseKeywordsTuple(
  10454. PyObject *kwds,
  10455. PyObject * const *kwvalues,
  10456. PyObject ** const argnames[],
  10457. PyObject *kwds2,
  10458. PyObject *values[],
  10459. Py_ssize_t num_pos_args,
  10460. Py_ssize_t num_kwargs,
  10461. const char* function_name,
  10462. int ignore_unknown_kwargs)
  10463. {
  10464. PyObject *key = NULL;
  10465. PyObject** const * name;
  10466. PyObject** const *first_kw_arg = argnames + num_pos_args;
  10467. for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
  10468. #if CYTHON_AVOID_BORROWED_REFS
  10469. key = __Pyx_PySequence_ITEM(kwds, pos);
  10470. #else
  10471. key = __Pyx_PyTuple_GET_ITEM(kwds, pos);
  10472. #endif
  10473. #if !CYTHON_ASSUME_SAFE_MACROS
  10474. if (unlikely(!key)) goto bad;
  10475. #endif
  10476. name = first_kw_arg;
  10477. while (*name && (**name != key)) name++;
  10478. if (*name) {
  10479. PyObject *value = kwvalues[pos];
  10480. values[name-argnames] = __Pyx_NewRef(value);
  10481. } else {
  10482. size_t index_found = 0;
  10483. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  10484. if (cmp == 1) {
  10485. PyObject *value = kwvalues[pos];
  10486. values[index_found] = __Pyx_NewRef(value);
  10487. } else {
  10488. if (unlikely(cmp == -1)) goto bad;
  10489. if (kwds2) {
  10490. PyObject *value = kwvalues[pos];
  10491. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  10492. } else if (!ignore_unknown_kwargs) {
  10493. goto invalid_keyword;
  10494. }
  10495. }
  10496. }
  10497. #if CYTHON_AVOID_BORROWED_REFS
  10498. Py_DECREF(key);
  10499. key = NULL;
  10500. #endif
  10501. }
  10502. return 0;
  10503. invalid_keyword:
  10504. PyErr_Format(PyExc_TypeError,
  10505. "%s() got an unexpected keyword argument '%U'",
  10506. function_name, key);
  10507. goto bad;
  10508. bad:
  10509. #if CYTHON_AVOID_BORROWED_REFS
  10510. Py_XDECREF(key);
  10511. #endif
  10512. return -1;
  10513. }
  10514. /* ParseKeywords */
  10515. static int __Pyx_ParseKeywords(
  10516. PyObject *kwds,
  10517. PyObject * const *kwvalues,
  10518. PyObject ** const argnames[],
  10519. PyObject *kwds2,
  10520. PyObject *values[],
  10521. Py_ssize_t num_pos_args,
  10522. Py_ssize_t num_kwargs,
  10523. const char* function_name,
  10524. int ignore_unknown_kwargs)
  10525. {
  10526. if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)))
  10527. return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  10528. else if (kwds2)
  10529. return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name);
  10530. else
  10531. return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  10532. }
  10533. /* RaiseArgTupleInvalid */
  10534. static void __Pyx_RaiseArgtupleInvalid(
  10535. const char* func_name,
  10536. int exact,
  10537. Py_ssize_t num_min,
  10538. Py_ssize_t num_max,
  10539. Py_ssize_t num_found)
  10540. {
  10541. Py_ssize_t num_expected;
  10542. const char *more_or_less;
  10543. if (num_found < num_min) {
  10544. num_expected = num_min;
  10545. more_or_less = "at least";
  10546. } else {
  10547. num_expected = num_max;
  10548. more_or_less = "at most";
  10549. }
  10550. if (exact) {
  10551. more_or_less = "exactly";
  10552. }
  10553. PyErr_Format(PyExc_TypeError,
  10554. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  10555. func_name, more_or_less, num_expected,
  10556. (num_expected == 1) ? "" : "s", num_found);
  10557. }
  10558. /* GetItemInt */
  10559. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  10560. PyObject *r;
  10561. if (unlikely(!j)) return NULL;
  10562. r = PyObject_GetItem(o, j);
  10563. Py_DECREF(j);
  10564. return r;
  10565. }
  10566. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  10567. int wraparound, int boundscheck, int unsafe_shared) {
  10568. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  10569. #if CYTHON_ASSUME_SAFE_SIZE
  10570. Py_ssize_t wrapped_i = i;
  10571. if (wraparound & unlikely(i < 0)) {
  10572. wrapped_i += PyList_GET_SIZE(o);
  10573. }
  10574. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS)) {
  10575. return __Pyx_PyList_GetItemRefFast(o, wrapped_i, unsafe_shared);
  10576. } else
  10577. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
  10578. return __Pyx_NewRef(PyList_GET_ITEM(o, wrapped_i));
  10579. }
  10580. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  10581. #else
  10582. (void)wraparound;
  10583. (void)boundscheck;
  10584. return PySequence_GetItem(o, i);
  10585. #endif
  10586. }
  10587. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  10588. int wraparound, int boundscheck, int unsafe_shared) {
  10589. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  10590. #if CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  10591. Py_ssize_t wrapped_i = i;
  10592. if (wraparound & unlikely(i < 0)) {
  10593. wrapped_i += PyTuple_GET_SIZE(o);
  10594. }
  10595. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
  10596. return __Pyx_NewRef(PyTuple_GET_ITEM(o, wrapped_i));
  10597. }
  10598. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  10599. #else
  10600. (void)wraparound;
  10601. (void)boundscheck;
  10602. return PySequence_GetItem(o, i);
  10603. #endif
  10604. }
  10605. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
  10606. int wraparound, int boundscheck, int unsafe_shared) {
  10607. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  10608. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  10609. if (is_list || PyList_CheckExact(o)) {
  10610. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  10611. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) {
  10612. return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared);
  10613. } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
  10614. return __Pyx_NewRef(PyList_GET_ITEM(o, n));
  10615. }
  10616. } else
  10617. #if !CYTHON_AVOID_BORROWED_REFS
  10618. if (PyTuple_CheckExact(o)) {
  10619. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  10620. if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
  10621. return __Pyx_NewRef(PyTuple_GET_ITEM(o, n));
  10622. }
  10623. } else
  10624. #endif
  10625. #endif
  10626. #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
  10627. {
  10628. PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
  10629. PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
  10630. if (!is_list && mm && mm->mp_subscript) {
  10631. PyObject *r, *key = PyLong_FromSsize_t(i);
  10632. if (unlikely(!key)) return NULL;
  10633. r = mm->mp_subscript(o, key);
  10634. Py_DECREF(key);
  10635. return r;
  10636. }
  10637. if (is_list || likely(sm && sm->sq_item)) {
  10638. if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
  10639. Py_ssize_t l = sm->sq_length(o);
  10640. if (likely(l >= 0)) {
  10641. i += l;
  10642. } else {
  10643. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  10644. return NULL;
  10645. PyErr_Clear();
  10646. }
  10647. }
  10648. return sm->sq_item(o, i);
  10649. }
  10650. }
  10651. #else
  10652. if (is_list || !PyMapping_Check(o)) {
  10653. return PySequence_GetItem(o, i);
  10654. }
  10655. #endif
  10656. (void)wraparound;
  10657. (void)boundscheck;
  10658. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  10659. }
  10660. /* RaiseException */
  10661. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  10662. PyObject* owned_instance = NULL;
  10663. if (tb == Py_None) {
  10664. tb = 0;
  10665. } else if (tb && !PyTraceBack_Check(tb)) {
  10666. PyErr_SetString(PyExc_TypeError,
  10667. "raise: arg 3 must be a traceback or None");
  10668. goto bad;
  10669. }
  10670. if (value == Py_None)
  10671. value = 0;
  10672. if (PyExceptionInstance_Check(type)) {
  10673. if (value) {
  10674. PyErr_SetString(PyExc_TypeError,
  10675. "instance exception may not have a separate value");
  10676. goto bad;
  10677. }
  10678. value = type;
  10679. type = (PyObject*) Py_TYPE(value);
  10680. } else if (PyExceptionClass_Check(type)) {
  10681. PyObject *instance_class = NULL;
  10682. if (value && PyExceptionInstance_Check(value)) {
  10683. instance_class = (PyObject*) Py_TYPE(value);
  10684. if (instance_class != type) {
  10685. int is_subclass = PyObject_IsSubclass(instance_class, type);
  10686. if (!is_subclass) {
  10687. instance_class = NULL;
  10688. } else if (unlikely(is_subclass == -1)) {
  10689. goto bad;
  10690. } else {
  10691. type = instance_class;
  10692. }
  10693. }
  10694. }
  10695. if (!instance_class) {
  10696. PyObject *args;
  10697. if (!value)
  10698. args = PyTuple_New(0);
  10699. else if (PyTuple_Check(value)) {
  10700. Py_INCREF(value);
  10701. args = value;
  10702. } else
  10703. args = PyTuple_Pack(1, value);
  10704. if (!args)
  10705. goto bad;
  10706. owned_instance = PyObject_Call(type, args, NULL);
  10707. Py_DECREF(args);
  10708. if (!owned_instance)
  10709. goto bad;
  10710. value = owned_instance;
  10711. if (!PyExceptionInstance_Check(value)) {
  10712. PyErr_Format(PyExc_TypeError,
  10713. "calling %R should have returned an instance of "
  10714. "BaseException, not %R",
  10715. type, Py_TYPE(value));
  10716. goto bad;
  10717. }
  10718. }
  10719. } else {
  10720. PyErr_SetString(PyExc_TypeError,
  10721. "raise: exception class must be a subclass of BaseException");
  10722. goto bad;
  10723. }
  10724. if (cause) {
  10725. PyObject *fixed_cause;
  10726. if (cause == Py_None) {
  10727. fixed_cause = NULL;
  10728. } else if (PyExceptionClass_Check(cause)) {
  10729. fixed_cause = PyObject_CallObject(cause, NULL);
  10730. if (fixed_cause == NULL)
  10731. goto bad;
  10732. } else if (PyExceptionInstance_Check(cause)) {
  10733. fixed_cause = cause;
  10734. Py_INCREF(fixed_cause);
  10735. } else {
  10736. PyErr_SetString(PyExc_TypeError,
  10737. "exception causes must derive from "
  10738. "BaseException");
  10739. goto bad;
  10740. }
  10741. PyException_SetCause(value, fixed_cause);
  10742. }
  10743. PyErr_SetObject(type, value);
  10744. if (tb) {
  10745. #if PY_VERSION_HEX >= 0x030C00A6
  10746. PyException_SetTraceback(value, tb);
  10747. #elif CYTHON_FAST_THREAD_STATE
  10748. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  10749. PyObject* tmp_tb = tstate->curexc_traceback;
  10750. if (tb != tmp_tb) {
  10751. Py_INCREF(tb);
  10752. tstate->curexc_traceback = tb;
  10753. Py_XDECREF(tmp_tb);
  10754. }
  10755. #else
  10756. PyObject *tmp_type, *tmp_value, *tmp_tb;
  10757. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  10758. Py_INCREF(tb);
  10759. PyErr_Restore(tmp_type, tmp_value, tb);
  10760. Py_XDECREF(tmp_tb);
  10761. #endif
  10762. }
  10763. bad:
  10764. Py_XDECREF(owned_instance);
  10765. return;
  10766. }
  10767. /* py_abs */
  10768. #if CYTHON_USE_PYLONG_INTERNALS
  10769. static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) {
  10770. #if PY_VERSION_HEX >= 0x030C00A7
  10771. if (likely(__Pyx_PyLong_IsCompact(n))) {
  10772. return PyLong_FromSize_t(__Pyx_PyLong_CompactValueUnsigned(n));
  10773. }
  10774. #else
  10775. if (likely(Py_SIZE(n) == -1)) {
  10776. return PyLong_FromUnsignedLong(__Pyx_PyLong_Digits(n)[0]);
  10777. }
  10778. #endif
  10779. #if CYTHON_COMPILING_IN_CPYTHON
  10780. {
  10781. PyObject *copy = _PyLong_Copy((PyLongObject*)n);
  10782. if (likely(copy)) {
  10783. #if PY_VERSION_HEX >= 0x030C00A7
  10784. ((PyLongObject*)copy)->long_value.lv_tag ^= ((PyLongObject*)copy)->long_value.lv_tag & _PyLong_SIGN_MASK;
  10785. #else
  10786. __Pyx_SET_SIZE(copy, -Py_SIZE(copy));
  10787. #endif
  10788. }
  10789. return copy;
  10790. }
  10791. #else
  10792. return PyNumber_Negative(n);
  10793. #endif
  10794. }
  10795. #endif
  10796. /* SliceTupleAndList */
  10797. #if CYTHON_COMPILING_IN_CPYTHON
  10798. static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
  10799. Py_ssize_t start = *_start, stop = *_stop, length = *_length;
  10800. if (start < 0) {
  10801. start += length;
  10802. if (start < 0)
  10803. start = 0;
  10804. }
  10805. if (stop < 0)
  10806. stop += length;
  10807. else if (stop > length)
  10808. stop = length;
  10809. *_length = stop - start;
  10810. *_start = start;
  10811. *_stop = stop;
  10812. }
  10813. static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
  10814. PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
  10815. Py_ssize_t length = PyTuple_GET_SIZE(src);
  10816. __Pyx_crop_slice(&start, &stop, &length);
  10817. return __Pyx_PyTuple_FromArray(((PyTupleObject*)src)->ob_item + start, length);
  10818. }
  10819. static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice_locked(
  10820. PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
  10821. Py_ssize_t length = PyList_GET_SIZE(src);
  10822. __Pyx_crop_slice(&start, &stop, &length);
  10823. if (length <= 0) {
  10824. return PyList_New(0);
  10825. }
  10826. return __Pyx_PyList_FromArray(((PyListObject*)src)->ob_item + start, length);
  10827. }
  10828. static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
  10829. PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
  10830. PyObject *result;
  10831. __Pyx_BEGIN_CRITICAL_SECTION(src);
  10832. result = __Pyx_PyList_GetSlice_locked(src, start, stop);
  10833. __Pyx_END_CRITICAL_SECTION();
  10834. return result;
  10835. }
  10836. #endif // CYTHON_COMPILING_IN_CPYTHON
  10837. /* PyLongBinop */
  10838. #if !CYTHON_COMPILING_IN_PYPY
  10839. static PyObject* __Pyx_Fallback___Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, int inplace) {
  10840. return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
  10841. }
  10842. #if CYTHON_USE_PYLONG_INTERNALS
  10843. static PyObject* __Pyx_Unpacked___Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  10844. CYTHON_MAYBE_UNUSED_VAR(inplace);
  10845. CYTHON_UNUSED_VAR(zerodivision_check);
  10846. const long a = intval;
  10847. long b;
  10848. const PY_LONG_LONG lla = intval;
  10849. PY_LONG_LONG llb;
  10850. if (unlikely(__Pyx_PyLong_IsZero(op2))) {
  10851. return __Pyx_NewRef(op1);
  10852. }
  10853. const int is_positive = __Pyx_PyLong_IsPos(op2);
  10854. const digit* digits = __Pyx_PyLong_Digits(op2);
  10855. const Py_ssize_t size = __Pyx_PyLong_DigitCount(op2);
  10856. if (likely(size == 1)) {
  10857. b = (long) digits[0];
  10858. if (!is_positive) b *= -1;
  10859. } else {
  10860. switch (size) {
  10861. case 2:
  10862. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  10863. b = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10864. if (!is_positive) b *= -1;
  10865. goto calculate_long;
  10866. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  10867. llb = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  10868. if (!is_positive) llb *= -1;
  10869. goto calculate_long_long;
  10870. }
  10871. break;
  10872. case 3:
  10873. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  10874. b = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10875. if (!is_positive) b *= -1;
  10876. goto calculate_long;
  10877. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  10878. 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]));
  10879. if (!is_positive) llb *= -1;
  10880. goto calculate_long_long;
  10881. }
  10882. break;
  10883. case 4:
  10884. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  10885. b = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  10886. if (!is_positive) b *= -1;
  10887. goto calculate_long;
  10888. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  10889. 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]));
  10890. if (!is_positive) llb *= -1;
  10891. goto calculate_long_long;
  10892. }
  10893. break;
  10894. }
  10895. return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
  10896. }
  10897. calculate_long:
  10898. {
  10899. long x;
  10900. x = a - b;
  10901. return PyLong_FromLong(x);
  10902. }
  10903. calculate_long_long:
  10904. {
  10905. PY_LONG_LONG llx;
  10906. llx = lla - llb;
  10907. return PyLong_FromLongLong(llx);
  10908. }
  10909. }
  10910. #endif
  10911. static PyObject* __Pyx_Float___Pyx_PyLong_SubtractCObj(PyObject *float_val, long intval, int zerodivision_check) {
  10912. CYTHON_UNUSED_VAR(zerodivision_check);
  10913. const long a = intval;
  10914. double b = __Pyx_PyFloat_AS_DOUBLE(float_val);
  10915. double result;
  10916. result = ((double)a) - (double)b;
  10917. return PyFloat_FromDouble(result);
  10918. }
  10919. static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractCObj(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  10920. CYTHON_MAYBE_UNUSED_VAR(intval);
  10921. CYTHON_UNUSED_VAR(zerodivision_check);
  10922. #if CYTHON_USE_PYLONG_INTERNALS
  10923. if (likely(PyLong_CheckExact(op2))) {
  10924. return __Pyx_Unpacked___Pyx_PyLong_SubtractCObj(op1, op2, intval, inplace, zerodivision_check);
  10925. }
  10926. #endif
  10927. if (PyFloat_CheckExact(op2)) {
  10928. return __Pyx_Float___Pyx_PyLong_SubtractCObj(op2, intval, zerodivision_check);
  10929. }
  10930. return __Pyx_Fallback___Pyx_PyLong_SubtractCObj(op1, op2, inplace);
  10931. }
  10932. #endif
  10933. /* PyObjectFormatAndDecref */
  10934. static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
  10935. if (unlikely(!s)) return NULL;
  10936. if (likely(PyUnicode_CheckExact(s))) return s;
  10937. return __Pyx_PyObject_FormatAndDecref(s, f);
  10938. }
  10939. static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
  10940. PyObject *result;
  10941. if (unlikely(!s)) return NULL;
  10942. result = PyObject_Format(s, f);
  10943. Py_DECREF(s);
  10944. return result;
  10945. }
  10946. /* JoinPyUnicode */
  10947. static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength,
  10948. Py_UCS4 max_char) {
  10949. #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  10950. PyObject *result_uval;
  10951. int result_ukind, kind_shift;
  10952. Py_ssize_t i, char_pos;
  10953. void *result_udata;
  10954. if (max_char > 1114111) max_char = 1114111;
  10955. result_uval = PyUnicode_New(result_ulength, max_char);
  10956. if (unlikely(!result_uval)) return NULL;
  10957. result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
  10958. kind_shift = (result_ukind == PyUnicode_4BYTE_KIND) ? 2 : result_ukind - 1;
  10959. result_udata = PyUnicode_DATA(result_uval);
  10960. assert(kind_shift == 2 || kind_shift == 1 || kind_shift == 0);
  10961. if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - result_ulength < 0))
  10962. goto overflow;
  10963. char_pos = 0;
  10964. for (i=0; i < value_count; i++) {
  10965. int ukind;
  10966. Py_ssize_t ulength;
  10967. void *udata;
  10968. PyObject *uval = values[i];
  10969. #if !CYTHON_COMPILING_IN_LIMITED_API
  10970. if (__Pyx_PyUnicode_READY(uval) == (-1))
  10971. goto bad;
  10972. #endif
  10973. ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
  10974. #if !CYTHON_ASSUME_SAFE_SIZE
  10975. if (unlikely(ulength < 0)) goto bad;
  10976. #endif
  10977. if (unlikely(!ulength))
  10978. continue;
  10979. if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - ulength < char_pos))
  10980. goto overflow;
  10981. ukind = __Pyx_PyUnicode_KIND(uval);
  10982. udata = __Pyx_PyUnicode_DATA(uval);
  10983. if (ukind == result_ukind) {
  10984. memcpy((char *)result_udata + (char_pos << kind_shift), udata, (size_t) (ulength << kind_shift));
  10985. } else {
  10986. #if PY_VERSION_HEX >= 0x030d0000
  10987. if (unlikely(PyUnicode_CopyCharacters(result_uval, char_pos, uval, 0, ulength) < 0)) goto bad;
  10988. #elif CYTHON_COMPILING_IN_CPYTHON || defined(_PyUnicode_FastCopyCharacters)
  10989. _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
  10990. #else
  10991. Py_ssize_t j;
  10992. for (j=0; j < ulength; j++) {
  10993. Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
  10994. __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
  10995. }
  10996. #endif
  10997. }
  10998. char_pos += ulength;
  10999. }
  11000. return result_uval;
  11001. overflow:
  11002. PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
  11003. bad:
  11004. Py_DECREF(result_uval);
  11005. return NULL;
  11006. #else
  11007. Py_ssize_t i;
  11008. PyObject *result = NULL;
  11009. PyObject *value_tuple = PyTuple_New(value_count);
  11010. if (unlikely(!value_tuple)) return NULL;
  11011. CYTHON_UNUSED_VAR(max_char);
  11012. CYTHON_UNUSED_VAR(result_ulength);
  11013. for (i=0; i<value_count; i++) {
  11014. if (__Pyx_PyTuple_SET_ITEM(value_tuple, i, values[i]) != (0)) goto bad;
  11015. Py_INCREF(values[i]);
  11016. }
  11017. result = PyUnicode_Join(__pyx_mstate_global->__pyx_empty_unicode, value_tuple);
  11018. bad:
  11019. Py_DECREF(value_tuple);
  11020. return result;
  11021. #endif
  11022. }
  11023. /* ArgTypeTestFunc (used by ArgTypeTest) */
  11024. static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
  11025. {
  11026. __Pyx_TypeName type_name;
  11027. __Pyx_TypeName obj_type_name;
  11028. PyObject *extra_info = __pyx_mstate_global->__pyx_empty_unicode;
  11029. int from_annotation_subclass = 0;
  11030. if (unlikely(!type)) {
  11031. PyErr_SetString(PyExc_SystemError, "Missing type object");
  11032. return 0;
  11033. }
  11034. else if (!exact) {
  11035. if (likely(__Pyx_TypeCheck(obj, type))) return 1;
  11036. } else if (exact == 2) {
  11037. if (__Pyx_TypeCheck(obj, type)) {
  11038. from_annotation_subclass = 1;
  11039. extra_info = __pyx_mstate_global->__pyx_kp_u_Note_that_Cython_is_deliberately;
  11040. }
  11041. }
  11042. type_name = __Pyx_PyType_GetFullyQualifiedName(type);
  11043. obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  11044. PyErr_Format(PyExc_TypeError,
  11045. "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME
  11046. ", got " __Pyx_FMT_TYPENAME ")"
  11047. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  11048. "%s%U"
  11049. #endif
  11050. , name, type_name, obj_type_name
  11051. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  11052. , (from_annotation_subclass ? ". " : ""), extra_info
  11053. #endif
  11054. );
  11055. #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  11056. if (exact == 2 && from_annotation_subclass) {
  11057. PyObject *res;
  11058. PyObject *vargs[2];
  11059. vargs[0] = PyErr_GetRaisedException();
  11060. vargs[1] = extra_info;
  11061. res = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_kp_u_add_note, vargs, 2, NULL);
  11062. Py_XDECREF(res);
  11063. PyErr_SetRaisedException(vargs[0]);
  11064. }
  11065. #endif
  11066. __Pyx_DECREF_TypeName(type_name);
  11067. __Pyx_DECREF_TypeName(obj_type_name);
  11068. return 0;
  11069. }
  11070. /* RaiseUnboundLocalError */
  11071. static void __Pyx_RaiseUnboundLocalError(const char *varname) {
  11072. PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
  11073. }
  11074. /* GetException (used by pep479) */
  11075. #if CYTHON_FAST_THREAD_STATE
  11076. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
  11077. #else
  11078. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
  11079. #endif
  11080. {
  11081. PyObject *local_type = NULL, *local_value, *local_tb = NULL;
  11082. #if CYTHON_FAST_THREAD_STATE
  11083. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11084. #if PY_VERSION_HEX >= 0x030C0000
  11085. local_value = tstate->current_exception;
  11086. tstate->current_exception = 0;
  11087. #else
  11088. local_type = tstate->curexc_type;
  11089. local_value = tstate->curexc_value;
  11090. local_tb = tstate->curexc_traceback;
  11091. tstate->curexc_type = 0;
  11092. tstate->curexc_value = 0;
  11093. tstate->curexc_traceback = 0;
  11094. #endif
  11095. #elif __PYX_LIMITED_VERSION_HEX > 0x030C0000
  11096. local_value = PyErr_GetRaisedException();
  11097. #else
  11098. PyErr_Fetch(&local_type, &local_value, &local_tb);
  11099. #endif
  11100. #if __PYX_LIMITED_VERSION_HEX > 0x030C0000
  11101. if (likely(local_value)) {
  11102. local_type = (PyObject*) Py_TYPE(local_value);
  11103. Py_INCREF(local_type);
  11104. local_tb = PyException_GetTraceback(local_value);
  11105. }
  11106. #else
  11107. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  11108. #if CYTHON_FAST_THREAD_STATE
  11109. if (unlikely(tstate->curexc_type))
  11110. #else
  11111. if (unlikely(PyErr_Occurred()))
  11112. #endif
  11113. goto bad;
  11114. if (local_tb) {
  11115. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  11116. goto bad;
  11117. }
  11118. #endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000
  11119. Py_XINCREF(local_tb);
  11120. Py_XINCREF(local_type);
  11121. Py_XINCREF(local_value);
  11122. *type = local_type;
  11123. *value = local_value;
  11124. *tb = local_tb;
  11125. #if CYTHON_FAST_THREAD_STATE
  11126. #if CYTHON_USE_EXC_INFO_STACK
  11127. {
  11128. _PyErr_StackItem *exc_info = tstate->exc_info;
  11129. #if PY_VERSION_HEX >= 0x030B00a4
  11130. tmp_value = exc_info->exc_value;
  11131. exc_info->exc_value = local_value;
  11132. tmp_type = NULL;
  11133. tmp_tb = NULL;
  11134. Py_XDECREF(local_type);
  11135. Py_XDECREF(local_tb);
  11136. #else
  11137. tmp_type = exc_info->exc_type;
  11138. tmp_value = exc_info->exc_value;
  11139. tmp_tb = exc_info->exc_traceback;
  11140. exc_info->exc_type = local_type;
  11141. exc_info->exc_value = local_value;
  11142. exc_info->exc_traceback = local_tb;
  11143. #endif
  11144. }
  11145. #else
  11146. tmp_type = tstate->exc_type;
  11147. tmp_value = tstate->exc_value;
  11148. tmp_tb = tstate->exc_traceback;
  11149. tstate->exc_type = local_type;
  11150. tstate->exc_value = local_value;
  11151. tstate->exc_traceback = local_tb;
  11152. #endif
  11153. Py_XDECREF(tmp_type);
  11154. Py_XDECREF(tmp_value);
  11155. Py_XDECREF(tmp_tb);
  11156. #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  11157. PyErr_SetHandledException(local_value);
  11158. Py_XDECREF(local_value);
  11159. Py_XDECREF(local_type);
  11160. Py_XDECREF(local_tb);
  11161. #else
  11162. PyErr_SetExcInfo(local_type, local_value, local_tb);
  11163. #endif
  11164. return 0;
  11165. #if __PYX_LIMITED_VERSION_HEX <= 0x030C0000
  11166. bad:
  11167. *type = 0;
  11168. *value = 0;
  11169. *tb = 0;
  11170. Py_XDECREF(local_type);
  11171. Py_XDECREF(local_value);
  11172. Py_XDECREF(local_tb);
  11173. return -1;
  11174. #endif
  11175. }
  11176. /* pep479 */
  11177. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen) {
  11178. PyObject *exc, *val, *tb, *cur_exc, *new_exc;
  11179. __Pyx_PyThreadState_declare
  11180. int is_async_stopiteration = 0;
  11181. CYTHON_MAYBE_UNUSED_VAR(in_async_gen);
  11182. __Pyx_PyThreadState_assign
  11183. cur_exc = __Pyx_PyErr_CurrentExceptionType();
  11184. if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) {
  11185. if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopAsyncIteration))) {
  11186. is_async_stopiteration = 1;
  11187. } else {
  11188. return;
  11189. }
  11190. }
  11191. __Pyx_GetException(&exc, &val, &tb);
  11192. Py_XDECREF(exc);
  11193. Py_XDECREF(tb);
  11194. new_exc = PyObject_CallFunction(PyExc_RuntimeError, "s",
  11195. is_async_stopiteration ? "async generator raised StopAsyncIteration" :
  11196. in_async_gen ? "async generator raised StopIteration" :
  11197. "generator raised StopIteration");
  11198. if (!new_exc) {
  11199. Py_XDECREF(val);
  11200. return;
  11201. }
  11202. PyException_SetCause(new_exc, val); // steals ref to val
  11203. PyErr_SetObject(PyExc_RuntimeError, new_exc);
  11204. }
  11205. /* PyDictVersioning (used by GetModuleGlobalName) */
  11206. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  11207. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
  11208. PyObject *dict = Py_TYPE(obj)->tp_dict;
  11209. return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
  11210. }
  11211. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
  11212. PyObject **dictptr = NULL;
  11213. Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
  11214. if (offset) {
  11215. #if CYTHON_COMPILING_IN_CPYTHON
  11216. dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
  11217. #else
  11218. dictptr = _PyObject_GetDictPtr(obj);
  11219. #endif
  11220. }
  11221. return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
  11222. }
  11223. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
  11224. PyObject *dict = Py_TYPE(obj)->tp_dict;
  11225. if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
  11226. return 0;
  11227. return obj_dict_version == __Pyx_get_object_dict_version(obj);
  11228. }
  11229. #endif
  11230. /* GetModuleGlobalName */
  11231. #if CYTHON_USE_DICT_VERSIONS
  11232. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
  11233. #else
  11234. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
  11235. #endif
  11236. {
  11237. PyObject *result;
  11238. #if CYTHON_COMPILING_IN_LIMITED_API
  11239. if (unlikely(!__pyx_m)) {
  11240. if (!PyErr_Occurred())
  11241. PyErr_SetNone(PyExc_NameError);
  11242. return NULL;
  11243. }
  11244. result = PyObject_GetAttr(__pyx_m, name);
  11245. if (likely(result)) {
  11246. return result;
  11247. }
  11248. PyErr_Clear();
  11249. #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  11250. if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear();
  11251. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  11252. if (likely(result)) {
  11253. return result;
  11254. }
  11255. #else
  11256. result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash);
  11257. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  11258. if (likely(result)) {
  11259. return __Pyx_NewRef(result);
  11260. }
  11261. PyErr_Clear();
  11262. #endif
  11263. return __Pyx_GetBuiltinName(name);
  11264. }
  11265. /* RaiseTooManyValuesToUnpack */
  11266. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  11267. PyErr_Format(PyExc_ValueError,
  11268. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  11269. }
  11270. /* RaiseNeedMoreValuesToUnpack */
  11271. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  11272. PyErr_Format(PyExc_ValueError,
  11273. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  11274. index, (index == 1) ? "" : "s");
  11275. }
  11276. /* IterFinish */
  11277. static CYTHON_INLINE int __Pyx_IterFinish(void) {
  11278. PyObject* exc_type;
  11279. __Pyx_PyThreadState_declare
  11280. __Pyx_PyThreadState_assign
  11281. exc_type = __Pyx_PyErr_CurrentExceptionType();
  11282. if (unlikely(exc_type)) {
  11283. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
  11284. return -1;
  11285. __Pyx_PyErr_Clear();
  11286. return 0;
  11287. }
  11288. return 0;
  11289. }
  11290. /* UnpackItemEndCheck */
  11291. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
  11292. if (unlikely(retval)) {
  11293. Py_DECREF(retval);
  11294. __Pyx_RaiseTooManyValuesError(expected);
  11295. return -1;
  11296. }
  11297. return __Pyx_IterFinish();
  11298. }
  11299. /* SliceObject */
  11300. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
  11301. Py_ssize_t cstart, Py_ssize_t cstop,
  11302. PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
  11303. int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
  11304. __Pyx_TypeName obj_type_name;
  11305. #if CYTHON_USE_TYPE_SLOTS
  11306. PyMappingMethods* mp = Py_TYPE(obj)->tp_as_mapping;
  11307. if (likely(mp && mp->mp_subscript))
  11308. #endif
  11309. {
  11310. PyObject* result;
  11311. PyObject *py_slice, *py_start, *py_stop;
  11312. if (_py_slice) {
  11313. py_slice = *_py_slice;
  11314. } else {
  11315. PyObject* owned_start = NULL;
  11316. PyObject* owned_stop = NULL;
  11317. if (_py_start) {
  11318. py_start = *_py_start;
  11319. } else {
  11320. if (has_cstart) {
  11321. owned_start = py_start = PyLong_FromSsize_t(cstart);
  11322. if (unlikely(!py_start)) goto bad;
  11323. } else
  11324. py_start = Py_None;
  11325. }
  11326. if (_py_stop) {
  11327. py_stop = *_py_stop;
  11328. } else {
  11329. if (has_cstop) {
  11330. owned_stop = py_stop = PyLong_FromSsize_t(cstop);
  11331. if (unlikely(!py_stop)) {
  11332. Py_XDECREF(owned_start);
  11333. goto bad;
  11334. }
  11335. } else
  11336. py_stop = Py_None;
  11337. }
  11338. py_slice = PySlice_New(py_start, py_stop, Py_None);
  11339. Py_XDECREF(owned_start);
  11340. Py_XDECREF(owned_stop);
  11341. if (unlikely(!py_slice)) goto bad;
  11342. }
  11343. #if CYTHON_USE_TYPE_SLOTS
  11344. result = mp->mp_subscript(obj, py_slice);
  11345. #else
  11346. result = PyObject_GetItem(obj, py_slice);
  11347. #endif
  11348. if (!_py_slice) {
  11349. Py_DECREF(py_slice);
  11350. }
  11351. return result;
  11352. }
  11353. obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  11354. PyErr_Format(PyExc_TypeError,
  11355. "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj_type_name);
  11356. __Pyx_DECREF_TypeName(obj_type_name);
  11357. bad:
  11358. return NULL;
  11359. }
  11360. /* PyObjectCallNoArg (used by PyObjectCallMethod0) */
  11361. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  11362. PyObject *arg[2] = {NULL, NULL};
  11363. return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  11364. }
  11365. /* PyObjectGetMethod (used by PyObjectCallMethod0) */
  11366. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  11367. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
  11368. PyObject *attr;
  11369. #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
  11370. __Pyx_TypeName type_name;
  11371. PyTypeObject *tp = Py_TYPE(obj);
  11372. PyObject *descr;
  11373. descrgetfunc f = NULL;
  11374. PyObject **dictptr, *dict;
  11375. int meth_found = 0;
  11376. assert (*method == NULL);
  11377. if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
  11378. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  11379. goto try_unpack;
  11380. }
  11381. if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
  11382. return 0;
  11383. }
  11384. descr = _PyType_Lookup(tp, name);
  11385. if (likely(descr != NULL)) {
  11386. Py_INCREF(descr);
  11387. #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR
  11388. if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR))
  11389. #else
  11390. #ifdef __Pyx_CyFunction_USED
  11391. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
  11392. #else
  11393. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type)))
  11394. #endif
  11395. #endif
  11396. {
  11397. meth_found = 1;
  11398. } else {
  11399. f = Py_TYPE(descr)->tp_descr_get;
  11400. if (f != NULL && PyDescr_IsData(descr)) {
  11401. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  11402. Py_DECREF(descr);
  11403. goto try_unpack;
  11404. }
  11405. }
  11406. }
  11407. dictptr = _PyObject_GetDictPtr(obj);
  11408. if (dictptr != NULL && (dict = *dictptr) != NULL) {
  11409. Py_INCREF(dict);
  11410. attr = __Pyx_PyDict_GetItemStr(dict, name);
  11411. if (attr != NULL) {
  11412. Py_INCREF(attr);
  11413. Py_DECREF(dict);
  11414. Py_XDECREF(descr);
  11415. goto try_unpack;
  11416. }
  11417. Py_DECREF(dict);
  11418. }
  11419. if (meth_found) {
  11420. *method = descr;
  11421. return 1;
  11422. }
  11423. if (f != NULL) {
  11424. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  11425. Py_DECREF(descr);
  11426. goto try_unpack;
  11427. }
  11428. if (likely(descr != NULL)) {
  11429. *method = descr;
  11430. return 0;
  11431. }
  11432. type_name = __Pyx_PyType_GetFullyQualifiedName(tp);
  11433. PyErr_Format(PyExc_AttributeError,
  11434. "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
  11435. type_name, name);
  11436. __Pyx_DECREF_TypeName(type_name);
  11437. return 0;
  11438. #else
  11439. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  11440. goto try_unpack;
  11441. #endif
  11442. try_unpack:
  11443. #if CYTHON_UNPACK_METHODS
  11444. if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
  11445. PyObject *function = PyMethod_GET_FUNCTION(attr);
  11446. Py_INCREF(function);
  11447. Py_DECREF(attr);
  11448. *method = function;
  11449. return 1;
  11450. }
  11451. #endif
  11452. *method = attr;
  11453. return 0;
  11454. }
  11455. #endif
  11456. /* PyObjectCallMethod0 (used by pop) */
  11457. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
  11458. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  11459. PyObject *args[1] = {obj};
  11460. (void) __Pyx_PyObject_CallOneArg;
  11461. (void) __Pyx_PyObject_CallNoArg;
  11462. return PyObject_VectorcallMethod(method_name, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  11463. #else
  11464. PyObject *method = NULL, *result = NULL;
  11465. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  11466. if (likely(is_method)) {
  11467. result = __Pyx_PyObject_CallOneArg(method, obj);
  11468. Py_DECREF(method);
  11469. return result;
  11470. }
  11471. if (unlikely(!method)) goto bad;
  11472. result = __Pyx_PyObject_CallNoArg(method);
  11473. Py_DECREF(method);
  11474. bad:
  11475. return result;
  11476. #endif
  11477. }
  11478. /* pop */
  11479. static CYTHON_INLINE PyObject* __Pyx__PyObject_Pop(PyObject* L) {
  11480. if (__Pyx_IS_TYPE(L, &PySet_Type)) {
  11481. return PySet_Pop(L);
  11482. }
  11483. return __Pyx_PyObject_CallMethod0(L, __pyx_mstate_global->__pyx_n_u_pop);
  11484. }
  11485. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  11486. static CYTHON_INLINE PyObject* __Pyx_PyList_Pop(PyObject* L) {
  11487. if (likely(PyList_GET_SIZE(L) > (((PyListObject*)L)->allocated >> 1))) {
  11488. __Pyx_SET_SIZE(L, Py_SIZE(L) - 1);
  11489. return PyList_GET_ITEM(L, PyList_GET_SIZE(L));
  11490. }
  11491. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyList_Type_pop, L);
  11492. }
  11493. #endif
  11494. /* RaiseUnexpectedTypeError */
  11495. static int
  11496. __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj)
  11497. {
  11498. __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  11499. PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME,
  11500. expected, obj_type_name);
  11501. __Pyx_DECREF_TypeName(obj_type_name);
  11502. return 0;
  11503. }
  11504. /* PyLongBinop */
  11505. #if !CYTHON_COMPILING_IN_PYPY
  11506. static PyObject* __Pyx_Fallback___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, int inplace) {
  11507. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  11508. }
  11509. #if CYTHON_USE_PYLONG_INTERNALS
  11510. static PyObject* __Pyx_Unpacked___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  11511. CYTHON_MAYBE_UNUSED_VAR(inplace);
  11512. CYTHON_UNUSED_VAR(zerodivision_check);
  11513. const long b = intval;
  11514. long a;
  11515. const PY_LONG_LONG llb = intval;
  11516. PY_LONG_LONG lla;
  11517. if (unlikely(__Pyx_PyLong_IsZero(op1))) {
  11518. return __Pyx_NewRef(op2);
  11519. }
  11520. const int is_positive = __Pyx_PyLong_IsPos(op1);
  11521. const digit* digits = __Pyx_PyLong_Digits(op1);
  11522. const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
  11523. if (likely(size == 1)) {
  11524. a = (long) digits[0];
  11525. if (!is_positive) a *= -1;
  11526. } else {
  11527. switch (size) {
  11528. case 2:
  11529. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  11530. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11531. if (!is_positive) a *= -1;
  11532. goto calculate_long;
  11533. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  11534. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  11535. if (!is_positive) lla *= -1;
  11536. goto calculate_long_long;
  11537. }
  11538. break;
  11539. case 3:
  11540. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  11541. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11542. if (!is_positive) a *= -1;
  11543. goto calculate_long;
  11544. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  11545. 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]));
  11546. if (!is_positive) lla *= -1;
  11547. goto calculate_long_long;
  11548. }
  11549. break;
  11550. case 4:
  11551. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  11552. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  11553. if (!is_positive) a *= -1;
  11554. goto calculate_long;
  11555. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  11556. 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]));
  11557. if (!is_positive) lla *= -1;
  11558. goto calculate_long_long;
  11559. }
  11560. break;
  11561. }
  11562. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  11563. }
  11564. calculate_long:
  11565. {
  11566. long x;
  11567. x = a + b;
  11568. return PyLong_FromLong(x);
  11569. }
  11570. calculate_long_long:
  11571. {
  11572. PY_LONG_LONG llx;
  11573. llx = lla + llb;
  11574. return PyLong_FromLongLong(llx);
  11575. }
  11576. }
  11577. #endif
  11578. static PyObject* __Pyx_Float___Pyx_PyLong_AddObjC(PyObject *float_val, long intval, int zerodivision_check) {
  11579. CYTHON_UNUSED_VAR(zerodivision_check);
  11580. const long b = intval;
  11581. double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
  11582. double result;
  11583. result = ((double)a) + (double)b;
  11584. return PyFloat_FromDouble(result);
  11585. }
  11586. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  11587. CYTHON_MAYBE_UNUSED_VAR(intval);
  11588. CYTHON_UNUSED_VAR(zerodivision_check);
  11589. #if CYTHON_USE_PYLONG_INTERNALS
  11590. if (likely(PyLong_CheckExact(op1))) {
  11591. return __Pyx_Unpacked___Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check);
  11592. }
  11593. #endif
  11594. if (PyFloat_CheckExact(op1)) {
  11595. return __Pyx_Float___Pyx_PyLong_AddObjC(op1, intval, zerodivision_check);
  11596. }
  11597. return __Pyx_Fallback___Pyx_PyLong_AddObjC(op1, op2, inplace);
  11598. }
  11599. #endif
  11600. /* GetTopmostException (used by SaveResetException) */
  11601. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  11602. static _PyErr_StackItem *
  11603. __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
  11604. {
  11605. _PyErr_StackItem *exc_info = tstate->exc_info;
  11606. while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
  11607. exc_info->previous_item != NULL)
  11608. {
  11609. exc_info = exc_info->previous_item;
  11610. }
  11611. return exc_info;
  11612. }
  11613. #endif
  11614. /* SaveResetException */
  11615. #if CYTHON_FAST_THREAD_STATE
  11616. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  11617. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  11618. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  11619. PyObject *exc_value = exc_info->exc_value;
  11620. if (exc_value == NULL || exc_value == Py_None) {
  11621. *value = NULL;
  11622. *type = NULL;
  11623. *tb = NULL;
  11624. } else {
  11625. *value = exc_value;
  11626. Py_INCREF(*value);
  11627. *type = (PyObject*) Py_TYPE(exc_value);
  11628. Py_INCREF(*type);
  11629. *tb = PyException_GetTraceback(exc_value);
  11630. }
  11631. #elif CYTHON_USE_EXC_INFO_STACK
  11632. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  11633. *type = exc_info->exc_type;
  11634. *value = exc_info->exc_value;
  11635. *tb = exc_info->exc_traceback;
  11636. Py_XINCREF(*type);
  11637. Py_XINCREF(*value);
  11638. Py_XINCREF(*tb);
  11639. #else
  11640. *type = tstate->exc_type;
  11641. *value = tstate->exc_value;
  11642. *tb = tstate->exc_traceback;
  11643. Py_XINCREF(*type);
  11644. Py_XINCREF(*value);
  11645. Py_XINCREF(*tb);
  11646. #endif
  11647. }
  11648. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  11649. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  11650. _PyErr_StackItem *exc_info = tstate->exc_info;
  11651. PyObject *tmp_value = exc_info->exc_value;
  11652. exc_info->exc_value = value;
  11653. Py_XDECREF(tmp_value);
  11654. Py_XDECREF(type);
  11655. Py_XDECREF(tb);
  11656. #else
  11657. PyObject *tmp_type, *tmp_value, *tmp_tb;
  11658. #if CYTHON_USE_EXC_INFO_STACK
  11659. _PyErr_StackItem *exc_info = tstate->exc_info;
  11660. tmp_type = exc_info->exc_type;
  11661. tmp_value = exc_info->exc_value;
  11662. tmp_tb = exc_info->exc_traceback;
  11663. exc_info->exc_type = type;
  11664. exc_info->exc_value = value;
  11665. exc_info->exc_traceback = tb;
  11666. #else
  11667. tmp_type = tstate->exc_type;
  11668. tmp_value = tstate->exc_value;
  11669. tmp_tb = tstate->exc_traceback;
  11670. tstate->exc_type = type;
  11671. tstate->exc_value = value;
  11672. tstate->exc_traceback = tb;
  11673. #endif
  11674. Py_XDECREF(tmp_type);
  11675. Py_XDECREF(tmp_value);
  11676. Py_XDECREF(tmp_tb);
  11677. #endif
  11678. }
  11679. #endif
  11680. /* pyfrozenset_new (used by PySetContains) */
  11681. static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
  11682. if (it) {
  11683. PyObject* result;
  11684. #if CYTHON_COMPILING_IN_PYPY
  11685. PyObject* args;
  11686. args = PyTuple_Pack(1, it);
  11687. if (unlikely(!args))
  11688. return NULL;
  11689. result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
  11690. Py_DECREF(args);
  11691. return result;
  11692. #else
  11693. if (PyFrozenSet_CheckExact(it)) {
  11694. Py_INCREF(it);
  11695. return it;
  11696. }
  11697. result = PyFrozenSet_New(it);
  11698. if (unlikely(!result))
  11699. return NULL;
  11700. if ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
  11701. #if CYTHON_COMPILING_IN_LIMITED_API
  11702. || __Pyx_get_runtime_version() >= 0x030A0000
  11703. #endif
  11704. )
  11705. return result;
  11706. {
  11707. Py_ssize_t size = __Pyx_PySet_GET_SIZE(result);
  11708. if (likely(size > 0))
  11709. return result;
  11710. #if !CYTHON_ASSUME_SAFE_SIZE
  11711. if (unlikely(size < 0)) {
  11712. Py_DECREF(result);
  11713. return NULL;
  11714. }
  11715. #endif
  11716. }
  11717. Py_DECREF(result);
  11718. #endif
  11719. }
  11720. return __Pyx_PyObject_CallNoArg((PyObject*) &PyFrozenSet_Type);
  11721. }
  11722. /* PySetContains */
  11723. static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
  11724. int result = -1;
  11725. if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
  11726. PyObject *tmpkey;
  11727. PyErr_Clear();
  11728. tmpkey = __Pyx_PyFrozenSet_New(key);
  11729. if (tmpkey != NULL) {
  11730. result = PySet_Contains(set, tmpkey);
  11731. Py_DECREF(tmpkey);
  11732. }
  11733. }
  11734. return result;
  11735. }
  11736. static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
  11737. int result = PySet_Contains(set, key);
  11738. if (unlikely(result < 0)) {
  11739. result = __Pyx_PySet_ContainsUnhashable(set, key);
  11740. }
  11741. return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
  11742. }
  11743. /* HasAttr (used by ImportImpl) */
  11744. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  11745. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
  11746. PyObject *r;
  11747. if (unlikely(!PyUnicode_Check(n))) {
  11748. PyErr_SetString(PyExc_TypeError,
  11749. "hasattr(): attribute name must be string");
  11750. return -1;
  11751. }
  11752. r = __Pyx_PyObject_GetAttrStrNoError(o, n);
  11753. if (!r) {
  11754. return (unlikely(PyErr_Occurred())) ? -1 : 0;
  11755. } else {
  11756. Py_DECREF(r);
  11757. return 1;
  11758. }
  11759. }
  11760. #endif
  11761. /* ImportImpl (used by Import) */
  11762. static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) {
  11763. PyObject *imported_module = PyImport_GetModule(qualname);
  11764. if (unlikely(!imported_module)) {
  11765. *module = NULL;
  11766. if (PyErr_Occurred()) {
  11767. return -1;
  11768. }
  11769. return 0;
  11770. }
  11771. *module = imported_module;
  11772. return 1;
  11773. }
  11774. static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) {
  11775. PyObject *imported_module;
  11776. PyObject *top_level_package_name;
  11777. Py_ssize_t i;
  11778. int status, module_found;
  11779. Py_ssize_t dot_index;
  11780. module_found = __Pyx__Import_GetModule(qualname, &imported_module);
  11781. if (unlikely(!module_found || module_found == -1)) {
  11782. *module = NULL;
  11783. return module_found;
  11784. }
  11785. if (imported_names) {
  11786. for (i = 0; i < len_imported_names; i++) {
  11787. PyObject *imported_name = imported_names[i];
  11788. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  11789. int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name);
  11790. #else
  11791. int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name);
  11792. if (unlikely(has_imported_attribute == -1)) goto error;
  11793. #endif
  11794. if (!has_imported_attribute) {
  11795. goto not_found;
  11796. }
  11797. }
  11798. *module = imported_module;
  11799. return 1;
  11800. }
  11801. dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1);
  11802. if (dot_index == -1) {
  11803. *module = imported_module;
  11804. return 1;
  11805. }
  11806. if (unlikely(dot_index == -2)) goto error;
  11807. top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index);
  11808. if (unlikely(!top_level_package_name)) goto error;
  11809. Py_DECREF(imported_module);
  11810. status = __Pyx__Import_GetModule(top_level_package_name, module);
  11811. Py_DECREF(top_level_package_name);
  11812. return status;
  11813. error:
  11814. Py_DECREF(imported_module);
  11815. *module = NULL;
  11816. return -1;
  11817. not_found:
  11818. Py_DECREF(imported_module);
  11819. *module = NULL;
  11820. return 0;
  11821. }
  11822. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level) {
  11823. PyObject *module = 0;
  11824. PyObject *empty_dict = 0;
  11825. PyObject *from_list = 0;
  11826. int module_found;
  11827. if (!qualname) {
  11828. qualname = name;
  11829. }
  11830. module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module);
  11831. if (likely(module_found == 1)) {
  11832. return module;
  11833. } else if (unlikely(module_found == -1)) {
  11834. return NULL;
  11835. }
  11836. empty_dict = PyDict_New();
  11837. if (unlikely(!empty_dict))
  11838. goto bad;
  11839. if (imported_names) {
  11840. #if CYTHON_COMPILING_IN_CPYTHON
  11841. from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names);
  11842. if (unlikely(!from_list))
  11843. goto bad;
  11844. #else
  11845. from_list = PyList_New(len_imported_names);
  11846. if (unlikely(!from_list)) goto bad;
  11847. for (Py_ssize_t i=0; i<len_imported_names; ++i) {
  11848. if (PyList_SetItem(from_list, i, __Pyx_NewRef(imported_names[i])) < 0) goto bad;
  11849. }
  11850. #endif
  11851. }
  11852. if (level == -1) {
  11853. const char* package_sep = strchr(__Pyx_MODULE_NAME, '.');
  11854. if (package_sep != (0)) {
  11855. module = PyImport_ImportModuleLevelObject(
  11856. name, moddict, empty_dict, from_list, 1);
  11857. if (unlikely(!module)) {
  11858. if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
  11859. goto bad;
  11860. PyErr_Clear();
  11861. }
  11862. }
  11863. level = 0;
  11864. }
  11865. if (!module) {
  11866. module = PyImport_ImportModuleLevelObject(
  11867. name, moddict, empty_dict, from_list, level);
  11868. }
  11869. bad:
  11870. Py_XDECREF(from_list);
  11871. Py_XDECREF(empty_dict);
  11872. return module;
  11873. }
  11874. /* Import */
  11875. static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) {
  11876. return __Pyx__Import(name, imported_names, len_imported_names, qualname, __pyx_mstate_global->__pyx_d, level);
  11877. }
  11878. /* ImportFrom */
  11879. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  11880. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  11881. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  11882. const char* module_name_str = 0;
  11883. PyObject* module_name = 0;
  11884. PyObject* module_dot = 0;
  11885. PyObject* full_name = 0;
  11886. PyErr_Clear();
  11887. module_name_str = PyModule_GetName(module);
  11888. if (unlikely(!module_name_str)) { goto modbad; }
  11889. module_name = PyUnicode_FromString(module_name_str);
  11890. if (unlikely(!module_name)) { goto modbad; }
  11891. module_dot = PyUnicode_Concat(module_name, __pyx_mstate_global->__pyx_kp_u_);
  11892. if (unlikely(!module_dot)) { goto modbad; }
  11893. full_name = PyUnicode_Concat(module_dot, name);
  11894. if (unlikely(!full_name)) { goto modbad; }
  11895. #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) ||\
  11896. CYTHON_COMPILING_IN_GRAAL
  11897. {
  11898. PyObject *modules = PyImport_GetModuleDict();
  11899. if (unlikely(!modules))
  11900. goto modbad;
  11901. value = PyObject_GetItem(modules, full_name);
  11902. }
  11903. #else
  11904. value = PyImport_GetModule(full_name);
  11905. #endif
  11906. modbad:
  11907. Py_XDECREF(full_name);
  11908. Py_XDECREF(module_dot);
  11909. Py_XDECREF(module_name);
  11910. }
  11911. if (unlikely(!value)) {
  11912. PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
  11913. }
  11914. return value;
  11915. }
  11916. /* AllocateExtensionType */
  11917. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) {
  11918. if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) {
  11919. allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc);
  11920. return alloc_func(t, 0);
  11921. } else {
  11922. newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc);
  11923. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11924. if (!tp_new) {
  11925. PyObject *new_str = PyUnicode_FromString("__new__");
  11926. if (likely(new_str)) {
  11927. PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL);
  11928. Py_DECREF(new_str);
  11929. return o;
  11930. } else
  11931. return NULL;
  11932. } else
  11933. #endif
  11934. return tp_new(t, __pyx_mstate_global->__pyx_empty_tuple, 0);
  11935. }
  11936. }
  11937. /* CallTypeTraverse */
  11938. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  11939. #else
  11940. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) {
  11941. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000
  11942. if (__Pyx_get_runtime_version() < 0x03090000) return 0;
  11943. #endif
  11944. if (!always_call) {
  11945. PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*);
  11946. unsigned long flags = PyType_GetFlags(base);
  11947. if (flags & Py_TPFLAGS_HEAPTYPE) {
  11948. return 0;
  11949. }
  11950. }
  11951. Py_VISIT((PyObject*)Py_TYPE(o));
  11952. return 0;
  11953. }
  11954. #endif
  11955. /* LimitedApiGetTypeDict (used by SetItemOnTypeDict) */
  11956. #if CYTHON_COMPILING_IN_LIMITED_API
  11957. static Py_ssize_t __Pyx_GetTypeDictOffset(void) {
  11958. PyObject *tp_dictoffset_o;
  11959. Py_ssize_t tp_dictoffset;
  11960. tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__");
  11961. if (unlikely(!tp_dictoffset_o)) return -1;
  11962. tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o);
  11963. Py_DECREF(tp_dictoffset_o);
  11964. if (unlikely(tp_dictoffset == 0)) {
  11965. PyErr_SetString(
  11966. PyExc_TypeError,
  11967. "'type' doesn't have a dictoffset");
  11968. return -1;
  11969. } else if (unlikely(tp_dictoffset < 0)) {
  11970. PyErr_SetString(
  11971. PyExc_TypeError,
  11972. "'type' has an unexpected negative dictoffset. "
  11973. "Please report this as Cython bug");
  11974. return -1;
  11975. }
  11976. return tp_dictoffset;
  11977. }
  11978. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) {
  11979. static Py_ssize_t tp_dictoffset = 0;
  11980. if (unlikely(tp_dictoffset == 0)) {
  11981. tp_dictoffset = __Pyx_GetTypeDictOffset();
  11982. if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) {
  11983. tp_dictoffset = 0; // try again next time?
  11984. return NULL;
  11985. }
  11986. }
  11987. return *(PyObject**)((char*)tp + tp_dictoffset);
  11988. }
  11989. #endif
  11990. /* SetItemOnTypeDict (used by FixUpExtensionType) */
  11991. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) {
  11992. int result;
  11993. PyObject *tp_dict;
  11994. #if CYTHON_COMPILING_IN_LIMITED_API
  11995. tp_dict = __Pyx_GetTypeDict(tp);
  11996. if (unlikely(!tp_dict)) return -1;
  11997. #else
  11998. tp_dict = tp->tp_dict;
  11999. #endif
  12000. result = PyDict_SetItem(tp_dict, k, v);
  12001. if (likely(!result)) {
  12002. PyType_Modified(tp);
  12003. if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) {
  12004. PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL);
  12005. if (!setNameResult) return -1;
  12006. Py_DECREF(setNameResult);
  12007. }
  12008. }
  12009. return result;
  12010. }
  12011. /* FixUpExtensionType */
  12012. static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) {
  12013. #if __PYX_LIMITED_VERSION_HEX > 0x030900B1
  12014. CYTHON_UNUSED_VAR(spec);
  12015. CYTHON_UNUSED_VAR(type);
  12016. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  12017. #else
  12018. const PyType_Slot *slot = spec->slots;
  12019. int changed = 0;
  12020. #if !CYTHON_COMPILING_IN_LIMITED_API
  12021. while (slot && slot->slot && slot->slot != Py_tp_members)
  12022. slot++;
  12023. if (slot && slot->slot == Py_tp_members) {
  12024. #if !CYTHON_COMPILING_IN_CPYTHON
  12025. const
  12026. #endif // !CYTHON_COMPILING_IN_CPYTHON)
  12027. PyMemberDef *memb = (PyMemberDef*) slot->pfunc;
  12028. while (memb && memb->name) {
  12029. if (memb->name[0] == '_' && memb->name[1] == '_') {
  12030. if (strcmp(memb->name, "__weaklistoffset__") == 0) {
  12031. assert(memb->type == T_PYSSIZET);
  12032. assert(memb->flags == READONLY);
  12033. type->tp_weaklistoffset = memb->offset;
  12034. changed = 1;
  12035. }
  12036. else if (strcmp(memb->name, "__dictoffset__") == 0) {
  12037. assert(memb->type == T_PYSSIZET);
  12038. assert(memb->flags == READONLY);
  12039. type->tp_dictoffset = memb->offset;
  12040. changed = 1;
  12041. }
  12042. #if CYTHON_METH_FASTCALL
  12043. else if (strcmp(memb->name, "__vectorcalloffset__") == 0) {
  12044. assert(memb->type == T_PYSSIZET);
  12045. assert(memb->flags == READONLY);
  12046. type->tp_vectorcall_offset = memb->offset;
  12047. changed = 1;
  12048. }
  12049. #endif // CYTHON_METH_FASTCALL
  12050. #if !CYTHON_COMPILING_IN_PYPY
  12051. else if (strcmp(memb->name, "__module__") == 0) {
  12052. PyObject *descr;
  12053. assert(memb->type == T_OBJECT);
  12054. assert(memb->flags == 0 || memb->flags == READONLY);
  12055. descr = PyDescr_NewMember(type, memb);
  12056. if (unlikely(!descr))
  12057. return -1;
  12058. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  12059. Py_DECREF(descr);
  12060. if (unlikely(set_item_result < 0)) {
  12061. return -1;
  12062. }
  12063. changed = 1;
  12064. }
  12065. #endif // !CYTHON_COMPILING_IN_PYPY
  12066. }
  12067. memb++;
  12068. }
  12069. }
  12070. #endif // !CYTHON_COMPILING_IN_LIMITED_API
  12071. #if !CYTHON_COMPILING_IN_PYPY
  12072. slot = spec->slots;
  12073. while (slot && slot->slot && slot->slot != Py_tp_getset)
  12074. slot++;
  12075. if (slot && slot->slot == Py_tp_getset) {
  12076. PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc;
  12077. while (getset && getset->name) {
  12078. if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) {
  12079. PyObject *descr = PyDescr_NewGetSet(type, getset);
  12080. if (unlikely(!descr))
  12081. return -1;
  12082. #if CYTHON_COMPILING_IN_LIMITED_API
  12083. PyObject *pyname = PyUnicode_FromString(getset->name);
  12084. if (unlikely(!pyname)) {
  12085. Py_DECREF(descr);
  12086. return -1;
  12087. }
  12088. int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr);
  12089. Py_DECREF(pyname);
  12090. #else
  12091. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  12092. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  12093. #endif
  12094. Py_DECREF(descr);
  12095. if (unlikely(set_item_result < 0)) {
  12096. return -1;
  12097. }
  12098. changed = 1;
  12099. }
  12100. ++getset;
  12101. }
  12102. }
  12103. #else
  12104. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  12105. #endif // !CYTHON_COMPILING_IN_PYPY
  12106. if (changed)
  12107. PyType_Modified(type);
  12108. #endif // PY_VERSION_HEX > 0x030900B1
  12109. return 0;
  12110. }
  12111. /* ValidateBasesTuple (used by PyType_Ready) */
  12112. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  12113. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) {
  12114. Py_ssize_t i, n;
  12115. #if CYTHON_ASSUME_SAFE_SIZE
  12116. n = PyTuple_GET_SIZE(bases);
  12117. #else
  12118. n = PyTuple_Size(bases);
  12119. if (unlikely(n < 0)) return -1;
  12120. #endif
  12121. for (i = 1; i < n; i++)
  12122. {
  12123. PyTypeObject *b;
  12124. #if CYTHON_AVOID_BORROWED_REFS
  12125. PyObject *b0 = PySequence_GetItem(bases, i);
  12126. if (!b0) return -1;
  12127. #elif CYTHON_ASSUME_SAFE_MACROS
  12128. PyObject *b0 = PyTuple_GET_ITEM(bases, i);
  12129. #else
  12130. PyObject *b0 = PyTuple_GetItem(bases, i);
  12131. if (!b0) return -1;
  12132. #endif
  12133. b = (PyTypeObject*) b0;
  12134. if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
  12135. {
  12136. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  12137. PyErr_Format(PyExc_TypeError,
  12138. "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name);
  12139. __Pyx_DECREF_TypeName(b_name);
  12140. #if CYTHON_AVOID_BORROWED_REFS
  12141. Py_DECREF(b0);
  12142. #endif
  12143. return -1;
  12144. }
  12145. if (dictoffset == 0)
  12146. {
  12147. Py_ssize_t b_dictoffset = 0;
  12148. #if CYTHON_USE_TYPE_SLOTS
  12149. b_dictoffset = b->tp_dictoffset;
  12150. #else
  12151. PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__");
  12152. if (!py_b_dictoffset) goto dictoffset_return;
  12153. b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset);
  12154. Py_DECREF(py_b_dictoffset);
  12155. if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return;
  12156. #endif
  12157. if (b_dictoffset) {
  12158. {
  12159. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  12160. PyErr_Format(PyExc_TypeError,
  12161. "extension type '%.200s' has no __dict__ slot, "
  12162. "but base type '" __Pyx_FMT_TYPENAME "' has: "
  12163. "either add 'cdef dict __dict__' to the extension type "
  12164. "or add '__slots__ = [...]' to the base type",
  12165. type_name, b_name);
  12166. __Pyx_DECREF_TypeName(b_name);
  12167. }
  12168. #if !CYTHON_USE_TYPE_SLOTS
  12169. dictoffset_return:
  12170. #endif
  12171. #if CYTHON_AVOID_BORROWED_REFS
  12172. Py_DECREF(b0);
  12173. #endif
  12174. return -1;
  12175. }
  12176. }
  12177. #if CYTHON_AVOID_BORROWED_REFS
  12178. Py_DECREF(b0);
  12179. #endif
  12180. }
  12181. return 0;
  12182. }
  12183. #endif
  12184. /* PyType_Ready */
  12185. CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) {
  12186. while (t) {
  12187. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  12188. if (bases) {
  12189. return 1;
  12190. }
  12191. t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*);
  12192. }
  12193. return 0;
  12194. }
  12195. static int __Pyx_PyType_Ready(PyTypeObject *t) {
  12196. #if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION)
  12197. (void)__Pyx_PyObject_CallMethod0;
  12198. #if CYTHON_USE_TYPE_SPECS
  12199. (void)__Pyx_validate_bases_tuple;
  12200. #endif
  12201. return PyType_Ready(t);
  12202. #else
  12203. int r;
  12204. if (!__Pyx_PyType_HasMultipleInheritance(t)) {
  12205. return PyType_Ready(t);
  12206. }
  12207. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  12208. if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1))
  12209. return -1;
  12210. #if !defined(PYSTON_MAJOR_VERSION)
  12211. {
  12212. int gc_was_enabled;
  12213. #if PY_VERSION_HEX >= 0x030A00b1
  12214. gc_was_enabled = PyGC_Disable();
  12215. (void)__Pyx_PyObject_CallMethod0;
  12216. #else
  12217. PyObject *ret, *py_status;
  12218. PyObject *gc = NULL;
  12219. #if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) &&\
  12220. !CYTHON_COMPILING_IN_GRAAL
  12221. gc = PyImport_GetModule(__pyx_mstate_global->__pyx_kp_u_gc);
  12222. #endif
  12223. if (unlikely(!gc)) gc = PyImport_Import(__pyx_mstate_global->__pyx_kp_u_gc);
  12224. if (unlikely(!gc)) return -1;
  12225. py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_isenabled);
  12226. if (unlikely(!py_status)) {
  12227. Py_DECREF(gc);
  12228. return -1;
  12229. }
  12230. gc_was_enabled = __Pyx_PyObject_IsTrue(py_status);
  12231. Py_DECREF(py_status);
  12232. if (gc_was_enabled > 0) {
  12233. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_disable);
  12234. if (unlikely(!ret)) {
  12235. Py_DECREF(gc);
  12236. return -1;
  12237. }
  12238. Py_DECREF(ret);
  12239. } else if (unlikely(gc_was_enabled == -1)) {
  12240. Py_DECREF(gc);
  12241. return -1;
  12242. }
  12243. #endif
  12244. t->tp_flags |= Py_TPFLAGS_HEAPTYPE;
  12245. #if PY_VERSION_HEX >= 0x030A0000
  12246. t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
  12247. #endif
  12248. #else
  12249. (void)__Pyx_PyObject_CallMethod0;
  12250. #endif
  12251. r = PyType_Ready(t);
  12252. #if !defined(PYSTON_MAJOR_VERSION)
  12253. t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
  12254. #if PY_VERSION_HEX >= 0x030A00b1
  12255. if (gc_was_enabled)
  12256. PyGC_Enable();
  12257. #else
  12258. if (gc_was_enabled) {
  12259. PyObject *tp, *v, *tb;
  12260. PyErr_Fetch(&tp, &v, &tb);
  12261. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_enable);
  12262. if (likely(ret || r == -1)) {
  12263. Py_XDECREF(ret);
  12264. PyErr_Restore(tp, v, tb);
  12265. } else {
  12266. Py_XDECREF(tp);
  12267. Py_XDECREF(v);
  12268. Py_XDECREF(tb);
  12269. r = -1;
  12270. }
  12271. }
  12272. Py_DECREF(gc);
  12273. #endif
  12274. }
  12275. #endif
  12276. return r;
  12277. #endif
  12278. }
  12279. /* ListPack */
  12280. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...) {
  12281. va_list va;
  12282. PyObject *l = PyList_New(n);
  12283. va_start(va, n);
  12284. if (unlikely(!l)) goto end;
  12285. for (Py_ssize_t i=0; i<n; ++i) {
  12286. PyObject *arg = va_arg(va, PyObject*);
  12287. Py_INCREF(arg);
  12288. if (__Pyx_PyList_SET_ITEM(l, i, arg) != (0)) {
  12289. Py_CLEAR(l);
  12290. goto end;
  12291. }
  12292. }
  12293. end:
  12294. va_end(va);
  12295. return l;
  12296. }
  12297. /* dict_setdefault (used by FetchCommonType) */
  12298. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) {
  12299. PyObject* value;
  12300. #if __PYX_LIMITED_VERSION_HEX >= 0x030F0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4)
  12301. PyDict_SetDefaultRef(d, key, default_value, &value);
  12302. #elif CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  12303. PyObject *args[] = {d, key, default_value};
  12304. value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  12305. #elif CYTHON_COMPILING_IN_LIMITED_API
  12306. value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL);
  12307. #else
  12308. value = PyDict_SetDefault(d, key, default_value);
  12309. if (unlikely(!value)) return NULL;
  12310. Py_INCREF(value);
  12311. #endif
  12312. return value;
  12313. }
  12314. /* AddModuleRef (used by FetchSharedCythonModule) */
  12315. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12316. static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) {
  12317. PyObject *module_dict = PyImport_GetModuleDict();
  12318. PyObject *m;
  12319. if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) {
  12320. return NULL;
  12321. }
  12322. if (m != NULL && PyModule_Check(m)) {
  12323. return m;
  12324. }
  12325. Py_XDECREF(m);
  12326. m = PyModule_NewObject(name);
  12327. if (m == NULL)
  12328. return NULL;
  12329. if (PyDict_CheckExact(module_dict)) {
  12330. PyObject *new_m;
  12331. (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m);
  12332. Py_DECREF(m);
  12333. return new_m;
  12334. } else {
  12335. if (PyObject_SetItem(module_dict, name, m) != 0) {
  12336. Py_DECREF(m);
  12337. return NULL;
  12338. }
  12339. return m;
  12340. }
  12341. }
  12342. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  12343. PyObject *py_name = PyUnicode_FromString(name);
  12344. if (!py_name) return NULL;
  12345. PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name);
  12346. Py_DECREF(py_name);
  12347. return module;
  12348. }
  12349. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  12350. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  12351. #else
  12352. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  12353. PyObject *module = PyImport_AddModule(name);
  12354. Py_XINCREF(module);
  12355. return module;
  12356. }
  12357. #endif
  12358. /* FetchSharedCythonModule (used by FetchCommonType) */
  12359. static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
  12360. return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME);
  12361. }
  12362. /* FetchCommonType (used by CommonTypesMetaclass) */
  12363. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  12364. static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  12365. PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases);
  12366. if (result && metaclass) {
  12367. PyObject *old_tp = (PyObject*)Py_TYPE(result);
  12368. Py_INCREF((PyObject*)metaclass);
  12369. #if __PYX_LIMITED_VERSION_HEX >= 0x03090000
  12370. Py_SET_TYPE(result, metaclass);
  12371. #else
  12372. result->ob_type = metaclass;
  12373. #endif
  12374. Py_DECREF(old_tp);
  12375. }
  12376. return result;
  12377. }
  12378. #else
  12379. #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b)
  12380. #endif
  12381. static int __Pyx_VerifyCachedType(PyObject *cached_type,
  12382. const char *name,
  12383. Py_ssize_t expected_basicsize) {
  12384. Py_ssize_t basicsize;
  12385. if (!PyType_Check(cached_type)) {
  12386. PyErr_Format(PyExc_TypeError,
  12387. "Shared Cython type %.200s is not a type object", name);
  12388. return -1;
  12389. }
  12390. if (expected_basicsize == 0) {
  12391. return 0; // size is inherited, nothing useful to check
  12392. }
  12393. #if CYTHON_COMPILING_IN_LIMITED_API
  12394. PyObject *py_basicsize;
  12395. py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__");
  12396. if (unlikely(!py_basicsize)) return -1;
  12397. basicsize = PyLong_AsSsize_t(py_basicsize);
  12398. Py_DECREF(py_basicsize);
  12399. py_basicsize = NULL;
  12400. if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1;
  12401. #else
  12402. basicsize = ((PyTypeObject*) cached_type)->tp_basicsize;
  12403. #endif
  12404. if (basicsize != expected_basicsize) {
  12405. PyErr_Format(PyExc_TypeError,
  12406. "Shared Cython type %.200s has the wrong size, try recompiling",
  12407. name);
  12408. return -1;
  12409. }
  12410. return 0;
  12411. }
  12412. static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  12413. PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name;
  12414. int get_item_ref_result;
  12415. const char* object_name = strrchr(spec->name, '.');
  12416. object_name = object_name ? object_name+1 : spec->name;
  12417. py_object_name = PyUnicode_FromString(object_name);
  12418. if (!py_object_name) return NULL;
  12419. abi_module = __Pyx_FetchSharedCythonABIModule();
  12420. if (!abi_module) goto done;
  12421. abi_module_dict = PyModule_GetDict(abi_module);
  12422. if (!abi_module_dict) goto done;
  12423. get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type);
  12424. if (get_item_ref_result == 1) {
  12425. if (__Pyx_VerifyCachedType(
  12426. cached_type,
  12427. object_name,
  12428. spec->basicsize) < 0) {
  12429. goto bad;
  12430. }
  12431. goto done;
  12432. } else if (unlikely(get_item_ref_result == -1)) {
  12433. goto bad;
  12434. }
  12435. cached_type = __Pyx_PyType_FromMetaclass(
  12436. metaclass,
  12437. CYTHON_USE_MODULE_STATE ? module : abi_module,
  12438. spec, bases);
  12439. if (unlikely(!cached_type)) goto bad;
  12440. if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad;
  12441. new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type);
  12442. if (unlikely(new_cached_type != cached_type)) {
  12443. if (unlikely(!new_cached_type)) goto bad;
  12444. Py_DECREF(cached_type);
  12445. cached_type = new_cached_type;
  12446. if (__Pyx_VerifyCachedType(
  12447. cached_type,
  12448. object_name,
  12449. spec->basicsize) < 0) {
  12450. goto bad;
  12451. }
  12452. goto done;
  12453. } else {
  12454. Py_DECREF(new_cached_type);
  12455. }
  12456. done:
  12457. Py_XDECREF(abi_module);
  12458. Py_DECREF(py_object_name);
  12459. assert(cached_type == NULL || PyType_Check(cached_type));
  12460. return (PyTypeObject *) cached_type;
  12461. bad:
  12462. Py_XDECREF(cached_type);
  12463. cached_type = NULL;
  12464. goto done;
  12465. }
  12466. /* CommonTypesMetaclass (used by CythonFunctionShared) */
  12467. static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) {
  12468. return PyUnicode_FromString(__PYX_ABI_MODULE_NAME);
  12469. }
  12470. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  12471. static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) {
  12472. PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types");
  12473. return NULL;
  12474. }
  12475. static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) {
  12476. PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable");
  12477. return -1;
  12478. }
  12479. #endif
  12480. static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = {
  12481. {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL},
  12482. {0, 0, 0, 0, 0}
  12483. };
  12484. static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = {
  12485. {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset},
  12486. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  12487. {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call},
  12488. {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call},
  12489. {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr},
  12490. #endif
  12491. {0, 0}
  12492. };
  12493. static PyType_Spec __pyx_CommonTypesMetaclass_spec = {
  12494. __PYX_TYPE_MODULE_PREFIX "_common_types_metatype",
  12495. 0,
  12496. 0,
  12497. Py_TPFLAGS_IMMUTABLETYPE |
  12498. Py_TPFLAGS_DISALLOW_INSTANTIATION |
  12499. Py_TPFLAGS_DEFAULT,
  12500. __pyx_CommonTypesMetaclass_slots
  12501. };
  12502. static int __pyx_CommonTypesMetaclass_init(PyObject *module) {
  12503. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  12504. PyObject *bases = PyTuple_Pack(1, &PyType_Type);
  12505. if (unlikely(!bases)) {
  12506. return -1;
  12507. }
  12508. mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases);
  12509. Py_DECREF(bases);
  12510. if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) {
  12511. return -1;
  12512. }
  12513. return 0;
  12514. }
  12515. /* PyMethodNew (used by CythonFunctionShared) */
  12516. #if CYTHON_COMPILING_IN_LIMITED_API
  12517. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  12518. PyObject *result;
  12519. CYTHON_UNUSED_VAR(typ);
  12520. if (!self)
  12521. return __Pyx_NewRef(func);
  12522. #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  12523. {
  12524. PyObject *args[] = {func, self};
  12525. result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL);
  12526. }
  12527. #else
  12528. result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL);
  12529. #endif
  12530. return result;
  12531. }
  12532. #else
  12533. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  12534. CYTHON_UNUSED_VAR(typ);
  12535. if (!self)
  12536. return __Pyx_NewRef(func);
  12537. return PyMethod_New(func, self);
  12538. }
  12539. #endif
  12540. /* PyVectorcallFastCallDict (used by CythonFunctionShared) */
  12541. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  12542. static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  12543. {
  12544. PyObject *res = NULL;
  12545. PyObject *kwnames;
  12546. PyObject **newargs;
  12547. PyObject **kwvalues;
  12548. Py_ssize_t i;
  12549. #if CYTHON_AVOID_BORROWED_REFS
  12550. PyObject *pos;
  12551. #else
  12552. Py_ssize_t pos;
  12553. #endif
  12554. size_t j;
  12555. PyObject *key, *value;
  12556. unsigned long keys_are_strings;
  12557. #if !CYTHON_ASSUME_SAFE_SIZE
  12558. Py_ssize_t nkw = PyDict_Size(kw);
  12559. if (unlikely(nkw == -1)) return NULL;
  12560. #else
  12561. Py_ssize_t nkw = PyDict_GET_SIZE(kw);
  12562. #endif
  12563. newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0]));
  12564. if (unlikely(newargs == NULL)) {
  12565. PyErr_NoMemory();
  12566. return NULL;
  12567. }
  12568. for (j = 0; j < nargs; j++) newargs[j] = args[j];
  12569. kwnames = PyTuple_New(nkw);
  12570. if (unlikely(kwnames == NULL)) {
  12571. PyMem_Free(newargs);
  12572. return NULL;
  12573. }
  12574. kwvalues = newargs + nargs;
  12575. pos = 0;
  12576. i = 0;
  12577. keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS;
  12578. while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) {
  12579. keys_are_strings &=
  12580. #if CYTHON_COMPILING_IN_LIMITED_API
  12581. PyType_GetFlags(Py_TYPE(key));
  12582. #else
  12583. Py_TYPE(key)->tp_flags;
  12584. #endif
  12585. #if !CYTHON_ASSUME_SAFE_MACROS
  12586. if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup;
  12587. #else
  12588. PyTuple_SET_ITEM(kwnames, i, key);
  12589. #endif
  12590. kwvalues[i] = value;
  12591. i++;
  12592. }
  12593. if (unlikely(!keys_are_strings)) {
  12594. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  12595. goto cleanup;
  12596. }
  12597. res = vc(func, newargs, nargs, kwnames);
  12598. cleanup:
  12599. #if CYTHON_AVOID_BORROWED_REFS
  12600. Py_DECREF(pos);
  12601. #endif
  12602. Py_DECREF(kwnames);
  12603. for (i = 0; i < nkw; i++)
  12604. Py_DECREF(kwvalues[i]);
  12605. PyMem_Free(newargs);
  12606. return res;
  12607. }
  12608. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  12609. {
  12610. Py_ssize_t kw_size =
  12611. likely(kw == NULL) ?
  12612. 0 :
  12613. #if !CYTHON_ASSUME_SAFE_SIZE
  12614. PyDict_Size(kw);
  12615. #else
  12616. PyDict_GET_SIZE(kw);
  12617. #endif
  12618. if (kw_size == 0) {
  12619. return vc(func, args, nargs, NULL);
  12620. }
  12621. #if !CYTHON_ASSUME_SAFE_SIZE
  12622. else if (unlikely(kw_size == -1)) {
  12623. return NULL;
  12624. }
  12625. #endif
  12626. return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw);
  12627. }
  12628. #endif
  12629. /* CythonFunctionShared (used by CythonFunction) */
  12630. #if CYTHON_COMPILING_IN_LIMITED_API
  12631. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
  12632. if (__Pyx_CyFunction_Check(func)) {
  12633. return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
  12634. } else if (PyCFunction_Check(func)) {
  12635. return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
  12636. }
  12637. return 0;
  12638. }
  12639. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  12640. if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) {
  12641. int result;
  12642. PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func);
  12643. if (unlikely(!newFunc)) {
  12644. PyErr_Clear(); // It's only an optimization, so don't throw an error
  12645. return 0;
  12646. }
  12647. result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
  12648. Py_DECREF(newFunc);
  12649. return result;
  12650. }
  12651. return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
  12652. }
  12653. #else
  12654. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  12655. if (PyMethod_Check(func)) {
  12656. func = PyMethod_GET_FUNCTION(func);
  12657. }
  12658. return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  12659. }
  12660. #endif
  12661. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
  12662. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  12663. __Pyx_Py_XDECREF_SET(
  12664. __Pyx_CyFunction_GetClassObj(f),
  12665. ((classobj) ? __Pyx_NewRef(classobj) : NULL));
  12666. #else
  12667. __Pyx_Py_XDECREF_SET(
  12668. ((PyCMethodObject *) (f))->mm_class,
  12669. (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
  12670. #endif
  12671. }
  12672. static PyObject *
  12673. __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
  12674. {
  12675. if (unlikely(op->func_doc == NULL)) {
  12676. #if CYTHON_COMPILING_IN_LIMITED_API
  12677. op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
  12678. if (unlikely(!op->func_doc)) return NULL;
  12679. #else
  12680. if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
  12681. op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
  12682. if (unlikely(op->func_doc == NULL))
  12683. return NULL;
  12684. } else {
  12685. Py_INCREF(Py_None);
  12686. return Py_None;
  12687. }
  12688. #endif
  12689. }
  12690. Py_INCREF(op->func_doc);
  12691. return op->func_doc;
  12692. }
  12693. static PyObject *
  12694. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) {
  12695. PyObject *result;
  12696. CYTHON_UNUSED_VAR(closure);
  12697. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12698. result = __Pyx_CyFunction_get_doc_locked(op);
  12699. __Pyx_END_CRITICAL_SECTION();
  12700. return result;
  12701. }
  12702. static int
  12703. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  12704. {
  12705. CYTHON_UNUSED_VAR(context);
  12706. if (value == NULL) {
  12707. value = Py_None;
  12708. }
  12709. Py_INCREF(value);
  12710. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12711. __Pyx_Py_XDECREF_SET(op->func_doc, value);
  12712. __Pyx_END_CRITICAL_SECTION();
  12713. return 0;
  12714. }
  12715. static PyObject *
  12716. __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
  12717. {
  12718. if (unlikely(op->func_name == NULL)) {
  12719. #if CYTHON_COMPILING_IN_LIMITED_API
  12720. op->func_name = PyObject_GetAttrString(op->func, "__name__");
  12721. #else
  12722. op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
  12723. #endif
  12724. if (unlikely(op->func_name == NULL))
  12725. return NULL;
  12726. }
  12727. Py_INCREF(op->func_name);
  12728. return op->func_name;
  12729. }
  12730. static PyObject *
  12731. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
  12732. {
  12733. PyObject *result = NULL;
  12734. CYTHON_UNUSED_VAR(context);
  12735. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12736. result = __Pyx_CyFunction_get_name_locked(op);
  12737. __Pyx_END_CRITICAL_SECTION();
  12738. return result;
  12739. }
  12740. static int
  12741. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  12742. {
  12743. CYTHON_UNUSED_VAR(context);
  12744. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  12745. PyErr_SetString(PyExc_TypeError,
  12746. "__name__ must be set to a string object");
  12747. return -1;
  12748. }
  12749. Py_INCREF(value);
  12750. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12751. __Pyx_Py_XDECREF_SET(op->func_name, value);
  12752. __Pyx_END_CRITICAL_SECTION();
  12753. return 0;
  12754. }
  12755. static PyObject *
  12756. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
  12757. {
  12758. CYTHON_UNUSED_VAR(context);
  12759. PyObject *result;
  12760. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12761. Py_INCREF(op->func_qualname);
  12762. result = op->func_qualname;
  12763. __Pyx_END_CRITICAL_SECTION();
  12764. return result;
  12765. }
  12766. static int
  12767. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  12768. {
  12769. CYTHON_UNUSED_VAR(context);
  12770. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  12771. PyErr_SetString(PyExc_TypeError,
  12772. "__qualname__ must be set to a string object");
  12773. return -1;
  12774. }
  12775. Py_INCREF(value);
  12776. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12777. __Pyx_Py_XDECREF_SET(op->func_qualname, value);
  12778. __Pyx_END_CRITICAL_SECTION();
  12779. return 0;
  12780. }
  12781. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  12782. static PyObject *
  12783. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
  12784. {
  12785. CYTHON_UNUSED_VAR(context);
  12786. if (unlikely(op->func_dict == NULL)) {
  12787. op->func_dict = PyDict_New();
  12788. if (unlikely(op->func_dict == NULL))
  12789. return NULL;
  12790. }
  12791. Py_INCREF(op->func_dict);
  12792. return op->func_dict;
  12793. }
  12794. #endif
  12795. static PyObject *
  12796. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
  12797. {
  12798. CYTHON_UNUSED_VAR(context);
  12799. Py_INCREF(op->func_globals);
  12800. return op->func_globals;
  12801. }
  12802. static PyObject *
  12803. __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
  12804. {
  12805. CYTHON_UNUSED_VAR(op);
  12806. CYTHON_UNUSED_VAR(context);
  12807. Py_INCREF(Py_None);
  12808. return Py_None;
  12809. }
  12810. static PyObject *
  12811. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
  12812. {
  12813. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  12814. CYTHON_UNUSED_VAR(context);
  12815. Py_INCREF(result);
  12816. return result;
  12817. }
  12818. static int
  12819. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  12820. int result = 0;
  12821. PyObject *res = op->defaults_getter((PyObject *) op);
  12822. if (unlikely(!res))
  12823. return -1;
  12824. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  12825. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  12826. Py_INCREF(op->defaults_tuple);
  12827. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  12828. Py_INCREF(op->defaults_kwdict);
  12829. #else
  12830. op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
  12831. if (unlikely(!op->defaults_tuple)) result = -1;
  12832. else {
  12833. op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
  12834. if (unlikely(!op->defaults_kwdict)) result = -1;
  12835. }
  12836. #endif
  12837. Py_DECREF(res);
  12838. return result;
  12839. }
  12840. static int
  12841. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  12842. CYTHON_UNUSED_VAR(context);
  12843. if (!value) {
  12844. value = Py_None;
  12845. } else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
  12846. PyErr_SetString(PyExc_TypeError,
  12847. "__defaults__ must be set to a tuple object");
  12848. return -1;
  12849. }
  12850. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
  12851. "currently affect the values used in function calls", 1);
  12852. Py_INCREF(value);
  12853. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12854. __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
  12855. __Pyx_END_CRITICAL_SECTION();
  12856. return 0;
  12857. }
  12858. static PyObject *
  12859. __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
  12860. PyObject* result = op->defaults_tuple;
  12861. if (unlikely(!result)) {
  12862. if (op->defaults_getter) {
  12863. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  12864. result = op->defaults_tuple;
  12865. } else {
  12866. result = Py_None;
  12867. }
  12868. }
  12869. Py_INCREF(result);
  12870. return result;
  12871. }
  12872. static PyObject *
  12873. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
  12874. PyObject* result = NULL;
  12875. CYTHON_UNUSED_VAR(context);
  12876. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12877. result = __Pyx_CyFunction_get_defaults_locked(op);
  12878. __Pyx_END_CRITICAL_SECTION();
  12879. return result;
  12880. }
  12881. static int
  12882. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  12883. CYTHON_UNUSED_VAR(context);
  12884. if (!value) {
  12885. value = Py_None;
  12886. } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
  12887. PyErr_SetString(PyExc_TypeError,
  12888. "__kwdefaults__ must be set to a dict object");
  12889. return -1;
  12890. }
  12891. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
  12892. "currently affect the values used in function calls", 1);
  12893. Py_INCREF(value);
  12894. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12895. __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
  12896. __Pyx_END_CRITICAL_SECTION();
  12897. return 0;
  12898. }
  12899. static PyObject *
  12900. __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
  12901. PyObject* result = op->defaults_kwdict;
  12902. if (unlikely(!result)) {
  12903. if (op->defaults_getter) {
  12904. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  12905. result = op->defaults_kwdict;
  12906. } else {
  12907. result = Py_None;
  12908. }
  12909. }
  12910. Py_INCREF(result);
  12911. return result;
  12912. }
  12913. static PyObject *
  12914. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
  12915. PyObject* result;
  12916. CYTHON_UNUSED_VAR(context);
  12917. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12918. result = __Pyx_CyFunction_get_kwdefaults_locked(op);
  12919. __Pyx_END_CRITICAL_SECTION();
  12920. return result;
  12921. }
  12922. static int
  12923. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  12924. CYTHON_UNUSED_VAR(context);
  12925. if (!value || value == Py_None) {
  12926. value = NULL;
  12927. } else if (unlikely(!PyDict_Check(value))) {
  12928. PyErr_SetString(PyExc_TypeError,
  12929. "__annotations__ must be set to a dict object");
  12930. return -1;
  12931. }
  12932. Py_XINCREF(value);
  12933. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12934. __Pyx_Py_XDECREF_SET(op->func_annotations, value);
  12935. __Pyx_END_CRITICAL_SECTION();
  12936. return 0;
  12937. }
  12938. static PyObject *
  12939. __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
  12940. PyObject* result = op->func_annotations;
  12941. if (unlikely(!result)) {
  12942. result = PyDict_New();
  12943. if (unlikely(!result)) return NULL;
  12944. op->func_annotations = result;
  12945. }
  12946. Py_INCREF(result);
  12947. return result;
  12948. }
  12949. static PyObject *
  12950. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) {
  12951. PyObject *result;
  12952. CYTHON_UNUSED_VAR(context);
  12953. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12954. result = __Pyx_CyFunction_get_annotations_locked(op);
  12955. __Pyx_END_CRITICAL_SECTION();
  12956. return result;
  12957. }
  12958. static PyObject *
  12959. __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
  12960. int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
  12961. if (is_coroutine) {
  12962. PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine;
  12963. fromlist = PyList_New(1);
  12964. if (unlikely(!fromlist)) return NULL;
  12965. Py_INCREF(marker);
  12966. #if CYTHON_ASSUME_SAFE_MACROS
  12967. PyList_SET_ITEM(fromlist, 0, marker);
  12968. #else
  12969. if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
  12970. Py_DECREF(marker);
  12971. Py_DECREF(fromlist);
  12972. return NULL;
  12973. }
  12974. #endif
  12975. module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0);
  12976. Py_DECREF(fromlist);
  12977. if (unlikely(!module)) goto ignore;
  12978. is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
  12979. Py_DECREF(module);
  12980. if (likely(is_coroutine_value)) {
  12981. return is_coroutine_value;
  12982. }
  12983. ignore:
  12984. PyErr_Clear();
  12985. }
  12986. return __Pyx_PyBool_FromLong(is_coroutine);
  12987. }
  12988. static PyObject *
  12989. __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
  12990. PyObject *result;
  12991. CYTHON_UNUSED_VAR(context);
  12992. if (op->func_is_coroutine) {
  12993. return __Pyx_NewRef(op->func_is_coroutine);
  12994. }
  12995. result = __Pyx_CyFunction_get_is_coroutine_value(op);
  12996. if (unlikely(!result))
  12997. return NULL;
  12998. __Pyx_BEGIN_CRITICAL_SECTION(op);
  12999. if (op->func_is_coroutine) {
  13000. Py_DECREF(result);
  13001. result = __Pyx_NewRef(op->func_is_coroutine);
  13002. } else {
  13003. op->func_is_coroutine = __Pyx_NewRef(result);
  13004. }
  13005. __Pyx_END_CRITICAL_SECTION();
  13006. return result;
  13007. }
  13008. static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) {
  13009. #if CYTHON_COMPILING_IN_LIMITED_API
  13010. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  13011. if (!py_name) return;
  13012. PyErr_Format(PyExc_TypeError,
  13013. "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  13014. py_name, message, size);
  13015. Py_DECREF(py_name);
  13016. #else
  13017. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  13018. PyErr_Format(PyExc_TypeError,
  13019. "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  13020. name, message, size);
  13021. #endif
  13022. }
  13023. static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) {
  13024. #if CYTHON_COMPILING_IN_LIMITED_API
  13025. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  13026. if (!py_name) return;
  13027. PyErr_Format(PyExc_TypeError,
  13028. "%.200S() %s",
  13029. py_name, message);
  13030. Py_DECREF(py_name);
  13031. #else
  13032. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  13033. PyErr_Format(PyExc_TypeError,
  13034. "%.200s() %s",
  13035. name, message);
  13036. #endif
  13037. }
  13038. #if CYTHON_COMPILING_IN_LIMITED_API
  13039. static PyObject *
  13040. __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
  13041. CYTHON_UNUSED_VAR(context);
  13042. return PyObject_GetAttrString(op->func, "__module__");
  13043. }
  13044. static int
  13045. __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  13046. CYTHON_UNUSED_VAR(context);
  13047. return PyObject_SetAttrString(op->func, "__module__", value);
  13048. }
  13049. #endif
  13050. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  13051. {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  13052. {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  13053. {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  13054. {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  13055. {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  13056. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  13057. {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  13058. {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  13059. #else
  13060. {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  13061. {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  13062. #endif
  13063. {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  13064. {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  13065. {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  13066. {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  13067. {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  13068. {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  13069. {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  13070. {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  13071. {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  13072. {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  13073. {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
  13074. #if CYTHON_COMPILING_IN_LIMITED_API
  13075. {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
  13076. #endif
  13077. {0, 0, 0, 0, 0}
  13078. };
  13079. static PyMemberDef __pyx_CyFunction_members[] = {
  13080. #if !CYTHON_COMPILING_IN_LIMITED_API
  13081. {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
  13082. #endif
  13083. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  13084. {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
  13085. #endif
  13086. #if CYTHON_METH_FASTCALL
  13087. #if CYTHON_COMPILING_IN_LIMITED_API
  13088. {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
  13089. #else
  13090. {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
  13091. #endif
  13092. #if CYTHON_COMPILING_IN_LIMITED_API
  13093. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
  13094. #else
  13095. {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
  13096. #endif
  13097. #endif
  13098. {0, 0, 0, 0, 0}
  13099. };
  13100. static PyObject *
  13101. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
  13102. {
  13103. PyObject *result = NULL;
  13104. CYTHON_UNUSED_VAR(args);
  13105. __Pyx_BEGIN_CRITICAL_SECTION(m);
  13106. Py_INCREF(m->func_qualname);
  13107. result = m->func_qualname;
  13108. __Pyx_END_CRITICAL_SECTION();
  13109. return result;
  13110. }
  13111. static PyMethodDef __pyx_CyFunction_methods[] = {
  13112. {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  13113. {0, 0, 0, 0}
  13114. };
  13115. #if CYTHON_COMPILING_IN_LIMITED_API
  13116. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  13117. #else
  13118. #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
  13119. #endif
  13120. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
  13121. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  13122. #if !CYTHON_COMPILING_IN_LIMITED_API
  13123. PyCFunctionObject *cf = (PyCFunctionObject*) op;
  13124. #endif
  13125. if (unlikely(op == NULL))
  13126. return NULL;
  13127. #if CYTHON_COMPILING_IN_LIMITED_API
  13128. op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
  13129. if (unlikely(!op->func)) return NULL;
  13130. #endif
  13131. op->flags = flags;
  13132. __Pyx_CyFunction_weakreflist(op) = NULL;
  13133. #if !CYTHON_COMPILING_IN_LIMITED_API
  13134. cf->m_ml = ml;
  13135. cf->m_self = (PyObject *) op;
  13136. #endif
  13137. Py_XINCREF(closure);
  13138. op->func_closure = closure;
  13139. #if !CYTHON_COMPILING_IN_LIMITED_API
  13140. Py_XINCREF(module);
  13141. cf->m_module = module;
  13142. #endif
  13143. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  13144. op->func_dict = NULL;
  13145. #endif
  13146. op->func_name = NULL;
  13147. Py_INCREF(qualname);
  13148. op->func_qualname = qualname;
  13149. op->func_doc = NULL;
  13150. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  13151. op->func_classobj = NULL;
  13152. #else
  13153. ((PyCMethodObject*)op)->mm_class = NULL;
  13154. #endif
  13155. op->func_globals = globals;
  13156. Py_INCREF(op->func_globals);
  13157. Py_XINCREF(code);
  13158. op->func_code = code;
  13159. op->defaults = NULL;
  13160. op->defaults_tuple = NULL;
  13161. op->defaults_kwdict = NULL;
  13162. op->defaults_getter = NULL;
  13163. op->func_annotations = NULL;
  13164. op->func_is_coroutine = NULL;
  13165. #if CYTHON_METH_FASTCALL
  13166. switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
  13167. case METH_NOARGS:
  13168. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
  13169. break;
  13170. case METH_O:
  13171. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
  13172. break;
  13173. case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
  13174. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
  13175. break;
  13176. case METH_FASTCALL | METH_KEYWORDS:
  13177. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
  13178. break;
  13179. case METH_VARARGS | METH_KEYWORDS:
  13180. __Pyx_CyFunction_func_vectorcall(op) = NULL;
  13181. break;
  13182. default:
  13183. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  13184. Py_DECREF(op);
  13185. return NULL;
  13186. }
  13187. #endif
  13188. return (PyObject *) op;
  13189. }
  13190. static int
  13191. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  13192. {
  13193. Py_CLEAR(m->func_closure);
  13194. #if CYTHON_COMPILING_IN_LIMITED_API
  13195. Py_CLEAR(m->func);
  13196. #else
  13197. Py_CLEAR(((PyCFunctionObject*)m)->m_module);
  13198. #endif
  13199. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  13200. Py_CLEAR(m->func_dict);
  13201. #elif PY_VERSION_HEX < 0x030d0000
  13202. _PyObject_ClearManagedDict((PyObject*)m);
  13203. #else
  13204. PyObject_ClearManagedDict((PyObject*)m);
  13205. #endif
  13206. Py_CLEAR(m->func_name);
  13207. Py_CLEAR(m->func_qualname);
  13208. Py_CLEAR(m->func_doc);
  13209. Py_CLEAR(m->func_globals);
  13210. Py_CLEAR(m->func_code);
  13211. #if !CYTHON_COMPILING_IN_LIMITED_API
  13212. #if PY_VERSION_HEX < 0x030900B1
  13213. Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
  13214. #else
  13215. {
  13216. PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
  13217. ((PyCMethodObject *) (m))->mm_class = NULL;
  13218. Py_XDECREF(cls);
  13219. }
  13220. #endif
  13221. #endif
  13222. Py_CLEAR(m->defaults_tuple);
  13223. Py_CLEAR(m->defaults_kwdict);
  13224. Py_CLEAR(m->func_annotations);
  13225. Py_CLEAR(m->func_is_coroutine);
  13226. Py_CLEAR(m->defaults);
  13227. return 0;
  13228. }
  13229. static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
  13230. {
  13231. if (__Pyx_CyFunction_weakreflist(m) != NULL)
  13232. PyObject_ClearWeakRefs((PyObject *) m);
  13233. __Pyx_CyFunction_clear(m);
  13234. __Pyx_PyHeapTypeObject_GC_Del(m);
  13235. }
  13236. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  13237. {
  13238. PyObject_GC_UnTrack(m);
  13239. __Pyx__CyFunction_dealloc(m);
  13240. }
  13241. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  13242. {
  13243. {
  13244. int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg);
  13245. if (e) return e;
  13246. }
  13247. Py_VISIT(m->func_closure);
  13248. #if CYTHON_COMPILING_IN_LIMITED_API
  13249. Py_VISIT(m->func);
  13250. #else
  13251. Py_VISIT(((PyCFunctionObject*)m)->m_module);
  13252. #endif
  13253. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  13254. Py_VISIT(m->func_dict);
  13255. #else
  13256. {
  13257. int e =
  13258. #if PY_VERSION_HEX < 0x030d0000
  13259. _PyObject_VisitManagedDict
  13260. #else
  13261. PyObject_VisitManagedDict
  13262. #endif
  13263. ((PyObject*)m, visit, arg);
  13264. if (e != 0) return e;
  13265. }
  13266. #endif
  13267. __Pyx_VISIT_CONST(m->func_name);
  13268. __Pyx_VISIT_CONST(m->func_qualname);
  13269. Py_VISIT(m->func_doc);
  13270. Py_VISIT(m->func_globals);
  13271. __Pyx_VISIT_CONST(m->func_code);
  13272. #if !CYTHON_COMPILING_IN_LIMITED_API
  13273. Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
  13274. #endif
  13275. Py_VISIT(m->defaults_tuple);
  13276. Py_VISIT(m->defaults_kwdict);
  13277. Py_VISIT(m->func_is_coroutine);
  13278. Py_VISIT(m->defaults);
  13279. return 0;
  13280. }
  13281. static PyObject*
  13282. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  13283. {
  13284. PyObject *repr;
  13285. __Pyx_BEGIN_CRITICAL_SECTION(op);
  13286. repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
  13287. op->func_qualname, (void *)op);
  13288. __Pyx_END_CRITICAL_SECTION();
  13289. return repr;
  13290. }
  13291. static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  13292. #if CYTHON_COMPILING_IN_LIMITED_API
  13293. PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
  13294. PyCFunction meth;
  13295. int flags;
  13296. meth = PyCFunction_GetFunction(f);
  13297. if (unlikely(!meth)) return NULL;
  13298. flags = PyCFunction_GetFlags(f);
  13299. if (unlikely(flags < 0)) return NULL;
  13300. #else
  13301. PyCFunctionObject* f = (PyCFunctionObject*)func;
  13302. PyCFunction meth = f->m_ml->ml_meth;
  13303. int flags = f->m_ml->ml_flags;
  13304. #endif
  13305. Py_ssize_t size;
  13306. switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
  13307. case METH_VARARGS:
  13308. if (likely(kw == NULL || PyDict_Size(kw) == 0))
  13309. return (*meth)(self, arg);
  13310. break;
  13311. case METH_VARARGS | METH_KEYWORDS:
  13312. return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
  13313. case METH_NOARGS:
  13314. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  13315. #if CYTHON_ASSUME_SAFE_SIZE
  13316. size = PyTuple_GET_SIZE(arg);
  13317. #else
  13318. size = PyTuple_Size(arg);
  13319. if (unlikely(size < 0)) return NULL;
  13320. #endif
  13321. if (likely(size == 0))
  13322. return (*meth)(self, NULL);
  13323. __Pyx_CyFunction_raise_argument_count_error(
  13324. (__pyx_CyFunctionObject*)func,
  13325. "takes no arguments", size);
  13326. return NULL;
  13327. }
  13328. break;
  13329. case METH_O:
  13330. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  13331. #if CYTHON_ASSUME_SAFE_SIZE
  13332. size = PyTuple_GET_SIZE(arg);
  13333. #else
  13334. size = PyTuple_Size(arg);
  13335. if (unlikely(size < 0)) return NULL;
  13336. #endif
  13337. if (likely(size == 1)) {
  13338. PyObject *result, *arg0;
  13339. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  13340. arg0 = PyTuple_GET_ITEM(arg, 0);
  13341. #else
  13342. arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
  13343. #endif
  13344. result = (*meth)(self, arg0);
  13345. #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  13346. Py_DECREF(arg0);
  13347. #endif
  13348. return result;
  13349. }
  13350. __Pyx_CyFunction_raise_argument_count_error(
  13351. (__pyx_CyFunctionObject*)func,
  13352. "takes exactly one argument", size);
  13353. return NULL;
  13354. }
  13355. break;
  13356. default:
  13357. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  13358. return NULL;
  13359. }
  13360. __Pyx_CyFunction_raise_type_error(
  13361. (__pyx_CyFunctionObject*)func, "takes no keyword arguments");
  13362. return NULL;
  13363. }
  13364. static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  13365. PyObject *self, *result;
  13366. #if CYTHON_COMPILING_IN_LIMITED_API
  13367. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
  13368. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  13369. #else
  13370. self = ((PyCFunctionObject*)func)->m_self;
  13371. #endif
  13372. result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
  13373. return result;
  13374. }
  13375. static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
  13376. PyObject *result;
  13377. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  13378. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  13379. __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
  13380. if (vc) {
  13381. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  13382. return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
  13383. #else
  13384. (void) &__Pyx_PyVectorcall_FastCallDict;
  13385. return PyVectorcall_Call(func, args, kw);
  13386. #endif
  13387. }
  13388. #endif
  13389. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  13390. Py_ssize_t argc;
  13391. PyObject *new_args;
  13392. PyObject *self;
  13393. #if CYTHON_ASSUME_SAFE_SIZE
  13394. argc = PyTuple_GET_SIZE(args);
  13395. #else
  13396. argc = PyTuple_Size(args);
  13397. if (unlikely(argc < 0)) return NULL;
  13398. #endif
  13399. new_args = PyTuple_GetSlice(args, 1, argc);
  13400. if (unlikely(!new_args))
  13401. return NULL;
  13402. self = PyTuple_GetItem(args, 0);
  13403. if (unlikely(!self)) {
  13404. Py_DECREF(new_args);
  13405. PyErr_Format(PyExc_TypeError,
  13406. "unbound method %.200S() needs an argument",
  13407. cyfunc->func_qualname);
  13408. return NULL;
  13409. }
  13410. result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
  13411. Py_DECREF(new_args);
  13412. } else {
  13413. result = __Pyx_CyFunction_Call(func, args, kw);
  13414. }
  13415. return result;
  13416. }
  13417. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  13418. static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
  13419. {
  13420. int ret = 0;
  13421. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  13422. if (unlikely(nargs < 1)) {
  13423. __Pyx_CyFunction_raise_type_error(
  13424. cyfunc, "needs an argument");
  13425. return -1;
  13426. }
  13427. ret = 1;
  13428. }
  13429. if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
  13430. __Pyx_CyFunction_raise_type_error(
  13431. cyfunc, "takes no keyword arguments");
  13432. return -1;
  13433. }
  13434. return ret;
  13435. }
  13436. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  13437. {
  13438. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  13439. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  13440. PyObject *self;
  13441. #if CYTHON_COMPILING_IN_LIMITED_API
  13442. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  13443. if (unlikely(!meth)) return NULL;
  13444. #else
  13445. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  13446. #endif
  13447. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  13448. case 1:
  13449. self = args[0];
  13450. args += 1;
  13451. nargs -= 1;
  13452. break;
  13453. case 0:
  13454. #if CYTHON_COMPILING_IN_LIMITED_API
  13455. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  13456. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  13457. #else
  13458. self = ((PyCFunctionObject*)cyfunc)->m_self;
  13459. #endif
  13460. break;
  13461. default:
  13462. return NULL;
  13463. }
  13464. if (unlikely(nargs != 0)) {
  13465. __Pyx_CyFunction_raise_argument_count_error(
  13466. cyfunc, "takes no arguments", nargs);
  13467. return NULL;
  13468. }
  13469. return meth(self, NULL);
  13470. }
  13471. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  13472. {
  13473. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  13474. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  13475. PyObject *self;
  13476. #if CYTHON_COMPILING_IN_LIMITED_API
  13477. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  13478. if (unlikely(!meth)) return NULL;
  13479. #else
  13480. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  13481. #endif
  13482. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  13483. case 1:
  13484. self = args[0];
  13485. args += 1;
  13486. nargs -= 1;
  13487. break;
  13488. case 0:
  13489. #if CYTHON_COMPILING_IN_LIMITED_API
  13490. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  13491. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  13492. #else
  13493. self = ((PyCFunctionObject*)cyfunc)->m_self;
  13494. #endif
  13495. break;
  13496. default:
  13497. return NULL;
  13498. }
  13499. if (unlikely(nargs != 1)) {
  13500. __Pyx_CyFunction_raise_argument_count_error(
  13501. cyfunc, "takes exactly one argument", nargs);
  13502. return NULL;
  13503. }
  13504. return meth(self, args[0]);
  13505. }
  13506. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  13507. {
  13508. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  13509. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  13510. PyObject *self;
  13511. #if CYTHON_COMPILING_IN_LIMITED_API
  13512. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  13513. if (unlikely(!meth)) return NULL;
  13514. #else
  13515. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  13516. #endif
  13517. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  13518. case 1:
  13519. self = args[0];
  13520. args += 1;
  13521. nargs -= 1;
  13522. break;
  13523. case 0:
  13524. #if CYTHON_COMPILING_IN_LIMITED_API
  13525. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  13526. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  13527. #else
  13528. self = ((PyCFunctionObject*)cyfunc)->m_self;
  13529. #endif
  13530. break;
  13531. default:
  13532. return NULL;
  13533. }
  13534. return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
  13535. }
  13536. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  13537. {
  13538. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  13539. PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
  13540. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  13541. PyObject *self;
  13542. #if CYTHON_COMPILING_IN_LIMITED_API
  13543. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  13544. if (unlikely(!meth)) return NULL;
  13545. #else
  13546. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  13547. #endif
  13548. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  13549. case 1:
  13550. self = args[0];
  13551. args += 1;
  13552. nargs -= 1;
  13553. break;
  13554. case 0:
  13555. #if CYTHON_COMPILING_IN_LIMITED_API
  13556. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  13557. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  13558. #else
  13559. self = ((PyCFunctionObject*)cyfunc)->m_self;
  13560. #endif
  13561. break;
  13562. default:
  13563. return NULL;
  13564. }
  13565. #if PY_VERSION_HEX < 0x030e00A6
  13566. size_t nargs_value = (size_t) nargs;
  13567. #else
  13568. Py_ssize_t nargs_value = nargs;
  13569. #endif
  13570. return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames);
  13571. }
  13572. #endif
  13573. static PyType_Slot __pyx_CyFunctionType_slots[] = {
  13574. {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
  13575. {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
  13576. {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
  13577. {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
  13578. {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
  13579. {Py_tp_methods, (void *)__pyx_CyFunction_methods},
  13580. {Py_tp_members, (void *)__pyx_CyFunction_members},
  13581. {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
  13582. {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
  13583. {0, 0},
  13584. };
  13585. static PyType_Spec __pyx_CyFunctionType_spec = {
  13586. __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
  13587. sizeof(__pyx_CyFunctionObject),
  13588. 0,
  13589. #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
  13590. Py_TPFLAGS_METHOD_DESCRIPTOR |
  13591. #endif
  13592. #if CYTHON_METH_FASTCALL
  13593. #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
  13594. Py_TPFLAGS_HAVE_VECTORCALL |
  13595. #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
  13596. _Py_TPFLAGS_HAVE_VECTORCALL |
  13597. #endif
  13598. #endif // CYTHON_METH_FASTCALL
  13599. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  13600. Py_TPFLAGS_MANAGED_DICT |
  13601. #endif
  13602. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  13603. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
  13604. __pyx_CyFunctionType_slots
  13605. };
  13606. static int __pyx_CyFunction_init(PyObject *module) {
  13607. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  13608. mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(
  13609. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL);
  13610. if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
  13611. return -1;
  13612. }
  13613. return 0;
  13614. }
  13615. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
  13616. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13617. m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
  13618. if (unlikely(!m->defaults))
  13619. return NULL;
  13620. return m->defaults;
  13621. }
  13622. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  13623. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13624. m->defaults_tuple = tuple;
  13625. Py_INCREF(tuple);
  13626. }
  13627. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  13628. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13629. m->defaults_kwdict = dict;
  13630. Py_INCREF(dict);
  13631. }
  13632. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  13633. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  13634. m->func_annotations = dict;
  13635. Py_INCREF(dict);
  13636. }
  13637. /* CythonFunction */
  13638. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
  13639. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  13640. PyObject *op = __Pyx_CyFunction_Init(
  13641. PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType),
  13642. ml, flags, qualname, closure, module, globals, code
  13643. );
  13644. if (likely(op)) {
  13645. PyObject_GC_Track(op);
  13646. }
  13647. return op;
  13648. }
  13649. /* ObjectGetItem */
  13650. #if CYTHON_USE_TYPE_SLOTS
  13651. static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
  13652. PyObject *runerr = NULL;
  13653. Py_ssize_t key_value;
  13654. key_value = __Pyx_PyIndex_AsSsize_t(index);
  13655. if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
  13656. return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1, 1);
  13657. }
  13658. if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
  13659. __Pyx_TypeName index_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(index));
  13660. PyErr_Clear();
  13661. PyErr_Format(PyExc_IndexError,
  13662. "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name);
  13663. __Pyx_DECREF_TypeName(index_type_name);
  13664. }
  13665. return NULL;
  13666. }
  13667. static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
  13668. __Pyx_TypeName obj_type_name;
  13669. if (likely(PyType_Check(obj))) {
  13670. PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, __pyx_mstate_global->__pyx_n_u_class_getitem);
  13671. if (!meth) {
  13672. PyErr_Clear();
  13673. } else {
  13674. PyObject *result = __Pyx_PyObject_CallOneArg(meth, key);
  13675. Py_DECREF(meth);
  13676. return result;
  13677. }
  13678. }
  13679. obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
  13680. PyErr_Format(PyExc_TypeError,
  13681. "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name);
  13682. __Pyx_DECREF_TypeName(obj_type_name);
  13683. return NULL;
  13684. }
  13685. static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) {
  13686. PyTypeObject *tp = Py_TYPE(obj);
  13687. PyMappingMethods *mm = tp->tp_as_mapping;
  13688. PySequenceMethods *sm = tp->tp_as_sequence;
  13689. if (likely(mm && mm->mp_subscript)) {
  13690. return mm->mp_subscript(obj, key);
  13691. }
  13692. if (likely(sm && sm->sq_item)) {
  13693. return __Pyx_PyObject_GetIndex(obj, key);
  13694. }
  13695. return __Pyx_PyObject_GetItem_Slow(obj, key);
  13696. }
  13697. #endif
  13698. /* CLineInTraceback (used by AddTraceback) */
  13699. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  13700. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  13701. #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
  13702. #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  13703. #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
  13704. #else
  13705. PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
  13706. PyObject **dict_ptr = _PyObject_GetDictPtr(o);
  13707. return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
  13708. }
  13709. #endif
  13710. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
  13711. PyObject *use_cline = NULL;
  13712. PyObject *ptype, *pvalue, *ptraceback;
  13713. PyObject *cython_runtime_dict;
  13714. CYTHON_MAYBE_UNUSED_VAR(tstate);
  13715. if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) {
  13716. return c_line;
  13717. }
  13718. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  13719. cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime);
  13720. if (likely(cython_runtime_dict)) {
  13721. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  13722. use_cline, cython_runtime_dict,
  13723. __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False))
  13724. }
  13725. if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  13726. c_line = 0;
  13727. }
  13728. Py_XDECREF(use_cline);
  13729. Py_XDECREF(cython_runtime_dict);
  13730. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  13731. return c_line;
  13732. }
  13733. #endif
  13734. /* CodeObjectCache (used by AddTraceback) */
  13735. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  13736. int start = 0, mid = 0, end = count - 1;
  13737. if (end >= 0 && code_line > entries[end].code_line) {
  13738. return count;
  13739. }
  13740. while (start < end) {
  13741. mid = start + (end - start) / 2;
  13742. if (code_line < entries[mid].code_line) {
  13743. end = mid;
  13744. } else if (code_line > entries[mid].code_line) {
  13745. start = mid + 1;
  13746. } else {
  13747. return mid;
  13748. }
  13749. }
  13750. if (code_line <= entries[mid].code_line) {
  13751. return mid;
  13752. } else {
  13753. return mid + 1;
  13754. }
  13755. }
  13756. static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) {
  13757. __Pyx_CachedCodeObjectType* code_object;
  13758. int pos;
  13759. if (unlikely(!code_line) || unlikely(!code_cache->entries)) {
  13760. return NULL;
  13761. }
  13762. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  13763. if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) {
  13764. return NULL;
  13765. }
  13766. code_object = code_cache->entries[pos].code_object;
  13767. Py_INCREF(code_object);
  13768. return code_object;
  13769. }
  13770. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) {
  13771. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  13772. (void)__pyx__find_code_object;
  13773. return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss.
  13774. #else
  13775. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  13776. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  13777. __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count);
  13778. if (old_count < 0) {
  13779. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  13780. return NULL;
  13781. }
  13782. #endif
  13783. __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line);
  13784. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  13785. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  13786. #endif
  13787. return result;
  13788. #endif
  13789. }
  13790. static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object)
  13791. {
  13792. int pos, i;
  13793. __Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
  13794. if (unlikely(!code_line)) {
  13795. return;
  13796. }
  13797. if (unlikely(!entries)) {
  13798. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  13799. if (likely(entries)) {
  13800. code_cache->entries = entries;
  13801. code_cache->max_count = 64;
  13802. code_cache->count = 1;
  13803. entries[0].code_line = code_line;
  13804. entries[0].code_object = code_object;
  13805. Py_INCREF(code_object);
  13806. }
  13807. return;
  13808. }
  13809. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  13810. if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) {
  13811. __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object;
  13812. entries[pos].code_object = code_object;
  13813. Py_INCREF(code_object);
  13814. Py_DECREF(tmp);
  13815. return;
  13816. }
  13817. if (code_cache->count == code_cache->max_count) {
  13818. int new_max = code_cache->max_count + 64;
  13819. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  13820. code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
  13821. if (unlikely(!entries)) {
  13822. return;
  13823. }
  13824. code_cache->entries = entries;
  13825. code_cache->max_count = new_max;
  13826. }
  13827. for (i=code_cache->count; i>pos; i--) {
  13828. entries[i] = entries[i-1];
  13829. }
  13830. entries[pos].code_line = code_line;
  13831. entries[pos].code_object = code_object;
  13832. code_cache->count++;
  13833. Py_INCREF(code_object);
  13834. }
  13835. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) {
  13836. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  13837. (void)__pyx__insert_code_object;
  13838. return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail.
  13839. #else
  13840. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  13841. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  13842. __pyx_nonatomic_int_type expected = 0;
  13843. if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) {
  13844. return;
  13845. }
  13846. #endif
  13847. __pyx__insert_code_object(code_cache, code_line, code_object);
  13848. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  13849. __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN);
  13850. #endif
  13851. #endif
  13852. }
  13853. /* AddTraceback */
  13854. #include "compile.h"
  13855. #include "frameobject.h"
  13856. #include "traceback.h"
  13857. #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
  13858. #ifndef Py_BUILD_CORE
  13859. #define Py_BUILD_CORE 1
  13860. #endif
  13861. #include "internal/pycore_frame.h"
  13862. #endif
  13863. #if CYTHON_COMPILING_IN_LIMITED_API
  13864. static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
  13865. PyObject *firstlineno, PyObject *name) {
  13866. PyObject *replace = NULL;
  13867. if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
  13868. if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
  13869. replace = PyObject_GetAttrString(code, "replace");
  13870. if (likely(replace)) {
  13871. PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict);
  13872. Py_DECREF(replace);
  13873. return result;
  13874. }
  13875. PyErr_Clear();
  13876. return NULL;
  13877. }
  13878. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  13879. int py_line, const char *filename) {
  13880. PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
  13881. PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
  13882. PyObject *exc_type, *exc_value, *exc_traceback;
  13883. int success = 0;
  13884. if (c_line) {
  13885. c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
  13886. }
  13887. PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
  13888. code_object = __pyx_find_code_object(c_line ? -c_line : py_line);
  13889. if (!code_object) {
  13890. code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
  13891. if (unlikely(!code_object)) goto bad;
  13892. py_py_line = PyLong_FromLong(py_line);
  13893. if (unlikely(!py_py_line)) goto bad;
  13894. if (c_line) {
  13895. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  13896. } else {
  13897. py_funcname = PyUnicode_FromString(funcname);
  13898. }
  13899. if (unlikely(!py_funcname)) goto bad;
  13900. dict = PyDict_New();
  13901. if (unlikely(!dict)) goto bad;
  13902. {
  13903. PyObject *old_code_object = code_object;
  13904. code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
  13905. Py_DECREF(old_code_object);
  13906. }
  13907. if (unlikely(!code_object)) goto bad;
  13908. __pyx_insert_code_object(c_line ? -c_line : py_line, code_object);
  13909. } else {
  13910. dict = PyDict_New();
  13911. }
  13912. getframe = PySys_GetObject("_getframe");
  13913. if (unlikely(!getframe)) goto bad;
  13914. if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
  13915. frame = PyEval_EvalCode(code_object, dict, dict);
  13916. if (unlikely(!frame) || frame == Py_None) goto bad;
  13917. success = 1;
  13918. bad:
  13919. PyErr_Restore(exc_type, exc_value, exc_traceback);
  13920. Py_XDECREF(code_object);
  13921. Py_XDECREF(py_py_line);
  13922. Py_XDECREF(py_funcname);
  13923. Py_XDECREF(dict);
  13924. Py_XDECREF(replace);
  13925. if (success) {
  13926. PyTraceBack_Here(
  13927. (struct _frame*)frame);
  13928. }
  13929. Py_XDECREF(frame);
  13930. }
  13931. #else
  13932. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  13933. const char *funcname, int c_line,
  13934. int py_line, const char *filename) {
  13935. PyCodeObject *py_code = NULL;
  13936. PyObject *py_funcname = NULL;
  13937. if (c_line) {
  13938. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  13939. if (!py_funcname) goto bad;
  13940. funcname = PyUnicode_AsUTF8(py_funcname);
  13941. if (!funcname) goto bad;
  13942. }
  13943. py_code = PyCode_NewEmpty(filename, funcname, py_line);
  13944. Py_XDECREF(py_funcname);
  13945. return py_code;
  13946. bad:
  13947. Py_XDECREF(py_funcname);
  13948. return NULL;
  13949. }
  13950. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  13951. int py_line, const char *filename) {
  13952. PyCodeObject *py_code = 0;
  13953. PyFrameObject *py_frame = 0;
  13954. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  13955. PyObject *ptype, *pvalue, *ptraceback;
  13956. if (c_line) {
  13957. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  13958. }
  13959. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  13960. if (!py_code) {
  13961. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  13962. py_code = __Pyx_CreateCodeObjectForTraceback(
  13963. funcname, c_line, py_line, filename);
  13964. if (!py_code) {
  13965. /* If the code object creation fails, then we should clear the
  13966. fetched exception references and propagate the new exception */
  13967. Py_XDECREF(ptype);
  13968. Py_XDECREF(pvalue);
  13969. Py_XDECREF(ptraceback);
  13970. goto bad;
  13971. }
  13972. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  13973. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  13974. }
  13975. py_frame = PyFrame_New(
  13976. tstate, /*PyThreadState *tstate,*/
  13977. py_code, /*PyCodeObject *code,*/
  13978. __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/
  13979. 0 /*PyObject *locals*/
  13980. );
  13981. if (!py_frame) goto bad;
  13982. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  13983. PyTraceBack_Here(py_frame);
  13984. bad:
  13985. Py_XDECREF(py_code);
  13986. Py_XDECREF(py_frame);
  13987. }
  13988. #endif
  13989. /* Declarations */
  13990. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  13991. #ifdef __cplusplus
  13992. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  13993. return ::std::complex< double >(x, y);
  13994. }
  13995. #else
  13996. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  13997. return x + y*(__pyx_t_double_complex)_Complex_I;
  13998. }
  13999. #endif
  14000. #else
  14001. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  14002. __pyx_t_double_complex z;
  14003. z.real = x;
  14004. z.imag = y;
  14005. return z;
  14006. }
  14007. #endif
  14008. /* Arithmetic */
  14009. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  14010. #else
  14011. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14012. return (a.real == b.real) && (a.imag == b.imag);
  14013. }
  14014. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14015. __pyx_t_double_complex z;
  14016. z.real = a.real + b.real;
  14017. z.imag = a.imag + b.imag;
  14018. return z;
  14019. }
  14020. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14021. __pyx_t_double_complex z;
  14022. z.real = a.real - b.real;
  14023. z.imag = a.imag - b.imag;
  14024. return z;
  14025. }
  14026. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14027. __pyx_t_double_complex z;
  14028. z.real = a.real * b.real - a.imag * b.imag;
  14029. z.imag = a.real * b.imag + a.imag * b.real;
  14030. return z;
  14031. }
  14032. #if 1
  14033. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14034. if (b.imag == 0) {
  14035. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  14036. } else if (fabs(b.real) >= fabs(b.imag)) {
  14037. if (b.real == 0 && b.imag == 0) {
  14038. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
  14039. } else {
  14040. double r = b.imag / b.real;
  14041. double s = (double)(1.0) / (b.real + b.imag * r);
  14042. return __pyx_t_double_complex_from_parts(
  14043. (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
  14044. }
  14045. } else {
  14046. double r = b.real / b.imag;
  14047. double s = (double)(1.0) / (b.imag + b.real * r);
  14048. return __pyx_t_double_complex_from_parts(
  14049. (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
  14050. }
  14051. }
  14052. #else
  14053. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14054. if (b.imag == 0) {
  14055. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  14056. } else {
  14057. double denom = b.real * b.real + b.imag * b.imag;
  14058. return __pyx_t_double_complex_from_parts(
  14059. (a.real * b.real + a.imag * b.imag) / denom,
  14060. (a.imag * b.real - a.real * b.imag) / denom);
  14061. }
  14062. }
  14063. #endif
  14064. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
  14065. __pyx_t_double_complex z;
  14066. z.real = -a.real;
  14067. z.imag = -a.imag;
  14068. return z;
  14069. }
  14070. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
  14071. return (a.real == 0) && (a.imag == 0);
  14072. }
  14073. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
  14074. __pyx_t_double_complex z;
  14075. z.real = a.real;
  14076. z.imag = -a.imag;
  14077. return z;
  14078. }
  14079. #if 1
  14080. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
  14081. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  14082. return sqrt(z.real*z.real + z.imag*z.imag);
  14083. #else
  14084. return hypot(z.real, z.imag);
  14085. #endif
  14086. }
  14087. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  14088. __pyx_t_double_complex z;
  14089. double r, lnr, theta, z_r, z_theta;
  14090. if (b.imag == 0 && b.real == (int)b.real) {
  14091. if (b.real < 0) {
  14092. double denom = a.real * a.real + a.imag * a.imag;
  14093. a.real = a.real / denom;
  14094. a.imag = -a.imag / denom;
  14095. b.real = -b.real;
  14096. }
  14097. switch ((int)b.real) {
  14098. case 0:
  14099. z.real = 1;
  14100. z.imag = 0;
  14101. return z;
  14102. case 1:
  14103. return a;
  14104. case 2:
  14105. return __Pyx_c_prod_double(a, a);
  14106. case 3:
  14107. z = __Pyx_c_prod_double(a, a);
  14108. return __Pyx_c_prod_double(z, a);
  14109. case 4:
  14110. z = __Pyx_c_prod_double(a, a);
  14111. return __Pyx_c_prod_double(z, z);
  14112. }
  14113. }
  14114. if (a.imag == 0) {
  14115. if (a.real == 0) {
  14116. return a;
  14117. } else if ((b.imag == 0) && (a.real >= 0)) {
  14118. z.real = pow(a.real, b.real);
  14119. z.imag = 0;
  14120. return z;
  14121. } else if (a.real > 0) {
  14122. r = a.real;
  14123. theta = 0;
  14124. } else {
  14125. r = -a.real;
  14126. theta = atan2(0.0, -1.0);
  14127. }
  14128. } else {
  14129. r = __Pyx_c_abs_double(a);
  14130. theta = atan2(a.imag, a.real);
  14131. }
  14132. lnr = log(r);
  14133. z_r = exp(lnr * b.real - theta * b.imag);
  14134. z_theta = theta * b.real + lnr * b.imag;
  14135. z.real = z_r * cos(z_theta);
  14136. z.imag = z_r * sin(z_theta);
  14137. return z;
  14138. }
  14139. #endif
  14140. #endif
  14141. /* FromPy */
  14142. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
  14143. #if CYTHON_COMPILING_IN_LIMITED_API
  14144. double real=-1.0, imag=-1.0;
  14145. real = PyComplex_RealAsDouble(o);
  14146. if (unlikely(real == -1.0 && PyErr_Occurred())) goto end;
  14147. imag = PyComplex_ImagAsDouble(o);
  14148. end:
  14149. return __pyx_t_double_complex_from_parts(
  14150. (double)real, (double)imag
  14151. );
  14152. #else
  14153. Py_complex cval;
  14154. #if !CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_GRAAL
  14155. if (PyComplex_CheckExact(o))
  14156. cval = ((PyComplexObject *)o)->cval;
  14157. else
  14158. #endif
  14159. cval = PyComplex_AsCComplex(o);
  14160. return __pyx_t_double_complex_from_parts(
  14161. (double)cval.real,
  14162. (double)cval.imag);
  14163. #endif
  14164. }
  14165. /* CIntFromPyVerify */
  14166. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  14167. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  14168. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  14169. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  14170. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  14171. {\
  14172. func_type value = func_value;\
  14173. if (sizeof(target_type) < sizeof(func_type)) {\
  14174. if (unlikely(value != (func_type) (target_type) value)) {\
  14175. func_type zero = 0;\
  14176. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  14177. return (target_type) -1;\
  14178. if (is_unsigned && unlikely(value < zero))\
  14179. goto raise_neg_overflow;\
  14180. else\
  14181. goto raise_overflow;\
  14182. }\
  14183. }\
  14184. return (target_type) value;\
  14185. }
  14186. /* CIntFromPy */
  14187. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) {
  14188. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14189. #pragma GCC diagnostic push
  14190. #pragma GCC diagnostic ignored "-Wconversion"
  14191. #endif
  14192. const int neg_one = (int) -1, const_zero = (int) 0;
  14193. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14194. #pragma GCC diagnostic pop
  14195. #endif
  14196. const int is_unsigned = neg_one > const_zero;
  14197. if (unlikely(!PyLong_Check(x))) {
  14198. int val;
  14199. PyObject *tmp = __Pyx_PyNumber_Long(x);
  14200. if (!tmp) return (int) -1;
  14201. val = __Pyx_PyLong_As_int(tmp);
  14202. Py_DECREF(tmp);
  14203. return val;
  14204. }
  14205. if (is_unsigned) {
  14206. #if CYTHON_USE_PYLONG_INTERNALS
  14207. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  14208. goto raise_neg_overflow;
  14209. } else if (__Pyx_PyLong_IsCompact(x)) {
  14210. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  14211. } else {
  14212. const digit* digits = __Pyx_PyLong_Digits(x);
  14213. assert(__Pyx_PyLong_DigitCount(x) > 1);
  14214. switch (__Pyx_PyLong_DigitCount(x)) {
  14215. case 2:
  14216. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  14217. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  14218. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14219. } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
  14220. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  14221. }
  14222. }
  14223. break;
  14224. case 3:
  14225. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  14226. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  14227. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14228. } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
  14229. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  14230. }
  14231. }
  14232. break;
  14233. case 4:
  14234. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  14235. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  14236. __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])))
  14237. } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
  14238. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  14239. }
  14240. }
  14241. break;
  14242. }
  14243. }
  14244. #endif
  14245. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  14246. if (unlikely(Py_SIZE(x) < 0)) {
  14247. goto raise_neg_overflow;
  14248. }
  14249. #else
  14250. {
  14251. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14252. if (unlikely(result < 0))
  14253. return (int) -1;
  14254. if (unlikely(result == 1))
  14255. goto raise_neg_overflow;
  14256. }
  14257. #endif
  14258. if ((sizeof(int) <= sizeof(unsigned long))) {
  14259. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  14260. } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
  14261. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14262. }
  14263. } else {
  14264. #if CYTHON_USE_PYLONG_INTERNALS
  14265. if (__Pyx_PyLong_IsCompact(x)) {
  14266. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  14267. } else {
  14268. const digit* digits = __Pyx_PyLong_Digits(x);
  14269. assert(__Pyx_PyLong_DigitCount(x) > 1);
  14270. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  14271. case -2:
  14272. if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
  14273. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  14274. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14275. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  14276. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14277. }
  14278. }
  14279. break;
  14280. case 2:
  14281. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  14282. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  14283. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14284. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  14285. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14286. }
  14287. }
  14288. break;
  14289. case -3:
  14290. if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  14291. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  14292. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14293. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  14294. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14295. }
  14296. }
  14297. break;
  14298. case 3:
  14299. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  14300. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  14301. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14302. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  14303. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14304. }
  14305. }
  14306. break;
  14307. case -4:
  14308. if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  14309. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  14310. __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])))
  14311. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  14312. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14313. }
  14314. }
  14315. break;
  14316. case 4:
  14317. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  14318. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  14319. __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])))
  14320. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  14321. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  14322. }
  14323. }
  14324. break;
  14325. }
  14326. }
  14327. #endif
  14328. if ((sizeof(int) <= sizeof(long))) {
  14329. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  14330. } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
  14331. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  14332. }
  14333. }
  14334. {
  14335. int val;
  14336. int ret = -1;
  14337. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  14338. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  14339. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  14340. if (unlikely(bytes_copied == -1)) {
  14341. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  14342. goto raise_overflow;
  14343. } else {
  14344. ret = 0;
  14345. }
  14346. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  14347. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14348. unsigned char *bytes = (unsigned char *)&val;
  14349. ret = _PyLong_AsByteArray((PyLongObject *)x,
  14350. bytes, sizeof(val),
  14351. is_little, !is_unsigned);
  14352. #else
  14353. PyObject *v;
  14354. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  14355. int bits, remaining_bits, is_negative = 0;
  14356. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  14357. if (likely(PyLong_CheckExact(x))) {
  14358. v = __Pyx_NewRef(x);
  14359. } else {
  14360. v = PyNumber_Long(x);
  14361. if (unlikely(!v)) return (int) -1;
  14362. assert(PyLong_CheckExact(v));
  14363. }
  14364. {
  14365. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  14366. if (unlikely(result < 0)) {
  14367. Py_DECREF(v);
  14368. return (int) -1;
  14369. }
  14370. is_negative = result == 1;
  14371. }
  14372. if (is_unsigned && unlikely(is_negative)) {
  14373. Py_DECREF(v);
  14374. goto raise_neg_overflow;
  14375. } else if (is_negative) {
  14376. stepval = PyNumber_Invert(v);
  14377. Py_DECREF(v);
  14378. if (unlikely(!stepval))
  14379. return (int) -1;
  14380. } else {
  14381. stepval = v;
  14382. }
  14383. v = NULL;
  14384. val = (int) 0;
  14385. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  14386. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  14387. for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
  14388. PyObject *tmp, *digit;
  14389. long idigit;
  14390. digit = PyNumber_And(stepval, mask);
  14391. if (unlikely(!digit)) goto done;
  14392. idigit = PyLong_AsLong(digit);
  14393. Py_DECREF(digit);
  14394. if (unlikely(idigit < 0)) goto done;
  14395. val |= ((int) idigit) << bits;
  14396. tmp = PyNumber_Rshift(stepval, shift);
  14397. if (unlikely(!tmp)) goto done;
  14398. Py_DECREF(stepval); stepval = tmp;
  14399. }
  14400. Py_DECREF(shift); shift = NULL;
  14401. Py_DECREF(mask); mask = NULL;
  14402. {
  14403. long idigit = PyLong_AsLong(stepval);
  14404. if (unlikely(idigit < 0)) goto done;
  14405. remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
  14406. if (unlikely(idigit >= (1L << remaining_bits)))
  14407. goto raise_overflow;
  14408. val |= ((int) idigit) << bits;
  14409. }
  14410. if (!is_unsigned) {
  14411. if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
  14412. goto raise_overflow;
  14413. if (is_negative)
  14414. val = ~val;
  14415. }
  14416. ret = 0;
  14417. done:
  14418. Py_XDECREF(shift);
  14419. Py_XDECREF(mask);
  14420. Py_XDECREF(stepval);
  14421. #endif
  14422. if (unlikely(ret))
  14423. return (int) -1;
  14424. return val;
  14425. }
  14426. raise_overflow:
  14427. PyErr_SetString(PyExc_OverflowError,
  14428. "value too large to convert to int");
  14429. return (int) -1;
  14430. raise_neg_overflow:
  14431. PyErr_SetString(PyExc_OverflowError,
  14432. "can't convert negative value to int");
  14433. return (int) -1;
  14434. }
  14435. /* PyObjectVectorCallKwBuilder (used by CIntToPy) */
  14436. #if CYTHON_VECTORCALL
  14437. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  14438. (void)__Pyx_PyObject_FastCallDict;
  14439. if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1;
  14440. Py_INCREF(key);
  14441. args[n] = value;
  14442. return 0;
  14443. }
  14444. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  14445. (void)__Pyx_VectorcallBuilder_AddArgStr;
  14446. if (unlikely(!PyUnicode_Check(key))) {
  14447. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  14448. return -1;
  14449. }
  14450. return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n);
  14451. }
  14452. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  14453. PyObject *pyKey = PyUnicode_FromString(key);
  14454. if (!pyKey) return -1;
  14455. return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n);
  14456. }
  14457. #else // CYTHON_VECTORCALL
  14458. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) {
  14459. if (unlikely(!PyUnicode_Check(key))) {
  14460. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  14461. return -1;
  14462. }
  14463. return PyDict_SetItem(builder, key, value);
  14464. }
  14465. #endif
  14466. /* CIntToPy */
  14467. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value) {
  14468. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14469. #pragma GCC diagnostic push
  14470. #pragma GCC diagnostic ignored "-Wconversion"
  14471. #endif
  14472. const int neg_one = (int) -1, const_zero = (int) 0;
  14473. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14474. #pragma GCC diagnostic pop
  14475. #endif
  14476. const int is_unsigned = neg_one > const_zero;
  14477. if (is_unsigned) {
  14478. if (sizeof(int) < sizeof(long)) {
  14479. return PyLong_FromLong((long) value);
  14480. } else if (sizeof(int) <= sizeof(unsigned long)) {
  14481. return PyLong_FromUnsignedLong((unsigned long) value);
  14482. #if !CYTHON_COMPILING_IN_PYPY
  14483. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  14484. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14485. #endif
  14486. }
  14487. } else {
  14488. if (sizeof(int) <= sizeof(long)) {
  14489. return PyLong_FromLong((long) value);
  14490. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  14491. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14492. }
  14493. }
  14494. {
  14495. unsigned char *bytes = (unsigned char *)&value;
  14496. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  14497. if (is_unsigned) {
  14498. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  14499. } else {
  14500. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  14501. }
  14502. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  14503. int one = 1; int little = (int)*(unsigned char *)&one;
  14504. return _PyLong_FromByteArray(bytes, sizeof(int),
  14505. little, !is_unsigned);
  14506. #else
  14507. int one = 1; int little = (int)*(unsigned char *)&one;
  14508. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  14509. PyObject *py_bytes = NULL, *order_str = NULL;
  14510. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  14511. if (!from_bytes) return NULL;
  14512. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int));
  14513. if (!py_bytes) goto limited_bad;
  14514. order_str = PyUnicode_FromString(little ? "little" : "big");
  14515. if (!order_str) goto limited_bad;
  14516. {
  14517. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  14518. if (!is_unsigned) {
  14519. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  14520. if (!kwds) goto limited_bad;
  14521. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  14522. }
  14523. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  14524. }
  14525. limited_bad:
  14526. Py_XDECREF(kwds);
  14527. Py_XDECREF(order_str);
  14528. Py_XDECREF(py_bytes);
  14529. Py_XDECREF(from_bytes);
  14530. return result;
  14531. #endif
  14532. }
  14533. }
  14534. /* CIntToPy */
  14535. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) {
  14536. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14537. #pragma GCC diagnostic push
  14538. #pragma GCC diagnostic ignored "-Wconversion"
  14539. #endif
  14540. const long neg_one = (long) -1, const_zero = (long) 0;
  14541. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14542. #pragma GCC diagnostic pop
  14543. #endif
  14544. const int is_unsigned = neg_one > const_zero;
  14545. if (is_unsigned) {
  14546. if (sizeof(long) < sizeof(long)) {
  14547. return PyLong_FromLong((long) value);
  14548. } else if (sizeof(long) <= sizeof(unsigned long)) {
  14549. return PyLong_FromUnsignedLong((unsigned long) value);
  14550. #if !CYTHON_COMPILING_IN_PYPY
  14551. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  14552. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  14553. #endif
  14554. }
  14555. } else {
  14556. if (sizeof(long) <= sizeof(long)) {
  14557. return PyLong_FromLong((long) value);
  14558. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  14559. return PyLong_FromLongLong((PY_LONG_LONG) value);
  14560. }
  14561. }
  14562. {
  14563. unsigned char *bytes = (unsigned char *)&value;
  14564. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  14565. if (is_unsigned) {
  14566. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  14567. } else {
  14568. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  14569. }
  14570. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  14571. int one = 1; int little = (int)*(unsigned char *)&one;
  14572. return _PyLong_FromByteArray(bytes, sizeof(long),
  14573. little, !is_unsigned);
  14574. #else
  14575. int one = 1; int little = (int)*(unsigned char *)&one;
  14576. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  14577. PyObject *py_bytes = NULL, *order_str = NULL;
  14578. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  14579. if (!from_bytes) return NULL;
  14580. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long));
  14581. if (!py_bytes) goto limited_bad;
  14582. order_str = PyUnicode_FromString(little ? "little" : "big");
  14583. if (!order_str) goto limited_bad;
  14584. {
  14585. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  14586. if (!is_unsigned) {
  14587. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  14588. if (!kwds) goto limited_bad;
  14589. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  14590. }
  14591. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  14592. }
  14593. limited_bad:
  14594. Py_XDECREF(kwds);
  14595. Py_XDECREF(order_str);
  14596. Py_XDECREF(py_bytes);
  14597. Py_XDECREF(from_bytes);
  14598. return result;
  14599. #endif
  14600. }
  14601. }
  14602. /* FormatTypeName */
  14603. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
  14604. static __Pyx_TypeName
  14605. __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp)
  14606. {
  14607. PyObject *module = NULL, *name = NULL, *result = NULL;
  14608. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  14609. name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  14610. __pyx_mstate_global->__pyx_n_u_qualname);
  14611. #else
  14612. name = PyType_GetQualName(tp);
  14613. #endif
  14614. if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad;
  14615. module = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  14616. __pyx_mstate_global->__pyx_n_u_module);
  14617. if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad;
  14618. if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) {
  14619. result = name;
  14620. name = NULL;
  14621. goto done;
  14622. }
  14623. result = PyUnicode_FromFormat("%U.%U", module, name);
  14624. if (unlikely(result == NULL)) goto bad;
  14625. done:
  14626. Py_XDECREF(name);
  14627. Py_XDECREF(module);
  14628. return result;
  14629. bad:
  14630. PyErr_Clear();
  14631. if (name) {
  14632. result = name;
  14633. name = NULL;
  14634. } else {
  14635. result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2);
  14636. }
  14637. goto done;
  14638. }
  14639. #endif
  14640. /* CIntFromPy */
  14641. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) {
  14642. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14643. #pragma GCC diagnostic push
  14644. #pragma GCC diagnostic ignored "-Wconversion"
  14645. #endif
  14646. const long neg_one = (long) -1, const_zero = (long) 0;
  14647. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  14648. #pragma GCC diagnostic pop
  14649. #endif
  14650. const int is_unsigned = neg_one > const_zero;
  14651. if (unlikely(!PyLong_Check(x))) {
  14652. long val;
  14653. PyObject *tmp = __Pyx_PyNumber_Long(x);
  14654. if (!tmp) return (long) -1;
  14655. val = __Pyx_PyLong_As_long(tmp);
  14656. Py_DECREF(tmp);
  14657. return val;
  14658. }
  14659. if (is_unsigned) {
  14660. #if CYTHON_USE_PYLONG_INTERNALS
  14661. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  14662. goto raise_neg_overflow;
  14663. } else if (__Pyx_PyLong_IsCompact(x)) {
  14664. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  14665. } else {
  14666. const digit* digits = __Pyx_PyLong_Digits(x);
  14667. assert(__Pyx_PyLong_DigitCount(x) > 1);
  14668. switch (__Pyx_PyLong_DigitCount(x)) {
  14669. case 2:
  14670. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  14671. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  14672. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14673. } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
  14674. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  14675. }
  14676. }
  14677. break;
  14678. case 3:
  14679. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  14680. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  14681. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14682. } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
  14683. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  14684. }
  14685. }
  14686. break;
  14687. case 4:
  14688. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  14689. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  14690. __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])))
  14691. } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
  14692. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  14693. }
  14694. }
  14695. break;
  14696. }
  14697. }
  14698. #endif
  14699. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  14700. if (unlikely(Py_SIZE(x) < 0)) {
  14701. goto raise_neg_overflow;
  14702. }
  14703. #else
  14704. {
  14705. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  14706. if (unlikely(result < 0))
  14707. return (long) -1;
  14708. if (unlikely(result == 1))
  14709. goto raise_neg_overflow;
  14710. }
  14711. #endif
  14712. if ((sizeof(long) <= sizeof(unsigned long))) {
  14713. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  14714. } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
  14715. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  14716. }
  14717. } else {
  14718. #if CYTHON_USE_PYLONG_INTERNALS
  14719. if (__Pyx_PyLong_IsCompact(x)) {
  14720. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  14721. } else {
  14722. const digit* digits = __Pyx_PyLong_Digits(x);
  14723. assert(__Pyx_PyLong_DigitCount(x) > 1);
  14724. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  14725. case -2:
  14726. if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
  14727. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  14728. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14729. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  14730. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14731. }
  14732. }
  14733. break;
  14734. case 2:
  14735. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  14736. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  14737. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14738. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  14739. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14740. }
  14741. }
  14742. break;
  14743. case -3:
  14744. if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  14745. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  14746. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14747. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  14748. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14749. }
  14750. }
  14751. break;
  14752. case 3:
  14753. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  14754. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  14755. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  14756. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  14757. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14758. }
  14759. }
  14760. break;
  14761. case -4:
  14762. if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  14763. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  14764. __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])))
  14765. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  14766. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14767. }
  14768. }
  14769. break;
  14770. case 4:
  14771. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  14772. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  14773. __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])))
  14774. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  14775. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  14776. }
  14777. }
  14778. break;
  14779. }
  14780. }
  14781. #endif
  14782. if ((sizeof(long) <= sizeof(long))) {
  14783. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  14784. } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
  14785. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  14786. }
  14787. }
  14788. {
  14789. long val;
  14790. int ret = -1;
  14791. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  14792. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  14793. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  14794. if (unlikely(bytes_copied == -1)) {
  14795. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  14796. goto raise_overflow;
  14797. } else {
  14798. ret = 0;
  14799. }
  14800. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  14801. int one = 1; int is_little = (int)*(unsigned char *)&one;
  14802. unsigned char *bytes = (unsigned char *)&val;
  14803. ret = _PyLong_AsByteArray((PyLongObject *)x,
  14804. bytes, sizeof(val),
  14805. is_little, !is_unsigned);
  14806. #else
  14807. PyObject *v;
  14808. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  14809. int bits, remaining_bits, is_negative = 0;
  14810. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  14811. if (likely(PyLong_CheckExact(x))) {
  14812. v = __Pyx_NewRef(x);
  14813. } else {
  14814. v = PyNumber_Long(x);
  14815. if (unlikely(!v)) return (long) -1;
  14816. assert(PyLong_CheckExact(v));
  14817. }
  14818. {
  14819. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  14820. if (unlikely(result < 0)) {
  14821. Py_DECREF(v);
  14822. return (long) -1;
  14823. }
  14824. is_negative = result == 1;
  14825. }
  14826. if (is_unsigned && unlikely(is_negative)) {
  14827. Py_DECREF(v);
  14828. goto raise_neg_overflow;
  14829. } else if (is_negative) {
  14830. stepval = PyNumber_Invert(v);
  14831. Py_DECREF(v);
  14832. if (unlikely(!stepval))
  14833. return (long) -1;
  14834. } else {
  14835. stepval = v;
  14836. }
  14837. v = NULL;
  14838. val = (long) 0;
  14839. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  14840. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  14841. for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
  14842. PyObject *tmp, *digit;
  14843. long idigit;
  14844. digit = PyNumber_And(stepval, mask);
  14845. if (unlikely(!digit)) goto done;
  14846. idigit = PyLong_AsLong(digit);
  14847. Py_DECREF(digit);
  14848. if (unlikely(idigit < 0)) goto done;
  14849. val |= ((long) idigit) << bits;
  14850. tmp = PyNumber_Rshift(stepval, shift);
  14851. if (unlikely(!tmp)) goto done;
  14852. Py_DECREF(stepval); stepval = tmp;
  14853. }
  14854. Py_DECREF(shift); shift = NULL;
  14855. Py_DECREF(mask); mask = NULL;
  14856. {
  14857. long idigit = PyLong_AsLong(stepval);
  14858. if (unlikely(idigit < 0)) goto done;
  14859. remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
  14860. if (unlikely(idigit >= (1L << remaining_bits)))
  14861. goto raise_overflow;
  14862. val |= ((long) idigit) << bits;
  14863. }
  14864. if (!is_unsigned) {
  14865. if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
  14866. goto raise_overflow;
  14867. if (is_negative)
  14868. val = ~val;
  14869. }
  14870. ret = 0;
  14871. done:
  14872. Py_XDECREF(shift);
  14873. Py_XDECREF(mask);
  14874. Py_XDECREF(stepval);
  14875. #endif
  14876. if (unlikely(ret))
  14877. return (long) -1;
  14878. return val;
  14879. }
  14880. raise_overflow:
  14881. PyErr_SetString(PyExc_OverflowError,
  14882. "value too large to convert to long");
  14883. return (long) -1;
  14884. raise_neg_overflow:
  14885. PyErr_SetString(PyExc_OverflowError,
  14886. "can't convert negative value to long");
  14887. return (long) -1;
  14888. }
  14889. /* FastTypeChecks */
  14890. #if CYTHON_COMPILING_IN_CPYTHON
  14891. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  14892. while (a) {
  14893. a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
  14894. if (a == b)
  14895. return 1;
  14896. }
  14897. return b == &PyBaseObject_Type;
  14898. }
  14899. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  14900. PyObject *mro;
  14901. if (a == b) return 1;
  14902. mro = a->tp_mro;
  14903. if (likely(mro)) {
  14904. Py_ssize_t i, n;
  14905. n = PyTuple_GET_SIZE(mro);
  14906. for (i = 0; i < n; i++) {
  14907. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  14908. return 1;
  14909. }
  14910. return 0;
  14911. }
  14912. return __Pyx_InBases(a, b);
  14913. }
  14914. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
  14915. PyObject *mro;
  14916. if (cls == a || cls == b) return 1;
  14917. mro = cls->tp_mro;
  14918. if (likely(mro)) {
  14919. Py_ssize_t i, n;
  14920. n = PyTuple_GET_SIZE(mro);
  14921. for (i = 0; i < n; i++) {
  14922. PyObject *base = PyTuple_GET_ITEM(mro, i);
  14923. if (base == (PyObject *)a || base == (PyObject *)b)
  14924. return 1;
  14925. }
  14926. return 0;
  14927. }
  14928. return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
  14929. }
  14930. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  14931. if (exc_type1) {
  14932. return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2);
  14933. } else {
  14934. return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  14935. }
  14936. }
  14937. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  14938. Py_ssize_t i, n;
  14939. assert(PyExceptionClass_Check(exc_type));
  14940. n = PyTuple_GET_SIZE(tuple);
  14941. for (i=0; i<n; i++) {
  14942. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  14943. }
  14944. for (i=0; i<n; i++) {
  14945. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  14946. if (likely(PyExceptionClass_Check(t))) {
  14947. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  14948. } else {
  14949. }
  14950. }
  14951. return 0;
  14952. }
  14953. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  14954. if (likely(err == exc_type)) return 1;
  14955. if (likely(PyExceptionClass_Check(err))) {
  14956. if (likely(PyExceptionClass_Check(exc_type))) {
  14957. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  14958. } else if (likely(PyTuple_Check(exc_type))) {
  14959. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  14960. } else {
  14961. }
  14962. }
  14963. return PyErr_GivenExceptionMatches(err, exc_type);
  14964. }
  14965. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  14966. assert(PyExceptionClass_Check(exc_type1));
  14967. assert(PyExceptionClass_Check(exc_type2));
  14968. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  14969. if (likely(PyExceptionClass_Check(err))) {
  14970. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  14971. }
  14972. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  14973. }
  14974. #endif
  14975. /* GetRuntimeVersion */
  14976. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  14977. void __Pyx_init_runtime_version(void) {
  14978. if (__Pyx_cached_runtime_version == 0) {
  14979. const char* rt_version = Py_GetVersion();
  14980. unsigned long version = 0;
  14981. unsigned long factor = 0x01000000UL;
  14982. unsigned int digit = 0;
  14983. int i = 0;
  14984. while (factor) {
  14985. while ('0' <= rt_version[i] && rt_version[i] <= '9') {
  14986. digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
  14987. ++i;
  14988. }
  14989. version += factor * digit;
  14990. if (rt_version[i] != '.')
  14991. break;
  14992. digit = 0;
  14993. factor >>= 8;
  14994. ++i;
  14995. }
  14996. __Pyx_cached_runtime_version = version;
  14997. }
  14998. }
  14999. #endif
  15000. static unsigned long __Pyx_get_runtime_version(void) {
  15001. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  15002. return Py_Version & ~0xFFUL;
  15003. #else
  15004. return __Pyx_cached_runtime_version;
  15005. #endif
  15006. }
  15007. /* SwapException (used by CoroutineBase) */
  15008. #if CYTHON_FAST_THREAD_STATE
  15009. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  15010. PyObject *tmp_type, *tmp_value, *tmp_tb;
  15011. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  15012. _PyErr_StackItem *exc_info = tstate->exc_info;
  15013. tmp_value = exc_info->exc_value;
  15014. exc_info->exc_value = *value;
  15015. if (tmp_value == NULL || tmp_value == Py_None) {
  15016. Py_XDECREF(tmp_value);
  15017. tmp_value = NULL;
  15018. tmp_type = NULL;
  15019. tmp_tb = NULL;
  15020. } else {
  15021. tmp_type = (PyObject*) Py_TYPE(tmp_value);
  15022. Py_INCREF(tmp_type);
  15023. #if CYTHON_COMPILING_IN_CPYTHON
  15024. tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
  15025. Py_XINCREF(tmp_tb);
  15026. #else
  15027. tmp_tb = PyException_GetTraceback(tmp_value);
  15028. #endif
  15029. }
  15030. #elif CYTHON_USE_EXC_INFO_STACK
  15031. _PyErr_StackItem *exc_info = tstate->exc_info;
  15032. tmp_type = exc_info->exc_type;
  15033. tmp_value = exc_info->exc_value;
  15034. tmp_tb = exc_info->exc_traceback;
  15035. exc_info->exc_type = *type;
  15036. exc_info->exc_value = *value;
  15037. exc_info->exc_traceback = *tb;
  15038. #else
  15039. tmp_type = tstate->exc_type;
  15040. tmp_value = tstate->exc_value;
  15041. tmp_tb = tstate->exc_traceback;
  15042. tstate->exc_type = *type;
  15043. tstate->exc_value = *value;
  15044. tstate->exc_traceback = *tb;
  15045. #endif
  15046. *type = tmp_type;
  15047. *value = tmp_value;
  15048. *tb = tmp_tb;
  15049. }
  15050. #else
  15051. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  15052. PyObject *tmp_type, *tmp_value, *tmp_tb;
  15053. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  15054. PyErr_SetExcInfo(*type, *value, *tb);
  15055. *type = tmp_type;
  15056. *value = tmp_value;
  15057. *tb = tmp_tb;
  15058. }
  15059. #endif
  15060. /* IterNextPlain (used by CoroutineBase) */
  15061. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  15062. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void) {
  15063. if (unlikely(!__pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache))
  15064. __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache = __Pyx_GetBuiltinName(__pyx_mstate_global->__pyx_n_u_next);
  15065. return __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache;
  15066. }
  15067. #endif
  15068. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator) {
  15069. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  15070. PyObject *result;
  15071. PyObject *next = __Pyx_GetBuiltinNext_LimitedAPI();
  15072. if (unlikely(!next)) return NULL;
  15073. result = PyObject_CallFunctionObjArgs(next, iterator, NULL);
  15074. return result;
  15075. #else
  15076. (void)__Pyx_GetBuiltinName; // only for early limited API
  15077. iternextfunc iternext = __Pyx_PyObject_GetIterNextFunc(iterator);
  15078. assert(iternext);
  15079. return iternext(iterator);
  15080. #endif
  15081. }
  15082. /* PyObjectCall2Args (used by PyObjectCallMethod1) */
  15083. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
  15084. PyObject *args[3] = {NULL, arg1, arg2};
  15085. return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  15086. }
  15087. /* PyObjectCallMethod1 (used by CoroutineBase) */
  15088. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  15089. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  15090. PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
  15091. Py_DECREF(method);
  15092. return result;
  15093. }
  15094. #endif
  15095. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  15096. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  15097. PyObject *args[2] = {obj, arg};
  15098. (void) __Pyx_PyObject_CallOneArg;
  15099. (void) __Pyx_PyObject_Call2Args;
  15100. return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  15101. #else
  15102. PyObject *method = NULL, *result;
  15103. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  15104. if (likely(is_method)) {
  15105. result = __Pyx_PyObject_Call2Args(method, obj, arg);
  15106. Py_DECREF(method);
  15107. return result;
  15108. }
  15109. if (unlikely(!method)) return NULL;
  15110. return __Pyx__PyObject_CallMethod1(method, arg);
  15111. #endif
  15112. }
  15113. /* ReturnWithStopIteration (used by CoroutineBase) */
  15114. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async);
  15115. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext) {
  15116. if (value == Py_None) {
  15117. if (async || !iternext)
  15118. PyErr_SetNone(async ? PyExc_StopAsyncIteration : PyExc_StopIteration);
  15119. return;
  15120. }
  15121. __Pyx__ReturnWithStopIteration(value, async);
  15122. }
  15123. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async) {
  15124. #if CYTHON_COMPILING_IN_CPYTHON
  15125. __Pyx_PyThreadState_declare
  15126. #endif
  15127. PyObject *exc;
  15128. PyObject *exc_type = async ? PyExc_StopAsyncIteration : PyExc_StopIteration;
  15129. #if CYTHON_COMPILING_IN_CPYTHON
  15130. if ((PY_VERSION_HEX >= (0x030C00A6)) || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
  15131. if (PY_VERSION_HEX >= (0x030e00A1)) {
  15132. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  15133. } else {
  15134. PyObject *args_tuple = PyTuple_New(1);
  15135. if (unlikely(!args_tuple)) return;
  15136. Py_INCREF(value);
  15137. PyTuple_SET_ITEM(args_tuple, 0, value);
  15138. exc = PyObject_Call(exc_type, args_tuple, NULL);
  15139. Py_DECREF(args_tuple);
  15140. }
  15141. if (unlikely(!exc)) return;
  15142. } else {
  15143. Py_INCREF(value);
  15144. exc = value;
  15145. }
  15146. #if CYTHON_FAST_THREAD_STATE
  15147. __Pyx_PyThreadState_assign
  15148. #if CYTHON_USE_EXC_INFO_STACK
  15149. if (!__pyx_tstate->exc_info->exc_value)
  15150. #else
  15151. if (!__pyx_tstate->exc_type)
  15152. #endif
  15153. {
  15154. Py_INCREF(exc_type);
  15155. __Pyx_ErrRestore(exc_type, exc, NULL);
  15156. return;
  15157. }
  15158. #endif
  15159. #else
  15160. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  15161. if (unlikely(!exc)) return;
  15162. #endif
  15163. PyErr_SetObject(exc_type, exc);
  15164. Py_DECREF(exc);
  15165. }
  15166. /* CoroutineBase (used by Generator) */
  15167. #if !CYTHON_COMPILING_IN_LIMITED_API
  15168. #include <frameobject.h>
  15169. #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
  15170. #ifndef Py_BUILD_CORE
  15171. #define Py_BUILD_CORE 1
  15172. #endif
  15173. #include "internal/pycore_frame.h"
  15174. #endif
  15175. #endif // CYTHON_COMPILING_IN_LIMITED_API
  15176. static CYTHON_INLINE void
  15177. __Pyx_Coroutine_Undelegate(__pyx_CoroutineObject *gen) {
  15178. #if CYTHON_USE_AM_SEND
  15179. gen->yieldfrom_am_send = NULL;
  15180. #endif
  15181. Py_CLEAR(gen->yieldfrom);
  15182. }
  15183. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *__pyx_tstate, PyObject **pvalue) {
  15184. PyObject *et, *ev, *tb;
  15185. PyObject *value = NULL;
  15186. CYTHON_UNUSED_VAR(__pyx_tstate);
  15187. __Pyx_ErrFetch(&et, &ev, &tb);
  15188. if (!et) {
  15189. Py_XDECREF(tb);
  15190. Py_XDECREF(ev);
  15191. Py_INCREF(Py_None);
  15192. *pvalue = Py_None;
  15193. return 0;
  15194. }
  15195. if (likely(et == PyExc_StopIteration)) {
  15196. if (!ev) {
  15197. Py_INCREF(Py_None);
  15198. value = Py_None;
  15199. }
  15200. else if (likely(__Pyx_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) {
  15201. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  15202. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  15203. if (unlikely(!value)) goto limited_api_failure;
  15204. #else
  15205. value = ((PyStopIterationObject *)ev)->value;
  15206. Py_INCREF(value);
  15207. #endif
  15208. Py_DECREF(ev);
  15209. }
  15210. else if (unlikely(PyTuple_Check(ev))) {
  15211. Py_ssize_t tuple_size = __Pyx_PyTuple_GET_SIZE(ev);
  15212. #if !CYTHON_ASSUME_SAFE_SIZE
  15213. if (unlikely(tuple_size < 0)) {
  15214. Py_XDECREF(tb);
  15215. Py_DECREF(ev);
  15216. Py_DECREF(et);
  15217. return -1;
  15218. }
  15219. #endif
  15220. if (tuple_size >= 1) {
  15221. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  15222. value = PyTuple_GET_ITEM(ev, 0);
  15223. Py_INCREF(value);
  15224. #elif CYTHON_ASSUME_SAFE_MACROS
  15225. value = PySequence_ITEM(ev, 0);
  15226. #else
  15227. value = PySequence_GetItem(ev, 0);
  15228. if (!value) goto limited_api_failure;
  15229. #endif
  15230. } else {
  15231. Py_INCREF(Py_None);
  15232. value = Py_None;
  15233. }
  15234. Py_DECREF(ev);
  15235. }
  15236. else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
  15237. value = ev;
  15238. }
  15239. if (likely(value)) {
  15240. Py_XDECREF(tb);
  15241. Py_DECREF(et);
  15242. *pvalue = value;
  15243. return 0;
  15244. }
  15245. } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
  15246. __Pyx_ErrRestore(et, ev, tb);
  15247. return -1;
  15248. }
  15249. PyErr_NormalizeException(&et, &ev, &tb);
  15250. if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
  15251. __Pyx_ErrRestore(et, ev, tb);
  15252. return -1;
  15253. }
  15254. Py_XDECREF(tb);
  15255. Py_DECREF(et);
  15256. #if CYTHON_COMPILING_IN_LIMITED_API
  15257. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  15258. #else
  15259. value = ((PyStopIterationObject *)ev)->value;
  15260. Py_INCREF(value);
  15261. #endif
  15262. Py_DECREF(ev);
  15263. #if CYTHON_COMPILING_IN_LIMITED_API
  15264. if (unlikely(!value)) return -1;
  15265. #endif
  15266. *pvalue = value;
  15267. return 0;
  15268. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL || !CYTHON_ASSUME_SAFE_MACROS
  15269. limited_api_failure:
  15270. Py_XDECREF(et);
  15271. Py_XDECREF(tb);
  15272. Py_XDECREF(ev);
  15273. return -1;
  15274. #endif
  15275. }
  15276. static CYTHON_INLINE
  15277. __Pyx_PySendResult __Pyx_Coroutine_status_from_result(PyObject **retval) {
  15278. if (*retval) {
  15279. return PYGEN_NEXT;
  15280. } else if (likely(__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, retval) == 0)) {
  15281. return PYGEN_RETURN;
  15282. } else {
  15283. return PYGEN_ERROR;
  15284. }
  15285. }
  15286. static CYTHON_INLINE
  15287. void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
  15288. #if PY_VERSION_HEX >= 0x030B00a4
  15289. Py_CLEAR(exc_state->exc_value);
  15290. #else
  15291. PyObject *t, *v, *tb;
  15292. t = exc_state->exc_type;
  15293. v = exc_state->exc_value;
  15294. tb = exc_state->exc_traceback;
  15295. exc_state->exc_type = NULL;
  15296. exc_state->exc_value = NULL;
  15297. exc_state->exc_traceback = NULL;
  15298. Py_XDECREF(t);
  15299. Py_XDECREF(v);
  15300. Py_XDECREF(tb);
  15301. #endif
  15302. }
  15303. #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
  15304. static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) {
  15305. const char *msg;
  15306. CYTHON_MAYBE_UNUSED_VAR(gen);
  15307. if ((0)) {
  15308. #ifdef __Pyx_Coroutine_USED
  15309. } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
  15310. msg = "coroutine already executing";
  15311. #endif
  15312. #ifdef __Pyx_AsyncGen_USED
  15313. } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
  15314. msg = "async generator already executing";
  15315. #endif
  15316. } else {
  15317. msg = "generator already executing";
  15318. }
  15319. PyErr_SetString(PyExc_ValueError, msg);
  15320. }
  15321. static void __Pyx_Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) {
  15322. CYTHON_MAYBE_UNUSED_VAR(gen);
  15323. CYTHON_MAYBE_UNUSED_VAR(closing);
  15324. #ifdef __Pyx_Coroutine_USED
  15325. if (!closing && __Pyx_Coroutine_Check(gen)) {
  15326. PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
  15327. } else
  15328. #endif
  15329. if (value) {
  15330. #ifdef __Pyx_AsyncGen_USED
  15331. if (__Pyx_AsyncGen_CheckExact(gen))
  15332. PyErr_SetNone(PyExc_StopAsyncIteration);
  15333. else
  15334. #endif
  15335. PyErr_SetNone(PyExc_StopIteration);
  15336. }
  15337. }
  15338. static
  15339. __Pyx_PySendResult __Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, PyObject **result, int closing) {
  15340. __Pyx_PyThreadState_declare
  15341. PyThreadState *tstate;
  15342. __Pyx_ExcInfoStruct *exc_state;
  15343. PyObject *retval;
  15344. assert(__Pyx_Coroutine_get_is_running(self)); // Callers should ensure is_running
  15345. if (unlikely(self->resume_label == -1)) {
  15346. __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
  15347. return PYGEN_ERROR;
  15348. }
  15349. #if CYTHON_FAST_THREAD_STATE
  15350. __Pyx_PyThreadState_assign
  15351. tstate = __pyx_tstate;
  15352. #else
  15353. tstate = __Pyx_PyThreadState_Current;
  15354. #endif
  15355. exc_state = &self->gi_exc_state;
  15356. if (exc_state->exc_value) {
  15357. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  15358. #else
  15359. PyObject *exc_tb;
  15360. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  15361. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  15362. #elif PY_VERSION_HEX >= 0x030B00a4
  15363. exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback;
  15364. #else
  15365. exc_tb = exc_state->exc_traceback;
  15366. #endif
  15367. if (exc_tb) {
  15368. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  15369. PyFrameObject *f = tb->tb_frame;
  15370. assert(f->f_back == NULL);
  15371. #if PY_VERSION_HEX >= 0x030B00A1
  15372. f->f_back = PyThreadState_GetFrame(tstate);
  15373. #else
  15374. Py_XINCREF(tstate->frame);
  15375. f->f_back = tstate->frame;
  15376. #endif
  15377. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  15378. Py_DECREF(exc_tb);
  15379. #endif
  15380. }
  15381. #endif
  15382. }
  15383. #if CYTHON_USE_EXC_INFO_STACK
  15384. exc_state->previous_item = tstate->exc_info;
  15385. tstate->exc_info = exc_state;
  15386. #else
  15387. if (exc_state->exc_type) {
  15388. __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  15389. } else {
  15390. __Pyx_Coroutine_ExceptionClear(exc_state);
  15391. __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  15392. }
  15393. #endif
  15394. retval = self->body(self, tstate, value);
  15395. #if CYTHON_USE_EXC_INFO_STACK
  15396. exc_state = &self->gi_exc_state;
  15397. tstate->exc_info = exc_state->previous_item;
  15398. exc_state->previous_item = NULL;
  15399. __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
  15400. #endif
  15401. *result = retval;
  15402. if (self->resume_label == -1) {
  15403. return likely(retval) ? PYGEN_RETURN : PYGEN_ERROR;
  15404. }
  15405. return PYGEN_NEXT;
  15406. }
  15407. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
  15408. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
  15409. CYTHON_UNUSED_VAR(exc_state);
  15410. #else
  15411. PyObject *exc_tb;
  15412. #if PY_VERSION_HEX >= 0x030B00a4
  15413. if (!exc_state->exc_value) return;
  15414. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  15415. #else
  15416. exc_tb = exc_state->exc_traceback;
  15417. #endif
  15418. if (likely(exc_tb)) {
  15419. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  15420. PyFrameObject *f = tb->tb_frame;
  15421. Py_CLEAR(f->f_back);
  15422. #if PY_VERSION_HEX >= 0x030B00a4
  15423. Py_DECREF(exc_tb);
  15424. #endif
  15425. }
  15426. #endif
  15427. }
  15428. #define __Pyx_Coroutine_MethodReturnFromResult(gen, result, retval, iternext)\
  15429. ((result) == PYGEN_NEXT ? (retval) : __Pyx__Coroutine_MethodReturnFromResult(gen, result, retval, iternext))
  15430. static PyObject *
  15431. __Pyx__Coroutine_MethodReturnFromResult(PyObject* gen, __Pyx_PySendResult result, PyObject *retval, int iternext) {
  15432. CYTHON_MAYBE_UNUSED_VAR(gen);
  15433. if (likely(result == PYGEN_RETURN)) {
  15434. int is_async = 0;
  15435. #ifdef __Pyx_AsyncGen_USED
  15436. is_async = __Pyx_AsyncGen_CheckExact(gen);
  15437. #endif
  15438. __Pyx_ReturnWithStopIteration(retval, is_async, iternext);
  15439. Py_XDECREF(retval);
  15440. }
  15441. return NULL;
  15442. }
  15443. #if CYTHON_COMPILING_IN_CPYTHON
  15444. static CYTHON_INLINE
  15445. PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
  15446. #if PY_VERSION_HEX <= 0x030A00A1
  15447. return _PyGen_Send(gen, arg);
  15448. #else
  15449. PyObject *result;
  15450. if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
  15451. if (PyAsyncGen_CheckExact(gen)) {
  15452. assert(result == Py_None);
  15453. PyErr_SetNone(PyExc_StopAsyncIteration);
  15454. }
  15455. else if (result == Py_None) {
  15456. PyErr_SetNone(PyExc_StopIteration);
  15457. }
  15458. else {
  15459. #if PY_VERSION_HEX < 0x030d00A1
  15460. _PyGen_SetStopIterationValue(result);
  15461. #else
  15462. if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) {
  15463. PyErr_SetObject(PyExc_StopIteration, result);
  15464. } else {
  15465. PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result);
  15466. if (likely(exc != NULL)) {
  15467. PyErr_SetObject(PyExc_StopIteration, exc);
  15468. Py_DECREF(exc);
  15469. }
  15470. }
  15471. #endif
  15472. }
  15473. Py_DECREF(result);
  15474. result = NULL;
  15475. }
  15476. return result;
  15477. #endif
  15478. }
  15479. #endif
  15480. static CYTHON_INLINE __Pyx_PySendResult
  15481. __Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen, PyObject** retval) {
  15482. __Pyx_PySendResult result;
  15483. PyObject *val = NULL;
  15484. assert(__Pyx_Coroutine_get_is_running(gen));
  15485. __Pyx_Coroutine_Undelegate(gen);
  15486. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
  15487. result = __Pyx_Coroutine_SendEx(gen, val, retval, 0);
  15488. Py_XDECREF(val);
  15489. return result;
  15490. }
  15491. #if CYTHON_USE_AM_SEND
  15492. static __Pyx_PySendResult
  15493. __Pyx_Coroutine_SendToDelegate(__pyx_CoroutineObject *gen, __Pyx_pyiter_sendfunc gen_am_send, PyObject *value, PyObject **retval) {
  15494. PyObject *ret = NULL;
  15495. __Pyx_PySendResult delegate_result, result;
  15496. assert(__Pyx_Coroutine_get_is_running(gen));
  15497. delegate_result = gen_am_send(gen->yieldfrom, value, &ret);
  15498. if (delegate_result == PYGEN_NEXT) {
  15499. assert (ret != NULL);
  15500. *retval = ret;
  15501. return PYGEN_NEXT;
  15502. }
  15503. assert (delegate_result != PYGEN_ERROR || ret == NULL);
  15504. __Pyx_Coroutine_Undelegate(gen);
  15505. result = __Pyx_Coroutine_SendEx(gen, ret, retval, 0);
  15506. Py_XDECREF(ret);
  15507. return result;
  15508. }
  15509. #endif
  15510. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
  15511. PyObject *retval = NULL;
  15512. __Pyx_PySendResult result = __Pyx_Coroutine_AmSend(self, value, &retval);
  15513. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  15514. }
  15515. static __Pyx_PySendResult
  15516. __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
  15517. __Pyx_PySendResult result;
  15518. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15519. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  15520. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  15521. return PYGEN_ERROR;
  15522. }
  15523. #if CYTHON_USE_AM_SEND
  15524. if (gen->yieldfrom_am_send) {
  15525. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, value, retval);
  15526. } else
  15527. #endif
  15528. if (gen->yieldfrom) {
  15529. PyObject *yf = gen->yieldfrom;
  15530. PyObject *ret;
  15531. #if !CYTHON_USE_AM_SEND
  15532. #ifdef __Pyx_Generator_USED
  15533. if (__Pyx_Generator_CheckExact(yf)) {
  15534. ret = __Pyx_Coroutine_Send(yf, value);
  15535. } else
  15536. #endif
  15537. #ifdef __Pyx_Coroutine_USED
  15538. if (__Pyx_Coroutine_Check(yf)) {
  15539. ret = __Pyx_Coroutine_Send(yf, value);
  15540. } else
  15541. #endif
  15542. #ifdef __Pyx_AsyncGen_USED
  15543. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15544. ret = __Pyx_async_gen_asend_send(yf, value);
  15545. } else
  15546. #endif
  15547. #if CYTHON_COMPILING_IN_CPYTHON
  15548. if (PyGen_CheckExact(yf)) {
  15549. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15550. } else
  15551. if (PyCoro_CheckExact(yf)) {
  15552. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  15553. } else
  15554. #endif
  15555. #endif
  15556. {
  15557. #if !CYTHON_COMPILING_IN_LIMITED_API || __PYX_LIMITED_VERSION_HEX >= 0x03080000
  15558. if (value == Py_None && PyIter_Check(yf))
  15559. ret = __Pyx_PyIter_Next_Plain(yf);
  15560. else
  15561. #endif
  15562. ret = __Pyx_PyObject_CallMethod1(yf, __pyx_mstate_global->__pyx_n_u_send, value);
  15563. }
  15564. if (likely(ret)) {
  15565. __Pyx_Coroutine_unset_is_running(gen);
  15566. *retval = ret;
  15567. return PYGEN_NEXT;
  15568. }
  15569. result = __Pyx_Coroutine_FinishDelegation(gen, retval);
  15570. } else {
  15571. result = __Pyx_Coroutine_SendEx(gen, value, retval, 0);
  15572. }
  15573. __Pyx_Coroutine_unset_is_running(gen);
  15574. return result;
  15575. }
  15576. static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
  15577. __Pyx_PySendResult result;
  15578. PyObject *retval = NULL;
  15579. CYTHON_UNUSED_VAR(gen);
  15580. assert(__Pyx_Coroutine_get_is_running(gen));
  15581. #ifdef __Pyx_Generator_USED
  15582. if (__Pyx_Generator_CheckExact(yf)) {
  15583. result = __Pyx_Coroutine_Close(yf, &retval);
  15584. } else
  15585. #endif
  15586. #ifdef __Pyx_Coroutine_USED
  15587. if (__Pyx_Coroutine_Check(yf)) {
  15588. result = __Pyx_Coroutine_Close(yf, &retval);
  15589. } else
  15590. if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  15591. result = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
  15592. } else
  15593. #endif
  15594. #ifdef __Pyx_AsyncGen_USED
  15595. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  15596. retval = __Pyx_async_gen_asend_close(yf, NULL);
  15597. result = PYGEN_RETURN;
  15598. } else
  15599. if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
  15600. retval = __Pyx_async_gen_athrow_close(yf, NULL);
  15601. result = PYGEN_RETURN;
  15602. } else
  15603. #endif
  15604. {
  15605. PyObject *meth;
  15606. result = PYGEN_RETURN;
  15607. meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_close);
  15608. if (unlikely(!meth)) {
  15609. if (unlikely(PyErr_Occurred())) {
  15610. PyErr_WriteUnraisable(yf);
  15611. }
  15612. } else {
  15613. retval = __Pyx_PyObject_CallNoArg(meth);
  15614. Py_DECREF(meth);
  15615. if (unlikely(!retval)) {
  15616. result = PYGEN_ERROR;
  15617. }
  15618. }
  15619. }
  15620. Py_XDECREF(retval);
  15621. return result == PYGEN_ERROR ? -1 : 0;
  15622. }
  15623. static PyObject *__Pyx_Generator_Next(PyObject *self) {
  15624. __Pyx_PySendResult result;
  15625. PyObject *retval = NULL;
  15626. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  15627. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  15628. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15629. }
  15630. #if CYTHON_USE_AM_SEND
  15631. if (gen->yieldfrom_am_send) {
  15632. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, Py_None, &retval);
  15633. } else
  15634. #endif
  15635. if (gen->yieldfrom) {
  15636. PyObject *yf = gen->yieldfrom;
  15637. PyObject *ret;
  15638. #ifdef __Pyx_Generator_USED
  15639. if (__Pyx_Generator_CheckExact(yf)) {
  15640. ret = __Pyx_Generator_Next(yf);
  15641. } else
  15642. #endif
  15643. #ifdef __Pyx_Coroutine_USED
  15644. if (__Pyx_Coroutine_CheckExact(yf)) {
  15645. ret = __Pyx_Coroutine_Send(yf, Py_None);
  15646. } else
  15647. #endif
  15648. #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX < 0x030A00A3 || !CYTHON_USE_AM_SEND)
  15649. if (PyGen_CheckExact(yf)) {
  15650. ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
  15651. } else
  15652. #endif
  15653. ret = __Pyx_PyIter_Next_Plain(yf);
  15654. if (likely(ret)) {
  15655. __Pyx_Coroutine_unset_is_running(gen);
  15656. return ret;
  15657. }
  15658. result = __Pyx_Coroutine_FinishDelegation(gen, &retval);
  15659. } else {
  15660. result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  15661. }
  15662. __Pyx_Coroutine_unset_is_running(gen);
  15663. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 1);
  15664. }
  15665. static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) {
  15666. PyObject *retval = NULL;
  15667. __Pyx_PySendResult result;
  15668. CYTHON_UNUSED_VAR(arg);
  15669. result = __Pyx_Coroutine_Close(self, &retval);
  15670. if (unlikely(result == PYGEN_ERROR))
  15671. return NULL;
  15672. Py_XDECREF(retval);
  15673. Py_RETURN_NONE;
  15674. }
  15675. static __Pyx_PySendResult
  15676. __Pyx_Coroutine_Close(PyObject *self, PyObject **retval) {
  15677. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15678. __Pyx_PySendResult result;
  15679. PyObject *yf;
  15680. int err = 0;
  15681. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  15682. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  15683. return PYGEN_ERROR;
  15684. }
  15685. yf = gen->yieldfrom;
  15686. if (yf) {
  15687. Py_INCREF(yf);
  15688. err = __Pyx_Coroutine_CloseIter(gen, yf);
  15689. __Pyx_Coroutine_Undelegate(gen);
  15690. Py_DECREF(yf);
  15691. }
  15692. if (err == 0)
  15693. PyErr_SetNone(PyExc_GeneratorExit);
  15694. result = __Pyx_Coroutine_SendEx(gen, NULL, retval, 1);
  15695. if (result == PYGEN_ERROR) {
  15696. __Pyx_PyThreadState_declare
  15697. __Pyx_PyThreadState_assign
  15698. __Pyx_Coroutine_unset_is_running(gen);
  15699. if (!__Pyx_PyErr_Occurred()) {
  15700. return PYGEN_RETURN;
  15701. } else if (likely(__Pyx_PyErr_ExceptionMatches2(PyExc_GeneratorExit, PyExc_StopIteration))) {
  15702. __Pyx_PyErr_Clear();
  15703. return PYGEN_RETURN;
  15704. }
  15705. return PYGEN_ERROR;
  15706. } else if (likely(result == PYGEN_RETURN && *retval == Py_None)) {
  15707. __Pyx_Coroutine_unset_is_running(gen);
  15708. return PYGEN_RETURN;
  15709. } else {
  15710. const char *msg;
  15711. Py_DECREF(*retval);
  15712. *retval = NULL;
  15713. if ((0)) {
  15714. #ifdef __Pyx_Coroutine_USED
  15715. } else if (__Pyx_Coroutine_Check(self)) {
  15716. msg = "coroutine ignored GeneratorExit";
  15717. #endif
  15718. #ifdef __Pyx_AsyncGen_USED
  15719. } else if (__Pyx_AsyncGen_CheckExact(self)) {
  15720. msg = "async generator ignored GeneratorExit";
  15721. #endif
  15722. } else {
  15723. msg = "generator ignored GeneratorExit";
  15724. }
  15725. PyErr_SetString(PyExc_RuntimeError, msg);
  15726. __Pyx_Coroutine_unset_is_running(gen);
  15727. return PYGEN_ERROR;
  15728. }
  15729. }
  15730. static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
  15731. PyObject *args, int close_on_genexit) {
  15732. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15733. PyObject *yf;
  15734. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen)))
  15735. return __Pyx_Coroutine_AlreadyRunningError(gen);
  15736. yf = gen->yieldfrom;
  15737. if (yf) {
  15738. __Pyx_PySendResult result;
  15739. PyObject *ret;
  15740. Py_INCREF(yf);
  15741. if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
  15742. int err = __Pyx_Coroutine_CloseIter(gen, yf);
  15743. Py_DECREF(yf);
  15744. __Pyx_Coroutine_Undelegate(gen);
  15745. if (err < 0)
  15746. goto propagate_exception;
  15747. goto throw_here;
  15748. }
  15749. if (0
  15750. #ifdef __Pyx_Generator_USED
  15751. || __Pyx_Generator_CheckExact(yf)
  15752. #endif
  15753. #ifdef __Pyx_Coroutine_USED
  15754. || __Pyx_Coroutine_Check(yf)
  15755. #endif
  15756. ) {
  15757. ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
  15758. #ifdef __Pyx_Coroutine_USED
  15759. } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  15760. ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
  15761. #endif
  15762. } else {
  15763. PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_throw);
  15764. if (unlikely(!meth)) {
  15765. Py_DECREF(yf);
  15766. if (unlikely(PyErr_Occurred())) {
  15767. __Pyx_Coroutine_unset_is_running(gen);
  15768. return NULL;
  15769. }
  15770. __Pyx_Coroutine_Undelegate(gen);
  15771. goto throw_here;
  15772. }
  15773. if (likely(args)) {
  15774. ret = __Pyx_PyObject_Call(meth, args, NULL);
  15775. } else {
  15776. PyObject *cargs[4] = {NULL, typ, val, tb};
  15777. ret = __Pyx_PyObject_FastCall(meth, cargs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  15778. }
  15779. Py_DECREF(meth);
  15780. }
  15781. Py_DECREF(yf);
  15782. if (ret) {
  15783. __Pyx_Coroutine_unset_is_running(gen);
  15784. return ret;
  15785. }
  15786. result = __Pyx_Coroutine_FinishDelegation(gen, &ret);
  15787. __Pyx_Coroutine_unset_is_running(gen);
  15788. return __Pyx_Coroutine_MethodReturnFromResult(self, result, ret, 0);
  15789. }
  15790. throw_here:
  15791. __Pyx_Raise(typ, val, tb, NULL);
  15792. propagate_exception:
  15793. {
  15794. PyObject *retval = NULL;
  15795. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, NULL, &retval, 0);
  15796. __Pyx_Coroutine_unset_is_running(gen);
  15797. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  15798. }
  15799. }
  15800. static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
  15801. PyObject *typ;
  15802. PyObject *val = NULL;
  15803. PyObject *tb = NULL;
  15804. if (unlikely(!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)))
  15805. return NULL;
  15806. return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
  15807. }
  15808. static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
  15809. #if PY_VERSION_HEX >= 0x030B00a4
  15810. Py_VISIT(exc_state->exc_value);
  15811. #else
  15812. Py_VISIT(exc_state->exc_type);
  15813. Py_VISIT(exc_state->exc_value);
  15814. Py_VISIT(exc_state->exc_traceback);
  15815. #endif
  15816. return 0;
  15817. }
  15818. static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
  15819. {
  15820. int e = __Pyx_call_type_traverse((PyObject*)gen, 1, visit, arg);
  15821. if (e) return e;
  15822. }
  15823. Py_VISIT(gen->closure);
  15824. Py_VISIT(gen->classobj);
  15825. Py_VISIT(gen->yieldfrom);
  15826. return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
  15827. }
  15828. static int __Pyx_Coroutine_clear(PyObject *self) {
  15829. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15830. Py_CLEAR(gen->closure);
  15831. Py_CLEAR(gen->classobj);
  15832. __Pyx_Coroutine_Undelegate(gen);
  15833. __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
  15834. #ifdef __Pyx_AsyncGen_USED
  15835. if (__Pyx_AsyncGen_CheckExact(self)) {
  15836. Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
  15837. }
  15838. #endif
  15839. Py_CLEAR(gen->gi_code);
  15840. Py_CLEAR(gen->gi_frame);
  15841. Py_CLEAR(gen->gi_name);
  15842. Py_CLEAR(gen->gi_qualname);
  15843. Py_CLEAR(gen->gi_modulename);
  15844. return 0;
  15845. }
  15846. static void __Pyx_Coroutine_dealloc(PyObject *self) {
  15847. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15848. PyObject_GC_UnTrack(gen);
  15849. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  15850. if (gen->gi_weakreflist != NULL)
  15851. #endif
  15852. PyObject_ClearWeakRefs(self);
  15853. if (gen->resume_label >= 0) {
  15854. PyObject_GC_Track(self);
  15855. #if CYTHON_USE_TP_FINALIZE
  15856. if (unlikely(PyObject_CallFinalizerFromDealloc(self)))
  15857. #else
  15858. {
  15859. destructor del = __Pyx_PyObject_GetSlot(gen, tp_del, destructor);
  15860. if (del) del(self);
  15861. }
  15862. if (unlikely(Py_REFCNT(self) > 0))
  15863. #endif
  15864. {
  15865. return;
  15866. }
  15867. PyObject_GC_UnTrack(self);
  15868. }
  15869. #ifdef __Pyx_AsyncGen_USED
  15870. if (__Pyx_AsyncGen_CheckExact(self)) {
  15871. /* We have to handle this case for asynchronous generators
  15872. right here, because this code has to be between UNTRACK
  15873. and GC_Del. */
  15874. Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
  15875. }
  15876. #endif
  15877. __Pyx_Coroutine_clear(self);
  15878. __Pyx_PyHeapTypeObject_GC_Del(gen);
  15879. }
  15880. #if CYTHON_USE_TP_FINALIZE
  15881. static void __Pyx_Coroutine_del(PyObject *self) {
  15882. PyObject *error_type, *error_value, *error_traceback;
  15883. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  15884. __Pyx_PyThreadState_declare
  15885. if (gen->resume_label < 0) {
  15886. return;
  15887. }
  15888. __Pyx_PyThreadState_assign
  15889. __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
  15890. #ifdef __Pyx_AsyncGen_USED
  15891. if (__Pyx_AsyncGen_CheckExact(self)) {
  15892. __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
  15893. PyObject *finalizer = agen->ag_finalizer;
  15894. if (finalizer && !agen->ag_closed) {
  15895. PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
  15896. if (unlikely(!res)) {
  15897. PyErr_WriteUnraisable(self);
  15898. } else {
  15899. Py_DECREF(res);
  15900. }
  15901. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  15902. return;
  15903. }
  15904. }
  15905. #endif
  15906. if (unlikely(gen->resume_label == 0 && !error_value)) {
  15907. #ifdef __Pyx_Coroutine_USED
  15908. #ifdef __Pyx_Generator_USED
  15909. if (!__Pyx_Generator_CheckExact(self))
  15910. #endif
  15911. {
  15912. PyObject_GC_UnTrack(self);
  15913. if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
  15914. PyErr_WriteUnraisable(self);
  15915. PyObject_GC_Track(self);
  15916. }
  15917. #endif
  15918. } else {
  15919. PyObject *retval = NULL;
  15920. __Pyx_PySendResult result = __Pyx_Coroutine_Close(self, &retval);
  15921. if (result == PYGEN_ERROR) {
  15922. PyErr_WriteUnraisable(self);
  15923. } else {
  15924. Py_XDECREF(retval);
  15925. }
  15926. }
  15927. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  15928. }
  15929. #endif
  15930. static PyObject *
  15931. __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context)
  15932. {
  15933. PyObject *name = self->gi_name;
  15934. CYTHON_UNUSED_VAR(context);
  15935. if (unlikely(!name)) name = Py_None;
  15936. Py_INCREF(name);
  15937. return name;
  15938. }
  15939. static int
  15940. __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context)
  15941. {
  15942. CYTHON_UNUSED_VAR(context);
  15943. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  15944. PyErr_SetString(PyExc_TypeError,
  15945. "__name__ must be set to a string object");
  15946. return -1;
  15947. }
  15948. Py_INCREF(value);
  15949. __Pyx_Py_XDECREF_SET(self->gi_name, value);
  15950. return 0;
  15951. }
  15952. static PyObject *
  15953. __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context)
  15954. {
  15955. PyObject *name = self->gi_qualname;
  15956. CYTHON_UNUSED_VAR(context);
  15957. if (unlikely(!name)) name = Py_None;
  15958. Py_INCREF(name);
  15959. return name;
  15960. }
  15961. static int
  15962. __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context)
  15963. {
  15964. CYTHON_UNUSED_VAR(context);
  15965. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  15966. PyErr_SetString(PyExc_TypeError,
  15967. "__qualname__ must be set to a string object");
  15968. return -1;
  15969. }
  15970. Py_INCREF(value);
  15971. __Pyx_Py_XDECREF_SET(self->gi_qualname, value);
  15972. return 0;
  15973. }
  15974. static PyObject *
  15975. __Pyx__Coroutine_get_frame(__pyx_CoroutineObject *self)
  15976. {
  15977. #if !CYTHON_COMPILING_IN_LIMITED_API
  15978. PyObject *frame;
  15979. #if PY_VERSION_HEX >= 0x030d0000
  15980. Py_BEGIN_CRITICAL_SECTION(self);
  15981. #endif
  15982. frame = self->gi_frame;
  15983. if (!frame) {
  15984. if (unlikely(!self->gi_code)) {
  15985. Py_RETURN_NONE;
  15986. }
  15987. PyObject *globals = PyDict_New();
  15988. if (unlikely(!globals)) return NULL;
  15989. frame = (PyObject *) PyFrame_New(
  15990. PyThreadState_Get(), /*PyThreadState *tstate,*/
  15991. (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/
  15992. globals, /*PyObject *globals,*/
  15993. 0 /*PyObject *locals*/
  15994. );
  15995. Py_DECREF(globals);
  15996. if (unlikely(!frame))
  15997. return NULL;
  15998. if (unlikely(self->gi_frame)) {
  15999. Py_DECREF(frame);
  16000. frame = self->gi_frame;
  16001. } else {
  16002. self->gi_frame = frame;
  16003. }
  16004. }
  16005. Py_INCREF(frame);
  16006. #if PY_VERSION_HEX >= 0x030d0000
  16007. Py_END_CRITICAL_SECTION();
  16008. #endif
  16009. return frame;
  16010. #else
  16011. CYTHON_UNUSED_VAR(self);
  16012. Py_RETURN_NONE;
  16013. #endif
  16014. }
  16015. static PyObject *
  16016. __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) {
  16017. CYTHON_UNUSED_VAR(context);
  16018. PyObject *frame = self->gi_frame;
  16019. if (frame)
  16020. return __Pyx_NewRef(frame);
  16021. return __Pyx__Coroutine_get_frame(self);
  16022. }
  16023. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  16024. PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16025. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16026. __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
  16027. if (unlikely(!gen))
  16028. return NULL;
  16029. return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
  16030. }
  16031. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  16032. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  16033. PyObject *name, PyObject *qualname, PyObject *module_name) {
  16034. gen->body = body;
  16035. gen->closure = closure;
  16036. Py_XINCREF(closure);
  16037. gen->is_running = 0;
  16038. gen->resume_label = 0;
  16039. gen->classobj = NULL;
  16040. gen->yieldfrom = NULL;
  16041. gen->yieldfrom_am_send = NULL;
  16042. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_LIMITED_API
  16043. gen->gi_exc_state.exc_value = NULL;
  16044. #else
  16045. gen->gi_exc_state.exc_type = NULL;
  16046. gen->gi_exc_state.exc_value = NULL;
  16047. gen->gi_exc_state.exc_traceback = NULL;
  16048. #endif
  16049. #if CYTHON_USE_EXC_INFO_STACK
  16050. gen->gi_exc_state.previous_item = NULL;
  16051. #endif
  16052. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  16053. gen->gi_weakreflist = NULL;
  16054. #endif
  16055. Py_XINCREF(qualname);
  16056. gen->gi_qualname = qualname;
  16057. Py_XINCREF(name);
  16058. gen->gi_name = name;
  16059. Py_XINCREF(module_name);
  16060. gen->gi_modulename = module_name;
  16061. Py_XINCREF(code);
  16062. gen->gi_code = code;
  16063. gen->gi_frame = NULL;
  16064. PyObject_GC_Track(gen);
  16065. return gen;
  16066. }
  16067. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen) {
  16068. char result;
  16069. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  16070. Py_BEGIN_CRITICAL_SECTION(gen);
  16071. #endif
  16072. result = gen->is_running;
  16073. gen->is_running = 1;
  16074. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  16075. Py_END_CRITICAL_SECTION();
  16076. #endif
  16077. return result;
  16078. }
  16079. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen) {
  16080. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  16081. Py_BEGIN_CRITICAL_SECTION(gen);
  16082. #endif
  16083. assert(gen->is_running);
  16084. gen->is_running = 0;
  16085. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  16086. Py_END_CRITICAL_SECTION();
  16087. #endif
  16088. }
  16089. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen) {
  16090. char result;
  16091. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  16092. Py_BEGIN_CRITICAL_SECTION(gen);
  16093. #endif
  16094. result = gen->is_running;
  16095. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  16096. Py_END_CRITICAL_SECTION();
  16097. #endif
  16098. return result;
  16099. }
  16100. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure) {
  16101. CYTHON_UNUSED_VAR(closure);
  16102. char result = __Pyx_Coroutine_get_is_running((__pyx_CoroutineObject*)gen);
  16103. if (result) Py_RETURN_TRUE;
  16104. else Py_RETURN_FALSE;
  16105. }
  16106. #if __PYX_HAS_PY_AM_SEND == 2
  16107. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send) {
  16108. Py_ssize_t ptr_offset = (char*)(type->tp_as_async) - (char*)type;
  16109. if (ptr_offset < 0 || ptr_offset > type->tp_basicsize) {
  16110. return;
  16111. }
  16112. memcpy((void*)static_amsend_methods, (void*)(type->tp_as_async), sizeof(*type->tp_as_async));
  16113. static_amsend_methods->am_send = am_send;
  16114. type->tp_as_async = __Pyx_SlotTpAsAsync(static_amsend_methods);
  16115. }
  16116. #endif
  16117. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg) {
  16118. CYTHON_UNUSED_VAR(arg);
  16119. __Pyx_TypeName self_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE((PyObject*)self));
  16120. PyErr_Format(PyExc_TypeError, "cannot pickle '" __Pyx_FMT_TYPENAME "' object",
  16121. self_type_name);
  16122. __Pyx_DECREF_TypeName(self_type_name);
  16123. return NULL;
  16124. }
  16125. /* Generator */
  16126. static PyMethodDef __pyx_Generator_methods[] = {
  16127. {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
  16128. PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
  16129. {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
  16130. PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
  16131. {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
  16132. PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
  16133. {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
  16134. {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
  16135. {0, 0, 0, 0}
  16136. };
  16137. static PyMemberDef __pyx_Generator_memberlist[] = {
  16138. {"gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
  16139. PyDoc_STR("object being iterated by 'yield from', or None")},
  16140. {"gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
  16141. {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
  16142. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  16143. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
  16144. #endif
  16145. {0, 0, 0, 0, 0}
  16146. };
  16147. static PyGetSetDef __pyx_Generator_getsets[] = {
  16148. {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
  16149. PyDoc_STR("name of the generator"), 0},
  16150. {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
  16151. PyDoc_STR("qualified name of the generator"), 0},
  16152. {"gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
  16153. PyDoc_STR("Frame of the generator"), 0},
  16154. {"gi_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
  16155. {0, 0, 0, 0, 0}
  16156. };
  16157. static PyType_Slot __pyx_GeneratorType_slots[] = {
  16158. {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
  16159. {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
  16160. {Py_tp_iter, (void *)PyObject_SelfIter},
  16161. {Py_tp_iternext, (void *)__Pyx_Generator_Next},
  16162. {Py_tp_methods, (void *)__pyx_Generator_methods},
  16163. {Py_tp_members, (void *)__pyx_Generator_memberlist},
  16164. {Py_tp_getset, (void *)__pyx_Generator_getsets},
  16165. {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
  16166. #if CYTHON_USE_TP_FINALIZE
  16167. {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
  16168. #endif
  16169. #if __PYX_HAS_PY_AM_SEND == 1
  16170. {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
  16171. #endif
  16172. {0, 0},
  16173. };
  16174. static PyType_Spec __pyx_GeneratorType_spec = {
  16175. __PYX_TYPE_MODULE_PREFIX "generator",
  16176. sizeof(__pyx_CoroutineObject),
  16177. 0,
  16178. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  16179. Py_TPFLAGS_MANAGED_WEAKREF |
  16180. #endif
  16181. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  16182. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND,
  16183. __pyx_GeneratorType_slots
  16184. };
  16185. #if __PYX_HAS_PY_AM_SEND == 2
  16186. static __Pyx_PyAsyncMethodsStruct __pyx_Generator_as_async;
  16187. #endif
  16188. static int __pyx_Generator_init(PyObject *module) {
  16189. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  16190. mstate->__pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(
  16191. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_GeneratorType_spec, NULL);
  16192. if (unlikely(!mstate->__pyx_GeneratorType)) {
  16193. return -1;
  16194. }
  16195. #if __PYX_HAS_PY_AM_SEND == 2
  16196. __Pyx_SetBackportTypeAmSend(mstate->__pyx_GeneratorType, &__pyx_Generator_as_async, &__Pyx_Coroutine_AmSend);
  16197. #endif
  16198. return 0;
  16199. }
  16200. static PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self) {
  16201. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  16202. PyObject *retval = NULL;
  16203. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  16204. return __Pyx_Coroutine_AlreadyRunningError(gen);
  16205. }
  16206. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  16207. __Pyx_Coroutine_unset_is_running(gen);
  16208. (void) result;
  16209. assert (result == PYGEN_RETURN || result == PYGEN_ERROR);
  16210. assert ((result == PYGEN_RETURN && retval != NULL) || (result == PYGEN_ERROR && retval == NULL));
  16211. return retval;
  16212. }
  16213. /* CheckBinaryVersion */
  16214. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
  16215. const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
  16216. if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
  16217. return 0;
  16218. if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
  16219. return 1;
  16220. {
  16221. char message[200];
  16222. PyOS_snprintf(message, sizeof(message),
  16223. "compile time Python version %d.%d "
  16224. "of module '%.100s' "
  16225. "%s "
  16226. "runtime version %d.%d",
  16227. (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
  16228. __Pyx_MODULE_NAME,
  16229. (allow_newer) ? "was newer than" : "does not match",
  16230. (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
  16231. );
  16232. return PyErr_WarnEx(NULL, message, 1);
  16233. }
  16234. }
  16235. /* NewCodeObj */
  16236. #if CYTHON_COMPILING_IN_LIMITED_API
  16237. static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  16238. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  16239. PyObject *fv, PyObject *cell, PyObject* fn,
  16240. PyObject *name, int fline, PyObject *lnos) {
  16241. PyObject *exception_table = NULL;
  16242. PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
  16243. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  16244. PyObject *version_info;
  16245. PyObject *py_minor_version = NULL;
  16246. #endif
  16247. long minor_version = 0;
  16248. PyObject *type, *value, *traceback;
  16249. PyErr_Fetch(&type, &value, &traceback);
  16250. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  16251. minor_version = 11;
  16252. #else
  16253. if (!(version_info = PySys_GetObject("version_info"))) goto end;
  16254. if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
  16255. minor_version = PyLong_AsLong(py_minor_version);
  16256. Py_DECREF(py_minor_version);
  16257. if (minor_version == -1 && PyErr_Occurred()) goto end;
  16258. #endif
  16259. if (!(types_module = PyImport_ImportModule("types"))) goto end;
  16260. if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
  16261. if (minor_version <= 7) {
  16262. (void)p;
  16263. result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code,
  16264. c, n, v, fn, name, fline, lnos, fv, cell);
  16265. } else if (minor_version <= 10) {
  16266. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code,
  16267. c, n, v, fn, name, fline, lnos, fv, cell);
  16268. } else {
  16269. if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
  16270. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code,
  16271. c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
  16272. }
  16273. end:
  16274. Py_XDECREF(code_type);
  16275. Py_XDECREF(exception_table);
  16276. Py_XDECREF(types_module);
  16277. if (type) {
  16278. PyErr_Restore(type, value, traceback);
  16279. }
  16280. return result;
  16281. }
  16282. #elif PY_VERSION_HEX >= 0x030B0000
  16283. static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  16284. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  16285. PyObject *fv, PyObject *cell, PyObject* fn,
  16286. PyObject *name, int fline, PyObject *lnos) {
  16287. PyCodeObject *result;
  16288. result =
  16289. #if PY_VERSION_HEX >= 0x030C0000
  16290. PyUnstable_Code_NewWithPosOnlyArgs
  16291. #else
  16292. PyCode_NewWithPosOnlyArgs
  16293. #endif
  16294. (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes);
  16295. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1
  16296. if (likely(result))
  16297. result->_co_firsttraceable = 0;
  16298. #endif
  16299. return result;
  16300. }
  16301. #elif !CYTHON_COMPILING_IN_PYPY
  16302. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  16303. PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  16304. #else
  16305. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  16306. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  16307. #endif
  16308. static PyObject* __Pyx_PyCode_New(
  16309. const __Pyx_PyCode_New_function_description descr,
  16310. PyObject * const *varnames,
  16311. PyObject *filename,
  16312. PyObject *funcname,
  16313. PyObject *line_table,
  16314. PyObject *tuple_dedup_map
  16315. ) {
  16316. PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL;
  16317. Py_ssize_t var_count = (Py_ssize_t) descr.nlocals;
  16318. PyObject *varnames_tuple = PyTuple_New(var_count);
  16319. if (unlikely(!varnames_tuple)) return NULL;
  16320. for (Py_ssize_t i=0; i < var_count; i++) {
  16321. Py_INCREF(varnames[i]);
  16322. if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done;
  16323. }
  16324. #if CYTHON_COMPILING_IN_LIMITED_API
  16325. varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple);
  16326. if (!varnames_tuple_dedup) {
  16327. if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done;
  16328. varnames_tuple_dedup = varnames_tuple;
  16329. }
  16330. #else
  16331. varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple);
  16332. if (unlikely(!varnames_tuple_dedup)) goto done;
  16333. #endif
  16334. #if CYTHON_AVOID_BORROWED_REFS
  16335. Py_INCREF(varnames_tuple_dedup);
  16336. #endif
  16337. if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) {
  16338. Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table);
  16339. #if !CYTHON_ASSUME_SAFE_SIZE
  16340. if (unlikely(line_table_length == -1)) goto done;
  16341. #endif
  16342. Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL;
  16343. code_bytes = PyBytes_FromStringAndSize(NULL, code_len);
  16344. if (unlikely(!code_bytes)) goto done;
  16345. char* c_code_bytes = PyBytes_AsString(code_bytes);
  16346. if (unlikely(!c_code_bytes)) goto done;
  16347. memset(c_code_bytes, 0, (size_t) code_len);
  16348. }
  16349. code_obj = (PyObject*) __Pyx__PyCode_New(
  16350. (int) descr.argcount,
  16351. (int) descr.num_posonly_args,
  16352. (int) descr.num_kwonly_args,
  16353. (int) descr.nlocals,
  16354. 0,
  16355. (int) descr.flags,
  16356. code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes,
  16357. __pyx_mstate_global->__pyx_empty_tuple,
  16358. __pyx_mstate_global->__pyx_empty_tuple,
  16359. varnames_tuple_dedup,
  16360. __pyx_mstate_global->__pyx_empty_tuple,
  16361. __pyx_mstate_global->__pyx_empty_tuple,
  16362. filename,
  16363. funcname,
  16364. (int) descr.first_line,
  16365. (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes
  16366. );
  16367. done:
  16368. Py_XDECREF(code_bytes);
  16369. #if CYTHON_AVOID_BORROWED_REFS
  16370. Py_XDECREF(varnames_tuple_dedup);
  16371. #endif
  16372. Py_DECREF(varnames_tuple);
  16373. return code_obj;
  16374. }
  16375. /* DecompressString */
  16376. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) {
  16377. PyObject *module = NULL, *decompress, *compressed_bytes, *decompressed;
  16378. const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib";
  16379. PyObject *methodname = PyUnicode_FromString("decompress");
  16380. if (unlikely(!methodname)) return NULL;
  16381. #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000
  16382. if (algo == 3) {
  16383. PyObject *fromlist = Py_BuildValue("[O]", methodname);
  16384. if (unlikely(!fromlist)) goto bad;
  16385. module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0);
  16386. Py_DECREF(fromlist);
  16387. } else
  16388. #endif
  16389. module = PyImport_ImportModule(module_name);
  16390. if (unlikely(!module)) goto import_failed;
  16391. decompress = PyObject_GetAttr(module, methodname);
  16392. if (unlikely(!decompress)) goto import_failed;
  16393. {
  16394. #ifdef __cplusplus
  16395. char *memview_bytes = const_cast<char*>(s);
  16396. #else
  16397. #if defined(__clang__)
  16398. #pragma clang diagnostic push
  16399. #pragma clang diagnostic ignored "-Wcast-qual"
  16400. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  16401. #pragma GCC diagnostic push
  16402. #pragma GCC diagnostic ignored "-Wcast-qual"
  16403. #endif
  16404. char *memview_bytes = (char*) s;
  16405. #if defined(__clang__)
  16406. #pragma clang diagnostic pop
  16407. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  16408. #pragma GCC diagnostic pop
  16409. #endif
  16410. #endif
  16411. #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ)
  16412. int memview_flags = 0x100;
  16413. #else
  16414. int memview_flags = PyBUF_READ;
  16415. #endif
  16416. compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags);
  16417. }
  16418. if (unlikely(!compressed_bytes)) {
  16419. Py_DECREF(decompress);
  16420. goto bad;
  16421. }
  16422. decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL);
  16423. Py_DECREF(compressed_bytes);
  16424. Py_DECREF(decompress);
  16425. Py_DECREF(module);
  16426. Py_DECREF(methodname);
  16427. return decompressed;
  16428. import_failed:
  16429. PyErr_Format(PyExc_ImportError,
  16430. "Failed to import '%.20s.decompress' - cannot initialise module strings. "
  16431. "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.",
  16432. module_name, algo);
  16433. bad:
  16434. Py_XDECREF(module);
  16435. Py_DECREF(methodname);
  16436. return NULL;
  16437. }
  16438. #include <string.h>
  16439. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) {
  16440. size_t len = strlen(s);
  16441. if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) {
  16442. PyErr_SetString(PyExc_OverflowError, "byte string is too long");
  16443. return -1;
  16444. }
  16445. return (Py_ssize_t) len;
  16446. }
  16447. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  16448. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  16449. if (unlikely(len < 0)) return NULL;
  16450. return __Pyx_PyUnicode_FromStringAndSize(c_str, len);
  16451. }
  16452. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) {
  16453. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  16454. if (unlikely(len < 0)) return NULL;
  16455. return PyByteArray_FromStringAndSize(c_str, len);
  16456. }
  16457. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  16458. Py_ssize_t ignore;
  16459. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  16460. }
  16461. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  16462. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16463. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  16464. #if CYTHON_COMPILING_IN_LIMITED_API
  16465. {
  16466. const char* result;
  16467. Py_ssize_t unicode_length;
  16468. CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16469. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  16470. if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL;
  16471. #else
  16472. result = PyUnicode_AsUTF8AndSize(o, length);
  16473. #endif
  16474. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16475. unicode_length = PyUnicode_GetLength(o);
  16476. if (unlikely(unicode_length < 0)) return NULL;
  16477. if (unlikely(unicode_length != *length)) {
  16478. PyUnicode_AsASCIIString(o);
  16479. return NULL;
  16480. }
  16481. #endif
  16482. return result;
  16483. }
  16484. #else
  16485. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  16486. if (likely(PyUnicode_IS_ASCII(o))) {
  16487. *length = PyUnicode_GET_LENGTH(o);
  16488. return PyUnicode_AsUTF8(o);
  16489. } else {
  16490. PyUnicode_AsASCIIString(o);
  16491. return NULL;
  16492. }
  16493. #else
  16494. return PyUnicode_AsUTF8AndSize(o, length);
  16495. #endif
  16496. #endif
  16497. }
  16498. #endif
  16499. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  16500. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  16501. if (PyUnicode_Check(o)) {
  16502. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  16503. } else
  16504. #endif
  16505. if (PyByteArray_Check(o)) {
  16506. #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)))
  16507. *length = PyByteArray_GET_SIZE(o);
  16508. return PyByteArray_AS_STRING(o);
  16509. #else
  16510. *length = PyByteArray_Size(o);
  16511. if (*length == -1) return NULL;
  16512. return PyByteArray_AsString(o);
  16513. #endif
  16514. } else
  16515. {
  16516. char* result;
  16517. int r = PyBytes_AsStringAndSize(o, &result, length);
  16518. if (unlikely(r < 0)) {
  16519. return NULL;
  16520. } else {
  16521. return result;
  16522. }
  16523. }
  16524. }
  16525. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  16526. int is_true = x == Py_True;
  16527. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  16528. else return PyObject_IsTrue(x);
  16529. }
  16530. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  16531. int retval;
  16532. if (unlikely(!x)) return -1;
  16533. retval = __Pyx_PyObject_IsTrue(x);
  16534. Py_DECREF(x);
  16535. return retval;
  16536. }
  16537. static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) {
  16538. __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result));
  16539. if (PyLong_Check(result)) {
  16540. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  16541. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). "
  16542. "The ability to return an instance of a strict subclass of int is deprecated, "
  16543. "and may be removed in a future version of Python.",
  16544. result_type_name)) {
  16545. __Pyx_DECREF_TypeName(result_type_name);
  16546. Py_DECREF(result);
  16547. return NULL;
  16548. }
  16549. __Pyx_DECREF_TypeName(result_type_name);
  16550. return result;
  16551. }
  16552. PyErr_Format(PyExc_TypeError,
  16553. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")",
  16554. result_type_name);
  16555. __Pyx_DECREF_TypeName(result_type_name);
  16556. Py_DECREF(result);
  16557. return NULL;
  16558. }
  16559. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) {
  16560. #if CYTHON_USE_TYPE_SLOTS
  16561. PyNumberMethods *m;
  16562. #endif
  16563. PyObject *res = NULL;
  16564. if (likely(PyLong_Check(x)))
  16565. return __Pyx_NewRef(x);
  16566. #if CYTHON_USE_TYPE_SLOTS
  16567. m = Py_TYPE(x)->tp_as_number;
  16568. if (likely(m && m->nb_int)) {
  16569. res = m->nb_int(x);
  16570. }
  16571. #else
  16572. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  16573. res = PyNumber_Long(x);
  16574. }
  16575. #endif
  16576. if (likely(res)) {
  16577. if (unlikely(!PyLong_CheckExact(res))) {
  16578. return __Pyx_PyNumber_LongWrongResultType(res);
  16579. }
  16580. }
  16581. else if (!PyErr_Occurred()) {
  16582. PyErr_SetString(PyExc_TypeError,
  16583. "an integer is required");
  16584. }
  16585. return res;
  16586. }
  16587. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  16588. Py_ssize_t ival;
  16589. PyObject *x;
  16590. if (likely(PyLong_CheckExact(b))) {
  16591. #if CYTHON_USE_PYLONG_INTERNALS
  16592. if (likely(__Pyx_PyLong_IsCompact(b))) {
  16593. return __Pyx_PyLong_CompactValue(b);
  16594. } else {
  16595. const digit* digits = __Pyx_PyLong_Digits(b);
  16596. const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b);
  16597. switch (size) {
  16598. case 2:
  16599. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16600. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16601. }
  16602. break;
  16603. case -2:
  16604. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  16605. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16606. }
  16607. break;
  16608. case 3:
  16609. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16610. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16611. }
  16612. break;
  16613. case -3:
  16614. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  16615. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  16616. }
  16617. break;
  16618. case 4:
  16619. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16620. 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]));
  16621. }
  16622. break;
  16623. case -4:
  16624. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  16625. 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]));
  16626. }
  16627. break;
  16628. }
  16629. }
  16630. #endif
  16631. return PyLong_AsSsize_t(b);
  16632. }
  16633. x = PyNumber_Index(b);
  16634. if (!x) return -1;
  16635. ival = PyLong_AsSsize_t(x);
  16636. Py_DECREF(x);
  16637. return ival;
  16638. }
  16639. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  16640. if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
  16641. return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
  16642. } else {
  16643. Py_ssize_t ival;
  16644. PyObject *x;
  16645. x = PyNumber_Index(o);
  16646. if (!x) return -1;
  16647. ival = PyLong_AsLong(x);
  16648. Py_DECREF(x);
  16649. return ival;
  16650. }
  16651. }
  16652. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) {
  16653. CYTHON_UNUSED_VAR(b);
  16654. return __Pyx_NewRef(Py_None);
  16655. }
  16656. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  16657. return __Pyx_NewRef(b ? Py_True: Py_False);
  16658. }
  16659. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) {
  16660. return PyLong_FromSize_t(ival);
  16661. }
  16662. /* MultiPhaseInitModuleState */
  16663. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  16664. #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16665. #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000)
  16666. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1
  16667. #else
  16668. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0
  16669. #endif
  16670. #endif
  16671. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS
  16672. #error "Module state with PEP489 requires atomics. Currently that's one of\
  16673. C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics"
  16674. #endif
  16675. #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16676. #define __Pyx_ModuleStateLookup_Lock()
  16677. #define __Pyx_ModuleStateLookup_Unlock()
  16678. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  16679. static PyMutex __Pyx_ModuleStateLookup_mutex = {0};
  16680. #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex)
  16681. #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex)
  16682. #elif defined(__cplusplus) && __cplusplus >= 201103L
  16683. #include <mutex>
  16684. static std::mutex __Pyx_ModuleStateLookup_mutex;
  16685. #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock()
  16686. #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock()
  16687. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__)
  16688. #include <threads.h>
  16689. static mtx_t __Pyx_ModuleStateLookup_mutex;
  16690. static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT;
  16691. static void __Pyx_ModuleStateLookup_initialize_mutex(void) {
  16692. mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain);
  16693. }
  16694. #define __Pyx_ModuleStateLookup_Lock()\
  16695. call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\
  16696. mtx_lock(&__Pyx_ModuleStateLookup_mutex)
  16697. #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex)
  16698. #elif defined(HAVE_PTHREAD_H)
  16699. #include <pthread.h>
  16700. static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER;
  16701. #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex)
  16702. #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex)
  16703. #elif defined(_WIN32)
  16704. #include <Windows.h> // synchapi.h on its own doesn't work
  16705. static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT;
  16706. #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  16707. #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  16708. #else
  16709. #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\
  16710. Requires C standard >= C11, or C++ standard >= C++11,\
  16711. or pthreads, or the Windows 32 API, or Python >= 3.13."
  16712. #endif
  16713. typedef struct {
  16714. int64_t id;
  16715. PyObject *module;
  16716. } __Pyx_InterpreterIdAndModule;
  16717. typedef struct {
  16718. char interpreter_id_as_index;
  16719. Py_ssize_t count;
  16720. Py_ssize_t allocated;
  16721. __Pyx_InterpreterIdAndModule table[1];
  16722. } __Pyx_ModuleStateLookupData;
  16723. #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32
  16724. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16725. static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0;
  16726. #endif
  16727. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16728. static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0;
  16729. #else
  16730. static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL;
  16731. #endif
  16732. static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound(
  16733. __Pyx_InterpreterIdAndModule* table,
  16734. Py_ssize_t count,
  16735. int64_t interpreterId) {
  16736. __Pyx_InterpreterIdAndModule* begin = table;
  16737. __Pyx_InterpreterIdAndModule* end = begin + count;
  16738. if (begin->id == interpreterId) {
  16739. return begin;
  16740. }
  16741. while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  16742. __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2;
  16743. if (halfway->id == interpreterId) {
  16744. return halfway;
  16745. }
  16746. if (halfway->id < interpreterId) {
  16747. begin = halfway;
  16748. } else {
  16749. end = halfway;
  16750. }
  16751. }
  16752. for (; begin < end; ++begin) {
  16753. if (begin->id >= interpreterId) return begin;
  16754. }
  16755. return begin;
  16756. }
  16757. static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) {
  16758. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  16759. if (interpreter_id == -1) return NULL;
  16760. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16761. __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  16762. {
  16763. __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  16764. if (likely(data)) {
  16765. __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data);
  16766. if (likely(data == new_data)) {
  16767. goto read_finished;
  16768. }
  16769. }
  16770. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  16771. __Pyx_ModuleStateLookup_Lock();
  16772. __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter);
  16773. data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  16774. __Pyx_ModuleStateLookup_Unlock();
  16775. }
  16776. read_finished:;
  16777. #else
  16778. __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data;
  16779. #endif
  16780. __Pyx_InterpreterIdAndModule* found = NULL;
  16781. if (unlikely(!data)) goto end;
  16782. if (data->interpreter_id_as_index) {
  16783. if (interpreter_id < data->count) {
  16784. found = data->table+interpreter_id;
  16785. }
  16786. } else {
  16787. found = __Pyx_State_FindModuleStateLookupTableLowerBound(
  16788. data->table, data->count, interpreter_id);
  16789. }
  16790. end:
  16791. {
  16792. PyObject *result=NULL;
  16793. if (found && found->id == interpreter_id) {
  16794. result = found->module;
  16795. }
  16796. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16797. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  16798. #endif
  16799. return result;
  16800. }
  16801. }
  16802. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16803. static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) {
  16804. while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0);
  16805. }
  16806. #else
  16807. #define __Pyx_ModuleStateLookup_wait_until_no_readers()
  16808. #endif
  16809. static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) {
  16810. Py_ssize_t to_allocate = (*old_data)->allocated;
  16811. while (to_allocate <= interpreter_id) {
  16812. if (to_allocate == 0) to_allocate = 1;
  16813. else to_allocate *= 2;
  16814. }
  16815. __Pyx_ModuleStateLookupData *new_data = *old_data;
  16816. if (to_allocate != (*old_data)->allocated) {
  16817. new_data = (__Pyx_ModuleStateLookupData *)realloc(
  16818. *old_data,
  16819. sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  16820. if (!new_data) {
  16821. PyErr_NoMemory();
  16822. return -1;
  16823. }
  16824. for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) {
  16825. new_data->table[i].id = i;
  16826. new_data->table[i].module = NULL;
  16827. }
  16828. new_data->allocated = to_allocate;
  16829. }
  16830. new_data->table[interpreter_id].module = module;
  16831. if (new_data->count < interpreter_id+1) {
  16832. new_data->count = interpreter_id+1;
  16833. }
  16834. *old_data = new_data;
  16835. return 0;
  16836. }
  16837. static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) {
  16838. __Pyx_InterpreterIdAndModule *read = data->table;
  16839. __Pyx_InterpreterIdAndModule *write = data->table;
  16840. __Pyx_InterpreterIdAndModule *end = read + data->count;
  16841. for (; read<end; ++read) {
  16842. if (read->module) {
  16843. write->id = read->id;
  16844. write->module = read->module;
  16845. ++write;
  16846. }
  16847. }
  16848. data->count = write - data->table;
  16849. for (; write<end; ++write) {
  16850. write->id = 0;
  16851. write->module = NULL;
  16852. }
  16853. data->interpreter_id_as_index = 0;
  16854. }
  16855. static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) {
  16856. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  16857. if (interpreter_id == -1) return -1;
  16858. int result = 0;
  16859. __Pyx_ModuleStateLookup_Lock();
  16860. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16861. __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *)
  16862. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  16863. #else
  16864. __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data;
  16865. #endif
  16866. __Pyx_ModuleStateLookupData *new_data = old_data;
  16867. if (!new_data) {
  16868. new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData));
  16869. if (!new_data) {
  16870. result = -1;
  16871. PyErr_NoMemory();
  16872. goto end;
  16873. }
  16874. new_data->allocated = 1;
  16875. new_data->interpreter_id_as_index = 1;
  16876. }
  16877. __Pyx_ModuleStateLookup_wait_until_no_readers();
  16878. if (new_data->interpreter_id_as_index) {
  16879. if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  16880. result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id);
  16881. goto end;
  16882. }
  16883. __Pyx_State_ConvertFromInterpIdAsIndex(new_data);
  16884. }
  16885. {
  16886. Py_ssize_t insert_at = 0;
  16887. {
  16888. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  16889. new_data->table, new_data->count, interpreter_id);
  16890. assert(lower_bound);
  16891. insert_at = lower_bound - new_data->table;
  16892. if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) {
  16893. lower_bound->module = module;
  16894. goto end; // already in table, nothing more to do
  16895. }
  16896. }
  16897. if (new_data->count+1 >= new_data->allocated) {
  16898. Py_ssize_t to_allocate = (new_data->count+1)*2;
  16899. new_data =
  16900. (__Pyx_ModuleStateLookupData*)realloc(
  16901. new_data,
  16902. sizeof(__Pyx_ModuleStateLookupData) +
  16903. (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  16904. if (!new_data) {
  16905. result = -1;
  16906. new_data = old_data;
  16907. PyErr_NoMemory();
  16908. goto end;
  16909. }
  16910. new_data->allocated = to_allocate;
  16911. }
  16912. ++new_data->count;
  16913. int64_t last_id = interpreter_id;
  16914. PyObject *last_module = module;
  16915. for (Py_ssize_t i=insert_at; i<new_data->count; ++i) {
  16916. int64_t current_id = new_data->table[i].id;
  16917. new_data->table[i].id = last_id;
  16918. last_id = current_id;
  16919. PyObject *current_module = new_data->table[i].module;
  16920. new_data->table[i].module = last_module;
  16921. last_module = current_module;
  16922. }
  16923. }
  16924. end:
  16925. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16926. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data);
  16927. #else
  16928. __Pyx_ModuleStateLookup_data = new_data;
  16929. #endif
  16930. __Pyx_ModuleStateLookup_Unlock();
  16931. return result;
  16932. }
  16933. static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) {
  16934. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  16935. if (interpreter_id == -1) return -1;
  16936. __Pyx_ModuleStateLookup_Lock();
  16937. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16938. __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *)
  16939. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  16940. #else
  16941. __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data;
  16942. #endif
  16943. if (data->interpreter_id_as_index) {
  16944. if (interpreter_id < data->count) {
  16945. data->table[interpreter_id].module = NULL;
  16946. }
  16947. goto done;
  16948. }
  16949. {
  16950. __Pyx_ModuleStateLookup_wait_until_no_readers();
  16951. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  16952. data->table, data->count, interpreter_id);
  16953. if (!lower_bound) goto done;
  16954. if (lower_bound->id != interpreter_id) goto done;
  16955. __Pyx_InterpreterIdAndModule *end = data->table+data->count;
  16956. for (;lower_bound<end-1; ++lower_bound) {
  16957. lower_bound->id = (lower_bound+1)->id;
  16958. lower_bound->module = (lower_bound+1)->module;
  16959. }
  16960. }
  16961. --data->count;
  16962. if (data->count == 0) {
  16963. free(data);
  16964. data = NULL;
  16965. }
  16966. done:
  16967. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  16968. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data);
  16969. #else
  16970. __Pyx_ModuleStateLookup_data = data;
  16971. #endif
  16972. __Pyx_ModuleStateLookup_Unlock();
  16973. return 0;
  16974. }
  16975. #endif
  16976. /* #### Code section: utility_code_pragmas_end ### */
  16977. #ifdef _MSC_VER
  16978. #pragma warning( pop )
  16979. #endif
  16980. /* #### Code section: end ### */
  16981. #endif /* Py_PYTHON_H */