cu2qu.c 634 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817
  1. /* Generated by Cython 3.2.2 */
  2. /* BEGIN: Cython Metadata
  3. {
  4. "distutils": {
  5. "define_macros": [
  6. [
  7. "CYTHON_TRACE_NOGIL",
  8. "1"
  9. ]
  10. ],
  11. "name": "fontTools.cu2qu.cu2qu",
  12. "sources": [
  13. "Lib/fontTools/cu2qu/cu2qu.py"
  14. ]
  15. },
  16. "module_name": "fontTools.cu2qu.cu2qu"
  17. }
  18. END: Cython Metadata */
  19. #ifndef PY_SSIZE_T_CLEAN
  20. #define PY_SSIZE_T_CLEAN
  21. #endif /* PY_SSIZE_T_CLEAN */
  22. /* InitLimitedAPI */
  23. #if defined(Py_LIMITED_API)
  24. #if !defined(CYTHON_LIMITED_API)
  25. #define CYTHON_LIMITED_API 1
  26. #endif
  27. #elif defined(CYTHON_LIMITED_API)
  28. #ifdef _MSC_VER
  29. #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.")
  30. #else
  31. #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.
  32. #endif
  33. #endif
  34. #include "Python.h"
  35. #ifndef Py_PYTHON_H
  36. #error Python headers needed to compile C extensions, please install development version of Python.
  37. #elif PY_VERSION_HEX < 0x03080000
  38. #error Cython requires Python 3.8+.
  39. #else
  40. #define __PYX_ABI_VERSION "3_2_2"
  41. #define CYTHON_HEX_VERSION 0x030202F0
  42. #define CYTHON_FUTURE_DIVISION 1
  43. /* CModulePreamble */
  44. #include <stddef.h>
  45. #ifndef offsetof
  46. #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
  47. #endif
  48. #if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS)
  49. #ifndef __stdcall
  50. #define __stdcall
  51. #endif
  52. #ifndef __cdecl
  53. #define __cdecl
  54. #endif
  55. #ifndef __fastcall
  56. #define __fastcall
  57. #endif
  58. #endif
  59. #ifndef DL_IMPORT
  60. #define DL_IMPORT(t) t
  61. #endif
  62. #ifndef DL_EXPORT
  63. #define DL_EXPORT(t) t
  64. #endif
  65. #define __PYX_COMMA ,
  66. #ifndef PY_LONG_LONG
  67. #define PY_LONG_LONG LONG_LONG
  68. #endif
  69. #ifndef Py_HUGE_VAL
  70. #define Py_HUGE_VAL HUGE_VAL
  71. #endif
  72. #define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX
  73. #if defined(GRAALVM_PYTHON)
  74. /* For very preliminary testing purposes. Most variables are set the same as PyPy.
  75. The existence of this section does not imply that anything works or is even tested */
  76. #define CYTHON_COMPILING_IN_PYPY 0
  77. #define CYTHON_COMPILING_IN_CPYTHON 0
  78. #define CYTHON_COMPILING_IN_LIMITED_API 0
  79. #define CYTHON_COMPILING_IN_GRAAL 1
  80. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  81. #undef CYTHON_USE_TYPE_SLOTS
  82. #define CYTHON_USE_TYPE_SLOTS 0
  83. #undef CYTHON_USE_TYPE_SPECS
  84. #define CYTHON_USE_TYPE_SPECS 0
  85. #undef CYTHON_USE_PYTYPE_LOOKUP
  86. #define CYTHON_USE_PYTYPE_LOOKUP 0
  87. #undef CYTHON_USE_PYLIST_INTERNALS
  88. #define CYTHON_USE_PYLIST_INTERNALS 0
  89. #undef CYTHON_USE_UNICODE_INTERNALS
  90. #define CYTHON_USE_UNICODE_INTERNALS 0
  91. #undef CYTHON_USE_UNICODE_WRITER
  92. #define CYTHON_USE_UNICODE_WRITER 0
  93. #undef CYTHON_USE_PYLONG_INTERNALS
  94. #define CYTHON_USE_PYLONG_INTERNALS 0
  95. #undef CYTHON_AVOID_BORROWED_REFS
  96. #define CYTHON_AVOID_BORROWED_REFS 1
  97. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  98. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  99. #undef CYTHON_ASSUME_SAFE_MACROS
  100. #define CYTHON_ASSUME_SAFE_MACROS 0
  101. #undef CYTHON_ASSUME_SAFE_SIZE
  102. #define CYTHON_ASSUME_SAFE_SIZE 0
  103. #undef CYTHON_UNPACK_METHODS
  104. #define CYTHON_UNPACK_METHODS 0
  105. #undef CYTHON_FAST_THREAD_STATE
  106. #define CYTHON_FAST_THREAD_STATE 0
  107. #undef CYTHON_FAST_GIL
  108. #define CYTHON_FAST_GIL 0
  109. #undef CYTHON_METH_FASTCALL
  110. #define CYTHON_METH_FASTCALL 0
  111. #undef CYTHON_FAST_PYCALL
  112. #define CYTHON_FAST_PYCALL 0
  113. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  114. #define CYTHON_PEP487_INIT_SUBCLASS 1
  115. #endif
  116. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  117. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  118. #undef CYTHON_USE_MODULE_STATE
  119. #define CYTHON_USE_MODULE_STATE 0
  120. #undef CYTHON_USE_SYS_MONITORING
  121. #define CYTHON_USE_SYS_MONITORING 0
  122. #undef CYTHON_USE_TP_FINALIZE
  123. #define CYTHON_USE_TP_FINALIZE 0
  124. #undef CYTHON_USE_AM_SEND
  125. #define CYTHON_USE_AM_SEND 0
  126. #undef CYTHON_USE_DICT_VERSIONS
  127. #define CYTHON_USE_DICT_VERSIONS 0
  128. #undef CYTHON_USE_EXC_INFO_STACK
  129. #define CYTHON_USE_EXC_INFO_STACK 1
  130. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  131. #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  132. #endif
  133. #undef CYTHON_USE_FREELISTS
  134. #define CYTHON_USE_FREELISTS 0
  135. #undef CYTHON_IMMORTAL_CONSTANTS
  136. #define CYTHON_IMMORTAL_CONSTANTS 0
  137. #elif defined(PYPY_VERSION)
  138. #define CYTHON_COMPILING_IN_PYPY 1
  139. #define CYTHON_COMPILING_IN_CPYTHON 0
  140. #define CYTHON_COMPILING_IN_LIMITED_API 0
  141. #define CYTHON_COMPILING_IN_GRAAL 0
  142. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  143. #undef CYTHON_USE_TYPE_SLOTS
  144. #define CYTHON_USE_TYPE_SLOTS 1
  145. #ifndef CYTHON_USE_TYPE_SPECS
  146. #define CYTHON_USE_TYPE_SPECS 0
  147. #endif
  148. #undef CYTHON_USE_PYTYPE_LOOKUP
  149. #define CYTHON_USE_PYTYPE_LOOKUP 0
  150. #undef CYTHON_USE_PYLIST_INTERNALS
  151. #define CYTHON_USE_PYLIST_INTERNALS 0
  152. #undef CYTHON_USE_UNICODE_INTERNALS
  153. #define CYTHON_USE_UNICODE_INTERNALS 0
  154. #undef CYTHON_USE_UNICODE_WRITER
  155. #define CYTHON_USE_UNICODE_WRITER 0
  156. #undef CYTHON_USE_PYLONG_INTERNALS
  157. #define CYTHON_USE_PYLONG_INTERNALS 0
  158. #undef CYTHON_AVOID_BORROWED_REFS
  159. #define CYTHON_AVOID_BORROWED_REFS 1
  160. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  161. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  162. #undef CYTHON_ASSUME_SAFE_MACROS
  163. #define CYTHON_ASSUME_SAFE_MACROS 0
  164. #ifndef CYTHON_ASSUME_SAFE_SIZE
  165. #define CYTHON_ASSUME_SAFE_SIZE 1
  166. #endif
  167. #undef CYTHON_UNPACK_METHODS
  168. #define CYTHON_UNPACK_METHODS 0
  169. #undef CYTHON_FAST_THREAD_STATE
  170. #define CYTHON_FAST_THREAD_STATE 0
  171. #undef CYTHON_FAST_GIL
  172. #define CYTHON_FAST_GIL 0
  173. #undef CYTHON_METH_FASTCALL
  174. #define CYTHON_METH_FASTCALL 0
  175. #undef CYTHON_FAST_PYCALL
  176. #define CYTHON_FAST_PYCALL 0
  177. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  178. #define CYTHON_PEP487_INIT_SUBCLASS 1
  179. #endif
  180. #if PY_VERSION_HEX < 0x03090000
  181. #undef CYTHON_PEP489_MULTI_PHASE_INIT
  182. #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  183. #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
  184. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  185. #endif
  186. #undef CYTHON_USE_MODULE_STATE
  187. #define CYTHON_USE_MODULE_STATE 0
  188. #undef CYTHON_USE_SYS_MONITORING
  189. #define CYTHON_USE_SYS_MONITORING 0
  190. #ifndef CYTHON_USE_TP_FINALIZE
  191. #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00)
  192. #endif
  193. #undef CYTHON_USE_AM_SEND
  194. #define CYTHON_USE_AM_SEND 0
  195. #undef CYTHON_USE_DICT_VERSIONS
  196. #define CYTHON_USE_DICT_VERSIONS 0
  197. #undef CYTHON_USE_EXC_INFO_STACK
  198. #define CYTHON_USE_EXC_INFO_STACK 0
  199. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  200. #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100)
  201. #endif
  202. #undef CYTHON_USE_FREELISTS
  203. #define CYTHON_USE_FREELISTS 0
  204. #undef CYTHON_IMMORTAL_CONSTANTS
  205. #define CYTHON_IMMORTAL_CONSTANTS 0
  206. #elif defined(CYTHON_LIMITED_API)
  207. #ifdef Py_LIMITED_API
  208. #undef __PYX_LIMITED_VERSION_HEX
  209. #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API
  210. #endif
  211. #define CYTHON_COMPILING_IN_PYPY 0
  212. #define CYTHON_COMPILING_IN_CPYTHON 0
  213. #define CYTHON_COMPILING_IN_LIMITED_API 1
  214. #define CYTHON_COMPILING_IN_GRAAL 0
  215. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  216. #undef CYTHON_USE_TYPE_SLOTS
  217. #define CYTHON_USE_TYPE_SLOTS 0
  218. #undef CYTHON_USE_TYPE_SPECS
  219. #define CYTHON_USE_TYPE_SPECS 1
  220. #undef CYTHON_USE_PYTYPE_LOOKUP
  221. #define CYTHON_USE_PYTYPE_LOOKUP 0
  222. #undef CYTHON_USE_PYLIST_INTERNALS
  223. #define CYTHON_USE_PYLIST_INTERNALS 0
  224. #undef CYTHON_USE_UNICODE_INTERNALS
  225. #define CYTHON_USE_UNICODE_INTERNALS 0
  226. #ifndef CYTHON_USE_UNICODE_WRITER
  227. #define CYTHON_USE_UNICODE_WRITER 0
  228. #endif
  229. #undef CYTHON_USE_PYLONG_INTERNALS
  230. #define CYTHON_USE_PYLONG_INTERNALS 0
  231. #ifndef CYTHON_AVOID_BORROWED_REFS
  232. #define CYTHON_AVOID_BORROWED_REFS 0
  233. #endif
  234. #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  235. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  236. #endif
  237. #undef CYTHON_ASSUME_SAFE_MACROS
  238. #define CYTHON_ASSUME_SAFE_MACROS 0
  239. #undef CYTHON_ASSUME_SAFE_SIZE
  240. #define CYTHON_ASSUME_SAFE_SIZE 0
  241. #undef CYTHON_UNPACK_METHODS
  242. #define CYTHON_UNPACK_METHODS 0
  243. #undef CYTHON_FAST_THREAD_STATE
  244. #define CYTHON_FAST_THREAD_STATE 0
  245. #undef CYTHON_FAST_GIL
  246. #define CYTHON_FAST_GIL 0
  247. #undef CYTHON_METH_FASTCALL
  248. #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
  249. #undef CYTHON_FAST_PYCALL
  250. #define CYTHON_FAST_PYCALL 0
  251. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  252. #define CYTHON_PEP487_INIT_SUBCLASS 1
  253. #endif
  254. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  255. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  256. #endif
  257. #ifndef CYTHON_USE_MODULE_STATE
  258. #define CYTHON_USE_MODULE_STATE 0
  259. #endif
  260. #undef CYTHON_USE_SYS_MONITORING
  261. #define CYTHON_USE_SYS_MONITORING 0
  262. #ifndef CYTHON_USE_TP_FINALIZE
  263. #define CYTHON_USE_TP_FINALIZE 0
  264. #endif
  265. #ifndef CYTHON_USE_AM_SEND
  266. #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
  267. #endif
  268. #undef CYTHON_USE_DICT_VERSIONS
  269. #define CYTHON_USE_DICT_VERSIONS 0
  270. #undef CYTHON_USE_EXC_INFO_STACK
  271. #define CYTHON_USE_EXC_INFO_STACK 0
  272. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  273. #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  274. #endif
  275. #ifndef CYTHON_USE_FREELISTS
  276. #define CYTHON_USE_FREELISTS 1
  277. #endif
  278. #undef CYTHON_IMMORTAL_CONSTANTS
  279. #define CYTHON_IMMORTAL_CONSTANTS 0
  280. #else
  281. #define CYTHON_COMPILING_IN_PYPY 0
  282. #define CYTHON_COMPILING_IN_CPYTHON 1
  283. #define CYTHON_COMPILING_IN_LIMITED_API 0
  284. #define CYTHON_COMPILING_IN_GRAAL 0
  285. #ifdef Py_GIL_DISABLED
  286. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1
  287. #else
  288. #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  289. #endif
  290. #if PY_VERSION_HEX < 0x030A0000
  291. #undef CYTHON_USE_TYPE_SLOTS
  292. #define CYTHON_USE_TYPE_SLOTS 1
  293. #elif !defined(CYTHON_USE_TYPE_SLOTS)
  294. #define CYTHON_USE_TYPE_SLOTS 1
  295. #endif
  296. #ifndef CYTHON_USE_TYPE_SPECS
  297. #define CYTHON_USE_TYPE_SPECS 0
  298. #endif
  299. #ifndef CYTHON_USE_PYTYPE_LOOKUP
  300. #define CYTHON_USE_PYTYPE_LOOKUP 1
  301. #endif
  302. #ifndef CYTHON_USE_PYLONG_INTERNALS
  303. #define CYTHON_USE_PYLONG_INTERNALS 1
  304. #endif
  305. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  306. #undef CYTHON_USE_PYLIST_INTERNALS
  307. #define CYTHON_USE_PYLIST_INTERNALS 0
  308. #elif !defined(CYTHON_USE_PYLIST_INTERNALS)
  309. #define CYTHON_USE_PYLIST_INTERNALS 1
  310. #endif
  311. #ifndef CYTHON_USE_UNICODE_INTERNALS
  312. #define CYTHON_USE_UNICODE_INTERNALS 1
  313. #endif
  314. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2
  315. #undef CYTHON_USE_UNICODE_WRITER
  316. #define CYTHON_USE_UNICODE_WRITER 0
  317. #elif !defined(CYTHON_USE_UNICODE_WRITER)
  318. #define CYTHON_USE_UNICODE_WRITER 1
  319. #endif
  320. #ifndef CYTHON_AVOID_BORROWED_REFS
  321. #define CYTHON_AVOID_BORROWED_REFS 0
  322. #endif
  323. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  324. #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  325. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  326. #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
  327. #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  328. #endif
  329. #ifndef CYTHON_ASSUME_SAFE_MACROS
  330. #define CYTHON_ASSUME_SAFE_MACROS 1
  331. #endif
  332. #ifndef CYTHON_ASSUME_SAFE_SIZE
  333. #define CYTHON_ASSUME_SAFE_SIZE 1
  334. #endif
  335. #ifndef CYTHON_UNPACK_METHODS
  336. #define CYTHON_UNPACK_METHODS 1
  337. #endif
  338. #ifndef CYTHON_FAST_THREAD_STATE
  339. #define CYTHON_FAST_THREAD_STATE 1
  340. #endif
  341. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  342. #undef CYTHON_FAST_GIL
  343. #define CYTHON_FAST_GIL 0
  344. #elif !defined(CYTHON_FAST_GIL)
  345. #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6)
  346. #endif
  347. #ifndef CYTHON_METH_FASTCALL
  348. #define CYTHON_METH_FASTCALL 1
  349. #endif
  350. #ifndef CYTHON_FAST_PYCALL
  351. #define CYTHON_FAST_PYCALL 1
  352. #endif
  353. #ifndef CYTHON_PEP487_INIT_SUBCLASS
  354. #define CYTHON_PEP487_INIT_SUBCLASS 1
  355. #endif
  356. #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
  357. #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  358. #endif
  359. #ifndef CYTHON_USE_MODULE_STATE
  360. #define CYTHON_USE_MODULE_STATE 0
  361. #endif
  362. #ifndef CYTHON_USE_SYS_MONITORING
  363. #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1)
  364. #endif
  365. #ifndef CYTHON_USE_TP_FINALIZE
  366. #define CYTHON_USE_TP_FINALIZE 1
  367. #endif
  368. #ifndef CYTHON_USE_AM_SEND
  369. #define CYTHON_USE_AM_SEND 1
  370. #endif
  371. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  372. #undef CYTHON_USE_DICT_VERSIONS
  373. #define CYTHON_USE_DICT_VERSIONS 0
  374. #elif !defined(CYTHON_USE_DICT_VERSIONS)
  375. #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE)
  376. #endif
  377. #ifndef CYTHON_USE_EXC_INFO_STACK
  378. #define CYTHON_USE_EXC_INFO_STACK 1
  379. #endif
  380. #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
  381. #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  382. #endif
  383. #ifndef CYTHON_USE_FREELISTS
  384. #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  385. #endif
  386. #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000
  387. #undef CYTHON_IMMORTAL_CONSTANTS
  388. #define CYTHON_IMMORTAL_CONSTANTS 0 // definitely won't work
  389. #elif !defined(CYTHON_IMMORTAL_CONSTANTS)
  390. #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  391. #endif
  392. #endif
  393. #ifndef CYTHON_COMPRESS_STRINGS
  394. #define CYTHON_COMPRESS_STRINGS 1
  395. #endif
  396. #ifndef CYTHON_FAST_PYCCALL
  397. #define CYTHON_FAST_PYCCALL CYTHON_FAST_PYCALL
  398. #endif
  399. #ifndef CYTHON_VECTORCALL
  400. #if CYTHON_COMPILING_IN_LIMITED_API
  401. #define CYTHON_VECTORCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
  402. #else
  403. #define CYTHON_VECTORCALL (CYTHON_FAST_PYCCALL)
  404. #endif
  405. #endif
  406. #if CYTHON_USE_PYLONG_INTERNALS
  407. #undef SHIFT
  408. #undef BASE
  409. #undef MASK
  410. #ifdef SIZEOF_VOID_P
  411. enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  412. #endif
  413. #endif
  414. #ifndef __has_attribute
  415. #define __has_attribute(x) 0
  416. #endif
  417. #ifndef __has_cpp_attribute
  418. #define __has_cpp_attribute(x) 0
  419. #endif
  420. #ifndef CYTHON_RESTRICT
  421. #if defined(__GNUC__)
  422. #define CYTHON_RESTRICT __restrict__
  423. #elif defined(_MSC_VER) && _MSC_VER >= 1400
  424. #define CYTHON_RESTRICT __restrict
  425. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  426. #define CYTHON_RESTRICT restrict
  427. #else
  428. #define CYTHON_RESTRICT
  429. #endif
  430. #endif
  431. #ifndef CYTHON_UNUSED
  432. #if defined(__cplusplus)
  433. /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17
  434. * but leads to warnings with -pedantic, since it is a C++17 feature */
  435. #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
  436. #if __has_cpp_attribute(maybe_unused)
  437. #define CYTHON_UNUSED [[maybe_unused]]
  438. #endif
  439. #endif
  440. #endif
  441. #endif
  442. #ifndef CYTHON_UNUSED
  443. # if defined(__GNUC__)
  444. # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
  445. # define CYTHON_UNUSED __attribute__ ((__unused__))
  446. # else
  447. # define CYTHON_UNUSED
  448. # endif
  449. # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
  450. # define CYTHON_UNUSED __attribute__ ((__unused__))
  451. # else
  452. # define CYTHON_UNUSED
  453. # endif
  454. #endif
  455. #ifndef CYTHON_UNUSED_VAR
  456. # if defined(__cplusplus)
  457. template<class T> void CYTHON_UNUSED_VAR( const T& ) { }
  458. # else
  459. # define CYTHON_UNUSED_VAR(x) (void)(x)
  460. # endif
  461. #endif
  462. #ifndef CYTHON_MAYBE_UNUSED_VAR
  463. #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x)
  464. #endif
  465. #ifndef CYTHON_NCP_UNUSED
  466. # if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  467. # define CYTHON_NCP_UNUSED
  468. # else
  469. # define CYTHON_NCP_UNUSED CYTHON_UNUSED
  470. # endif
  471. #endif
  472. #ifndef CYTHON_USE_CPP_STD_MOVE
  473. #if defined(__cplusplus) && (\
  474. __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
  475. #define CYTHON_USE_CPP_STD_MOVE 1
  476. #else
  477. #define CYTHON_USE_CPP_STD_MOVE 0
  478. #endif
  479. #endif
  480. #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
  481. #include <stdint.h>
  482. typedef uintptr_t __pyx_uintptr_t;
  483. #ifndef CYTHON_FALLTHROUGH
  484. #if defined(__cplusplus)
  485. /* for clang __has_cpp_attribute(fallthrough) is true even before C++17
  486. * but leads to warnings with -pedantic, since it is a C++17 feature */
  487. #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
  488. #if __has_cpp_attribute(fallthrough)
  489. #define CYTHON_FALLTHROUGH [[fallthrough]]
  490. #endif
  491. #endif
  492. #ifndef CYTHON_FALLTHROUGH
  493. #if __has_cpp_attribute(clang::fallthrough)
  494. #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
  495. #elif __has_cpp_attribute(gnu::fallthrough)
  496. #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
  497. #endif
  498. #endif
  499. #endif
  500. #ifndef CYTHON_FALLTHROUGH
  501. #if __has_attribute(fallthrough)
  502. #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
  503. #else
  504. #define CYTHON_FALLTHROUGH
  505. #endif
  506. #endif
  507. #if defined(__clang__) && defined(__apple_build_version__)
  508. #if __apple_build_version__ < 7000000
  509. #undef CYTHON_FALLTHROUGH
  510. #define CYTHON_FALLTHROUGH
  511. #endif
  512. #endif
  513. #endif
  514. #ifndef Py_UNREACHABLE
  515. #define Py_UNREACHABLE() assert(0); abort()
  516. #endif
  517. #ifdef __cplusplus
  518. template <typename T>
  519. struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);};
  520. #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL<type>::value)
  521. #else
  522. #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0)
  523. #endif
  524. #if CYTHON_COMPILING_IN_PYPY == 1
  525. #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x030A0000)
  526. #else
  527. #define __PYX_NEED_TP_PRINT_SLOT (PY_VERSION_HEX < 0x03090000)
  528. #endif
  529. #define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer))
  530. /* CInitCode */
  531. #ifndef CYTHON_INLINE
  532. #if defined(__clang__)
  533. #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  534. #elif defined(__GNUC__)
  535. #define CYTHON_INLINE __inline__
  536. #elif defined(_MSC_VER)
  537. #define CYTHON_INLINE __inline
  538. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  539. #define CYTHON_INLINE inline
  540. #else
  541. #define CYTHON_INLINE
  542. #endif
  543. #endif
  544. /* PythonCompatibility */
  545. #define __PYX_BUILD_PY_SSIZE_T "n"
  546. #define CYTHON_FORMAT_SSIZE_T "z"
  547. #define __Pyx_BUILTIN_MODULE_NAME "builtins"
  548. #define __Pyx_DefaultClassType PyType_Type
  549. #if CYTHON_COMPILING_IN_LIMITED_API
  550. #ifndef CO_OPTIMIZED
  551. static int CO_OPTIMIZED;
  552. #endif
  553. #ifndef CO_NEWLOCALS
  554. static int CO_NEWLOCALS;
  555. #endif
  556. #ifndef CO_VARARGS
  557. static int CO_VARARGS;
  558. #endif
  559. #ifndef CO_VARKEYWORDS
  560. static int CO_VARKEYWORDS;
  561. #endif
  562. #ifndef CO_ASYNC_GENERATOR
  563. static int CO_ASYNC_GENERATOR;
  564. #endif
  565. #ifndef CO_GENERATOR
  566. static int CO_GENERATOR;
  567. #endif
  568. #ifndef CO_COROUTINE
  569. static int CO_COROUTINE;
  570. #endif
  571. #else
  572. #ifndef CO_COROUTINE
  573. #define CO_COROUTINE 0x80
  574. #endif
  575. #ifndef CO_ASYNC_GENERATOR
  576. #define CO_ASYNC_GENERATOR 0x200
  577. #endif
  578. #endif
  579. static int __Pyx_init_co_variables(void);
  580. #if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE)
  581. #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type)
  582. #else
  583. #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type))
  584. #endif
  585. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is)
  586. #define __Pyx_Py_Is(x, y) Py_Is(x, y)
  587. #else
  588. #define __Pyx_Py_Is(x, y) ((x) == (y))
  589. #endif
  590. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone)
  591. #define __Pyx_Py_IsNone(ob) Py_IsNone(ob)
  592. #else
  593. #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None)
  594. #endif
  595. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue)
  596. #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob)
  597. #else
  598. #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True)
  599. #endif
  600. #if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse)
  601. #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob)
  602. #else
  603. #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False)
  604. #endif
  605. #define __Pyx_NoneAsNull(obj) (__Pyx_Py_IsNone(obj) ? NULL : (obj))
  606. #if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY
  607. #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
  608. #else
  609. #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
  610. #endif
  611. #ifndef Py_TPFLAGS_CHECKTYPES
  612. #define Py_TPFLAGS_CHECKTYPES 0
  613. #endif
  614. #ifndef Py_TPFLAGS_HAVE_INDEX
  615. #define Py_TPFLAGS_HAVE_INDEX 0
  616. #endif
  617. #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  618. #define Py_TPFLAGS_HAVE_NEWBUFFER 0
  619. #endif
  620. #ifndef Py_TPFLAGS_HAVE_FINALIZE
  621. #define Py_TPFLAGS_HAVE_FINALIZE 0
  622. #endif
  623. #ifndef Py_TPFLAGS_SEQUENCE
  624. #define Py_TPFLAGS_SEQUENCE 0
  625. #endif
  626. #ifndef Py_TPFLAGS_MAPPING
  627. #define Py_TPFLAGS_MAPPING 0
  628. #endif
  629. #ifndef Py_TPFLAGS_IMMUTABLETYPE
  630. #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
  631. #endif
  632. #ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION
  633. #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
  634. #endif
  635. #ifndef METH_STACKLESS
  636. #define METH_STACKLESS 0
  637. #endif
  638. #ifndef METH_FASTCALL
  639. #ifndef METH_FASTCALL
  640. #define METH_FASTCALL 0x80
  641. #endif
  642. typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  643. typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
  644. Py_ssize_t nargs, PyObject *kwnames);
  645. #else
  646. #if PY_VERSION_HEX >= 0x030d00A4
  647. # define __Pyx_PyCFunctionFast PyCFunctionFast
  648. # define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords
  649. #else
  650. # define __Pyx_PyCFunctionFast _PyCFunctionFast
  651. # define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  652. #endif
  653. #endif
  654. #if CYTHON_METH_FASTCALL
  655. #define __Pyx_METH_FASTCALL METH_FASTCALL
  656. #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast
  657. #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords
  658. #else
  659. #define __Pyx_METH_FASTCALL METH_VARARGS
  660. #define __Pyx_PyCFunction_FastCall PyCFunction
  661. #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords
  662. #endif
  663. #if CYTHON_VECTORCALL
  664. #define __pyx_vectorcallfunc vectorcallfunc
  665. #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET PY_VECTORCALL_ARGUMENTS_OFFSET
  666. #define __Pyx_PyVectorcall_NARGS(n) PyVectorcall_NARGS((size_t)(n))
  667. #else
  668. #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET 0
  669. #define __Pyx_PyVectorcall_NARGS(n) ((Py_ssize_t)(n))
  670. #endif
  671. #if PY_VERSION_HEX >= 0x030900B1
  672. #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_CheckExact(func)
  673. #else
  674. #define __Pyx_PyCFunction_CheckExact(func) PyCFunction_Check(func)
  675. #endif
  676. #define __Pyx_CyOrPyCFunction_Check(func) PyCFunction_Check(func)
  677. #if CYTHON_COMPILING_IN_CPYTHON
  678. #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) (((PyCFunctionObject*)(func))->m_ml->ml_meth)
  679. #elif !CYTHON_COMPILING_IN_LIMITED_API
  680. #define __Pyx_CyOrPyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(func)
  681. #endif
  682. #if CYTHON_COMPILING_IN_CPYTHON
  683. #define __Pyx_CyOrPyCFunction_GET_FLAGS(func) (((PyCFunctionObject*)(func))->m_ml->ml_flags)
  684. static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) {
  685. return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self;
  686. }
  687. #endif
  688. static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) {
  689. #if CYTHON_COMPILING_IN_LIMITED_API
  690. return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
  691. #else
  692. return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  693. #endif
  694. }
  695. #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCFunction(func, cfunc)
  696. #if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000)
  697. #define __Pyx_PyType_FromModuleAndSpec(m, s, b) ((void)m, PyType_FromSpecWithBases(s, b))
  698. typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *);
  699. #else
  700. #define __Pyx_PyType_FromModuleAndSpec(m, s, b) PyType_FromModuleAndSpec(m, s, b)
  701. #define __Pyx_PyCMethod PyCMethod
  702. #endif
  703. #ifndef METH_METHOD
  704. #define METH_METHOD 0x200
  705. #endif
  706. #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  707. #define PyObject_Malloc(s) PyMem_Malloc(s)
  708. #define PyObject_Free(p) PyMem_Free(p)
  709. #define PyObject_Realloc(p) PyMem_Realloc(p)
  710. #endif
  711. #if CYTHON_COMPILING_IN_LIMITED_API
  712. #define __Pyx_PyFrame_SetLineNumber(frame, lineno)
  713. #elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  714. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  715. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno))
  716. #elif CYTHON_COMPILING_IN_GRAAL
  717. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  718. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno))
  719. #else
  720. #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
  721. #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
  722. #endif
  723. #if CYTHON_COMPILING_IN_LIMITED_API
  724. #define __Pyx_PyThreadState_Current PyThreadState_Get()
  725. #elif !CYTHON_FAST_THREAD_STATE
  726. #define __Pyx_PyThreadState_Current PyThreadState_GET()
  727. #elif PY_VERSION_HEX >= 0x030d00A1
  728. #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
  729. #else
  730. #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
  731. #endif
  732. #if CYTHON_USE_MODULE_STATE
  733. static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op)
  734. {
  735. void *result;
  736. result = PyModule_GetState(op);
  737. if (!result)
  738. Py_FatalError("Couldn't find the module state");
  739. return result;
  740. }
  741. #define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o)
  742. #else
  743. #define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global)
  744. #endif
  745. #define __Pyx_PyObject_GetSlot(obj, name, func_ctype) __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype)
  746. #define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype)
  747. #define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
  748. #define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
  749. #if CYTHON_USE_TYPE_SLOTS
  750. #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((type)->name)
  751. #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype)
  752. #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL)
  753. #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype)
  754. #else
  755. #define __Pyx_PyType_GetSlot(type, name, func_ctype) ((func_ctype) PyType_GetSlot((type), Py_##name))
  756. #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\
  757. ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\
  758. (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\
  759. __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL)
  760. #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype)
  761. #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype)
  762. #endif
  763. #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
  764. #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
  765. #else
  766. #define __Pyx_PyDict_NewPresized(n) PyDict_New()
  767. #endif
  768. #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
  769. #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
  770. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS
  771. #define __Pyx_PyDict_GetItemStrWithError(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
  772. static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) {
  773. PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name);
  774. if (res == NULL) PyErr_Clear();
  775. return res;
  776. }
  777. #elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000
  778. #define __Pyx_PyDict_GetItemStrWithError PyDict_GetItemWithError
  779. #define __Pyx_PyDict_GetItemStr PyDict_GetItem
  780. #else
  781. static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) {
  782. #if CYTHON_COMPILING_IN_PYPY
  783. return PyDict_GetItem(dict, name);
  784. #else
  785. PyDictEntry *ep;
  786. PyDictObject *mp = (PyDictObject*) dict;
  787. long hash = ((PyStringObject *) name)->ob_shash;
  788. assert(hash != -1);
  789. ep = (mp->ma_lookup)(mp, name, hash);
  790. if (ep == NULL) {
  791. return NULL;
  792. }
  793. return ep->me_value;
  794. #endif
  795. }
  796. #define __Pyx_PyDict_GetItemStr PyDict_GetItem
  797. #endif
  798. #if CYTHON_USE_TYPE_SLOTS
  799. #define __Pyx_PyType_GetFlags(tp) (((PyTypeObject *)tp)->tp_flags)
  800. #define __Pyx_PyType_HasFeature(type, feature) ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
  801. #else
  802. #define __Pyx_PyType_GetFlags(tp) (PyType_GetFlags((PyTypeObject *)tp))
  803. #define __Pyx_PyType_HasFeature(type, feature) PyType_HasFeature(type, feature)
  804. #endif
  805. #define __Pyx_PyObject_GetIterNextFunc(iterator) __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc)
  806. #if CYTHON_USE_TYPE_SPECS
  807. #define __Pyx_PyHeapTypeObject_GC_Del(obj) {\
  808. PyTypeObject *type = Py_TYPE((PyObject*)obj);\
  809. assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\
  810. PyObject_GC_Del(obj);\
  811. Py_DECREF(type);\
  812. }
  813. #else
  814. #define __Pyx_PyHeapTypeObject_GC_Del(obj) PyObject_GC_Del(obj)
  815. #endif
  816. #if CYTHON_COMPILING_IN_LIMITED_API
  817. #define __Pyx_PyUnicode_READY(op) (0)
  818. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
  819. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((void)u, 1114111U)
  820. #define __Pyx_PyUnicode_KIND(u) ((void)u, (0))
  821. #define __Pyx_PyUnicode_DATA(u) ((void*)u)
  822. #define __Pyx_PyUnicode_READ(k, d, i) ((void)k, PyUnicode_ReadChar((PyObject*)(d), i))
  823. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GetLength(u))
  824. #else
  825. #if PY_VERSION_HEX >= 0x030C0000
  826. #define __Pyx_PyUnicode_READY(op) (0)
  827. #else
  828. #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
  829. 0 : _PyUnicode_Ready((PyObject *)(op)))
  830. #endif
  831. #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  832. #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
  833. #define __Pyx_PyUnicode_KIND(u) ((int)PyUnicode_KIND(u))
  834. #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
  835. #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
  836. #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, (Py_UCS4) ch)
  837. #if PY_VERSION_HEX >= 0x030C0000
  838. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
  839. #else
  840. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
  841. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
  842. #else
  843. #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
  844. #endif
  845. #endif
  846. #endif
  847. #if CYTHON_COMPILING_IN_PYPY
  848. #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
  849. #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
  850. #else
  851. #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
  852. #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
  853. PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
  854. #endif
  855. #if CYTHON_COMPILING_IN_PYPY
  856. #if !defined(PyUnicode_DecodeUnicodeEscape)
  857. #define PyUnicode_DecodeUnicodeEscape(s, size, errors) PyUnicode_Decode(s, size, "unicode_escape", errors)
  858. #endif
  859. #if !defined(PyUnicode_Contains)
  860. #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
  861. #endif
  862. #if !defined(PyByteArray_Check)
  863. #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
  864. #endif
  865. #if !defined(PyObject_Format)
  866. #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
  867. #endif
  868. #endif
  869. #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
  870. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  871. #define __Pyx_PySequence_ListKeepNew(obj)\
  872. (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj))
  873. #elif CYTHON_COMPILING_IN_CPYTHON
  874. #define __Pyx_PySequence_ListKeepNew(obj)\
  875. (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj))
  876. #else
  877. #define __Pyx_PySequence_ListKeepNew(obj) PySequence_List(obj)
  878. #endif
  879. #ifndef PySet_CheckExact
  880. #define PySet_CheckExact(obj) __Pyx_IS_TYPE(obj, &PySet_Type)
  881. #endif
  882. #if PY_VERSION_HEX >= 0x030900A4
  883. #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  884. #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
  885. #else
  886. #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  887. #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
  888. #endif
  889. enum __Pyx_ReferenceSharing {
  890. __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check
  891. __Pyx_ReferenceSharing_OwnStrongReference,
  892. __Pyx_ReferenceSharing_FunctionArgument,
  893. __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar
  894. };
  895. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000
  896. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\
  897. (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\
  898. (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\
  899. (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0)))
  900. #elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API
  901. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1)
  902. #else
  903. #define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0)
  904. #endif
  905. #if CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  906. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  907. #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
  908. #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
  909. #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  910. #else
  911. #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i)
  912. #endif
  913. #elif CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
  914. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  915. #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
  916. #else
  917. #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i))
  918. #endif
  919. #else
  920. #define __Pyx_PyList_GetItemRef(o, i) __Pyx_NewRef(PyList_GET_ITEM(o, i))
  921. #endif
  922. #if CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !CYTHON_COMPILING_IN_LIMITED_API && CYTHON_ASSUME_SAFE_MACROS
  923. #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) (__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\
  924. __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i))
  925. #else
  926. #define __Pyx_PyList_GetItemRefFast(o, i, unsafe_shared) __Pyx_PyList_GetItemRef(o, i)
  927. #endif
  928. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  929. #define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result)
  930. #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  931. static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  932. *result = PyObject_GetItem(dict, key);
  933. if (*result == NULL) {
  934. if (PyErr_ExceptionMatches(PyExc_KeyError)) {
  935. PyErr_Clear();
  936. return 0;
  937. }
  938. return -1;
  939. }
  940. return 1;
  941. }
  942. #else
  943. static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  944. *result = PyDict_GetItemWithError(dict, key);
  945. if (*result == NULL) {
  946. return PyErr_Occurred() ? -1 : 0;
  947. }
  948. Py_INCREF(*result);
  949. return 1;
  950. }
  951. #endif
  952. #if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST
  953. #define __Pyx_VISIT_CONST(obj) Py_VISIT(obj)
  954. #else
  955. #define __Pyx_VISIT_CONST(obj)
  956. #endif
  957. #if CYTHON_ASSUME_SAFE_MACROS
  958. #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i)
  959. #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
  960. #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0))
  961. #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i)
  962. #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0))
  963. #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i)
  964. #else
  965. #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i)
  966. #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
  967. #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v)
  968. #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i)
  969. #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v)
  970. #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i)
  971. #endif
  972. #if CYTHON_ASSUME_SAFE_SIZE
  973. #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o)
  974. #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o)
  975. #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o)
  976. #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
  977. #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o)
  978. #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o)
  979. #else
  980. #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o)
  981. #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o)
  982. #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o)
  983. #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o)
  984. #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o)
  985. #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o)
  986. #endif
  987. #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString)
  988. #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
  989. #endif
  990. #define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t
  991. #define __Pyx_PyLong_AsHash_t __Pyx_PyIndex_AsSsize_t
  992. #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
  993. #define __Pyx_PySendResult PySendResult
  994. #else
  995. typedef enum {
  996. PYGEN_RETURN = 0,
  997. PYGEN_ERROR = -1,
  998. PYGEN_NEXT = 1,
  999. } __Pyx_PySendResult;
  1000. #endif
  1001. #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3
  1002. typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
  1003. #else
  1004. #define __Pyx_pyiter_sendfunc sendfunc
  1005. #endif
  1006. #if !CYTHON_USE_AM_SEND
  1007. #define __PYX_HAS_PY_AM_SEND 0
  1008. #elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000
  1009. #define __PYX_HAS_PY_AM_SEND 1
  1010. #else
  1011. #define __PYX_HAS_PY_AM_SEND 2 // our own backported implementation
  1012. #endif
  1013. #if __PYX_HAS_PY_AM_SEND < 2
  1014. #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
  1015. #else
  1016. typedef struct {
  1017. unaryfunc am_await;
  1018. unaryfunc am_aiter;
  1019. unaryfunc am_anext;
  1020. __Pyx_pyiter_sendfunc am_send;
  1021. } __Pyx_PyAsyncMethodsStruct;
  1022. #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s))
  1023. #endif
  1024. #if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0
  1025. #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21)
  1026. #else
  1027. #define __Pyx_TPFLAGS_HAVE_AM_SEND (0)
  1028. #endif
  1029. #if PY_VERSION_HEX >= 0x03090000
  1030. #define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get()
  1031. #else
  1032. #define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp
  1033. #endif
  1034. #if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000
  1035. #ifdef __cplusplus
  1036. extern "C"
  1037. #endif
  1038. PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
  1039. #endif
  1040. #if CYTHON_COMPILING_IN_LIMITED_API
  1041. static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) {
  1042. int value;
  1043. PyObject *py_value = PyObject_GetAttrString(inspect, name);
  1044. if (!py_value) return 0;
  1045. value = (int) PyLong_AsLong(py_value);
  1046. Py_DECREF(py_value);
  1047. *write_to = value;
  1048. return value != -1 || !PyErr_Occurred();
  1049. }
  1050. static int __Pyx_init_co_variables(void) {
  1051. PyObject *inspect;
  1052. int result;
  1053. inspect = PyImport_ImportModule("inspect");
  1054. result =
  1055. #if !defined(CO_OPTIMIZED)
  1056. __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) &&
  1057. #endif
  1058. #if !defined(CO_NEWLOCALS)
  1059. __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) &&
  1060. #endif
  1061. #if !defined(CO_VARARGS)
  1062. __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) &&
  1063. #endif
  1064. #if !defined(CO_VARKEYWORDS)
  1065. __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) &&
  1066. #endif
  1067. #if !defined(CO_ASYNC_GENERATOR)
  1068. __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) &&
  1069. #endif
  1070. #if !defined(CO_GENERATOR)
  1071. __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) &&
  1072. #endif
  1073. #if !defined(CO_COROUTINE)
  1074. __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) &&
  1075. #endif
  1076. 1;
  1077. Py_DECREF(inspect);
  1078. return result ? 0 : -1;
  1079. }
  1080. #else
  1081. static int __Pyx_init_co_variables(void) {
  1082. return 0; // It's a limited API-only feature
  1083. }
  1084. #endif
  1085. /* MathInitCode */
  1086. #if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  1087. #ifndef _USE_MATH_DEFINES
  1088. #define _USE_MATH_DEFINES
  1089. #endif
  1090. #endif
  1091. #include <math.h>
  1092. #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
  1093. #define __Pyx_truncl trunc
  1094. #else
  1095. #define __Pyx_truncl truncl
  1096. #endif
  1097. #ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  1098. #define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0
  1099. #endif
  1100. #ifndef CYTHON_CLINE_IN_TRACEBACK
  1101. #define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  1102. #endif
  1103. #if CYTHON_CLINE_IN_TRACEBACK
  1104. #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; }
  1105. #else
  1106. #define __PYX_MARK_ERR_POS(f_index, lineno) { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; }
  1107. #endif
  1108. #define __PYX_ERR(f_index, lineno, Ln_error) \
  1109. { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
  1110. #ifdef CYTHON_EXTERN_C
  1111. #undef __PYX_EXTERN_C
  1112. #define __PYX_EXTERN_C CYTHON_EXTERN_C
  1113. #elif defined(__PYX_EXTERN_C)
  1114. #ifdef _MSC_VER
  1115. #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
  1116. #else
  1117. #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
  1118. #endif
  1119. #else
  1120. #ifdef __cplusplus
  1121. #define __PYX_EXTERN_C extern "C"
  1122. #else
  1123. #define __PYX_EXTERN_C extern
  1124. #endif
  1125. #endif
  1126. #define __PYX_HAVE__fontTools__cu2qu__cu2qu
  1127. #define __PYX_HAVE_API__fontTools__cu2qu__cu2qu
  1128. /* Early includes */
  1129. #ifdef _OPENMP
  1130. #include <omp.h>
  1131. #endif /* _OPENMP */
  1132. #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
  1133. #define CYTHON_WITHOUT_ASSERTIONS
  1134. #endif
  1135. #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
  1136. #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
  1137. #define __PYX_DEFAULT_STRING_ENCODING ""
  1138. #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
  1139. #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
  1140. #define __Pyx_uchar_cast(c) ((unsigned char)c)
  1141. #define __Pyx_long_cast(x) ((long)x)
  1142. #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
  1143. (sizeof(type) < sizeof(Py_ssize_t)) ||\
  1144. (sizeof(type) > sizeof(Py_ssize_t) &&\
  1145. likely(v < (type)PY_SSIZE_T_MAX ||\
  1146. v == (type)PY_SSIZE_T_MAX) &&\
  1147. (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
  1148. v == (type)PY_SSIZE_T_MIN))) ||\
  1149. (sizeof(type) == sizeof(Py_ssize_t) &&\
  1150. (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
  1151. v == (type)PY_SSIZE_T_MAX))) )
  1152. static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
  1153. return (size_t) i < (size_t) limit;
  1154. }
  1155. #if defined (__cplusplus) && __cplusplus >= 201103L
  1156. #include <cstdlib>
  1157. #define __Pyx_sst_abs(value) std::abs(value)
  1158. #elif SIZEOF_INT >= SIZEOF_SIZE_T
  1159. #define __Pyx_sst_abs(value) abs(value)
  1160. #elif SIZEOF_LONG >= SIZEOF_SIZE_T
  1161. #define __Pyx_sst_abs(value) labs(value)
  1162. #elif defined (_MSC_VER)
  1163. #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
  1164. #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  1165. #define __Pyx_sst_abs(value) llabs(value)
  1166. #elif defined (__GNUC__)
  1167. #define __Pyx_sst_abs(value) __builtin_llabs(value)
  1168. #else
  1169. #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
  1170. #endif
  1171. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s);
  1172. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
  1173. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
  1174. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*);
  1175. #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
  1176. #define __Pyx_PyBytes_FromString PyBytes_FromString
  1177. #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
  1178. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
  1179. #if CYTHON_ASSUME_SAFE_MACROS
  1180. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
  1181. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
  1182. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
  1183. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
  1184. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
  1185. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
  1186. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s)
  1187. #else
  1188. #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AsString(s))
  1189. #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AsString(s))
  1190. #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AsString(s))
  1191. #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AsString(s))
  1192. #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AsString(s))
  1193. #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AsString(s))
  1194. #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s)
  1195. #endif
  1196. #define __Pyx_PyObject_AsWritableString(s) ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1197. #define __Pyx_PyObject_AsWritableSString(s) ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1198. #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
  1199. #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
  1200. #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
  1201. #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
  1202. #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
  1203. #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
  1204. #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
  1205. #define __Pyx_PyUnicode_FromOrdinal(o) PyUnicode_FromOrdinal((int)o)
  1206. #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
  1207. static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) {
  1208. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef)
  1209. return Py_NewRef(obj);
  1210. #else
  1211. Py_INCREF(obj);
  1212. return obj;
  1213. #endif
  1214. }
  1215. static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) {
  1216. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef)
  1217. return Py_XNewRef(obj);
  1218. #else
  1219. Py_XINCREF(obj);
  1220. return obj;
  1221. #endif
  1222. }
  1223. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b);
  1224. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
  1225. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
  1226. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
  1227. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x);
  1228. #define __Pyx_PySequence_Tuple(obj)\
  1229. (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
  1230. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
  1231. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t);
  1232. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
  1233. #if CYTHON_ASSUME_SAFE_MACROS
  1234. #define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
  1235. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x)
  1236. #else
  1237. #define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
  1238. #define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x)
  1239. #endif
  1240. #define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x))
  1241. #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
  1242. #if CYTHON_USE_PYLONG_INTERNALS
  1243. #if PY_VERSION_HEX >= 0x030C00A7
  1244. #ifndef _PyLong_SIGN_MASK
  1245. #define _PyLong_SIGN_MASK 3
  1246. #endif
  1247. #ifndef _PyLong_NON_SIZE_BITS
  1248. #define _PyLong_NON_SIZE_BITS 3
  1249. #endif
  1250. #define __Pyx_PyLong_Sign(x) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK)
  1251. #define __Pyx_PyLong_IsNeg(x) ((__Pyx_PyLong_Sign(x) & 2) != 0)
  1252. #define __Pyx_PyLong_IsNonNeg(x) (!__Pyx_PyLong_IsNeg(x))
  1253. #define __Pyx_PyLong_IsZero(x) (__Pyx_PyLong_Sign(x) & 1)
  1254. #define __Pyx_PyLong_IsPos(x) (__Pyx_PyLong_Sign(x) == 0)
  1255. #define __Pyx_PyLong_CompactValueUnsigned(x) (__Pyx_PyLong_Digits(x)[0])
  1256. #define __Pyx_PyLong_DigitCount(x) ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS))
  1257. #define __Pyx_PyLong_SignedDigitCount(x)\
  1258. ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x))
  1259. #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue)
  1260. #define __Pyx_PyLong_IsCompact(x) PyUnstable_Long_IsCompact((PyLongObject*) x)
  1261. #define __Pyx_PyLong_CompactValue(x) PyUnstable_Long_CompactValue((PyLongObject*) x)
  1262. #else
  1263. #define __Pyx_PyLong_IsCompact(x) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS))
  1264. #define __Pyx_PyLong_CompactValue(x) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
  1265. #endif
  1266. typedef Py_ssize_t __Pyx_compact_pylong;
  1267. typedef size_t __Pyx_compact_upylong;
  1268. #else
  1269. #define __Pyx_PyLong_IsNeg(x) (Py_SIZE(x) < 0)
  1270. #define __Pyx_PyLong_IsNonNeg(x) (Py_SIZE(x) >= 0)
  1271. #define __Pyx_PyLong_IsZero(x) (Py_SIZE(x) == 0)
  1272. #define __Pyx_PyLong_IsPos(x) (Py_SIZE(x) > 0)
  1273. #define __Pyx_PyLong_CompactValueUnsigned(x) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
  1274. #define __Pyx_PyLong_DigitCount(x) __Pyx_sst_abs(Py_SIZE(x))
  1275. #define __Pyx_PyLong_SignedDigitCount(x) Py_SIZE(x)
  1276. #define __Pyx_PyLong_IsCompact(x) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
  1277. #define __Pyx_PyLong_CompactValue(x)\
  1278. ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
  1279. typedef sdigit __Pyx_compact_pylong;
  1280. typedef digit __Pyx_compact_upylong;
  1281. #endif
  1282. #if PY_VERSION_HEX >= 0x030C00A5
  1283. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->long_value.ob_digit)
  1284. #else
  1285. #define __Pyx_PyLong_Digits(x) (((PyLongObject*)x)->ob_digit)
  1286. #endif
  1287. #endif
  1288. #if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  1289. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
  1290. #elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  1291. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL)
  1292. #else
  1293. #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
  1294. #endif
  1295. /* Test for GCC > 2.95 */
  1296. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  1297. #define likely(x) __builtin_expect(!!(x), 1)
  1298. #define unlikely(x) __builtin_expect(!!(x), 0)
  1299. #else /* !__GNUC__ or GCC < 2.95 */
  1300. #define likely(x) (x)
  1301. #define unlikely(x) (x)
  1302. #endif /* __GNUC__ */
  1303. /* PretendToInitialize */
  1304. #ifdef __cplusplus
  1305. #if __cplusplus > 201103L
  1306. #include <type_traits>
  1307. #endif
  1308. template <typename T>
  1309. static void __Pyx_pretend_to_initialize(T* ptr) {
  1310. #if __cplusplus > 201103L
  1311. if ((std::is_trivially_default_constructible<T>::value))
  1312. #endif
  1313. *ptr = T();
  1314. (void)ptr;
  1315. }
  1316. #else
  1317. static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
  1318. #endif
  1319. #if !CYTHON_USE_MODULE_STATE
  1320. static PyObject *__pyx_m = NULL;
  1321. #endif
  1322. static int __pyx_lineno;
  1323. static int __pyx_clineno = 0;
  1324. static const char * const __pyx_cfilenm = __FILE__;
  1325. static const char *__pyx_filename;
  1326. /* Header.proto */
  1327. #if !defined(CYTHON_CCOMPLEX)
  1328. #if defined(__cplusplus)
  1329. #define CYTHON_CCOMPLEX 1
  1330. #elif (defined(_Complex_I) && !defined(_MSC_VER)) || ((defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_COMPLEX__) && !defined(_MSC_VER))
  1331. #define CYTHON_CCOMPLEX 1
  1332. #else
  1333. #define CYTHON_CCOMPLEX 0
  1334. #endif
  1335. #endif
  1336. #if CYTHON_CCOMPLEX
  1337. #ifdef __cplusplus
  1338. #include <complex>
  1339. #else
  1340. #include <complex.h>
  1341. #endif
  1342. #endif
  1343. #if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
  1344. #undef _Complex_I
  1345. #define _Complex_I 1.0fj
  1346. #endif
  1347. /* #### Code section: filename_table ### */
  1348. static const char* const __pyx_f[] = {
  1349. "Lib/fontTools/cu2qu/cu2qu.py",
  1350. };
  1351. /* #### Code section: utility_code_proto_before_types ### */
  1352. /* Atomics.proto (used by UnpackUnboundCMethod) */
  1353. #include <pythread.h>
  1354. #ifndef CYTHON_ATOMICS
  1355. #define CYTHON_ATOMICS 1
  1356. #endif
  1357. #define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS
  1358. #define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1359. #define __pyx_atomic_int_type int
  1360. #define __pyx_nonatomic_int_type int
  1361. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1362. (__STDC_VERSION__ >= 201112L) &&\
  1363. !defined(__STDC_NO_ATOMICS__))
  1364. #include <stdatomic.h>
  1365. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1366. (__cplusplus >= 201103L) ||\
  1367. (defined(_MSC_VER) && _MSC_VER >= 1700)))
  1368. #include <atomic>
  1369. #endif
  1370. #if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
  1371. (__STDC_VERSION__ >= 201112L) &&\
  1372. !defined(__STDC_NO_ATOMICS__) &&\
  1373. ATOMIC_INT_LOCK_FREE == 2)
  1374. #undef __pyx_atomic_int_type
  1375. #define __pyx_atomic_int_type atomic_int
  1376. #define __pyx_atomic_ptr_type atomic_uintptr_t
  1377. #define __pyx_nonatomic_ptr_type uintptr_t
  1378. #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed)
  1379. #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel)
  1380. #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel)
  1381. #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg)
  1382. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1383. #define __pyx_atomic_load(value) atomic_load(value)
  1384. #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value)
  1385. #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed)
  1386. #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire)
  1387. #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1388. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
  1389. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1390. #pragma message ("Using standard C atomics")
  1391. #elif defined(__PYX_DEBUG_ATOMICS)
  1392. #warning "Using standard C atomics"
  1393. #endif
  1394. #elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
  1395. (__cplusplus >= 201103L) ||\
  1396. \
  1397. (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\
  1398. ATOMIC_INT_LOCK_FREE == 2)
  1399. #undef __pyx_atomic_int_type
  1400. #define __pyx_atomic_int_type std::atomic_int
  1401. #define __pyx_atomic_ptr_type std::atomic_uintptr_t
  1402. #define __pyx_nonatomic_ptr_type uintptr_t
  1403. #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed)
  1404. #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel)
  1405. #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel)
  1406. #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg)
  1407. #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1408. #define __pyx_atomic_load(value) std::atomic_load(value)
  1409. #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value)
  1410. #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed)
  1411. #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire)
  1412. #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
  1413. #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
  1414. #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
  1415. #pragma message ("Using standard C++ atomics")
  1416. #elif defined(__PYX_DEBUG_ATOMICS)
  1417. #warning "Using standard C++ atomics"
  1418. #endif
  1419. #elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\
  1420. (__GNUC_MINOR__ > 1 ||\
  1421. (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2))))
  1422. #define __pyx_atomic_ptr_type void*
  1423. #define __pyx_nonatomic_ptr_type void*
  1424. #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1)
  1425. #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1)
  1426. #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1)
  1427. #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg)
  1428. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1429. __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1430. int result = old == *expected;
  1431. *expected = old;
  1432. return result;
  1433. }
  1434. #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0)
  1435. #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value)
  1436. #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0)
  1437. #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0)
  1438. #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value)
  1439. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1440. __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired);
  1441. int result = old == *expected;
  1442. *expected = old;
  1443. return result;
  1444. }
  1445. #ifdef __PYX_DEBUG_ATOMICS
  1446. #warning "Using GNU atomics"
  1447. #endif
  1448. #elif CYTHON_ATOMICS && defined(_MSC_VER)
  1449. #include <intrin.h>
  1450. #undef __pyx_atomic_int_type
  1451. #define __pyx_atomic_int_type long
  1452. #define __pyx_atomic_ptr_type void*
  1453. #undef __pyx_nonatomic_int_type
  1454. #define __pyx_nonatomic_int_type long
  1455. #define __pyx_nonatomic_ptr_type void*
  1456. #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer)
  1457. #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1)
  1458. #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1)
  1459. #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1)
  1460. #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg)
  1461. static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
  1462. __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected);
  1463. int result = old == *expected;
  1464. *expected = old;
  1465. return result;
  1466. }
  1467. #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0)
  1468. #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value)
  1469. #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value
  1470. #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0)
  1471. #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value)
  1472. static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
  1473. __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected);
  1474. int result = old == *expected;
  1475. *expected = old;
  1476. return result;
  1477. }
  1478. #ifdef __PYX_DEBUG_ATOMICS
  1479. #pragma message ("Using MSVC atomics")
  1480. #endif
  1481. #else
  1482. #undef CYTHON_ATOMICS
  1483. #define CYTHON_ATOMICS 0
  1484. #ifdef __PYX_DEBUG_ATOMICS
  1485. #warning "Not using atomics"
  1486. #endif
  1487. #endif
  1488. /* CriticalSectionsDefinition.proto (used by CriticalSections) */
  1489. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1490. #define __Pyx_PyCriticalSection void*
  1491. #define __Pyx_PyCriticalSection2 void*
  1492. #define __Pyx_PyCriticalSection_End(cs)
  1493. #define __Pyx_PyCriticalSection2_End(cs)
  1494. #else
  1495. #define __Pyx_PyCriticalSection PyCriticalSection
  1496. #define __Pyx_PyCriticalSection2 PyCriticalSection2
  1497. #define __Pyx_PyCriticalSection_End PyCriticalSection_End
  1498. #define __Pyx_PyCriticalSection2_End PyCriticalSection2_End
  1499. #endif
  1500. /* CriticalSections.proto (used by ParseKeywordsImpl) */
  1501. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1502. #define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs)
  1503. #define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs)
  1504. #else
  1505. #define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin
  1506. #define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin
  1507. #endif
  1508. #if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1509. #define __Pyx_BEGIN_CRITICAL_SECTION(o) {
  1510. #define __Pyx_END_CRITICAL_SECTION() }
  1511. #else
  1512. #define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION
  1513. #define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION
  1514. #endif
  1515. /* IncludeStructmemberH.proto (used by FixUpExtensionType) */
  1516. #include <structmember.h>
  1517. /* #### Code section: numeric_typedefs ### */
  1518. /* #### Code section: complex_type_declarations ### */
  1519. /* Declarations.proto */
  1520. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  1521. #ifdef __cplusplus
  1522. typedef ::std::complex< double > __pyx_t_double_complex;
  1523. #else
  1524. typedef double _Complex __pyx_t_double_complex;
  1525. #endif
  1526. #else
  1527. typedef struct { double real, imag; } __pyx_t_double_complex;
  1528. #endif
  1529. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
  1530. /* #### Code section: type_declarations ### */
  1531. /*--- Type declarations ---*/
  1532. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  1533. /* "fontTools/cu2qu/cu2qu.py":150
  1534. *
  1535. *
  1536. * @cython.locals( # <<<<<<<<<<<<<<
  1537. * p0=cython.complex,
  1538. * p1=cython.complex,
  1539. */
  1540. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen {
  1541. PyObject_HEAD
  1542. __pyx_t_double_complex __pyx_v_a;
  1543. __pyx_t_double_complex __pyx_v_a1;
  1544. __pyx_t_double_complex __pyx_v_b;
  1545. __pyx_t_double_complex __pyx_v_b1;
  1546. __pyx_t_double_complex __pyx_v_c;
  1547. __pyx_t_double_complex __pyx_v_c1;
  1548. __pyx_t_double_complex __pyx_v_d;
  1549. __pyx_t_double_complex __pyx_v_d1;
  1550. double __pyx_v_delta_2;
  1551. double __pyx_v_delta_3;
  1552. double __pyx_v_dt;
  1553. int __pyx_v_i;
  1554. int __pyx_v_n;
  1555. __pyx_t_double_complex __pyx_v_p0;
  1556. __pyx_t_double_complex __pyx_v_p1;
  1557. __pyx_t_double_complex __pyx_v_p2;
  1558. __pyx_t_double_complex __pyx_v_p3;
  1559. double __pyx_v_t1;
  1560. double __pyx_v_t1_2;
  1561. int __pyx_t_0;
  1562. int __pyx_t_1;
  1563. int __pyx_t_2;
  1564. };
  1565. /* #### Code section: utility_code_proto ### */
  1566. /* --- Runtime support code (head) --- */
  1567. /* Refnanny.proto */
  1568. #ifndef CYTHON_REFNANNY
  1569. #define CYTHON_REFNANNY 0
  1570. #endif
  1571. #if CYTHON_REFNANNY
  1572. typedef struct {
  1573. void (*INCREF)(void*, PyObject*, Py_ssize_t);
  1574. void (*DECREF)(void*, PyObject*, Py_ssize_t);
  1575. void (*GOTREF)(void*, PyObject*, Py_ssize_t);
  1576. void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
  1577. void* (*SetupContext)(const char*, Py_ssize_t, const char*);
  1578. void (*FinishContext)(void**);
  1579. } __Pyx_RefNannyAPIStruct;
  1580. static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  1581. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  1582. #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  1583. #define __Pyx_RefNannySetupContext(name, acquire_gil)\
  1584. if (acquire_gil) {\
  1585. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1586. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1587. PyGILState_Release(__pyx_gilstate_save);\
  1588. } else {\
  1589. __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
  1590. }
  1591. #define __Pyx_RefNannyFinishContextNogil() {\
  1592. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1593. __Pyx_RefNannyFinishContext();\
  1594. PyGILState_Release(__pyx_gilstate_save);\
  1595. }
  1596. #define __Pyx_RefNannyFinishContextNogil() {\
  1597. PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
  1598. __Pyx_RefNannyFinishContext();\
  1599. PyGILState_Release(__pyx_gilstate_save);\
  1600. }
  1601. #define __Pyx_RefNannyFinishContext()\
  1602. __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  1603. #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1604. #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1605. #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1606. #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  1607. #define __Pyx_XINCREF(r) do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
  1608. #define __Pyx_XDECREF(r) do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
  1609. #define __Pyx_XGOTREF(r) do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
  1610. #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
  1611. #else
  1612. #define __Pyx_RefNannyDeclarations
  1613. #define __Pyx_RefNannySetupContext(name, acquire_gil)
  1614. #define __Pyx_RefNannyFinishContextNogil()
  1615. #define __Pyx_RefNannyFinishContext()
  1616. #define __Pyx_INCREF(r) Py_INCREF(r)
  1617. #define __Pyx_DECREF(r) Py_DECREF(r)
  1618. #define __Pyx_GOTREF(r)
  1619. #define __Pyx_GIVEREF(r)
  1620. #define __Pyx_XINCREF(r) Py_XINCREF(r)
  1621. #define __Pyx_XDECREF(r) Py_XDECREF(r)
  1622. #define __Pyx_XGOTREF(r)
  1623. #define __Pyx_XGIVEREF(r)
  1624. #endif
  1625. #define __Pyx_Py_XDECREF_SET(r, v) do {\
  1626. PyObject *tmp = (PyObject *) r;\
  1627. r = v; Py_XDECREF(tmp);\
  1628. } while (0)
  1629. #define __Pyx_XDECREF_SET(r, v) do {\
  1630. PyObject *tmp = (PyObject *) r;\
  1631. r = v; __Pyx_XDECREF(tmp);\
  1632. } while (0)
  1633. #define __Pyx_DECREF_SET(r, v) do {\
  1634. PyObject *tmp = (PyObject *) r;\
  1635. r = v; __Pyx_DECREF(tmp);\
  1636. } while (0)
  1637. #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
  1638. #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
  1639. /* IncludeStdlibH.proto */
  1640. #include <stdlib.h>
  1641. /* PyObjectCall.proto (used by PyObjectFastCall) */
  1642. #if CYTHON_COMPILING_IN_CPYTHON
  1643. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
  1644. #else
  1645. #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
  1646. #endif
  1647. /* PyObjectCallMethO.proto (used by PyObjectFastCall) */
  1648. #if CYTHON_COMPILING_IN_CPYTHON
  1649. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
  1650. #endif
  1651. /* PyObjectFastCall.proto */
  1652. #define __Pyx_PyObject_FastCall(func, args, nargs) __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
  1653. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs);
  1654. /* PyLongCompare.proto */
  1655. static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
  1656. /* RaiseTooManyValuesToUnpack.proto */
  1657. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
  1658. /* RaiseNeedMoreValuesToUnpack.proto */
  1659. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
  1660. /* PyThreadStateGet.proto (used by PyErrFetchRestore) */
  1661. #if CYTHON_FAST_THREAD_STATE
  1662. #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
  1663. #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
  1664. #if PY_VERSION_HEX >= 0x030C00A6
  1665. #define __Pyx_PyErr_Occurred() (__pyx_tstate->current_exception != NULL)
  1666. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL)
  1667. #else
  1668. #define __Pyx_PyErr_Occurred() (__pyx_tstate->curexc_type != NULL)
  1669. #define __Pyx_PyErr_CurrentExceptionType() (__pyx_tstate->curexc_type)
  1670. #endif
  1671. #else
  1672. #define __Pyx_PyThreadState_declare
  1673. #define __Pyx_PyThreadState_assign
  1674. #define __Pyx_PyErr_Occurred() (PyErr_Occurred() != NULL)
  1675. #define __Pyx_PyErr_CurrentExceptionType() PyErr_Occurred()
  1676. #endif
  1677. /* PyErrFetchRestore.proto (used by IterFinish) */
  1678. #if CYTHON_FAST_THREAD_STATE
  1679. #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
  1680. #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
  1681. #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
  1682. #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
  1683. #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
  1684. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1685. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1686. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
  1687. #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
  1688. #else
  1689. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1690. #endif
  1691. #else
  1692. #define __Pyx_PyErr_Clear() PyErr_Clear()
  1693. #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
  1694. #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
  1695. #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
  1696. #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
  1697. #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
  1698. #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
  1699. #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
  1700. #endif
  1701. /* IterFinish.proto */
  1702. static CYTHON_INLINE int __Pyx_IterFinish(void);
  1703. /* UnpackItemEndCheck.proto */
  1704. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
  1705. /* GetItemInt.proto */
  1706. #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1707. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1708. __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\
  1709. (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
  1710. __Pyx_GetItemInt_Generic(o, to_py_func(i))))
  1711. #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1712. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1713. __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1714. (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  1715. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  1716. int wraparound, int boundscheck, int unsafe_shared);
  1717. #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  1718. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  1719. __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
  1720. (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
  1721. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  1722. int wraparound, int boundscheck, int unsafe_shared);
  1723. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
  1724. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
  1725. int is_list, int wraparound, int boundscheck, int unsafe_shared);
  1726. /* PyErrExceptionMatches.proto (used by PyObjectGetAttrStrNoError) */
  1727. #if CYTHON_FAST_THREAD_STATE
  1728. #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
  1729. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
  1730. #else
  1731. #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
  1732. #endif
  1733. /* PyObjectGetAttrStr.proto (used by PyObjectGetAttrStrNoError) */
  1734. #if CYTHON_USE_TYPE_SLOTS
  1735. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
  1736. #else
  1737. #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
  1738. #endif
  1739. /* PyObjectGetAttrStrNoError.proto (used by GetBuiltinName) */
  1740. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
  1741. /* GetBuiltinName.proto (used by GetModuleGlobalName) */
  1742. static PyObject *__Pyx_GetBuiltinName(PyObject *name);
  1743. /* PyDictVersioning.proto (used by GetModuleGlobalName) */
  1744. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  1745. #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
  1746. #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
  1747. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
  1748. (version_var) = __PYX_GET_DICT_VERSION(dict);\
  1749. (cache_var) = (value);
  1750. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
  1751. static PY_UINT64_T __pyx_dict_version = 0;\
  1752. static PyObject *__pyx_dict_cached_value = NULL;\
  1753. if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
  1754. (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\
  1755. } else {\
  1756. (VAR) = __pyx_dict_cached_value = (LOOKUP);\
  1757. __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
  1758. }\
  1759. }
  1760. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
  1761. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
  1762. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
  1763. #else
  1764. #define __PYX_GET_DICT_VERSION(dict) (0)
  1765. #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
  1766. #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
  1767. #endif
  1768. /* GetModuleGlobalName.proto */
  1769. #if CYTHON_USE_DICT_VERSIONS
  1770. #define __Pyx_GetModuleGlobalName(var, name) do {\
  1771. static PY_UINT64_T __pyx_dict_version = 0;\
  1772. static PyObject *__pyx_dict_cached_value = NULL;\
  1773. (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\
  1774. (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
  1775. __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1776. } while(0)
  1777. #define __Pyx_GetModuleGlobalNameUncached(var, name) do {\
  1778. PY_UINT64_T __pyx_dict_version;\
  1779. PyObject *__pyx_dict_cached_value;\
  1780. (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
  1781. } while(0)
  1782. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
  1783. #else
  1784. #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1785. #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
  1786. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
  1787. #endif
  1788. /* TupleAndListFromArray.proto (used by fastcall) */
  1789. #if CYTHON_COMPILING_IN_CPYTHON
  1790. static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
  1791. #endif
  1792. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL
  1793. static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
  1794. #endif
  1795. /* IncludeStringH.proto (used by BytesEquals) */
  1796. #include <string.h>
  1797. /* BytesEquals.proto (used by UnicodeEquals) */
  1798. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
  1799. /* UnicodeEquals.proto (used by fastcall) */
  1800. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
  1801. /* fastcall.proto */
  1802. #if CYTHON_AVOID_BORROWED_REFS
  1803. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i)
  1804. #elif CYTHON_ASSUME_SAFE_MACROS
  1805. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i))
  1806. #else
  1807. #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i))
  1808. #endif
  1809. #define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
  1810. #define __Pyx_KwValues_VARARGS(args, nargs) NULL
  1811. #define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
  1812. #define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
  1813. #if CYTHON_METH_FASTCALL
  1814. #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i])
  1815. #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds)
  1816. #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
  1817. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
  1818. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  1819. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);
  1820. #else
  1821. #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
  1822. #endif
  1823. #else
  1824. #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS
  1825. #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
  1826. #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
  1827. #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
  1828. #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
  1829. #endif
  1830. #define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1831. #if CYTHON_METH_FASTCALL || (CYTHON_COMPILING_IN_CPYTHON && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  1832. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start)
  1833. #else
  1834. #define __Pyx_ArgsSlice_FASTCALL(args, start, stop) PyTuple_GetSlice(args, start, stop)
  1835. #endif
  1836. /* py_dict_items.proto (used by OwnedDictNext) */
  1837. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
  1838. /* CallCFunction.proto (used by CallUnboundCMethod0) */
  1839. #define __Pyx_CallCFunction(cfunc, self, args)\
  1840. ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args)
  1841. #define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\
  1842. ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs)
  1843. #define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\
  1844. ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs)
  1845. #define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\
  1846. ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames)
  1847. /* PyObjectCallOneArg.proto (used by CallUnboundCMethod0) */
  1848. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
  1849. /* UnpackUnboundCMethod.proto (used by CallUnboundCMethod0) */
  1850. typedef struct {
  1851. PyObject *type;
  1852. PyObject **method_name;
  1853. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
  1854. __pyx_atomic_int_type initialized;
  1855. #endif
  1856. PyCFunction func;
  1857. PyObject *method;
  1858. int flag;
  1859. } __Pyx_CachedCFunction;
  1860. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  1861. static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) {
  1862. #if !CYTHON_ATOMICS
  1863. return 1;
  1864. #else
  1865. __pyx_nonatomic_int_type expected = 0;
  1866. if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) {
  1867. return 0;
  1868. }
  1869. return expected;
  1870. #endif
  1871. }
  1872. static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) {
  1873. #if CYTHON_ATOMICS
  1874. __pyx_atomic_store(&cfunc->initialized, 2);
  1875. #endif
  1876. }
  1877. #else
  1878. #define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2
  1879. #define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc)
  1880. #endif
  1881. /* CallUnboundCMethod0.proto */
  1882. CYTHON_UNUSED
  1883. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1884. #if CYTHON_COMPILING_IN_CPYTHON
  1885. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
  1886. #else
  1887. #define __Pyx_CallUnboundCMethod0(cfunc, self) __Pyx__CallUnboundCMethod0(cfunc, self)
  1888. #endif
  1889. /* py_dict_values.proto (used by OwnedDictNext) */
  1890. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d);
  1891. /* OwnedDictNext.proto (used by ParseKeywordsImpl) */
  1892. #if CYTHON_AVOID_BORROWED_REFS
  1893. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue);
  1894. #else
  1895. CYTHON_INLINE
  1896. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue);
  1897. #endif
  1898. /* RaiseDoubleKeywords.proto (used by ParseKeywordsImpl) */
  1899. static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
  1900. /* ParseKeywordsImpl.export */
  1901. static int __Pyx_ParseKeywordsTuple(
  1902. PyObject *kwds,
  1903. PyObject * const *kwvalues,
  1904. PyObject ** const argnames[],
  1905. PyObject *kwds2,
  1906. PyObject *values[],
  1907. Py_ssize_t num_pos_args,
  1908. Py_ssize_t num_kwargs,
  1909. const char* function_name,
  1910. int ignore_unknown_kwargs
  1911. );
  1912. static int __Pyx_ParseKeywordDictToDict(
  1913. PyObject *kwds,
  1914. PyObject ** const argnames[],
  1915. PyObject *kwds2,
  1916. PyObject *values[],
  1917. Py_ssize_t num_pos_args,
  1918. const char* function_name
  1919. );
  1920. static int __Pyx_ParseKeywordDict(
  1921. PyObject *kwds,
  1922. PyObject ** const argnames[],
  1923. PyObject *values[],
  1924. Py_ssize_t num_pos_args,
  1925. Py_ssize_t num_kwargs,
  1926. const char* function_name,
  1927. int ignore_unknown_kwargs
  1928. );
  1929. /* CallUnboundCMethod2.proto */
  1930. CYTHON_UNUSED
  1931. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
  1932. #if CYTHON_COMPILING_IN_CPYTHON
  1933. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
  1934. #else
  1935. #define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2) __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
  1936. #endif
  1937. /* ParseKeywords.proto */
  1938. static CYTHON_INLINE int __Pyx_ParseKeywords(
  1939. PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[],
  1940. PyObject *kwds2, PyObject *values[],
  1941. Py_ssize_t num_pos_args, Py_ssize_t num_kwargs,
  1942. const char* function_name,
  1943. int ignore_unknown_kwargs
  1944. );
  1945. /* RaiseArgTupleInvalid.proto */
  1946. static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
  1947. Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
  1948. /* GetException.proto (used by pep479) */
  1949. #if CYTHON_FAST_THREAD_STATE
  1950. #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
  1951. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1952. #else
  1953. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
  1954. #endif
  1955. /* pep479.proto */
  1956. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen);
  1957. /* GetTopmostException.proto (used by SaveResetException) */
  1958. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  1959. static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
  1960. #endif
  1961. /* SaveResetException.proto */
  1962. #if CYTHON_FAST_THREAD_STATE
  1963. #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
  1964. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  1965. #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
  1966. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
  1967. #else
  1968. #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
  1969. #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
  1970. #endif
  1971. /* PyZeroDivisionError_Check.proto */
  1972. #define __Pyx_PyExc_ZeroDivisionError_Check(obj) __Pyx_TypeCheck(obj, PyExc_ZeroDivisionError)
  1973. /* IterNextPlain.proto (used by IterNext) */
  1974. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator);
  1975. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  1976. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void);
  1977. #endif
  1978. /* IterNext.proto */
  1979. #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
  1980. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);
  1981. /* ListAppend.proto */
  1982. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  1983. static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
  1984. PyListObject* L = (PyListObject*) list;
  1985. Py_ssize_t len = Py_SIZE(list);
  1986. if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
  1987. Py_INCREF(x);
  1988. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  1989. L->ob_item[len] = x;
  1990. #else
  1991. PyList_SET_ITEM(list, len, x);
  1992. #endif
  1993. __Pyx_SET_SIZE(list, len + 1);
  1994. return 0;
  1995. }
  1996. return PyList_Append(list, x);
  1997. }
  1998. #else
  1999. #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
  2000. #endif
  2001. /* ListCompAppend.proto */
  2002. #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
  2003. static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
  2004. PyListObject* L = (PyListObject*) list;
  2005. Py_ssize_t len = Py_SIZE(list);
  2006. if (likely(L->allocated > len)) {
  2007. Py_INCREF(x);
  2008. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
  2009. L->ob_item[len] = x;
  2010. #else
  2011. PyList_SET_ITEM(list, len, x);
  2012. #endif
  2013. __Pyx_SET_SIZE(list, len + 1);
  2014. return 0;
  2015. }
  2016. return PyList_Append(list, x);
  2017. }
  2018. #else
  2019. #define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
  2020. #endif
  2021. /* PyLongBinop.proto */
  2022. #if !CYTHON_COMPILING_IN_PYPY
  2023. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
  2024. #else
  2025. #define __Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
  2026. (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
  2027. #endif
  2028. /* RaiseException.export */
  2029. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
  2030. /* AssertionsEnabled.proto */
  2031. #if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000
  2032. static int __pyx_assertions_enabled_flag;
  2033. #define __pyx_assertions_enabled() (__pyx_assertions_enabled_flag)
  2034. #if __clang__ || __GNUC__
  2035. __attribute__((no_sanitize("thread")))
  2036. #endif
  2037. static int __Pyx_init_assertions_enabled(void) {
  2038. PyObject *builtins, *debug, *debug_str;
  2039. int flag;
  2040. builtins = PyEval_GetBuiltins();
  2041. if (!builtins) goto bad;
  2042. debug_str = PyUnicode_FromStringAndSize("__debug__", 9);
  2043. if (!debug_str) goto bad;
  2044. debug = PyObject_GetItem(builtins, debug_str);
  2045. Py_DECREF(debug_str);
  2046. if (!debug) goto bad;
  2047. flag = PyObject_IsTrue(debug);
  2048. Py_DECREF(debug);
  2049. if (flag == -1) goto bad;
  2050. __pyx_assertions_enabled_flag = flag;
  2051. return 0;
  2052. bad:
  2053. __pyx_assertions_enabled_flag = 1;
  2054. return -1;
  2055. }
  2056. #else
  2057. #define __Pyx_init_assertions_enabled() (0)
  2058. #define __pyx_assertions_enabled() (!Py_OptimizeFlag)
  2059. #endif
  2060. /* PyAssertionError_Check.proto */
  2061. #define __Pyx_PyExc_AssertionError_Check(obj) __Pyx_TypeCheck(obj, PyExc_AssertionError)
  2062. /* SetItemInt.proto */
  2063. #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
  2064. (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
  2065. __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck, unsafe_shared) :\
  2066. (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
  2067. __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
  2068. static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
  2069. static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
  2070. int is_list, int wraparound, int boundscheck, int unsafe_shared);
  2071. /* ModInt[long].proto */
  2072. static CYTHON_INLINE long __Pyx_mod_long(long, long, int b_is_constant);
  2073. /* CheckTypeForFreelists.proto */
  2074. #if CYTHON_USE_FREELISTS
  2075. #if CYTHON_USE_TYPE_SPECS
  2076. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t) == (expected_tp)))
  2077. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS Py_TPFLAGS_IS_ABSTRACT
  2078. #else
  2079. #define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t)->tp_basicsize == (expected_size)))
  2080. #define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)
  2081. #endif
  2082. #define __PYX_CHECK_TYPE_FOR_FREELISTS(t, expected_tp, expected_size)\
  2083. (__PYX_CHECK_FINAL_TYPE_FOR_FREELISTS((t), (expected_tp), (expected_size)) &\
  2084. (int) (!__Pyx_PyType_HasFeature((t), __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS)))
  2085. #endif
  2086. /* AllocateExtensionType.proto */
  2087. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final);
  2088. /* LimitedApiGetTypeDict.proto (used by SetItemOnTypeDict) */
  2089. #if CYTHON_COMPILING_IN_LIMITED_API
  2090. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp);
  2091. #endif
  2092. /* SetItemOnTypeDict.proto (used by FixUpExtensionType) */
  2093. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v);
  2094. #define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v)
  2095. /* FixUpExtensionType.proto */
  2096. static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type);
  2097. /* PyObjectCallNoArg.proto (used by PyObjectCallMethod0) */
  2098. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
  2099. /* PyObjectGetMethod.proto (used by PyObjectCallMethod0) */
  2100. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  2101. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
  2102. #endif
  2103. /* PyObjectCallMethod0.proto (used by PyType_Ready) */
  2104. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
  2105. /* ValidateBasesTuple.proto (used by PyType_Ready) */
  2106. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  2107. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases);
  2108. #endif
  2109. /* PyType_Ready.proto */
  2110. CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t);
  2111. /* HasAttr.proto (used by ImportImpl) */
  2112. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2113. #define __Pyx_HasAttr(o, n) PyObject_HasAttrWithError(o, n)
  2114. #else
  2115. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
  2116. #endif
  2117. /* ImportImpl.export */
  2118. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level);
  2119. /* Import.proto */
  2120. static CYTHON_INLINE PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level);
  2121. /* ImportFrom.proto */
  2122. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
  2123. /* ListPack.proto */
  2124. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...);
  2125. /* pybytes_as_double.proto (used by pyunicode_as_double) */
  2126. static double __Pyx_SlowPyString_AsDouble(PyObject *obj);
  2127. static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length);
  2128. static CYTHON_INLINE double __Pyx_PyBytes_AsDouble(PyObject *obj) {
  2129. char* as_c_string;
  2130. Py_ssize_t size;
  2131. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  2132. as_c_string = PyBytes_AS_STRING(obj);
  2133. size = PyBytes_GET_SIZE(obj);
  2134. #else
  2135. if (PyBytes_AsStringAndSize(obj, &as_c_string, &size) < 0) {
  2136. return (double)-1;
  2137. }
  2138. #endif
  2139. return __Pyx__PyBytes_AsDouble(obj, as_c_string, size);
  2140. }
  2141. static CYTHON_INLINE double __Pyx_PyByteArray_AsDouble(PyObject *obj) {
  2142. char* as_c_string;
  2143. Py_ssize_t size;
  2144. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  2145. as_c_string = PyByteArray_AS_STRING(obj);
  2146. size = PyByteArray_GET_SIZE(obj);
  2147. #else
  2148. as_c_string = PyByteArray_AsString(obj);
  2149. if (as_c_string == NULL) {
  2150. return (double)-1;
  2151. }
  2152. size = PyByteArray_Size(obj);
  2153. #endif
  2154. return __Pyx__PyBytes_AsDouble(obj, as_c_string, size);
  2155. }
  2156. /* pyunicode_as_double.proto */
  2157. #if !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS
  2158. static const char* __Pyx__PyUnicode_AsDouble_Copy(const void* data, const int kind, char* buffer, Py_ssize_t start, Py_ssize_t end) {
  2159. int last_was_punctuation;
  2160. Py_ssize_t i;
  2161. last_was_punctuation = 1;
  2162. for (i=start; i <= end; i++) {
  2163. Py_UCS4 chr = PyUnicode_READ(kind, data, i);
  2164. int is_punctuation = (chr == '_') | (chr == '.');
  2165. *buffer = (char)chr;
  2166. buffer += (chr != '_');
  2167. if (unlikely(chr > 127)) goto parse_failure;
  2168. if (unlikely(last_was_punctuation & is_punctuation)) goto parse_failure;
  2169. last_was_punctuation = is_punctuation;
  2170. }
  2171. if (unlikely(last_was_punctuation)) goto parse_failure;
  2172. *buffer = '\0';
  2173. return buffer;
  2174. parse_failure:
  2175. return NULL;
  2176. }
  2177. static double __Pyx__PyUnicode_AsDouble_inf_nan(const void* data, int kind, Py_ssize_t start, Py_ssize_t length) {
  2178. int matches = 1;
  2179. Py_UCS4 chr;
  2180. Py_UCS4 sign = PyUnicode_READ(kind, data, start);
  2181. int is_signed = (sign == '-') | (sign == '+');
  2182. start += is_signed;
  2183. length -= is_signed;
  2184. switch (PyUnicode_READ(kind, data, start)) {
  2185. #ifdef Py_NAN
  2186. case 'n':
  2187. case 'N':
  2188. if (unlikely(length != 3)) goto parse_failure;
  2189. chr = PyUnicode_READ(kind, data, start+1);
  2190. matches &= (chr == 'a') | (chr == 'A');
  2191. chr = PyUnicode_READ(kind, data, start+2);
  2192. matches &= (chr == 'n') | (chr == 'N');
  2193. if (unlikely(!matches)) goto parse_failure;
  2194. return (sign == '-') ? -Py_NAN : Py_NAN;
  2195. #endif
  2196. case 'i':
  2197. case 'I':
  2198. if (unlikely(length < 3)) goto parse_failure;
  2199. chr = PyUnicode_READ(kind, data, start+1);
  2200. matches &= (chr == 'n') | (chr == 'N');
  2201. chr = PyUnicode_READ(kind, data, start+2);
  2202. matches &= (chr == 'f') | (chr == 'F');
  2203. if (likely(length == 3 && matches))
  2204. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  2205. if (unlikely(length != 8)) goto parse_failure;
  2206. chr = PyUnicode_READ(kind, data, start+3);
  2207. matches &= (chr == 'i') | (chr == 'I');
  2208. chr = PyUnicode_READ(kind, data, start+4);
  2209. matches &= (chr == 'n') | (chr == 'N');
  2210. chr = PyUnicode_READ(kind, data, start+5);
  2211. matches &= (chr == 'i') | (chr == 'I');
  2212. chr = PyUnicode_READ(kind, data, start+6);
  2213. matches &= (chr == 't') | (chr == 'T');
  2214. chr = PyUnicode_READ(kind, data, start+7);
  2215. matches &= (chr == 'y') | (chr == 'Y');
  2216. if (unlikely(!matches)) goto parse_failure;
  2217. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  2218. case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
  2219. break;
  2220. default:
  2221. goto parse_failure;
  2222. }
  2223. return 0.0;
  2224. parse_failure:
  2225. return -1.0;
  2226. }
  2227. static double __Pyx_PyUnicode_AsDouble_WithSpaces(PyObject *obj) {
  2228. double value;
  2229. const char *last;
  2230. char *end;
  2231. Py_ssize_t start, length = PyUnicode_GET_LENGTH(obj);
  2232. const int kind = PyUnicode_KIND(obj);
  2233. const void* data = PyUnicode_DATA(obj);
  2234. start = 0;
  2235. while (Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, start)))
  2236. start++;
  2237. while (start < length - 1 && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, length - 1)))
  2238. length--;
  2239. length -= start;
  2240. if (unlikely(length <= 0)) goto fallback;
  2241. value = __Pyx__PyUnicode_AsDouble_inf_nan(data, kind, start, length);
  2242. if (unlikely(value == -1.0)) goto fallback;
  2243. if (value != 0.0) return value;
  2244. if (length < 40) {
  2245. char number[40];
  2246. last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length);
  2247. if (unlikely(!last)) goto fallback;
  2248. value = PyOS_string_to_double(number, &end, NULL);
  2249. } else {
  2250. char *number = (char*) PyMem_Malloc((length + 1) * sizeof(char));
  2251. if (unlikely(!number)) goto fallback;
  2252. last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length);
  2253. if (unlikely(!last)) {
  2254. PyMem_Free(number);
  2255. goto fallback;
  2256. }
  2257. value = PyOS_string_to_double(number, &end, NULL);
  2258. PyMem_Free(number);
  2259. }
  2260. if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) {
  2261. return value;
  2262. }
  2263. fallback:
  2264. return __Pyx_SlowPyString_AsDouble(obj);
  2265. }
  2266. #endif
  2267. static CYTHON_INLINE double __Pyx_PyUnicode_AsDouble(PyObject *obj) {
  2268. #if !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS
  2269. if (unlikely(__Pyx_PyUnicode_READY(obj) == -1))
  2270. return (double)-1;
  2271. if (likely(PyUnicode_IS_ASCII(obj))) {
  2272. const char *s;
  2273. Py_ssize_t length;
  2274. s = PyUnicode_AsUTF8AndSize(obj, &length);
  2275. return __Pyx__PyBytes_AsDouble(obj, s, length);
  2276. }
  2277. return __Pyx_PyUnicode_AsDouble_WithSpaces(obj);
  2278. #else
  2279. return __Pyx_SlowPyString_AsDouble(obj);
  2280. #endif
  2281. }
  2282. /* FloatExceptionCheck.proto */
  2283. #define __PYX_CHECK_FLOAT_EXCEPTION(value, error_value)\
  2284. ((error_value) == (error_value) ?\
  2285. (value) == (error_value) :\
  2286. (value) != (value))
  2287. /* dict_setdefault.proto (used by FetchCommonType) */
  2288. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value);
  2289. /* AddModuleRef.proto (used by FetchSharedCythonModule) */
  2290. #if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\
  2291. __PYX_LIMITED_VERSION_HEX < 0x030d0000)
  2292. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name);
  2293. #else
  2294. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  2295. #endif
  2296. /* FetchSharedCythonModule.proto (used by FetchCommonType) */
  2297. static PyObject *__Pyx_FetchSharedCythonABIModule(void);
  2298. /* FetchCommonType.proto (used by CommonTypesMetaclass) */
  2299. static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases);
  2300. /* CommonTypesMetaclass.proto (used by CythonFunctionShared) */
  2301. static int __pyx_CommonTypesMetaclass_init(PyObject *module);
  2302. #define __Pyx_CommonTypesMetaclass_USED
  2303. /* CallTypeTraverse.proto (used by CythonFunctionShared) */
  2304. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  2305. #define __Pyx_call_type_traverse(o, always_call, visit, arg) 0
  2306. #else
  2307. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg);
  2308. #endif
  2309. /* PyMethodNew.proto (used by CythonFunctionShared) */
  2310. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ);
  2311. /* PyVectorcallFastCallDict.proto (used by CythonFunctionShared) */
  2312. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  2313. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
  2314. #endif
  2315. /* CythonFunctionShared.proto (used by CythonFunction) */
  2316. #define __Pyx_CyFunction_USED
  2317. #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
  2318. #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
  2319. #define __Pyx_CYFUNCTION_CCLASS 0x04
  2320. #define __Pyx_CYFUNCTION_COROUTINE 0x08
  2321. #define __Pyx_CyFunction_GetClosure(f)\
  2322. (((__pyx_CyFunctionObject *) (f))->func_closure)
  2323. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2324. #define __Pyx_CyFunction_GetClassObj(f)\
  2325. (((__pyx_CyFunctionObject *) (f))->func_classobj)
  2326. #else
  2327. #define __Pyx_CyFunction_GetClassObj(f)\
  2328. ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
  2329. #endif
  2330. #define __Pyx_CyFunction_SetClassObj(f, classobj)\
  2331. __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
  2332. #define __Pyx_CyFunction_Defaults(type, f)\
  2333. ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
  2334. #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
  2335. ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
  2336. typedef struct {
  2337. #if CYTHON_COMPILING_IN_LIMITED_API
  2338. PyObject_HEAD
  2339. PyObject *func;
  2340. #elif PY_VERSION_HEX < 0x030900B1
  2341. PyCFunctionObject func;
  2342. #else
  2343. PyCMethodObject func;
  2344. #endif
  2345. #if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL
  2346. __pyx_vectorcallfunc func_vectorcall;
  2347. #endif
  2348. #if CYTHON_COMPILING_IN_LIMITED_API
  2349. PyObject *func_weakreflist;
  2350. #endif
  2351. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2352. PyObject *func_dict;
  2353. #endif
  2354. PyObject *func_name;
  2355. PyObject *func_qualname;
  2356. PyObject *func_doc;
  2357. PyObject *func_globals;
  2358. PyObject *func_code;
  2359. PyObject *func_closure;
  2360. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  2361. PyObject *func_classobj;
  2362. #endif
  2363. PyObject *defaults;
  2364. int flags;
  2365. PyObject *defaults_tuple;
  2366. PyObject *defaults_kwdict;
  2367. PyObject *(*defaults_getter)(PyObject *);
  2368. PyObject *func_annotations;
  2369. PyObject *func_is_coroutine;
  2370. } __pyx_CyFunctionObject;
  2371. #undef __Pyx_CyOrPyCFunction_Check
  2372. #define __Pyx_CyFunction_Check(obj) __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2373. #define __Pyx_CyOrPyCFunction_Check(obj) __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type)
  2374. #define __Pyx_CyFunction_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType)
  2375. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));
  2376. #undef __Pyx_IsSameCFunction
  2377. #define __Pyx_IsSameCFunction(func, cfunc) __Pyx__IsSameCyOrCFunction(func, cfunc)
  2378. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
  2379. int flags, PyObject* qualname,
  2380. PyObject *closure,
  2381. PyObject *module, PyObject *globals,
  2382. PyObject* code);
  2383. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
  2384. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
  2385. PyTypeObject *defaults_type);
  2386. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
  2387. PyObject *tuple);
  2388. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
  2389. PyObject *dict);
  2390. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
  2391. PyObject *dict);
  2392. static int __pyx_CyFunction_init(PyObject *module);
  2393. #if CYTHON_METH_FASTCALL
  2394. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2395. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2396. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2397. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
  2398. #if CYTHON_COMPILING_IN_LIMITED_API
  2399. #define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
  2400. #else
  2401. #define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
  2402. #endif
  2403. #endif
  2404. /* CythonFunction.proto */
  2405. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
  2406. int flags, PyObject* qualname,
  2407. PyObject *closure,
  2408. PyObject *module, PyObject *globals,
  2409. PyObject* code);
  2410. /* CLineInTraceback.proto (used by AddTraceback) */
  2411. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  2412. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
  2413. #else
  2414. #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
  2415. #endif
  2416. /* CodeObjectCache.proto (used by AddTraceback) */
  2417. #if CYTHON_COMPILING_IN_LIMITED_API
  2418. typedef PyObject __Pyx_CachedCodeObjectType;
  2419. #else
  2420. typedef PyCodeObject __Pyx_CachedCodeObjectType;
  2421. #endif
  2422. typedef struct {
  2423. __Pyx_CachedCodeObjectType* code_object;
  2424. int code_line;
  2425. } __Pyx_CodeObjectCacheEntry;
  2426. struct __Pyx_CodeObjectCache {
  2427. int count;
  2428. int max_count;
  2429. __Pyx_CodeObjectCacheEntry* entries;
  2430. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  2431. __pyx_atomic_int_type accessor_count;
  2432. #endif
  2433. };
  2434. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
  2435. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line);
  2436. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object);
  2437. /* AddTraceback.proto */
  2438. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  2439. int py_line, const char *filename);
  2440. /* RealImag.proto */
  2441. #if CYTHON_CCOMPLEX
  2442. #ifdef __cplusplus
  2443. #define __Pyx_CREAL(z) ((z).real())
  2444. #define __Pyx_CIMAG(z) ((z).imag())
  2445. #else
  2446. #define __Pyx_CREAL(z) (__real__(z))
  2447. #define __Pyx_CIMAG(z) (__imag__(z))
  2448. #endif
  2449. #else
  2450. #define __Pyx_CREAL(z) ((z).real)
  2451. #define __Pyx_CIMAG(z) ((z).imag)
  2452. #endif
  2453. #if defined(__cplusplus) && CYTHON_CCOMPLEX\
  2454. && (defined(_WIN32) || defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 5 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4 )) || __cplusplus >= 201103)
  2455. #define __Pyx_SET_CREAL(z,x) ((z).real(x))
  2456. #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
  2457. #else
  2458. #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
  2459. #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
  2460. #endif
  2461. /* Arithmetic.proto */
  2462. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  2463. #define __Pyx_c_eq_double(a, b) ((a)==(b))
  2464. #define __Pyx_c_sum_double(a, b) ((a)+(b))
  2465. #define __Pyx_c_diff_double(a, b) ((a)-(b))
  2466. #define __Pyx_c_prod_double(a, b) ((a)*(b))
  2467. #define __Pyx_c_quot_double(a, b) ((a)/(b))
  2468. #define __Pyx_c_neg_double(a) (-(a))
  2469. #ifdef __cplusplus
  2470. #define __Pyx_c_is_zero_double(z) ((z)==(double)0)
  2471. #define __Pyx_c_conj_double(z) (::std::conj(z))
  2472. #if 1
  2473. #define __Pyx_c_abs_double(z) (::std::abs(z))
  2474. #define __Pyx_c_pow_double(a, b) (::std::pow(a, b))
  2475. #endif
  2476. #else
  2477. #define __Pyx_c_is_zero_double(z) ((z)==0)
  2478. #define __Pyx_c_conj_double(z) (conj(z))
  2479. #if 1
  2480. #define __Pyx_c_abs_double(z) (cabs(z))
  2481. #define __Pyx_c_pow_double(a, b) (cpow(a, b))
  2482. #endif
  2483. #endif
  2484. #else
  2485. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2486. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2487. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2488. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2489. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2490. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex);
  2491. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex);
  2492. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex);
  2493. #if 1
  2494. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex);
  2495. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex, __pyx_t_double_complex);
  2496. #endif
  2497. #endif
  2498. /* FromPy.proto */
  2499. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject*);
  2500. /* GCCDiagnostics.proto */
  2501. #if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
  2502. #define __Pyx_HAS_GCC_DIAGNOSTIC
  2503. #endif
  2504. /* ToPy.proto */
  2505. #define __pyx_PyComplex_FromComplex(z)\
  2506. PyComplex_FromDoubles((double)__Pyx_CREAL(z),\
  2507. (double)__Pyx_CIMAG(z))
  2508. /* CIntFromPy.proto */
  2509. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *);
  2510. /* PyObjectVectorCallKwBuilder.proto (used by CIntToPy) */
  2511. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2512. #if CYTHON_VECTORCALL
  2513. #if PY_VERSION_HEX >= 0x03090000
  2514. #define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall
  2515. #else
  2516. #define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall
  2517. #endif
  2518. #define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n)
  2519. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2520. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n);
  2521. #else
  2522. #define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict
  2523. #define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n)
  2524. #define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value)
  2525. #define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value)
  2526. #endif
  2527. /* CIntToPy.proto */
  2528. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value);
  2529. /* CIntToPy.proto */
  2530. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value);
  2531. /* FormatTypeName.proto */
  2532. #if CYTHON_COMPILING_IN_LIMITED_API
  2533. typedef PyObject *__Pyx_TypeName;
  2534. #define __Pyx_FMT_TYPENAME "%U"
  2535. #define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
  2536. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  2537. #define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName
  2538. #else
  2539. static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp);
  2540. #endif
  2541. #else // !LIMITED_API
  2542. typedef const char *__Pyx_TypeName;
  2543. #define __Pyx_FMT_TYPENAME "%.200s"
  2544. #define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name)
  2545. #define __Pyx_DECREF_TypeName(obj)
  2546. #endif
  2547. /* CIntFromPy.proto */
  2548. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *);
  2549. /* FastTypeChecks.proto */
  2550. #if CYTHON_COMPILING_IN_CPYTHON
  2551. #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
  2552. #define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
  2553. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
  2554. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);
  2555. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
  2556. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
  2557. #else
  2558. #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
  2559. #define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
  2560. #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
  2561. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) {
  2562. return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2);
  2563. }
  2564. #endif
  2565. #define __Pyx_PyErr_ExceptionMatches2(err1, err2) __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2)
  2566. #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
  2567. #ifdef PyExceptionInstance_Check
  2568. #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj)
  2569. #else
  2570. #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException)
  2571. #endif
  2572. /* GetRuntimeVersion.proto */
  2573. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  2574. static unsigned long __Pyx_cached_runtime_version = 0;
  2575. static void __Pyx_init_runtime_version(void);
  2576. #else
  2577. #define __Pyx_init_runtime_version()
  2578. #endif
  2579. static unsigned long __Pyx_get_runtime_version(void);
  2580. /* SwapException.proto (used by CoroutineBase) */
  2581. #if CYTHON_FAST_THREAD_STATE
  2582. #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
  2583. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
  2584. #else
  2585. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
  2586. #endif
  2587. /* PyObjectCall2Args.proto (used by PyObjectCallMethod1) */
  2588. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
  2589. /* PyObjectCallMethod1.proto (used by CoroutineBase) */
  2590. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
  2591. /* ReturnWithStopIteration.proto (used by CoroutineBase) */
  2592. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext);
  2593. /* CoroutineBase.proto (used by Generator) */
  2594. struct __pyx_CoroutineObject;
  2595. typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *);
  2596. #if CYTHON_USE_EXC_INFO_STACK
  2597. #define __Pyx_ExcInfoStruct _PyErr_StackItem
  2598. #else
  2599. typedef struct {
  2600. PyObject *exc_type;
  2601. PyObject *exc_value;
  2602. PyObject *exc_traceback;
  2603. } __Pyx_ExcInfoStruct;
  2604. #endif
  2605. typedef struct __pyx_CoroutineObject {
  2606. PyObject_HEAD
  2607. __pyx_coroutine_body_t body;
  2608. PyObject *closure;
  2609. __Pyx_ExcInfoStruct gi_exc_state;
  2610. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  2611. PyObject *gi_weakreflist;
  2612. #endif
  2613. PyObject *classobj;
  2614. PyObject *yieldfrom;
  2615. __Pyx_pyiter_sendfunc yieldfrom_am_send;
  2616. PyObject *gi_name;
  2617. PyObject *gi_qualname;
  2618. PyObject *gi_modulename;
  2619. PyObject *gi_code;
  2620. PyObject *gi_frame;
  2621. #if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
  2622. PyMonitoringState __pyx_pymonitoring_state[__Pyx_MonitoringEventTypes_CyGen_count];
  2623. uint64_t __pyx_pymonitoring_version;
  2624. #endif
  2625. int resume_label;
  2626. char is_running;
  2627. } __pyx_CoroutineObject;
  2628. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  2629. PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2630. PyObject *name, PyObject *qualname, PyObject *module_name);
  2631. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  2632. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  2633. PyObject *name, PyObject *qualname, PyObject *module_name);
  2634. static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
  2635. static int __Pyx_Coroutine_clear(PyObject *self);
  2636. static __Pyx_PySendResult __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval);
  2637. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
  2638. static __Pyx_PySendResult __Pyx_Coroutine_Close(PyObject *self, PyObject **retval);
  2639. static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
  2640. #if CYTHON_USE_EXC_INFO_STACK
  2641. #define __Pyx_Coroutine_SwapException(self)
  2642. #define __Pyx_Coroutine_ResetAndClearException(self) __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
  2643. #else
  2644. #define __Pyx_Coroutine_SwapException(self) {\
  2645. __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
  2646. __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
  2647. }
  2648. #define __Pyx_Coroutine_ResetAndClearException(self) {\
  2649. __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
  2650. (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
  2651. }
  2652. #endif
  2653. #if CYTHON_FAST_THREAD_STATE
  2654. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2655. __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
  2656. #else
  2657. #define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
  2658. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
  2659. #endif
  2660. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
  2661. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
  2662. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen);
  2663. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen);
  2664. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen);
  2665. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure);
  2666. #if __PYX_HAS_PY_AM_SEND == 2
  2667. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send);
  2668. #endif
  2669. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg);
  2670. /* Generator.proto */
  2671. #define __Pyx_Generator_USED
  2672. #define __Pyx_Generator_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_GeneratorType)
  2673. #define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
  2674. __Pyx__Coroutine_New(__pyx_mstate_global->__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
  2675. static PyObject *__Pyx_Generator_Next(PyObject *self);
  2676. static int __pyx_Generator_init(PyObject *module);
  2677. static CYTHON_INLINE PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self);
  2678. /* CheckBinaryVersion.proto */
  2679. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);
  2680. /* DecompressString.proto */
  2681. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo);
  2682. /* MultiPhaseInitModuleState.proto */
  2683. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  2684. static PyObject *__Pyx_State_FindModule(void*);
  2685. static int __Pyx_State_AddModule(PyObject* module, void*);
  2686. static int __Pyx_State_RemoveModule(void*);
  2687. #elif CYTHON_USE_MODULE_STATE
  2688. #define __Pyx_State_FindModule PyState_FindModule
  2689. #define __Pyx_State_AddModule PyState_AddModule
  2690. #define __Pyx_State_RemoveModule PyState_RemoveModule
  2691. #endif
  2692. /* #### Code section: module_declarations ### */
  2693. /* CythonABIVersion.proto */
  2694. #if CYTHON_COMPILING_IN_LIMITED_API
  2695. #if CYTHON_METH_FASTCALL
  2696. #define __PYX_FASTCALL_ABI_SUFFIX "_fastcall"
  2697. #else
  2698. #define __PYX_FASTCALL_ABI_SUFFIX
  2699. #endif
  2700. #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
  2701. #else
  2702. #define __PYX_LIMITED_ABI_SUFFIX
  2703. #endif
  2704. #if __PYX_HAS_PY_AM_SEND == 1
  2705. #define __PYX_AM_SEND_ABI_SUFFIX
  2706. #elif __PYX_HAS_PY_AM_SEND == 2
  2707. #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport"
  2708. #else
  2709. #define __PYX_AM_SEND_ABI_SUFFIX "noamsend"
  2710. #endif
  2711. #ifndef __PYX_MONITORING_ABI_SUFFIX
  2712. #define __PYX_MONITORING_ABI_SUFFIX
  2713. #endif
  2714. #if CYTHON_USE_TP_FINALIZE
  2715. #define __PYX_TP_FINALIZE_ABI_SUFFIX
  2716. #else
  2717. #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize"
  2718. #endif
  2719. #if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED)
  2720. #define __PYX_FREELISTS_ABI_SUFFIX
  2721. #else
  2722. #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists"
  2723. #endif
  2724. #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
  2725. #define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
  2726. #define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."
  2727. /* Module declarations from "cython" */
  2728. /* Module declarations from "fontTools.cu2qu.cu2qu" */
  2729. static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2730. static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu__complex_div_by_real(__pyx_t_double_complex, double); /*proto*/
  2731. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2732. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2733. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, PyObject *); /*proto*/
  2734. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2735. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2736. static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(double, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2737. static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex); /*proto*/
  2738. static int __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, __pyx_t_double_complex, double); /*proto*/
  2739. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *, double); /*proto*/
  2740. static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(PyObject *, int, double, int); /*proto*/
  2741. /* #### Code section: typeinfo ### */
  2742. /* #### Code section: before_global_var ### */
  2743. #define __Pyx_MODULE_NAME "fontTools.cu2qu.cu2qu"
  2744. extern int __pyx_module_is_main_fontTools__cu2qu__cu2qu;
  2745. int __pyx_module_is_main_fontTools__cu2qu__cu2qu = 0;
  2746. /* Implementation of "fontTools.cu2qu.cu2qu" */
  2747. /* #### Code section: global_var ### */
  2748. /* #### Code section: string_decls ### */
  2749. /* #### Code section: decls ### */
  2750. static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(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, __pyx_t_double_complex __pyx_v_p3, int __pyx_v_n); /* proto */
  2751. static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curve, double __pyx_v_max_err, int __pyx_v_all_quadratic); /* proto */
  2752. static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curves, PyObject *__pyx_v_max_errors, int __pyx_v_all_quadratic); /* proto */
  2753. static PyObject *__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
  2754. /* #### Code section: late_includes ### */
  2755. /* #### Code section: module_state ### */
  2756. /* SmallCodeConfig */
  2757. #ifndef CYTHON_SMALL_CODE
  2758. #if defined(__clang__)
  2759. #define CYTHON_SMALL_CODE
  2760. #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  2761. #define CYTHON_SMALL_CODE __attribute__((cold))
  2762. #else
  2763. #define CYTHON_SMALL_CODE
  2764. #endif
  2765. #endif
  2766. typedef struct {
  2767. PyObject *__pyx_d;
  2768. PyObject *__pyx_b;
  2769. PyObject *__pyx_cython_runtime;
  2770. PyObject *__pyx_empty_tuple;
  2771. PyObject *__pyx_empty_bytes;
  2772. PyObject *__pyx_empty_unicode;
  2773. PyObject *__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  2774. PyTypeObject *__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  2775. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items;
  2776. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop;
  2777. __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values;
  2778. PyObject *__pyx_codeobj_tab[3];
  2779. PyObject *__pyx_string_tab[80];
  2780. PyObject *__pyx_number_tab[6];
  2781. /* #### Code section: module_state_contents ### */
  2782. /* IterNextPlain.module_state_decls */
  2783. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  2784. PyObject *__Pyx_GetBuiltinNext_LimitedAPI_cache;
  2785. #endif
  2786. #if CYTHON_USE_FREELISTS
  2787. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[8];
  2788. int __pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  2789. #endif
  2790. /* CommonTypesMetaclass.module_state_decls */
  2791. PyTypeObject *__pyx_CommonTypesMetaclassType;
  2792. /* CachedMethodType.module_state_decls */
  2793. #if CYTHON_COMPILING_IN_LIMITED_API
  2794. PyObject *__Pyx_CachedMethodType;
  2795. #endif
  2796. /* CythonFunctionShared.module_state_decls */
  2797. PyTypeObject *__pyx_CyFunctionType;
  2798. /* CodeObjectCache.module_state_decls */
  2799. struct __Pyx_CodeObjectCache __pyx_code_cache;
  2800. /* Generator.module_state_decls */
  2801. PyTypeObject *__pyx_GeneratorType;
  2802. /* #### Code section: module_state_end ### */
  2803. } __pyx_mstatetype;
  2804. #if CYTHON_USE_MODULE_STATE
  2805. #ifdef __cplusplus
  2806. namespace {
  2807. extern struct PyModuleDef __pyx_moduledef;
  2808. } /* anonymous namespace */
  2809. #else
  2810. static struct PyModuleDef __pyx_moduledef;
  2811. #endif
  2812. #define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef)))
  2813. #define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef))
  2814. #else
  2815. static __pyx_mstatetype __pyx_mstate_global_static =
  2816. #ifdef __cplusplus
  2817. {};
  2818. #else
  2819. {0};
  2820. #endif
  2821. static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static;
  2822. #endif
  2823. /* #### Code section: constant_name_defines ### */
  2824. #define __pyx_kp_u_ __pyx_string_tab[0]
  2825. #define __pyx_kp_u_Lib_fontTools_cu2qu_cu2qu_py __pyx_string_tab[1]
  2826. #define __pyx_kp_u_Return_quadratic_Bezier_splines __pyx_string_tab[2]
  2827. #define __pyx_kp_u__2 __pyx_string_tab[3]
  2828. #define __pyx_kp_u_curves_to_quadratic_line_503 __pyx_string_tab[4]
  2829. #define __pyx_kp_u_disable __pyx_string_tab[5]
  2830. #define __pyx_kp_u_enable __pyx_string_tab[6]
  2831. #define __pyx_kp_u_fontTools_cu2qu_errors __pyx_string_tab[7]
  2832. #define __pyx_kp_u_gc __pyx_string_tab[8]
  2833. #define __pyx_kp_u_isenabled __pyx_string_tab[9]
  2834. #define __pyx_n_u_ApproxNotFoundError __pyx_string_tab[10]
  2835. #define __pyx_n_u_COMPILED __pyx_string_tab[11]
  2836. #define __pyx_n_u_Cu2QuError __pyx_string_tab[12]
  2837. #define __pyx_n_u_Error __pyx_string_tab[13]
  2838. #define __pyx_n_u_MAX_N __pyx_string_tab[14]
  2839. #define __pyx_n_u_NAN __pyx_string_tab[15]
  2840. #define __pyx_n_u_NaN __pyx_string_tab[16]
  2841. #define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[17]
  2842. #define __pyx_n_u_a __pyx_string_tab[18]
  2843. #define __pyx_n_u_a1 __pyx_string_tab[19]
  2844. #define __pyx_n_u_all __pyx_string_tab[20]
  2845. #define __pyx_n_u_all_quadratic __pyx_string_tab[21]
  2846. #define __pyx_n_u_asyncio_coroutines __pyx_string_tab[22]
  2847. #define __pyx_n_u_b __pyx_string_tab[23]
  2848. #define __pyx_n_u_b1 __pyx_string_tab[24]
  2849. #define __pyx_n_u_c __pyx_string_tab[25]
  2850. #define __pyx_n_u_c1 __pyx_string_tab[26]
  2851. #define __pyx_n_u_cline_in_traceback __pyx_string_tab[27]
  2852. #define __pyx_n_u_close __pyx_string_tab[28]
  2853. #define __pyx_n_u_curve __pyx_string_tab[29]
  2854. #define __pyx_n_u_curve_to_quadratic __pyx_string_tab[30]
  2855. #define __pyx_n_u_curves __pyx_string_tab[31]
  2856. #define __pyx_n_u_curves_to_quadratic __pyx_string_tab[32]
  2857. #define __pyx_n_u_d __pyx_string_tab[33]
  2858. #define __pyx_n_u_d1 __pyx_string_tab[34]
  2859. #define __pyx_n_u_delta_2 __pyx_string_tab[35]
  2860. #define __pyx_n_u_delta_3 __pyx_string_tab[36]
  2861. #define __pyx_n_u_dt __pyx_string_tab[37]
  2862. #define __pyx_n_u_errors __pyx_string_tab[38]
  2863. #define __pyx_n_u_fontTools_cu2qu_cu2qu __pyx_string_tab[39]
  2864. #define __pyx_n_u_func __pyx_string_tab[40]
  2865. #define __pyx_n_u_i __pyx_string_tab[41]
  2866. #define __pyx_n_u_imag __pyx_string_tab[42]
  2867. #define __pyx_n_u_is_coroutine __pyx_string_tab[43]
  2868. #define __pyx_n_u_isnan __pyx_string_tab[44]
  2869. #define __pyx_n_u_items __pyx_string_tab[45]
  2870. #define __pyx_n_u_l __pyx_string_tab[46]
  2871. #define __pyx_n_u_last_i __pyx_string_tab[47]
  2872. #define __pyx_n_u_main __pyx_string_tab[48]
  2873. #define __pyx_n_u_math __pyx_string_tab[49]
  2874. #define __pyx_n_u_max_err __pyx_string_tab[50]
  2875. #define __pyx_n_u_max_errors __pyx_string_tab[51]
  2876. #define __pyx_n_u_module __pyx_string_tab[52]
  2877. #define __pyx_n_u_n __pyx_string_tab[53]
  2878. #define __pyx_n_u_name __pyx_string_tab[54]
  2879. #define __pyx_n_u_next __pyx_string_tab[55]
  2880. #define __pyx_n_u_p __pyx_string_tab[56]
  2881. #define __pyx_n_u_p0 __pyx_string_tab[57]
  2882. #define __pyx_n_u_p1 __pyx_string_tab[58]
  2883. #define __pyx_n_u_p2 __pyx_string_tab[59]
  2884. #define __pyx_n_u_p3 __pyx_string_tab[60]
  2885. #define __pyx_n_u_pop __pyx_string_tab[61]
  2886. #define __pyx_n_u_qualname __pyx_string_tab[62]
  2887. #define __pyx_n_u_real __pyx_string_tab[63]
  2888. #define __pyx_n_u_s __pyx_string_tab[64]
  2889. #define __pyx_n_u_send __pyx_string_tab[65]
  2890. #define __pyx_n_u_set_name __pyx_string_tab[66]
  2891. #define __pyx_n_u_setdefault __pyx_string_tab[67]
  2892. #define __pyx_n_u_spline __pyx_string_tab[68]
  2893. #define __pyx_n_u_splines __pyx_string_tab[69]
  2894. #define __pyx_n_u_split_cubic_into_n_gen __pyx_string_tab[70]
  2895. #define __pyx_n_u_t1 __pyx_string_tab[71]
  2896. #define __pyx_n_u_t1_2 __pyx_string_tab[72]
  2897. #define __pyx_n_u_test __pyx_string_tab[73]
  2898. #define __pyx_n_u_throw __pyx_string_tab[74]
  2899. #define __pyx_n_u_value __pyx_string_tab[75]
  2900. #define __pyx_n_u_values __pyx_string_tab[76]
  2901. #define __pyx_kp_b_iso88591_AWBc_U_U_3fBa_AWCy_7_2QgQgT_a_Q __pyx_string_tab[77]
  2902. #define __pyx_kp_b_iso88591_J_Qawb_4uG4y_3a_3c_1A_avRq_T_AV __pyx_string_tab[78]
  2903. #define __pyx_kp_b_iso88591__3 __pyx_string_tab[79]
  2904. #define __pyx_int_1 __pyx_number_tab[0]
  2905. #define __pyx_int_2 __pyx_number_tab[1]
  2906. #define __pyx_int_3 __pyx_number_tab[2]
  2907. #define __pyx_int_4 __pyx_number_tab[3]
  2908. #define __pyx_int_6 __pyx_number_tab[4]
  2909. #define __pyx_int_100 __pyx_number_tab[5]
  2910. /* #### Code section: module_state_clear ### */
  2911. #if CYTHON_USE_MODULE_STATE
  2912. static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) {
  2913. __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m);
  2914. if (!clear_module_state) return 0;
  2915. Py_CLEAR(clear_module_state->__pyx_d);
  2916. Py_CLEAR(clear_module_state->__pyx_b);
  2917. Py_CLEAR(clear_module_state->__pyx_cython_runtime);
  2918. Py_CLEAR(clear_module_state->__pyx_empty_tuple);
  2919. Py_CLEAR(clear_module_state->__pyx_empty_bytes);
  2920. Py_CLEAR(clear_module_state->__pyx_empty_unicode);
  2921. #if CYTHON_PEP489_MULTI_PHASE_INIT
  2922. __Pyx_State_RemoveModule(NULL);
  2923. #endif
  2924. Py_CLEAR(clear_module_state->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2925. Py_CLEAR(clear_module_state->__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2926. for (int i=0; i<3; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); }
  2927. for (int i=0; i<80; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); }
  2928. for (int i=0; i<6; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); }
  2929. /* #### Code section: module_state_clear_contents ### */
  2930. /* CommonTypesMetaclass.module_state_clear */
  2931. Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType);
  2932. /* CythonFunctionShared.module_state_clear */
  2933. Py_CLEAR(clear_module_state->__pyx_CyFunctionType);
  2934. /* Generator.module_state_clear */
  2935. Py_CLEAR(clear_module_state->__pyx_GeneratorType);
  2936. /* #### Code section: module_state_clear_end ### */
  2937. return 0;
  2938. }
  2939. #endif
  2940. /* #### Code section: module_state_traverse ### */
  2941. #if CYTHON_USE_MODULE_STATE
  2942. static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
  2943. __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m);
  2944. if (!traverse_module_state) return 0;
  2945. Py_VISIT(traverse_module_state->__pyx_d);
  2946. Py_VISIT(traverse_module_state->__pyx_b);
  2947. Py_VISIT(traverse_module_state->__pyx_cython_runtime);
  2948. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple);
  2949. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes);
  2950. __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode);
  2951. Py_VISIT(traverse_module_state->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2952. Py_VISIT(traverse_module_state->__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  2953. for (int i=0; i<3; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); }
  2954. for (int i=0; i<80; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); }
  2955. for (int i=0; i<6; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); }
  2956. /* #### Code section: module_state_traverse_contents ### */
  2957. /* CommonTypesMetaclass.module_state_traverse */
  2958. Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType);
  2959. /* CythonFunctionShared.module_state_traverse */
  2960. Py_VISIT(traverse_module_state->__pyx_CyFunctionType);
  2961. /* Generator.module_state_traverse */
  2962. Py_VISIT(traverse_module_state->__pyx_GeneratorType);
  2963. /* #### Code section: module_state_traverse_end ### */
  2964. return 0;
  2965. }
  2966. #endif
  2967. /* #### Code section: module_code ### */
  2968. /* "fontTools/cu2qu/cu2qu.py":37
  2969. *
  2970. *
  2971. * @cython.cfunc # <<<<<<<<<<<<<<
  2972. * @cython.inline
  2973. * @cython.returns(cython.double)
  2974. */
  2975. static CYTHON_INLINE double __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_t_double_complex __pyx_v_v1, __pyx_t_double_complex __pyx_v_v2) {
  2976. double __pyx_v_result;
  2977. double __pyx_r;
  2978. double __pyx_t_1;
  2979. int __pyx_t_2;
  2980. /* "fontTools/cu2qu/cu2qu.py":51
  2981. * double: Dot product.
  2982. * """
  2983. * result = (v1 * v2.conjugate()).real # <<<<<<<<<<<<<<
  2984. * # When vectors are perpendicular (i.e. dot product is 0), the above expression may
  2985. * # yield slightly different results when running in pure Python vs C/Cython,
  2986. */
  2987. __pyx_t_1 = __Pyx_CREAL(__Pyx_c_prod_double(__pyx_v_v1, __Pyx_c_conj_double(__pyx_v_v2)));
  2988. __pyx_v_result = __pyx_t_1;
  2989. /* "fontTools/cu2qu/cu2qu.py":58
  2990. * # implementation. Because we are using the result in a denominator and catching
  2991. * # ZeroDivisionError (see `calc_intersect`), it's best to normalize the result here.
  2992. * if abs(result) < 1e-15: # <<<<<<<<<<<<<<
  2993. * result = 0.0
  2994. * return result
  2995. */
  2996. __pyx_t_1 = fabs(__pyx_v_result);
  2997. __pyx_t_2 = (__pyx_t_1 < 1e-15);
  2998. if (__pyx_t_2) {
  2999. /* "fontTools/cu2qu/cu2qu.py":59
  3000. * # ZeroDivisionError (see `calc_intersect`), it's best to normalize the result here.
  3001. * if abs(result) < 1e-15:
  3002. * result = 0.0 # <<<<<<<<<<<<<<
  3003. * return result
  3004. *
  3005. */
  3006. __pyx_v_result = 0.0;
  3007. /* "fontTools/cu2qu/cu2qu.py":58
  3008. * # implementation. Because we are using the result in a denominator and catching
  3009. * # ZeroDivisionError (see `calc_intersect`), it's best to normalize the result here.
  3010. * if abs(result) < 1e-15: # <<<<<<<<<<<<<<
  3011. * result = 0.0
  3012. * return result
  3013. */
  3014. }
  3015. /* "fontTools/cu2qu/cu2qu.py":60
  3016. * if abs(result) < 1e-15:
  3017. * result = 0.0
  3018. * return result # <<<<<<<<<<<<<<
  3019. *
  3020. *
  3021. */
  3022. __pyx_r = __pyx_v_result;
  3023. goto __pyx_L0;
  3024. /* "fontTools/cu2qu/cu2qu.py":37
  3025. *
  3026. *
  3027. * @cython.cfunc # <<<<<<<<<<<<<<
  3028. * @cython.inline
  3029. * @cython.returns(cython.double)
  3030. */
  3031. /* function exit code */
  3032. __pyx_L0:;
  3033. return __pyx_r;
  3034. }
  3035. /* "fontTools/cu2qu/cu2qu.py":63
  3036. *
  3037. *
  3038. * @cython.cfunc # <<<<<<<<<<<<<<
  3039. * @cython.locals(z=cython.complex, den=cython.double)
  3040. * @cython.locals(zr=cython.double, zi=cython.double)
  3041. */
  3042. static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu__complex_div_by_real(__pyx_t_double_complex __pyx_v_z, double __pyx_v_den) {
  3043. double __pyx_v_zr;
  3044. double __pyx_v_zi;
  3045. PyObject *__pyx_r = NULL;
  3046. __Pyx_RefNannyDeclarations
  3047. double __pyx_t_1;
  3048. PyObject *__pyx_t_2 = NULL;
  3049. PyObject *__pyx_t_3 = NULL;
  3050. PyObject *__pyx_t_4 = NULL;
  3051. PyObject *__pyx_t_5 = NULL;
  3052. size_t __pyx_t_6;
  3053. int __pyx_lineno = 0;
  3054. const char *__pyx_filename = NULL;
  3055. int __pyx_clineno = 0;
  3056. __Pyx_RefNannySetupContext("_complex_div_by_real", 0);
  3057. /* "fontTools/cu2qu/cu2qu.py":75
  3058. * https://github.com/fonttools/fonttools/issues/3928
  3059. * """
  3060. * zr = z.real # <<<<<<<<<<<<<<
  3061. * zi = z.imag
  3062. * return complex(zr / den, zi / den)
  3063. */
  3064. __pyx_t_1 = __Pyx_CREAL(__pyx_v_z);
  3065. __pyx_v_zr = __pyx_t_1;
  3066. /* "fontTools/cu2qu/cu2qu.py":76
  3067. * """
  3068. * zr = z.real
  3069. * zi = z.imag # <<<<<<<<<<<<<<
  3070. * return complex(zr / den, zi / den)
  3071. *
  3072. */
  3073. __pyx_t_1 = __Pyx_CIMAG(__pyx_v_z);
  3074. __pyx_v_zi = __pyx_t_1;
  3075. /* "fontTools/cu2qu/cu2qu.py":77
  3076. * zr = z.real
  3077. * zi = z.imag
  3078. * return complex(zr / den, zi / den) # <<<<<<<<<<<<<<
  3079. *
  3080. *
  3081. */
  3082. __Pyx_XDECREF(__pyx_r);
  3083. __pyx_t_3 = NULL;
  3084. if (unlikely(__pyx_v_den == 0)) {
  3085. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  3086. __PYX_ERR(0, 77, __pyx_L1_error)
  3087. }
  3088. __pyx_t_4 = PyFloat_FromDouble((__pyx_v_zr / __pyx_v_den)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 77, __pyx_L1_error)
  3089. __Pyx_GOTREF(__pyx_t_4);
  3090. if (unlikely(__pyx_v_den == 0)) {
  3091. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  3092. __PYX_ERR(0, 77, __pyx_L1_error)
  3093. }
  3094. __pyx_t_5 = PyFloat_FromDouble((__pyx_v_zi / __pyx_v_den)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 77, __pyx_L1_error)
  3095. __Pyx_GOTREF(__pyx_t_5);
  3096. __pyx_t_6 = 1;
  3097. {
  3098. PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_4, __pyx_t_5};
  3099. __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)(&PyComplex_Type), __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  3100. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3101. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3102. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3103. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error)
  3104. __Pyx_GOTREF(__pyx_t_2);
  3105. }
  3106. __pyx_r = __pyx_t_2;
  3107. __pyx_t_2 = 0;
  3108. goto __pyx_L0;
  3109. /* "fontTools/cu2qu/cu2qu.py":63
  3110. *
  3111. *
  3112. * @cython.cfunc # <<<<<<<<<<<<<<
  3113. * @cython.locals(z=cython.complex, den=cython.double)
  3114. * @cython.locals(zr=cython.double, zi=cython.double)
  3115. */
  3116. /* function exit code */
  3117. __pyx_L1_error:;
  3118. __Pyx_XDECREF(__pyx_t_2);
  3119. __Pyx_XDECREF(__pyx_t_3);
  3120. __Pyx_XDECREF(__pyx_t_4);
  3121. __Pyx_XDECREF(__pyx_t_5);
  3122. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._complex_div_by_real", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3123. __pyx_r = 0;
  3124. __pyx_L0:;
  3125. __Pyx_XGIVEREF(__pyx_r);
  3126. __Pyx_RefNannyFinishContext();
  3127. return __pyx_r;
  3128. }
  3129. /* "fontTools/cu2qu/cu2qu.py":80
  3130. *
  3131. *
  3132. * @cython.cfunc # <<<<<<<<<<<<<<
  3133. * @cython.inline
  3134. * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex)
  3135. */
  3136. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex __pyx_v_b, __pyx_t_double_complex __pyx_v_c, __pyx_t_double_complex __pyx_v_d) {
  3137. __pyx_t_double_complex __pyx_v__1;
  3138. __pyx_t_double_complex __pyx_v__2;
  3139. __pyx_t_double_complex __pyx_v__3;
  3140. __pyx_t_double_complex __pyx_v__4;
  3141. PyObject *__pyx_r = NULL;
  3142. __Pyx_RefNannyDeclarations
  3143. PyObject *__pyx_t_1 = NULL;
  3144. PyObject *__pyx_t_2 = NULL;
  3145. PyObject *__pyx_t_3 = NULL;
  3146. __pyx_t_double_complex __pyx_t_4;
  3147. PyObject *__pyx_t_5 = NULL;
  3148. PyObject *__pyx_t_6 = NULL;
  3149. int __pyx_lineno = 0;
  3150. const char *__pyx_filename = NULL;
  3151. int __pyx_clineno = 0;
  3152. __Pyx_RefNannySetupContext("calc_cubic_points", 0);
  3153. /* "fontTools/cu2qu/cu2qu.py":87
  3154. * )
  3155. * def calc_cubic_points(a, b, c, d):
  3156. * _1 = d # <<<<<<<<<<<<<<
  3157. * _2 = _complex_div_by_real(c, 3.0) + d
  3158. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3159. */
  3160. __pyx_v__1 = __pyx_v_d;
  3161. /* "fontTools/cu2qu/cu2qu.py":88
  3162. * def calc_cubic_points(a, b, c, d):
  3163. * _1 = d
  3164. * _2 = _complex_div_by_real(c, 3.0) + d # <<<<<<<<<<<<<<
  3165. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3166. * _4 = a + d + c + b
  3167. */
  3168. __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu__complex_div_by_real(__pyx_v_c, 3.0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
  3169. __Pyx_GOTREF(__pyx_t_1);
  3170. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_d); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
  3171. __Pyx_GOTREF(__pyx_t_2);
  3172. __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
  3173. __Pyx_GOTREF(__pyx_t_3);
  3174. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3175. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3176. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 88, __pyx_L1_error)
  3177. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3178. __pyx_v__2 = __pyx_t_4;
  3179. /* "fontTools/cu2qu/cu2qu.py":89
  3180. * _1 = d
  3181. * _2 = _complex_div_by_real(c, 3.0) + d
  3182. * _3 = _complex_div_by_real(b + c, 3.0) + _2 # <<<<<<<<<<<<<<
  3183. * _4 = a + d + c + b
  3184. * return _1, _2, _3, _4
  3185. */
  3186. __pyx_t_3 = __pyx_f_9fontTools_5cu2qu_5cu2qu__complex_div_by_real(__Pyx_c_sum_double(__pyx_v_b, __pyx_v_c), 3.0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 89, __pyx_L1_error)
  3187. __Pyx_GOTREF(__pyx_t_3);
  3188. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v__2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
  3189. __Pyx_GOTREF(__pyx_t_2);
  3190. __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 89, __pyx_L1_error)
  3191. __Pyx_GOTREF(__pyx_t_1);
  3192. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3193. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3194. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 89, __pyx_L1_error)
  3195. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  3196. __pyx_v__3 = __pyx_t_4;
  3197. /* "fontTools/cu2qu/cu2qu.py":90
  3198. * _2 = _complex_div_by_real(c, 3.0) + d
  3199. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3200. * _4 = a + d + c + b # <<<<<<<<<<<<<<
  3201. * return _1, _2, _3, _4
  3202. *
  3203. */
  3204. __pyx_v__4 = __Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_a, __pyx_v_d), __pyx_v_c), __pyx_v_b);
  3205. /* "fontTools/cu2qu/cu2qu.py":91
  3206. * _3 = _complex_div_by_real(b + c, 3.0) + _2
  3207. * _4 = a + d + c + b
  3208. * return _1, _2, _3, _4 # <<<<<<<<<<<<<<
  3209. *
  3210. *
  3211. */
  3212. __Pyx_XDECREF(__pyx_r);
  3213. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v__1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 91, __pyx_L1_error)
  3214. __Pyx_GOTREF(__pyx_t_1);
  3215. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v__2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
  3216. __Pyx_GOTREF(__pyx_t_2);
  3217. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v__3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 91, __pyx_L1_error)
  3218. __Pyx_GOTREF(__pyx_t_3);
  3219. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v__4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 91, __pyx_L1_error)
  3220. __Pyx_GOTREF(__pyx_t_5);
  3221. __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 91, __pyx_L1_error)
  3222. __Pyx_GOTREF(__pyx_t_6);
  3223. __Pyx_GIVEREF(__pyx_t_1);
  3224. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3225. __Pyx_GIVEREF(__pyx_t_2);
  3226. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3227. __Pyx_GIVEREF(__pyx_t_3);
  3228. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3229. __Pyx_GIVEREF(__pyx_t_5);
  3230. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5) != (0)) __PYX_ERR(0, 91, __pyx_L1_error);
  3231. __pyx_t_1 = 0;
  3232. __pyx_t_2 = 0;
  3233. __pyx_t_3 = 0;
  3234. __pyx_t_5 = 0;
  3235. __pyx_r = __pyx_t_6;
  3236. __pyx_t_6 = 0;
  3237. goto __pyx_L0;
  3238. /* "fontTools/cu2qu/cu2qu.py":80
  3239. *
  3240. *
  3241. * @cython.cfunc # <<<<<<<<<<<<<<
  3242. * @cython.inline
  3243. * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex)
  3244. */
  3245. /* function exit code */
  3246. __pyx_L1_error:;
  3247. __Pyx_XDECREF(__pyx_t_1);
  3248. __Pyx_XDECREF(__pyx_t_2);
  3249. __Pyx_XDECREF(__pyx_t_3);
  3250. __Pyx_XDECREF(__pyx_t_5);
  3251. __Pyx_XDECREF(__pyx_t_6);
  3252. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_points", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3253. __pyx_r = 0;
  3254. __pyx_L0:;
  3255. __Pyx_XGIVEREF(__pyx_r);
  3256. __Pyx_RefNannyFinishContext();
  3257. return __pyx_r;
  3258. }
  3259. /* "fontTools/cu2qu/cu2qu.py":94
  3260. *
  3261. *
  3262. * @cython.cfunc # <<<<<<<<<<<<<<
  3263. * @cython.inline
  3264. * @cython.locals(
  3265. */
  3266. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__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) {
  3267. __pyx_t_double_complex __pyx_v_a;
  3268. __pyx_t_double_complex __pyx_v_b;
  3269. __pyx_t_double_complex __pyx_v_c;
  3270. __pyx_t_double_complex __pyx_v_d;
  3271. PyObject *__pyx_r = NULL;
  3272. __Pyx_RefNannyDeclarations
  3273. PyObject *__pyx_t_1 = NULL;
  3274. PyObject *__pyx_t_2 = NULL;
  3275. PyObject *__pyx_t_3 = NULL;
  3276. PyObject *__pyx_t_4 = NULL;
  3277. PyObject *__pyx_t_5 = NULL;
  3278. int __pyx_lineno = 0;
  3279. const char *__pyx_filename = NULL;
  3280. int __pyx_clineno = 0;
  3281. __Pyx_RefNannySetupContext("calc_cubic_parameters", 0);
  3282. /* "fontTools/cu2qu/cu2qu.py":101
  3283. * @cython.locals(a=cython.complex, b=cython.complex, c=cython.complex, d=cython.complex)
  3284. * def calc_cubic_parameters(p0, p1, p2, p3):
  3285. * c = (p1 - p0) * 3.0 # <<<<<<<<<<<<<<
  3286. * b = (p2 - p1) * 3.0 - c
  3287. * d = p0
  3288. */
  3289. __pyx_v_c = __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0), __pyx_t_double_complex_from_parts(3.0, 0));
  3290. /* "fontTools/cu2qu/cu2qu.py":102
  3291. * def calc_cubic_parameters(p0, p1, p2, p3):
  3292. * c = (p1 - p0) * 3.0
  3293. * b = (p2 - p1) * 3.0 - c # <<<<<<<<<<<<<<
  3294. * d = p0
  3295. * a = p3 - d - c - b
  3296. */
  3297. __pyx_v_b = __Pyx_c_diff_double(__Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p1), __pyx_t_double_complex_from_parts(3.0, 0)), __pyx_v_c);
  3298. /* "fontTools/cu2qu/cu2qu.py":103
  3299. * c = (p1 - p0) * 3.0
  3300. * b = (p2 - p1) * 3.0 - c
  3301. * d = p0 # <<<<<<<<<<<<<<
  3302. * a = p3 - d - c - b
  3303. * return a, b, c, d
  3304. */
  3305. __pyx_v_d = __pyx_v_p0;
  3306. /* "fontTools/cu2qu/cu2qu.py":104
  3307. * b = (p2 - p1) * 3.0 - c
  3308. * d = p0
  3309. * a = p3 - d - c - b # <<<<<<<<<<<<<<
  3310. * return a, b, c, d
  3311. *
  3312. */
  3313. __pyx_v_a = __Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__pyx_v_p3, __pyx_v_d), __pyx_v_c), __pyx_v_b);
  3314. /* "fontTools/cu2qu/cu2qu.py":105
  3315. * d = p0
  3316. * a = p3 - d - c - b
  3317. * return a, b, c, d # <<<<<<<<<<<<<<
  3318. *
  3319. *
  3320. */
  3321. __Pyx_XDECREF(__pyx_r);
  3322. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_a); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error)
  3323. __Pyx_GOTREF(__pyx_t_1);
  3324. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_b); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 105, __pyx_L1_error)
  3325. __Pyx_GOTREF(__pyx_t_2);
  3326. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_v_c); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 105, __pyx_L1_error)
  3327. __Pyx_GOTREF(__pyx_t_3);
  3328. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_v_d); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error)
  3329. __Pyx_GOTREF(__pyx_t_4);
  3330. __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 105, __pyx_L1_error)
  3331. __Pyx_GOTREF(__pyx_t_5);
  3332. __Pyx_GIVEREF(__pyx_t_1);
  3333. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3334. __Pyx_GIVEREF(__pyx_t_2);
  3335. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3336. __Pyx_GIVEREF(__pyx_t_3);
  3337. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3338. __Pyx_GIVEREF(__pyx_t_4);
  3339. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4) != (0)) __PYX_ERR(0, 105, __pyx_L1_error);
  3340. __pyx_t_1 = 0;
  3341. __pyx_t_2 = 0;
  3342. __pyx_t_3 = 0;
  3343. __pyx_t_4 = 0;
  3344. __pyx_r = __pyx_t_5;
  3345. __pyx_t_5 = 0;
  3346. goto __pyx_L0;
  3347. /* "fontTools/cu2qu/cu2qu.py":94
  3348. *
  3349. *
  3350. * @cython.cfunc # <<<<<<<<<<<<<<
  3351. * @cython.inline
  3352. * @cython.locals(
  3353. */
  3354. /* function exit code */
  3355. __pyx_L1_error:;
  3356. __Pyx_XDECREF(__pyx_t_1);
  3357. __Pyx_XDECREF(__pyx_t_2);
  3358. __Pyx_XDECREF(__pyx_t_3);
  3359. __Pyx_XDECREF(__pyx_t_4);
  3360. __Pyx_XDECREF(__pyx_t_5);
  3361. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_cubic_parameters", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3362. __pyx_r = 0;
  3363. __pyx_L0:;
  3364. __Pyx_XGIVEREF(__pyx_r);
  3365. __Pyx_RefNannyFinishContext();
  3366. return __pyx_r;
  3367. }
  3368. /* "fontTools/cu2qu/cu2qu.py":108
  3369. *
  3370. *
  3371. * @cython.cfunc # <<<<<<<<<<<<<<
  3372. * @cython.inline
  3373. * @cython.locals(
  3374. */
  3375. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__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, PyObject *__pyx_v_n) {
  3376. PyObject *__pyx_v_a = NULL;
  3377. PyObject *__pyx_v_b = NULL;
  3378. PyObject *__pyx_r = NULL;
  3379. __Pyx_RefNannyDeclarations
  3380. int __pyx_t_1;
  3381. PyObject *__pyx_t_2 = NULL;
  3382. PyObject *__pyx_t_3 = NULL;
  3383. PyObject *__pyx_t_4 = NULL;
  3384. PyObject *__pyx_t_5 = NULL;
  3385. PyObject *(*__pyx_t_6)(PyObject *);
  3386. __pyx_t_double_complex __pyx_t_7;
  3387. __pyx_t_double_complex __pyx_t_8;
  3388. __pyx_t_double_complex __pyx_t_9;
  3389. __pyx_t_double_complex __pyx_t_10;
  3390. PyObject *__pyx_t_11 = NULL;
  3391. PyObject *__pyx_t_12 = NULL;
  3392. PyObject *__pyx_t_13 = NULL;
  3393. size_t __pyx_t_14;
  3394. int __pyx_lineno = 0;
  3395. const char *__pyx_filename = NULL;
  3396. int __pyx_clineno = 0;
  3397. __Pyx_RefNannySetupContext("split_cubic_into_n_iter", 0);
  3398. /* "fontTools/cu2qu/cu2qu.py":130
  3399. * """
  3400. * # Hand-coded special-cases
  3401. * if n == 2: # <<<<<<<<<<<<<<
  3402. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3403. * if n == 3:
  3404. */
  3405. __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_n, __pyx_mstate_global->__pyx_int_2, 2, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 130, __pyx_L1_error)
  3406. if (__pyx_t_1) {
  3407. /* "fontTools/cu2qu/cu2qu.py":131
  3408. * # Hand-coded special-cases
  3409. * if n == 2:
  3410. * return iter(split_cubic_into_two(p0, p1, p2, p3)) # <<<<<<<<<<<<<<
  3411. * if n == 3:
  3412. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3413. */
  3414. __Pyx_XDECREF(__pyx_r);
  3415. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
  3416. __Pyx_GOTREF(__pyx_t_2);
  3417. __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 131, __pyx_L1_error)
  3418. __Pyx_GOTREF(__pyx_t_3);
  3419. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3420. __pyx_r = __pyx_t_3;
  3421. __pyx_t_3 = 0;
  3422. goto __pyx_L0;
  3423. /* "fontTools/cu2qu/cu2qu.py":130
  3424. * """
  3425. * # Hand-coded special-cases
  3426. * if n == 2: # <<<<<<<<<<<<<<
  3427. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3428. * if n == 3:
  3429. */
  3430. }
  3431. /* "fontTools/cu2qu/cu2qu.py":132
  3432. * if n == 2:
  3433. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3434. * if n == 3: # <<<<<<<<<<<<<<
  3435. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3436. * if n == 4:
  3437. */
  3438. __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_n, __pyx_mstate_global->__pyx_int_3, 3, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 132, __pyx_L1_error)
  3439. if (__pyx_t_1) {
  3440. /* "fontTools/cu2qu/cu2qu.py":133
  3441. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3442. * if n == 3:
  3443. * return iter(split_cubic_into_three(p0, p1, p2, p3)) # <<<<<<<<<<<<<<
  3444. * if n == 4:
  3445. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3446. */
  3447. __Pyx_XDECREF(__pyx_r);
  3448. __pyx_t_3 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
  3449. __Pyx_GOTREF(__pyx_t_3);
  3450. __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
  3451. __Pyx_GOTREF(__pyx_t_2);
  3452. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3453. __pyx_r = __pyx_t_2;
  3454. __pyx_t_2 = 0;
  3455. goto __pyx_L0;
  3456. /* "fontTools/cu2qu/cu2qu.py":132
  3457. * if n == 2:
  3458. * return iter(split_cubic_into_two(p0, p1, p2, p3))
  3459. * if n == 3: # <<<<<<<<<<<<<<
  3460. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3461. * if n == 4:
  3462. */
  3463. }
  3464. /* "fontTools/cu2qu/cu2qu.py":134
  3465. * if n == 3:
  3466. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3467. * if n == 4: # <<<<<<<<<<<<<<
  3468. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3469. * return iter(
  3470. */
  3471. __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_n, __pyx_mstate_global->__pyx_int_4, 4, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 134, __pyx_L1_error)
  3472. if (__pyx_t_1) {
  3473. /* "fontTools/cu2qu/cu2qu.py":135
  3474. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3475. * if n == 4:
  3476. * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<<
  3477. * return iter(
  3478. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3479. */
  3480. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error)
  3481. __Pyx_GOTREF(__pyx_t_2);
  3482. if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
  3483. PyObject* sequence = __pyx_t_2;
  3484. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  3485. if (unlikely(size != 2)) {
  3486. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  3487. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  3488. __PYX_ERR(0, 135, __pyx_L1_error)
  3489. }
  3490. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3491. if (likely(PyTuple_CheckExact(sequence))) {
  3492. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
  3493. __Pyx_INCREF(__pyx_t_3);
  3494. __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
  3495. __Pyx_INCREF(__pyx_t_4);
  3496. } else {
  3497. __pyx_t_3 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  3498. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
  3499. __Pyx_XGOTREF(__pyx_t_3);
  3500. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  3501. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
  3502. __Pyx_XGOTREF(__pyx_t_4);
  3503. }
  3504. #else
  3505. __pyx_t_3 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 135, __pyx_L1_error)
  3506. __Pyx_GOTREF(__pyx_t_3);
  3507. __pyx_t_4 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 135, __pyx_L1_error)
  3508. __Pyx_GOTREF(__pyx_t_4);
  3509. #endif
  3510. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3511. } else {
  3512. Py_ssize_t index = -1;
  3513. __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 135, __pyx_L1_error)
  3514. __Pyx_GOTREF(__pyx_t_5);
  3515. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3516. __pyx_t_6 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5);
  3517. index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
  3518. __Pyx_GOTREF(__pyx_t_3);
  3519. index = 1; __pyx_t_4 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed;
  3520. __Pyx_GOTREF(__pyx_t_4);
  3521. if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < (0)) __PYX_ERR(0, 135, __pyx_L1_error)
  3522. __pyx_t_6 = NULL;
  3523. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3524. goto __pyx_L7_unpacking_done;
  3525. __pyx_L6_unpacking_failed:;
  3526. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3527. __pyx_t_6 = NULL;
  3528. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  3529. __PYX_ERR(0, 135, __pyx_L1_error)
  3530. __pyx_L7_unpacking_done:;
  3531. }
  3532. __pyx_v_a = __pyx_t_3;
  3533. __pyx_t_3 = 0;
  3534. __pyx_v_b = __pyx_t_4;
  3535. __pyx_t_4 = 0;
  3536. /* "fontTools/cu2qu/cu2qu.py":136
  3537. * if n == 4:
  3538. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3539. * return iter( # <<<<<<<<<<<<<<
  3540. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3541. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3542. */
  3543. __Pyx_XDECREF(__pyx_r);
  3544. /* "fontTools/cu2qu/cu2qu.py":137
  3545. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3546. * return iter(
  3547. * split_cubic_into_two(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<<
  3548. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3549. * )
  3550. */
  3551. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
  3552. __Pyx_GOTREF(__pyx_t_2);
  3553. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3554. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3555. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
  3556. __Pyx_GOTREF(__pyx_t_2);
  3557. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3558. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3559. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
  3560. __Pyx_GOTREF(__pyx_t_2);
  3561. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3562. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3563. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_a, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
  3564. __Pyx_GOTREF(__pyx_t_2);
  3565. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 137, __pyx_L1_error)
  3566. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3567. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
  3568. __Pyx_GOTREF(__pyx_t_2);
  3569. /* "fontTools/cu2qu/cu2qu.py":138
  3570. * return iter(
  3571. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3572. * + split_cubic_into_two(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<<
  3573. * )
  3574. * if n == 6:
  3575. */
  3576. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
  3577. __Pyx_GOTREF(__pyx_t_4);
  3578. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3579. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3580. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
  3581. __Pyx_GOTREF(__pyx_t_4);
  3582. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3583. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3584. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
  3585. __Pyx_GOTREF(__pyx_t_4);
  3586. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3587. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3588. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_b, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
  3589. __Pyx_GOTREF(__pyx_t_4);
  3590. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 138, __pyx_L1_error)
  3591. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3592. __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 138, __pyx_L1_error)
  3593. __Pyx_GOTREF(__pyx_t_4);
  3594. __pyx_t_3 = PyNumber_Add(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
  3595. __Pyx_GOTREF(__pyx_t_3);
  3596. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3597. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3598. /* "fontTools/cu2qu/cu2qu.py":136
  3599. * if n == 4:
  3600. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3601. * return iter( # <<<<<<<<<<<<<<
  3602. * split_cubic_into_two(a[0], a[1], a[2], a[3])
  3603. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3604. */
  3605. __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 136, __pyx_L1_error)
  3606. __Pyx_GOTREF(__pyx_t_4);
  3607. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3608. __pyx_r = __pyx_t_4;
  3609. __pyx_t_4 = 0;
  3610. goto __pyx_L0;
  3611. /* "fontTools/cu2qu/cu2qu.py":134
  3612. * if n == 3:
  3613. * return iter(split_cubic_into_three(p0, p1, p2, p3))
  3614. * if n == 4: # <<<<<<<<<<<<<<
  3615. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3616. * return iter(
  3617. */
  3618. }
  3619. /* "fontTools/cu2qu/cu2qu.py":140
  3620. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3621. * )
  3622. * if n == 6: # <<<<<<<<<<<<<<
  3623. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3624. * return iter(
  3625. */
  3626. __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_n, __pyx_mstate_global->__pyx_int_6, 6, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 140, __pyx_L1_error)
  3627. if (__pyx_t_1) {
  3628. /* "fontTools/cu2qu/cu2qu.py":141
  3629. * )
  3630. * if n == 6:
  3631. * a, b = split_cubic_into_two(p0, p1, p2, p3) # <<<<<<<<<<<<<<
  3632. * return iter(
  3633. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3634. */
  3635. __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L1_error)
  3636. __Pyx_GOTREF(__pyx_t_4);
  3637. if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
  3638. PyObject* sequence = __pyx_t_4;
  3639. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  3640. if (unlikely(size != 2)) {
  3641. if (size > 2) __Pyx_RaiseTooManyValuesError(2);
  3642. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  3643. __PYX_ERR(0, 141, __pyx_L1_error)
  3644. }
  3645. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  3646. if (likely(PyTuple_CheckExact(sequence))) {
  3647. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
  3648. __Pyx_INCREF(__pyx_t_3);
  3649. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
  3650. __Pyx_INCREF(__pyx_t_2);
  3651. } else {
  3652. __pyx_t_3 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  3653. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
  3654. __Pyx_XGOTREF(__pyx_t_3);
  3655. __pyx_t_2 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  3656. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
  3657. __Pyx_XGOTREF(__pyx_t_2);
  3658. }
  3659. #else
  3660. __pyx_t_3 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 141, __pyx_L1_error)
  3661. __Pyx_GOTREF(__pyx_t_3);
  3662. __pyx_t_2 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
  3663. __Pyx_GOTREF(__pyx_t_2);
  3664. #endif
  3665. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3666. } else {
  3667. Py_ssize_t index = -1;
  3668. __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 141, __pyx_L1_error)
  3669. __Pyx_GOTREF(__pyx_t_5);
  3670. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3671. __pyx_t_6 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5);
  3672. index = 0; __pyx_t_3 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L9_unpacking_failed;
  3673. __Pyx_GOTREF(__pyx_t_3);
  3674. index = 1; __pyx_t_2 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L9_unpacking_failed;
  3675. __Pyx_GOTREF(__pyx_t_2);
  3676. if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_5), 2) < (0)) __PYX_ERR(0, 141, __pyx_L1_error)
  3677. __pyx_t_6 = NULL;
  3678. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3679. goto __pyx_L10_unpacking_done;
  3680. __pyx_L9_unpacking_failed:;
  3681. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3682. __pyx_t_6 = NULL;
  3683. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  3684. __PYX_ERR(0, 141, __pyx_L1_error)
  3685. __pyx_L10_unpacking_done:;
  3686. }
  3687. __pyx_v_a = __pyx_t_3;
  3688. __pyx_t_3 = 0;
  3689. __pyx_v_b = __pyx_t_2;
  3690. __pyx_t_2 = 0;
  3691. /* "fontTools/cu2qu/cu2qu.py":142
  3692. * if n == 6:
  3693. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3694. * return iter( # <<<<<<<<<<<<<<
  3695. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3696. * + split_cubic_into_three(b[0], b[1], b[2], b[3])
  3697. */
  3698. __Pyx_XDECREF(__pyx_r);
  3699. /* "fontTools/cu2qu/cu2qu.py":143
  3700. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3701. * return iter(
  3702. * split_cubic_into_three(a[0], a[1], a[2], a[3]) # <<<<<<<<<<<<<<
  3703. * + split_cubic_into_three(b[0], b[1], b[2], b[3])
  3704. * )
  3705. */
  3706. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
  3707. __Pyx_GOTREF(__pyx_t_4);
  3708. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3709. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3710. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
  3711. __Pyx_GOTREF(__pyx_t_4);
  3712. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3713. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3714. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
  3715. __Pyx_GOTREF(__pyx_t_4);
  3716. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3717. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3718. __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_a, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
  3719. __Pyx_GOTREF(__pyx_t_4);
  3720. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
  3721. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3722. __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
  3723. __Pyx_GOTREF(__pyx_t_4);
  3724. /* "fontTools/cu2qu/cu2qu.py":144
  3725. * return iter(
  3726. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3727. * + split_cubic_into_three(b[0], b[1], b[2], b[3]) # <<<<<<<<<<<<<<
  3728. * )
  3729. *
  3730. */
  3731. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
  3732. __Pyx_GOTREF(__pyx_t_2);
  3733. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3734. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3735. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
  3736. __Pyx_GOTREF(__pyx_t_2);
  3737. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3738. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3739. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
  3740. __Pyx_GOTREF(__pyx_t_2);
  3741. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3742. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3743. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_b, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
  3744. __Pyx_GOTREF(__pyx_t_2);
  3745. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 144, __pyx_L1_error)
  3746. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3747. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
  3748. __Pyx_GOTREF(__pyx_t_2);
  3749. __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
  3750. __Pyx_GOTREF(__pyx_t_3);
  3751. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3752. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  3753. /* "fontTools/cu2qu/cu2qu.py":142
  3754. * if n == 6:
  3755. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3756. * return iter( # <<<<<<<<<<<<<<
  3757. * split_cubic_into_three(a[0], a[1], a[2], a[3])
  3758. * + split_cubic_into_three(b[0], b[1], b[2], b[3])
  3759. */
  3760. __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
  3761. __Pyx_GOTREF(__pyx_t_2);
  3762. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  3763. __pyx_r = __pyx_t_2;
  3764. __pyx_t_2 = 0;
  3765. goto __pyx_L0;
  3766. /* "fontTools/cu2qu/cu2qu.py":140
  3767. * + split_cubic_into_two(b[0], b[1], b[2], b[3])
  3768. * )
  3769. * if n == 6: # <<<<<<<<<<<<<<
  3770. * a, b = split_cubic_into_two(p0, p1, p2, p3)
  3771. * return iter(
  3772. */
  3773. }
  3774. /* "fontTools/cu2qu/cu2qu.py":147
  3775. * )
  3776. *
  3777. * return _split_cubic_into_n_gen(p0, p1, p2, p3, n) # <<<<<<<<<<<<<<
  3778. *
  3779. *
  3780. */
  3781. __Pyx_XDECREF(__pyx_r);
  3782. __pyx_t_3 = NULL;
  3783. __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_split_cubic_into_n_gen); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 147, __pyx_L1_error)
  3784. __Pyx_GOTREF(__pyx_t_4);
  3785. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 147, __pyx_L1_error)
  3786. __Pyx_GOTREF(__pyx_t_5);
  3787. __pyx_t_11 = __pyx_PyComplex_FromComplex(__pyx_v_p1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 147, __pyx_L1_error)
  3788. __Pyx_GOTREF(__pyx_t_11);
  3789. __pyx_t_12 = __pyx_PyComplex_FromComplex(__pyx_v_p2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 147, __pyx_L1_error)
  3790. __Pyx_GOTREF(__pyx_t_12);
  3791. __pyx_t_13 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 147, __pyx_L1_error)
  3792. __Pyx_GOTREF(__pyx_t_13);
  3793. __pyx_t_14 = 1;
  3794. #if CYTHON_UNPACK_METHODS
  3795. if (unlikely(PyMethod_Check(__pyx_t_4))) {
  3796. __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
  3797. assert(__pyx_t_3);
  3798. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
  3799. __Pyx_INCREF(__pyx_t_3);
  3800. __Pyx_INCREF(__pyx__function);
  3801. __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
  3802. __pyx_t_14 = 0;
  3803. }
  3804. #endif
  3805. {
  3806. PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_t_5, __pyx_t_11, __pyx_t_12, __pyx_t_13, __pyx_v_n};
  3807. __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_14, (6-__pyx_t_14) | (__pyx_t_14*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  3808. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  3809. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  3810. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  3811. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  3812. __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  3813. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  3814. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 147, __pyx_L1_error)
  3815. __Pyx_GOTREF(__pyx_t_2);
  3816. }
  3817. __pyx_r = __pyx_t_2;
  3818. __pyx_t_2 = 0;
  3819. goto __pyx_L0;
  3820. /* "fontTools/cu2qu/cu2qu.py":108
  3821. *
  3822. *
  3823. * @cython.cfunc # <<<<<<<<<<<<<<
  3824. * @cython.inline
  3825. * @cython.locals(
  3826. */
  3827. /* function exit code */
  3828. __pyx_L1_error:;
  3829. __Pyx_XDECREF(__pyx_t_2);
  3830. __Pyx_XDECREF(__pyx_t_3);
  3831. __Pyx_XDECREF(__pyx_t_4);
  3832. __Pyx_XDECREF(__pyx_t_5);
  3833. __Pyx_XDECREF(__pyx_t_11);
  3834. __Pyx_XDECREF(__pyx_t_12);
  3835. __Pyx_XDECREF(__pyx_t_13);
  3836. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_n_iter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3837. __pyx_r = 0;
  3838. __pyx_L0:;
  3839. __Pyx_XDECREF(__pyx_v_a);
  3840. __Pyx_XDECREF(__pyx_v_b);
  3841. __Pyx_XGIVEREF(__pyx_r);
  3842. __Pyx_RefNannyFinishContext();
  3843. return __pyx_r;
  3844. }
  3845. static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
  3846. /* "fontTools/cu2qu/cu2qu.py":150
  3847. *
  3848. *
  3849. * @cython.locals( # <<<<<<<<<<<<<<
  3850. * p0=cython.complex,
  3851. * p1=cython.complex,
  3852. */
  3853. /* Python wrapper */
  3854. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self,
  3855. #if CYTHON_METH_FASTCALL
  3856. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3857. #else
  3858. PyObject *__pyx_args, PyObject *__pyx_kwds
  3859. #endif
  3860. ); /*proto*/
  3861. PyDoc_STRVAR(__pyx_doc_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen, "_split_cubic_into_n_gen(double complex p0, double complex p1, double complex p2, double complex p3, int n)");
  3862. static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen = {"_split_cubic_into_n_gen", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen};
  3863. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen(PyObject *__pyx_self,
  3864. #if CYTHON_METH_FASTCALL
  3865. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  3866. #else
  3867. PyObject *__pyx_args, PyObject *__pyx_kwds
  3868. #endif
  3869. ) {
  3870. __pyx_t_double_complex __pyx_v_p0;
  3871. __pyx_t_double_complex __pyx_v_p1;
  3872. __pyx_t_double_complex __pyx_v_p2;
  3873. __pyx_t_double_complex __pyx_v_p3;
  3874. int __pyx_v_n;
  3875. #if !CYTHON_METH_FASTCALL
  3876. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  3877. #endif
  3878. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  3879. PyObject* values[5] = {0,0,0,0,0};
  3880. int __pyx_lineno = 0;
  3881. const char *__pyx_filename = NULL;
  3882. int __pyx_clineno = 0;
  3883. PyObject *__pyx_r = 0;
  3884. __Pyx_RefNannyDeclarations
  3885. __Pyx_RefNannySetupContext("_split_cubic_into_n_gen (wrapper)", 0);
  3886. #if !CYTHON_METH_FASTCALL
  3887. #if CYTHON_ASSUME_SAFE_SIZE
  3888. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  3889. #else
  3890. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  3891. #endif
  3892. #endif
  3893. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  3894. {
  3895. 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,&__pyx_mstate_global->__pyx_n_u_p3,&__pyx_mstate_global->__pyx_n_u_n,0};
  3896. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  3897. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 150, __pyx_L3_error)
  3898. if (__pyx_kwds_len > 0) {
  3899. switch (__pyx_nargs) {
  3900. case 5:
  3901. values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
  3902. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 150, __pyx_L3_error)
  3903. CYTHON_FALLTHROUGH;
  3904. case 4:
  3905. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  3906. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 150, __pyx_L3_error)
  3907. CYTHON_FALLTHROUGH;
  3908. case 3:
  3909. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3910. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 150, __pyx_L3_error)
  3911. CYTHON_FALLTHROUGH;
  3912. case 2:
  3913. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  3914. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 150, __pyx_L3_error)
  3915. CYTHON_FALLTHROUGH;
  3916. case 1:
  3917. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3918. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 150, __pyx_L3_error)
  3919. CYTHON_FALLTHROUGH;
  3920. case 0: break;
  3921. default: goto __pyx_L5_argtuple_error;
  3922. }
  3923. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  3924. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_split_cubic_into_n_gen", 0) < (0)) __PYX_ERR(0, 150, __pyx_L3_error)
  3925. for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
  3926. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, i); __PYX_ERR(0, 150, __pyx_L3_error) }
  3927. }
  3928. } else if (unlikely(__pyx_nargs != 5)) {
  3929. goto __pyx_L5_argtuple_error;
  3930. } else {
  3931. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  3932. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 150, __pyx_L3_error)
  3933. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  3934. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 150, __pyx_L3_error)
  3935. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  3936. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 150, __pyx_L3_error)
  3937. values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
  3938. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 150, __pyx_L3_error)
  3939. values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
  3940. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 150, __pyx_L3_error)
  3941. }
  3942. __pyx_v_p0 = __Pyx_PyComplex_As___pyx_t_double_complex(values[0]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3943. __pyx_v_p1 = __Pyx_PyComplex_As___pyx_t_double_complex(values[1]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3944. __pyx_v_p2 = __Pyx_PyComplex_As___pyx_t_double_complex(values[2]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3945. __pyx_v_p3 = __Pyx_PyComplex_As___pyx_t_double_complex(values[3]); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3946. __pyx_v_n = __Pyx_PyLong_As_int(values[4]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
  3947. }
  3948. goto __pyx_L6_skip;
  3949. __pyx_L5_argtuple_error:;
  3950. __Pyx_RaiseArgtupleInvalid("_split_cubic_into_n_gen", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 150, __pyx_L3_error)
  3951. __pyx_L6_skip:;
  3952. goto __pyx_L4_argument_unpacking_done;
  3953. __pyx_L3_error:;
  3954. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3955. Py_XDECREF(values[__pyx_temp]);
  3956. }
  3957. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3958. __Pyx_RefNannyFinishContext();
  3959. return NULL;
  3960. __pyx_L4_argument_unpacking_done:;
  3961. __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(__pyx_self, __pyx_v_p0, __pyx_v_p1, __pyx_v_p2, __pyx_v_p3, __pyx_v_n);
  3962. /* function exit code */
  3963. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  3964. Py_XDECREF(values[__pyx_temp]);
  3965. }
  3966. __Pyx_RefNannyFinishContext();
  3967. return __pyx_r;
  3968. }
  3969. static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu__split_cubic_into_n_gen(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, __pyx_t_double_complex __pyx_v_p3, int __pyx_v_n) {
  3970. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_cur_scope;
  3971. PyObject *__pyx_r = NULL;
  3972. __Pyx_RefNannyDeclarations
  3973. int __pyx_lineno = 0;
  3974. const char *__pyx_filename = NULL;
  3975. int __pyx_clineno = 0;
  3976. __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0);
  3977. __pyx_cur_scope = (struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(__pyx_mstate_global->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  3978. if (unlikely(!__pyx_cur_scope)) {
  3979. __pyx_cur_scope = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)Py_None);
  3980. __Pyx_INCREF(Py_None);
  3981. __PYX_ERR(0, 150, __pyx_L1_error)
  3982. } else {
  3983. __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  3984. }
  3985. __pyx_cur_scope->__pyx_v_p0 = __pyx_v_p0;
  3986. __pyx_cur_scope->__pyx_v_p1 = __pyx_v_p1;
  3987. __pyx_cur_scope->__pyx_v_p2 = __pyx_v_p2;
  3988. __pyx_cur_scope->__pyx_v_p3 = __pyx_v_p3;
  3989. __pyx_cur_scope->__pyx_v_n = __pyx_v_n;
  3990. {
  3991. __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_split_cubic_into_n_gen, __pyx_mstate_global->__pyx_n_u_split_cubic_into_n_gen, __pyx_mstate_global->__pyx_n_u_fontTools_cu2qu_cu2qu); if (unlikely(!gen)) __PYX_ERR(0, 150, __pyx_L1_error)
  3992. __Pyx_DECREF(__pyx_cur_scope);
  3993. __Pyx_RefNannyFinishContext();
  3994. return (PyObject *) gen;
  3995. }
  3996. /* function exit code */
  3997. __pyx_L1_error:;
  3998. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu._split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
  3999. __pyx_r = NULL;
  4000. __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  4001. __Pyx_XGIVEREF(__pyx_r);
  4002. __Pyx_RefNannyFinishContext();
  4003. return __pyx_r;
  4004. }
  4005. static PyObject *__pyx_gb_9fontTools_5cu2qu_5cu2qu_2generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
  4006. {
  4007. struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *__pyx_cur_scope = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)__pyx_generator->closure);
  4008. PyObject *__pyx_r = NULL;
  4009. PyObject *__pyx_t_1 = NULL;
  4010. PyObject *__pyx_t_2 = NULL;
  4011. PyObject *__pyx_t_3 = NULL;
  4012. PyObject *__pyx_t_4 = NULL;
  4013. PyObject *__pyx_t_5 = NULL;
  4014. PyObject *__pyx_t_6 = NULL;
  4015. PyObject *(*__pyx_t_7)(PyObject *);
  4016. __pyx_t_double_complex __pyx_t_8;
  4017. __pyx_t_double_complex __pyx_t_9;
  4018. __pyx_t_double_complex __pyx_t_10;
  4019. __pyx_t_double_complex __pyx_t_11;
  4020. int __pyx_t_12;
  4021. int __pyx_t_13;
  4022. int __pyx_t_14;
  4023. int __pyx_lineno = 0;
  4024. const char *__pyx_filename = NULL;
  4025. int __pyx_clineno = 0;
  4026. __Pyx_RefNannyDeclarations
  4027. __Pyx_RefNannySetupContext("_split_cubic_into_n_gen", 0);
  4028. switch (__pyx_generator->resume_label) {
  4029. case 0: goto __pyx_L3_first_run;
  4030. case 1: goto __pyx_L8_resume_from_yield;
  4031. default: /* CPython raises the right error here */
  4032. __Pyx_RefNannyFinishContext();
  4033. return NULL;
  4034. }
  4035. __pyx_L3_first_run:;
  4036. if (unlikely(__pyx_sent_value != Py_None)) {
  4037. if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started generator");
  4038. __PYX_ERR(0, 150, __pyx_L1_error)
  4039. }
  4040. /* "fontTools/cu2qu/cu2qu.py":165
  4041. * )
  4042. * def _split_cubic_into_n_gen(p0, p1, p2, p3, n):
  4043. * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3) # <<<<<<<<<<<<<<
  4044. * dt = 1 / n
  4045. * delta_2 = dt * dt
  4046. */
  4047. __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_parameters(__pyx_cur_scope->__pyx_v_p0, __pyx_cur_scope->__pyx_v_p1, __pyx_cur_scope->__pyx_v_p2, __pyx_cur_scope->__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error)
  4048. __Pyx_GOTREF(__pyx_t_1);
  4049. if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
  4050. PyObject* sequence = __pyx_t_1;
  4051. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  4052. if (unlikely(size != 4)) {
  4053. if (size > 4) __Pyx_RaiseTooManyValuesError(4);
  4054. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  4055. __PYX_ERR(0, 165, __pyx_L1_error)
  4056. }
  4057. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  4058. if (likely(PyTuple_CheckExact(sequence))) {
  4059. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
  4060. __Pyx_INCREF(__pyx_t_2);
  4061. __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1);
  4062. __Pyx_INCREF(__pyx_t_3);
  4063. __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2);
  4064. __Pyx_INCREF(__pyx_t_4);
  4065. __pyx_t_5 = PyTuple_GET_ITEM(sequence, 3);
  4066. __Pyx_INCREF(__pyx_t_5);
  4067. } else {
  4068. __pyx_t_2 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  4069. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error)
  4070. __Pyx_XGOTREF(__pyx_t_2);
  4071. __pyx_t_3 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  4072. if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error)
  4073. __Pyx_XGOTREF(__pyx_t_3);
  4074. __pyx_t_4 = __Pyx_PyList_GetItemRefFast(sequence, 2, __Pyx_ReferenceSharing_SharedReference);
  4075. if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error)
  4076. __Pyx_XGOTREF(__pyx_t_4);
  4077. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(sequence, 3, __Pyx_ReferenceSharing_SharedReference);
  4078. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error)
  4079. __Pyx_XGOTREF(__pyx_t_5);
  4080. }
  4081. #else
  4082. {
  4083. Py_ssize_t i;
  4084. PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
  4085. for (i=0; i < 4; i++) {
  4086. PyObject* item = __Pyx_PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 165, __pyx_L1_error)
  4087. __Pyx_GOTREF(item);
  4088. *(temps[i]) = item;
  4089. }
  4090. }
  4091. #endif
  4092. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4093. } else {
  4094. Py_ssize_t index = -1;
  4095. PyObject** temps[4] = {&__pyx_t_2,&__pyx_t_3,&__pyx_t_4,&__pyx_t_5};
  4096. __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 165, __pyx_L1_error)
  4097. __Pyx_GOTREF(__pyx_t_6);
  4098. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  4099. __pyx_t_7 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6);
  4100. for (index=0; index < 4; index++) {
  4101. PyObject* item = __pyx_t_7(__pyx_t_6); if (unlikely(!item)) goto __pyx_L4_unpacking_failed;
  4102. __Pyx_GOTREF(item);
  4103. *(temps[index]) = item;
  4104. }
  4105. if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 4) < (0)) __PYX_ERR(0, 165, __pyx_L1_error)
  4106. __pyx_t_7 = NULL;
  4107. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4108. goto __pyx_L5_unpacking_done;
  4109. __pyx_L4_unpacking_failed:;
  4110. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  4111. __pyx_t_7 = NULL;
  4112. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  4113. __PYX_ERR(0, 165, __pyx_L1_error)
  4114. __pyx_L5_unpacking_done:;
  4115. }
  4116. __pyx_t_8 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4117. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  4118. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_3); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4119. __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  4120. __pyx_t_10 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4121. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  4122. __pyx_t_11 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 165, __pyx_L1_error)
  4123. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  4124. __pyx_cur_scope->__pyx_v_a = __pyx_t_8;
  4125. __pyx_cur_scope->__pyx_v_b = __pyx_t_9;
  4126. __pyx_cur_scope->__pyx_v_c = __pyx_t_10;
  4127. __pyx_cur_scope->__pyx_v_d = __pyx_t_11;
  4128. /* "fontTools/cu2qu/cu2qu.py":166
  4129. * def _split_cubic_into_n_gen(p0, p1, p2, p3, n):
  4130. * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3)
  4131. * dt = 1 / n # <<<<<<<<<<<<<<
  4132. * delta_2 = dt * dt
  4133. * delta_3 = dt * delta_2
  4134. */
  4135. if (unlikely(__pyx_cur_scope->__pyx_v_n == 0)) {
  4136. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4137. __PYX_ERR(0, 166, __pyx_L1_error)
  4138. }
  4139. __pyx_cur_scope->__pyx_v_dt = (1.0 / ((double)__pyx_cur_scope->__pyx_v_n));
  4140. /* "fontTools/cu2qu/cu2qu.py":167
  4141. * a, b, c, d = calc_cubic_parameters(p0, p1, p2, p3)
  4142. * dt = 1 / n
  4143. * delta_2 = dt * dt # <<<<<<<<<<<<<<
  4144. * delta_3 = dt * delta_2
  4145. * for i in range(n):
  4146. */
  4147. __pyx_cur_scope->__pyx_v_delta_2 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_dt);
  4148. /* "fontTools/cu2qu/cu2qu.py":168
  4149. * dt = 1 / n
  4150. * delta_2 = dt * dt
  4151. * delta_3 = dt * delta_2 # <<<<<<<<<<<<<<
  4152. * for i in range(n):
  4153. * t1 = i * dt
  4154. */
  4155. __pyx_cur_scope->__pyx_v_delta_3 = (__pyx_cur_scope->__pyx_v_dt * __pyx_cur_scope->__pyx_v_delta_2);
  4156. /* "fontTools/cu2qu/cu2qu.py":169
  4157. * delta_2 = dt * dt
  4158. * delta_3 = dt * delta_2
  4159. * for i in range(n): # <<<<<<<<<<<<<<
  4160. * t1 = i * dt
  4161. * t1_2 = t1 * t1
  4162. */
  4163. __pyx_t_12 = __pyx_cur_scope->__pyx_v_n;
  4164. __pyx_t_13 = __pyx_t_12;
  4165. for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_13; __pyx_t_14+=1) {
  4166. __pyx_cur_scope->__pyx_v_i = __pyx_t_14;
  4167. /* "fontTools/cu2qu/cu2qu.py":170
  4168. * delta_3 = dt * delta_2
  4169. * for i in range(n):
  4170. * t1 = i * dt # <<<<<<<<<<<<<<
  4171. * t1_2 = t1 * t1
  4172. * # calc new a, b, c and d
  4173. */
  4174. __pyx_cur_scope->__pyx_v_t1 = (__pyx_cur_scope->__pyx_v_i * __pyx_cur_scope->__pyx_v_dt);
  4175. /* "fontTools/cu2qu/cu2qu.py":171
  4176. * for i in range(n):
  4177. * t1 = i * dt
  4178. * t1_2 = t1 * t1 # <<<<<<<<<<<<<<
  4179. * # calc new a, b, c and d
  4180. * a1 = a * delta_3
  4181. */
  4182. __pyx_cur_scope->__pyx_v_t1_2 = (__pyx_cur_scope->__pyx_v_t1 * __pyx_cur_scope->__pyx_v_t1);
  4183. /* "fontTools/cu2qu/cu2qu.py":173
  4184. * t1_2 = t1 * t1
  4185. * # calc new a, b, c and d
  4186. * a1 = a * delta_3 # <<<<<<<<<<<<<<
  4187. * b1 = (3 * a * t1 + b) * delta_2
  4188. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4189. */
  4190. __pyx_cur_scope->__pyx_v_a1 = __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_a, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_delta_3, 0));
  4191. /* "fontTools/cu2qu/cu2qu.py":174
  4192. * # calc new a, b, c and d
  4193. * a1 = a * delta_3
  4194. * b1 = (3 * a * t1 + b) * delta_2 # <<<<<<<<<<<<<<
  4195. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4196. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d
  4197. */
  4198. __pyx_cur_scope->__pyx_v_b1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_cur_scope->__pyx_v_a), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_cur_scope->__pyx_v_b), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_delta_2, 0));
  4199. /* "fontTools/cu2qu/cu2qu.py":175
  4200. * a1 = a * delta_3
  4201. * b1 = (3 * a * t1 + b) * delta_2
  4202. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt # <<<<<<<<<<<<<<
  4203. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d
  4204. * yield calc_cubic_points(a1, b1, c1, d1)
  4205. */
  4206. __pyx_cur_scope->__pyx_v_c1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_cur_scope->__pyx_v_b), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_cur_scope->__pyx_v_c), __Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_cur_scope->__pyx_v_a), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0))), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_dt, 0));
  4207. /* "fontTools/cu2qu/cu2qu.py":176
  4208. * b1 = (3 * a * t1 + b) * delta_2
  4209. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4210. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d # <<<<<<<<<<<<<<
  4211. * yield calc_cubic_points(a1, b1, c1, d1)
  4212. *
  4213. */
  4214. __pyx_cur_scope->__pyx_v_d1 = __Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_a, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0)), __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0)), __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_b, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1_2, 0))), __Pyx_c_prod_double(__pyx_cur_scope->__pyx_v_c, __pyx_t_double_complex_from_parts(__pyx_cur_scope->__pyx_v_t1, 0))), __pyx_cur_scope->__pyx_v_d);
  4215. /* "fontTools/cu2qu/cu2qu.py":177
  4216. * c1 = (2 * b * t1 + c + 3 * a * t1_2) * dt
  4217. * d1 = a * t1 * t1_2 + b * t1_2 + c * t1 + d
  4218. * yield calc_cubic_points(a1, b1, c1, d1) # <<<<<<<<<<<<<<
  4219. *
  4220. *
  4221. */
  4222. __pyx_t_1 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_cubic_points(__pyx_cur_scope->__pyx_v_a1, __pyx_cur_scope->__pyx_v_b1, __pyx_cur_scope->__pyx_v_c1, __pyx_cur_scope->__pyx_v_d1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
  4223. __Pyx_GOTREF(__pyx_t_1);
  4224. __pyx_r = __pyx_t_1;
  4225. __pyx_t_1 = 0;
  4226. __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
  4227. __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
  4228. __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
  4229. __Pyx_XGIVEREF(__pyx_r);
  4230. __Pyx_RefNannyFinishContext();
  4231. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4232. /* return from generator, yielding value */
  4233. __pyx_generator->resume_label = 1;
  4234. return __pyx_r;
  4235. __pyx_L8_resume_from_yield:;
  4236. __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
  4237. __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
  4238. __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
  4239. if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 177, __pyx_L1_error)
  4240. }
  4241. CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
  4242. /* "fontTools/cu2qu/cu2qu.py":150
  4243. *
  4244. *
  4245. * @cython.locals( # <<<<<<<<<<<<<<
  4246. * p0=cython.complex,
  4247. * p1=cython.complex,
  4248. */
  4249. /* function exit code */
  4250. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  4251. goto __pyx_L0;
  4252. __pyx_L1_error:;
  4253. __Pyx_XDECREF(__pyx_t_1);
  4254. __Pyx_XDECREF(__pyx_t_2);
  4255. __Pyx_XDECREF(__pyx_t_3);
  4256. __Pyx_XDECREF(__pyx_t_4);
  4257. __Pyx_XDECREF(__pyx_t_5);
  4258. __Pyx_XDECREF(__pyx_t_6);
  4259. if (__Pyx_PyErr_Occurred()) {
  4260. __Pyx_Generator_Replace_StopIteration(0);
  4261. __Pyx_AddTraceback("_split_cubic_into_n_gen", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4262. }
  4263. __pyx_L0:;
  4264. __Pyx_XGIVEREF(__pyx_r);
  4265. #if !CYTHON_USE_EXC_INFO_STACK
  4266. __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  4267. #endif
  4268. __pyx_generator->resume_label = -1;
  4269. __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  4270. __Pyx_RefNannyFinishContext();
  4271. return __pyx_r;
  4272. }
  4273. /* "fontTools/cu2qu/cu2qu.py":180
  4274. *
  4275. *
  4276. * @cython.cfunc # <<<<<<<<<<<<<<
  4277. * @cython.inline
  4278. * @cython.locals(
  4279. */
  4280. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_two(__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) {
  4281. __pyx_t_double_complex __pyx_v_mid;
  4282. __pyx_t_double_complex __pyx_v_deriv3;
  4283. PyObject *__pyx_r = NULL;
  4284. __Pyx_RefNannyDeclarations
  4285. PyObject *__pyx_t_1 = NULL;
  4286. __pyx_t_double_complex __pyx_t_2;
  4287. PyObject *__pyx_t_3 = NULL;
  4288. PyObject *__pyx_t_4 = NULL;
  4289. PyObject *__pyx_t_5 = NULL;
  4290. PyObject *__pyx_t_6 = NULL;
  4291. PyObject *__pyx_t_7 = NULL;
  4292. int __pyx_lineno = 0;
  4293. const char *__pyx_filename = NULL;
  4294. int __pyx_clineno = 0;
  4295. __Pyx_RefNannySetupContext("split_cubic_into_two", 0);
  4296. /* "fontTools/cu2qu/cu2qu.py":201
  4297. * values).
  4298. * """
  4299. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<<
  4300. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4301. * return (
  4302. */
  4303. __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));
  4304. /* "fontTools/cu2qu/cu2qu.py":202
  4305. * """
  4306. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4307. * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<<
  4308. * return (
  4309. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid),
  4310. */
  4311. __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));
  4312. /* "fontTools/cu2qu/cu2qu.py":203
  4313. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4314. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4315. * return ( # <<<<<<<<<<<<<<
  4316. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid),
  4317. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3),
  4318. */
  4319. __Pyx_XDECREF(__pyx_r);
  4320. /* "fontTools/cu2qu/cu2qu.py":204
  4321. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4322. * return (
  4323. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<<
  4324. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3),
  4325. * )
  4326. */
  4327. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
  4328. __Pyx_GOTREF(__pyx_t_1);
  4329. __pyx_t_2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p0, __pyx_v_p1), __pyx_t_double_complex_from_parts(0.5, 0));
  4330. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
  4331. __Pyx_GOTREF(__pyx_t_3);
  4332. __pyx_t_2 = __Pyx_c_diff_double(__pyx_v_mid, __pyx_v_deriv3);
  4333. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
  4334. __Pyx_GOTREF(__pyx_t_4);
  4335. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 204, __pyx_L1_error)
  4336. __Pyx_GOTREF(__pyx_t_5);
  4337. __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 204, __pyx_L1_error)
  4338. __Pyx_GOTREF(__pyx_t_6);
  4339. __Pyx_GIVEREF(__pyx_t_1);
  4340. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4341. __Pyx_GIVEREF(__pyx_t_3);
  4342. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4343. __Pyx_GIVEREF(__pyx_t_4);
  4344. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_4) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4345. __Pyx_GIVEREF(__pyx_t_5);
  4346. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_5) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4347. __pyx_t_1 = 0;
  4348. __pyx_t_3 = 0;
  4349. __pyx_t_4 = 0;
  4350. __pyx_t_5 = 0;
  4351. /* "fontTools/cu2qu/cu2qu.py":205
  4352. * return (
  4353. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid),
  4354. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3), # <<<<<<<<<<<<<<
  4355. * )
  4356. *
  4357. */
  4358. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_v_mid); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 205, __pyx_L1_error)
  4359. __Pyx_GOTREF(__pyx_t_5);
  4360. __pyx_t_2 = __Pyx_c_sum_double(__pyx_v_mid, __pyx_v_deriv3);
  4361. __pyx_t_4 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error)
  4362. __Pyx_GOTREF(__pyx_t_4);
  4363. __pyx_t_2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(0.5, 0));
  4364. __pyx_t_3 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 205, __pyx_L1_error)
  4365. __Pyx_GOTREF(__pyx_t_3);
  4366. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
  4367. __Pyx_GOTREF(__pyx_t_1);
  4368. __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 205, __pyx_L1_error)
  4369. __Pyx_GOTREF(__pyx_t_7);
  4370. __Pyx_GIVEREF(__pyx_t_5);
  4371. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4372. __Pyx_GIVEREF(__pyx_t_4);
  4373. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4374. __Pyx_GIVEREF(__pyx_t_3);
  4375. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_3) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4376. __Pyx_GIVEREF(__pyx_t_1);
  4377. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_1) != (0)) __PYX_ERR(0, 205, __pyx_L1_error);
  4378. __pyx_t_5 = 0;
  4379. __pyx_t_4 = 0;
  4380. __pyx_t_3 = 0;
  4381. __pyx_t_1 = 0;
  4382. /* "fontTools/cu2qu/cu2qu.py":204
  4383. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4384. * return (
  4385. * (p0, (p0 + p1) * 0.5, mid - deriv3, mid), # <<<<<<<<<<<<<<
  4386. * (mid, mid + deriv3, (p2 + p3) * 0.5, p3),
  4387. * )
  4388. */
  4389. __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
  4390. __Pyx_GOTREF(__pyx_t_1);
  4391. __Pyx_GIVEREF(__pyx_t_6);
  4392. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4393. __Pyx_GIVEREF(__pyx_t_7);
  4394. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7) != (0)) __PYX_ERR(0, 204, __pyx_L1_error);
  4395. __pyx_t_6 = 0;
  4396. __pyx_t_7 = 0;
  4397. __pyx_r = __pyx_t_1;
  4398. __pyx_t_1 = 0;
  4399. goto __pyx_L0;
  4400. /* "fontTools/cu2qu/cu2qu.py":180
  4401. *
  4402. *
  4403. * @cython.cfunc # <<<<<<<<<<<<<<
  4404. * @cython.inline
  4405. * @cython.locals(
  4406. */
  4407. /* function exit code */
  4408. __pyx_L1_error:;
  4409. __Pyx_XDECREF(__pyx_t_1);
  4410. __Pyx_XDECREF(__pyx_t_3);
  4411. __Pyx_XDECREF(__pyx_t_4);
  4412. __Pyx_XDECREF(__pyx_t_5);
  4413. __Pyx_XDECREF(__pyx_t_6);
  4414. __Pyx_XDECREF(__pyx_t_7);
  4415. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_two", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4416. __pyx_r = 0;
  4417. __pyx_L0:;
  4418. __Pyx_XGIVEREF(__pyx_r);
  4419. __Pyx_RefNannyFinishContext();
  4420. return __pyx_r;
  4421. }
  4422. /* "fontTools/cu2qu/cu2qu.py":209
  4423. *
  4424. *
  4425. * @cython.cfunc # <<<<<<<<<<<<<<
  4426. * @cython.inline
  4427. * @cython.locals(
  4428. */
  4429. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_three(__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) {
  4430. __pyx_t_double_complex __pyx_v_mid1;
  4431. __pyx_t_double_complex __pyx_v_deriv1;
  4432. __pyx_t_double_complex __pyx_v_mid2;
  4433. __pyx_t_double_complex __pyx_v_deriv2;
  4434. PyObject *__pyx_r = NULL;
  4435. __Pyx_RefNannyDeclarations
  4436. PyObject *__pyx_t_1 = NULL;
  4437. __pyx_t_double_complex __pyx_t_2;
  4438. __pyx_t_double_complex __pyx_t_3;
  4439. __pyx_t_double_complex __pyx_t_4;
  4440. PyObject *__pyx_t_5 = NULL;
  4441. PyObject *__pyx_t_6 = NULL;
  4442. PyObject *__pyx_t_7 = NULL;
  4443. PyObject *__pyx_t_8 = NULL;
  4444. PyObject *__pyx_t_9 = NULL;
  4445. PyObject *__pyx_t_10 = NULL;
  4446. int __pyx_lineno = 0;
  4447. const char *__pyx_filename = NULL;
  4448. int __pyx_clineno = 0;
  4449. __Pyx_RefNannySetupContext("split_cubic_into_three", 0);
  4450. /* "fontTools/cu2qu/cu2qu.py":238
  4451. * values).
  4452. * """
  4453. * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27) # <<<<<<<<<<<<<<
  4454. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27)
  4455. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4456. */
  4457. __pyx_v_mid1 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(8, 0), __pyx_v_p0), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(12, 0), __pyx_v_p1)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(6, 0), __pyx_v_p2)), __pyx_v_p3), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0));
  4458. /* "fontTools/cu2qu/cu2qu.py":239
  4459. * """
  4460. * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27)
  4461. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27) # <<<<<<<<<<<<<<
  4462. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4463. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4464. */
  4465. __pyx_v_deriv1 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_p3, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_v_p2)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(4, 0), __pyx_v_p0)), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0));
  4466. /* "fontTools/cu2qu/cu2qu.py":240
  4467. * mid1 = (8 * p0 + 12 * p1 + 6 * p2 + p3) * (1 / 27)
  4468. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27)
  4469. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27) # <<<<<<<<<<<<<<
  4470. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4471. * return (
  4472. */
  4473. __pyx_v_mid2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(6, 0), __pyx_v_p1)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(12, 0), __pyx_v_p2)), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(8, 0), __pyx_v_p3)), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0));
  4474. /* "fontTools/cu2qu/cu2qu.py":241
  4475. * deriv1 = (p3 + 3 * p2 - 4 * p0) * (1 / 27)
  4476. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4477. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27) # <<<<<<<<<<<<<<
  4478. * return (
  4479. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4480. */
  4481. __pyx_v_deriv2 = __Pyx_c_prod_double(__Pyx_c_diff_double(__Pyx_c_diff_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(4, 0), __pyx_v_p3), __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(3, 0), __pyx_v_p1)), __pyx_v_p0), __pyx_t_double_complex_from_parts((1.0 / 27.0), 0));
  4482. /* "fontTools/cu2qu/cu2qu.py":242
  4483. * mid2 = (p0 + 6 * p1 + 12 * p2 + 8 * p3) * (1 / 27)
  4484. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4485. * return ( # <<<<<<<<<<<<<<
  4486. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4487. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4488. */
  4489. __Pyx_XDECREF(__pyx_r);
  4490. /* "fontTools/cu2qu/cu2qu.py":243
  4491. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4492. * return (
  4493. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<<
  4494. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4495. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3),
  4496. */
  4497. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_p0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
  4498. __Pyx_GOTREF(__pyx_t_1);
  4499. __pyx_t_2 = __Pyx_c_sum_double(__Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_v_p0), __pyx_v_p1);
  4500. __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0);
  4501. if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) {
  4502. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4503. __PYX_ERR(0, 243, __pyx_L1_error)
  4504. }
  4505. __pyx_t_4 = __Pyx_c_quot_double(__pyx_t_2, __pyx_t_3);
  4506. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L1_error)
  4507. __Pyx_GOTREF(__pyx_t_5);
  4508. __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid1, __pyx_v_deriv1);
  4509. __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 243, __pyx_L1_error)
  4510. __Pyx_GOTREF(__pyx_t_6);
  4511. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L1_error)
  4512. __Pyx_GOTREF(__pyx_t_7);
  4513. __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 243, __pyx_L1_error)
  4514. __Pyx_GOTREF(__pyx_t_8);
  4515. __Pyx_GIVEREF(__pyx_t_1);
  4516. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4517. __Pyx_GIVEREF(__pyx_t_5);
  4518. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4519. __Pyx_GIVEREF(__pyx_t_6);
  4520. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_6) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4521. __Pyx_GIVEREF(__pyx_t_7);
  4522. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_7) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4523. __pyx_t_1 = 0;
  4524. __pyx_t_5 = 0;
  4525. __pyx_t_6 = 0;
  4526. __pyx_t_7 = 0;
  4527. /* "fontTools/cu2qu/cu2qu.py":244
  4528. * return (
  4529. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4530. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2), # <<<<<<<<<<<<<<
  4531. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3),
  4532. * )
  4533. */
  4534. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_mid1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 244, __pyx_L1_error)
  4535. __Pyx_GOTREF(__pyx_t_7);
  4536. __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid1, __pyx_v_deriv1);
  4537. __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 244, __pyx_L1_error)
  4538. __Pyx_GOTREF(__pyx_t_6);
  4539. __pyx_t_4 = __Pyx_c_diff_double(__pyx_v_mid2, __pyx_v_deriv2);
  4540. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 244, __pyx_L1_error)
  4541. __Pyx_GOTREF(__pyx_t_5);
  4542. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error)
  4543. __Pyx_GOTREF(__pyx_t_1);
  4544. __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 244, __pyx_L1_error)
  4545. __Pyx_GOTREF(__pyx_t_9);
  4546. __Pyx_GIVEREF(__pyx_t_7);
  4547. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4548. __Pyx_GIVEREF(__pyx_t_6);
  4549. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_6) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4550. __Pyx_GIVEREF(__pyx_t_5);
  4551. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_5) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4552. __Pyx_GIVEREF(__pyx_t_1);
  4553. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_1) != (0)) __PYX_ERR(0, 244, __pyx_L1_error);
  4554. __pyx_t_7 = 0;
  4555. __pyx_t_6 = 0;
  4556. __pyx_t_5 = 0;
  4557. __pyx_t_1 = 0;
  4558. /* "fontTools/cu2qu/cu2qu.py":245
  4559. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1),
  4560. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4561. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3), # <<<<<<<<<<<<<<
  4562. * )
  4563. *
  4564. */
  4565. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_mid2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error)
  4566. __Pyx_GOTREF(__pyx_t_1);
  4567. __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_mid2, __pyx_v_deriv2);
  4568. __pyx_t_5 = __pyx_PyComplex_FromComplex(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 245, __pyx_L1_error)
  4569. __Pyx_GOTREF(__pyx_t_5);
  4570. __pyx_t_4 = __Pyx_c_sum_double(__pyx_v_p2, __Pyx_c_prod_double(__pyx_t_double_complex_from_parts(2, 0), __pyx_v_p3));
  4571. __pyx_t_3 = __pyx_t_double_complex_from_parts(3.0, 0);
  4572. if (unlikely(__Pyx_c_is_zero_double(__pyx_t_3))) {
  4573. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4574. __PYX_ERR(0, 245, __pyx_L1_error)
  4575. }
  4576. __pyx_t_2 = __Pyx_c_quot_double(__pyx_t_4, __pyx_t_3);
  4577. __pyx_t_6 = __pyx_PyComplex_FromComplex(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 245, __pyx_L1_error)
  4578. __Pyx_GOTREF(__pyx_t_6);
  4579. __pyx_t_7 = __pyx_PyComplex_FromComplex(__pyx_v_p3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 245, __pyx_L1_error)
  4580. __Pyx_GOTREF(__pyx_t_7);
  4581. __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 245, __pyx_L1_error)
  4582. __Pyx_GOTREF(__pyx_t_10);
  4583. __Pyx_GIVEREF(__pyx_t_1);
  4584. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4585. __Pyx_GIVEREF(__pyx_t_5);
  4586. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4587. __Pyx_GIVEREF(__pyx_t_6);
  4588. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_6) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4589. __Pyx_GIVEREF(__pyx_t_7);
  4590. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_7) != (0)) __PYX_ERR(0, 245, __pyx_L1_error);
  4591. __pyx_t_1 = 0;
  4592. __pyx_t_5 = 0;
  4593. __pyx_t_6 = 0;
  4594. __pyx_t_7 = 0;
  4595. /* "fontTools/cu2qu/cu2qu.py":243
  4596. * deriv2 = (4 * p3 - 3 * p1 - p0) * (1 / 27)
  4597. * return (
  4598. * (p0, (2 * p0 + p1) / 3.0, mid1 - deriv1, mid1), # <<<<<<<<<<<<<<
  4599. * (mid1, mid1 + deriv1, mid2 - deriv2, mid2),
  4600. * (mid2, mid2 + deriv2, (p2 + 2 * p3) / 3.0, p3),
  4601. */
  4602. __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L1_error)
  4603. __Pyx_GOTREF(__pyx_t_7);
  4604. __Pyx_GIVEREF(__pyx_t_8);
  4605. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4606. __Pyx_GIVEREF(__pyx_t_9);
  4607. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4608. __Pyx_GIVEREF(__pyx_t_10);
  4609. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_10) != (0)) __PYX_ERR(0, 243, __pyx_L1_error);
  4610. __pyx_t_8 = 0;
  4611. __pyx_t_9 = 0;
  4612. __pyx_t_10 = 0;
  4613. __pyx_r = __pyx_t_7;
  4614. __pyx_t_7 = 0;
  4615. goto __pyx_L0;
  4616. /* "fontTools/cu2qu/cu2qu.py":209
  4617. *
  4618. *
  4619. * @cython.cfunc # <<<<<<<<<<<<<<
  4620. * @cython.inline
  4621. * @cython.locals(
  4622. */
  4623. /* function exit code */
  4624. __pyx_L1_error:;
  4625. __Pyx_XDECREF(__pyx_t_1);
  4626. __Pyx_XDECREF(__pyx_t_5);
  4627. __Pyx_XDECREF(__pyx_t_6);
  4628. __Pyx_XDECREF(__pyx_t_7);
  4629. __Pyx_XDECREF(__pyx_t_8);
  4630. __Pyx_XDECREF(__pyx_t_9);
  4631. __Pyx_XDECREF(__pyx_t_10);
  4632. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.split_cubic_into_three", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4633. __pyx_r = 0;
  4634. __pyx_L0:;
  4635. __Pyx_XGIVEREF(__pyx_r);
  4636. __Pyx_RefNannyFinishContext();
  4637. return __pyx_r;
  4638. }
  4639. /* "fontTools/cu2qu/cu2qu.py":249
  4640. *
  4641. *
  4642. * @cython.cfunc # <<<<<<<<<<<<<<
  4643. * @cython.inline
  4644. * @cython.returns(cython.complex)
  4645. */
  4646. static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(double __pyx_v_t, __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) {
  4647. __pyx_t_double_complex __pyx_v__p1;
  4648. __pyx_t_double_complex __pyx_v__p2;
  4649. __pyx_t_double_complex __pyx_r;
  4650. /* "fontTools/cu2qu/cu2qu.py":273
  4651. * complex: Location of candidate control point on quadratic curve.
  4652. * """
  4653. * _p1 = p0 + (p1 - p0) * 1.5 # <<<<<<<<<<<<<<
  4654. * _p2 = p3 + (p2 - p3) * 1.5
  4655. * return _p1 + (_p2 - _p1) * t
  4656. */
  4657. __pyx_v__p1 = __Pyx_c_sum_double(__pyx_v_p0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p1, __pyx_v_p0), __pyx_t_double_complex_from_parts(1.5, 0)));
  4658. /* "fontTools/cu2qu/cu2qu.py":274
  4659. * """
  4660. * _p1 = p0 + (p1 - p0) * 1.5
  4661. * _p2 = p3 + (p2 - p3) * 1.5 # <<<<<<<<<<<<<<
  4662. * return _p1 + (_p2 - _p1) * t
  4663. *
  4664. */
  4665. __pyx_v__p2 = __Pyx_c_sum_double(__pyx_v_p3, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_p2, __pyx_v_p3), __pyx_t_double_complex_from_parts(1.5, 0)));
  4666. /* "fontTools/cu2qu/cu2qu.py":275
  4667. * _p1 = p0 + (p1 - p0) * 1.5
  4668. * _p2 = p3 + (p2 - p3) * 1.5
  4669. * return _p1 + (_p2 - _p1) * t # <<<<<<<<<<<<<<
  4670. *
  4671. *
  4672. */
  4673. __pyx_r = __Pyx_c_sum_double(__pyx_v__p1, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v__p2, __pyx_v__p1), __pyx_t_double_complex_from_parts(__pyx_v_t, 0)));
  4674. goto __pyx_L0;
  4675. /* "fontTools/cu2qu/cu2qu.py":249
  4676. *
  4677. *
  4678. * @cython.cfunc # <<<<<<<<<<<<<<
  4679. * @cython.inline
  4680. * @cython.returns(cython.complex)
  4681. */
  4682. /* function exit code */
  4683. __pyx_L0:;
  4684. return __pyx_r;
  4685. }
  4686. /* "fontTools/cu2qu/cu2qu.py":278
  4687. *
  4688. *
  4689. * @cython.cfunc # <<<<<<<<<<<<<<
  4690. * @cython.inline
  4691. * @cython.returns(cython.complex)
  4692. */
  4693. static CYTHON_INLINE __pyx_t_double_complex __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_double_complex __pyx_v_a, __pyx_t_double_complex __pyx_v_b, __pyx_t_double_complex __pyx_v_c, __pyx_t_double_complex __pyx_v_d) {
  4694. __pyx_t_double_complex __pyx_v_ab;
  4695. __pyx_t_double_complex __pyx_v_cd;
  4696. __pyx_t_double_complex __pyx_v_p;
  4697. double __pyx_v_h;
  4698. __pyx_t_double_complex __pyx_r;
  4699. __Pyx_RefNannyDeclarations
  4700. PyObject *__pyx_t_1 = NULL;
  4701. PyObject *__pyx_t_2 = NULL;
  4702. PyObject *__pyx_t_3 = NULL;
  4703. double __pyx_t_4;
  4704. double __pyx_t_5;
  4705. int __pyx_t_6;
  4706. PyObject *__pyx_t_7 = NULL;
  4707. PyObject *__pyx_t_8 = NULL;
  4708. PyObject *__pyx_t_9 = NULL;
  4709. int __pyx_t_10;
  4710. int __pyx_t_11;
  4711. PyObject *__pyx_t_12 = NULL;
  4712. PyObject *__pyx_t_13 = NULL;
  4713. PyObject *__pyx_t_14 = NULL;
  4714. PyObject *__pyx_t_15 = NULL;
  4715. size_t __pyx_t_16;
  4716. __pyx_t_double_complex __pyx_t_17;
  4717. int __pyx_lineno = 0;
  4718. const char *__pyx_filename = NULL;
  4719. int __pyx_clineno = 0;
  4720. __Pyx_RefNannySetupContext("calc_intersect", 0);
  4721. /* "fontTools/cu2qu/cu2qu.py":296
  4722. * if no intersection was found.
  4723. * """
  4724. * ab = b - a # <<<<<<<<<<<<<<
  4725. * cd = d - c
  4726. * p = ab * 1j
  4727. */
  4728. __pyx_v_ab = __Pyx_c_diff_double(__pyx_v_b, __pyx_v_a);
  4729. /* "fontTools/cu2qu/cu2qu.py":297
  4730. * """
  4731. * ab = b - a
  4732. * cd = d - c # <<<<<<<<<<<<<<
  4733. * p = ab * 1j
  4734. * try:
  4735. */
  4736. __pyx_v_cd = __Pyx_c_diff_double(__pyx_v_d, __pyx_v_c);
  4737. /* "fontTools/cu2qu/cu2qu.py":298
  4738. * ab = b - a
  4739. * cd = d - c
  4740. * p = ab * 1j # <<<<<<<<<<<<<<
  4741. * try:
  4742. * h = dot(p, a - c) / dot(p, cd)
  4743. */
  4744. __pyx_v_p = __Pyx_c_prod_double(__pyx_v_ab, __pyx_t_double_complex_from_parts(0, 1.0));
  4745. /* "fontTools/cu2qu/cu2qu.py":299
  4746. * cd = d - c
  4747. * p = ab * 1j
  4748. * try: # <<<<<<<<<<<<<<
  4749. * h = dot(p, a - c) / dot(p, cd)
  4750. * except ZeroDivisionError:
  4751. */
  4752. {
  4753. __Pyx_PyThreadState_declare
  4754. __Pyx_PyThreadState_assign
  4755. __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
  4756. __Pyx_XGOTREF(__pyx_t_1);
  4757. __Pyx_XGOTREF(__pyx_t_2);
  4758. __Pyx_XGOTREF(__pyx_t_3);
  4759. /*try:*/ {
  4760. /* "fontTools/cu2qu/cu2qu.py":300
  4761. * p = ab * 1j
  4762. * try:
  4763. * h = dot(p, a - c) / dot(p, cd) # <<<<<<<<<<<<<<
  4764. * except ZeroDivisionError:
  4765. * # if 3 or 4 points are equal, we do have an intersection despite the zero-div:
  4766. */
  4767. __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_v_p, __Pyx_c_diff_double(__pyx_v_a, __pyx_v_c)); if (unlikely(__pyx_t_4 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L3_error)
  4768. __pyx_t_5 = __pyx_f_9fontTools_5cu2qu_5cu2qu_dot(__pyx_v_p, __pyx_v_cd); if (unlikely(__pyx_t_5 == ((double)-1) && PyErr_Occurred())) __PYX_ERR(0, 300, __pyx_L3_error)
  4769. if (unlikely(__pyx_t_5 == 0)) {
  4770. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  4771. __PYX_ERR(0, 300, __pyx_L3_error)
  4772. }
  4773. __pyx_v_h = (__pyx_t_4 / __pyx_t_5);
  4774. /* "fontTools/cu2qu/cu2qu.py":299
  4775. * cd = d - c
  4776. * p = ab * 1j
  4777. * try: # <<<<<<<<<<<<<<
  4778. * h = dot(p, a - c) / dot(p, cd)
  4779. * except ZeroDivisionError:
  4780. */
  4781. }
  4782. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  4783. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  4784. __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
  4785. goto __pyx_L8_try_end;
  4786. __pyx_L3_error:;
  4787. /* "fontTools/cu2qu/cu2qu.py":301
  4788. * try:
  4789. * h = dot(p, a - c) / dot(p, cd)
  4790. * except ZeroDivisionError: # <<<<<<<<<<<<<<
  4791. * # if 3 or 4 points are equal, we do have an intersection despite the zero-div:
  4792. * # return one of the off-curves so that the algorithm can attempt a one-curve
  4793. */
  4794. __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ZeroDivisionError))));
  4795. if (__pyx_t_6) {
  4796. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4797. if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 301, __pyx_L5_except_error)
  4798. __Pyx_XGOTREF(__pyx_t_7);
  4799. __Pyx_XGOTREF(__pyx_t_8);
  4800. __Pyx_XGOTREF(__pyx_t_9);
  4801. /* "fontTools/cu2qu/cu2qu.py":306
  4802. * # solution if it's within tolerance:
  4803. * # https://github.com/linebender/kurbo/pull/484
  4804. * if b == c and (a == b or c == d): # <<<<<<<<<<<<<<
  4805. * return b
  4806. * return complex(NAN, NAN)
  4807. */
  4808. __pyx_t_11 = (__Pyx_c_eq_double(__pyx_v_b, __pyx_v_c));
  4809. if (__pyx_t_11) {
  4810. } else {
  4811. __pyx_t_10 = __pyx_t_11;
  4812. goto __pyx_L12_bool_binop_done;
  4813. }
  4814. __pyx_t_11 = (__Pyx_c_eq_double(__pyx_v_a, __pyx_v_b));
  4815. if (!__pyx_t_11) {
  4816. } else {
  4817. __pyx_t_10 = __pyx_t_11;
  4818. goto __pyx_L12_bool_binop_done;
  4819. }
  4820. __pyx_t_11 = (__Pyx_c_eq_double(__pyx_v_c, __pyx_v_d));
  4821. __pyx_t_10 = __pyx_t_11;
  4822. __pyx_L12_bool_binop_done:;
  4823. if (__pyx_t_10) {
  4824. /* "fontTools/cu2qu/cu2qu.py":307
  4825. * # https://github.com/linebender/kurbo/pull/484
  4826. * if b == c and (a == b or c == d):
  4827. * return b # <<<<<<<<<<<<<<
  4828. * return complex(NAN, NAN)
  4829. * return c + cd * h
  4830. */
  4831. __pyx_r = __pyx_v_b;
  4832. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4833. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4834. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4835. goto __pyx_L6_except_return;
  4836. /* "fontTools/cu2qu/cu2qu.py":306
  4837. * # solution if it's within tolerance:
  4838. * # https://github.com/linebender/kurbo/pull/484
  4839. * if b == c and (a == b or c == d): # <<<<<<<<<<<<<<
  4840. * return b
  4841. * return complex(NAN, NAN)
  4842. */
  4843. }
  4844. /* "fontTools/cu2qu/cu2qu.py":308
  4845. * if b == c and (a == b or c == d):
  4846. * return b
  4847. * return complex(NAN, NAN) # <<<<<<<<<<<<<<
  4848. * return c + cd * h
  4849. *
  4850. */
  4851. __pyx_t_13 = NULL;
  4852. __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_NAN); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 308, __pyx_L5_except_error)
  4853. __Pyx_GOTREF(__pyx_t_14);
  4854. __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_NAN); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 308, __pyx_L5_except_error)
  4855. __Pyx_GOTREF(__pyx_t_15);
  4856. __pyx_t_16 = 1;
  4857. {
  4858. PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_t_14, __pyx_t_15};
  4859. __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)(&PyComplex_Type), __pyx_callargs+__pyx_t_16, (3-__pyx_t_16) | (__pyx_t_16*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  4860. __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
  4861. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  4862. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  4863. if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 308, __pyx_L5_except_error)
  4864. __Pyx_GOTREF(__pyx_t_12);
  4865. }
  4866. __pyx_t_17 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_12); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 308, __pyx_L5_except_error)
  4867. __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
  4868. __pyx_r = __pyx_t_17;
  4869. __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  4870. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  4871. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  4872. goto __pyx_L6_except_return;
  4873. }
  4874. goto __pyx_L5_except_error;
  4875. /* "fontTools/cu2qu/cu2qu.py":299
  4876. * cd = d - c
  4877. * p = ab * 1j
  4878. * try: # <<<<<<<<<<<<<<
  4879. * h = dot(p, a - c) / dot(p, cd)
  4880. * except ZeroDivisionError:
  4881. */
  4882. __pyx_L5_except_error:;
  4883. __Pyx_XGIVEREF(__pyx_t_1);
  4884. __Pyx_XGIVEREF(__pyx_t_2);
  4885. __Pyx_XGIVEREF(__pyx_t_3);
  4886. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  4887. goto __pyx_L1_error;
  4888. __pyx_L6_except_return:;
  4889. __Pyx_XGIVEREF(__pyx_t_1);
  4890. __Pyx_XGIVEREF(__pyx_t_2);
  4891. __Pyx_XGIVEREF(__pyx_t_3);
  4892. __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
  4893. goto __pyx_L0;
  4894. __pyx_L8_try_end:;
  4895. }
  4896. /* "fontTools/cu2qu/cu2qu.py":309
  4897. * return b
  4898. * return complex(NAN, NAN)
  4899. * return c + cd * h # <<<<<<<<<<<<<<
  4900. *
  4901. *
  4902. */
  4903. __pyx_r = __Pyx_c_sum_double(__pyx_v_c, __Pyx_c_prod_double(__pyx_v_cd, __pyx_t_double_complex_from_parts(__pyx_v_h, 0)));
  4904. goto __pyx_L0;
  4905. /* "fontTools/cu2qu/cu2qu.py":278
  4906. *
  4907. *
  4908. * @cython.cfunc # <<<<<<<<<<<<<<
  4909. * @cython.inline
  4910. * @cython.returns(cython.complex)
  4911. */
  4912. /* function exit code */
  4913. __pyx_L1_error:;
  4914. __Pyx_XDECREF(__pyx_t_7);
  4915. __Pyx_XDECREF(__pyx_t_8);
  4916. __Pyx_XDECREF(__pyx_t_9);
  4917. __Pyx_XDECREF(__pyx_t_12);
  4918. __Pyx_XDECREF(__pyx_t_13);
  4919. __Pyx_XDECREF(__pyx_t_14);
  4920. __Pyx_XDECREF(__pyx_t_15);
  4921. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.calc_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
  4922. __pyx_r = __pyx_t_double_complex_from_parts(0, 0);
  4923. __pyx_L0:;
  4924. __Pyx_RefNannyFinishContext();
  4925. return __pyx_r;
  4926. }
  4927. /* "fontTools/cu2qu/cu2qu.py":312
  4928. *
  4929. *
  4930. * @cython.cfunc # <<<<<<<<<<<<<<
  4931. * @cython.returns(cython.int)
  4932. * @cython.locals(
  4933. */
  4934. static int __pyx_f_9fontTools_5cu2qu_5cu2qu_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) {
  4935. __pyx_t_double_complex __pyx_v_mid;
  4936. __pyx_t_double_complex __pyx_v_deriv3;
  4937. int __pyx_r;
  4938. int __pyx_t_1;
  4939. int __pyx_t_2;
  4940. int __pyx_t_3;
  4941. int __pyx_t_4;
  4942. int __pyx_lineno = 0;
  4943. const char *__pyx_filename = NULL;
  4944. int __pyx_clineno = 0;
  4945. /* "fontTools/cu2qu/cu2qu.py":341
  4946. * """
  4947. * # First check p2 then p1, as p2 has higher error early on.
  4948. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  4949. * return True
  4950. *
  4951. */
  4952. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p2) <= __pyx_v_tolerance);
  4953. if (__pyx_t_2) {
  4954. } else {
  4955. __pyx_t_1 = __pyx_t_2;
  4956. goto __pyx_L4_bool_binop_done;
  4957. }
  4958. __pyx_t_2 = (__Pyx_c_abs_double(__pyx_v_p1) <= __pyx_v_tolerance);
  4959. __pyx_t_1 = __pyx_t_2;
  4960. __pyx_L4_bool_binop_done:;
  4961. if (__pyx_t_1) {
  4962. /* "fontTools/cu2qu/cu2qu.py":342
  4963. * # First check p2 then p1, as p2 has higher error early on.
  4964. * if abs(p2) <= tolerance and abs(p1) <= tolerance:
  4965. * return True # <<<<<<<<<<<<<<
  4966. *
  4967. * # Split.
  4968. */
  4969. __pyx_r = 1;
  4970. goto __pyx_L0;
  4971. /* "fontTools/cu2qu/cu2qu.py":341
  4972. * """
  4973. * # First check p2 then p1, as p2 has higher error early on.
  4974. * if abs(p2) <= tolerance and abs(p1) <= tolerance: # <<<<<<<<<<<<<<
  4975. * return True
  4976. *
  4977. */
  4978. }
  4979. /* "fontTools/cu2qu/cu2qu.py":345
  4980. *
  4981. * # Split.
  4982. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125 # <<<<<<<<<<<<<<
  4983. * if abs(mid) > tolerance:
  4984. * return False
  4985. */
  4986. __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));
  4987. /* "fontTools/cu2qu/cu2qu.py":346
  4988. * # Split.
  4989. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4990. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  4991. * return False
  4992. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  4993. */
  4994. __pyx_t_1 = (__Pyx_c_abs_double(__pyx_v_mid) > __pyx_v_tolerance);
  4995. if (__pyx_t_1) {
  4996. /* "fontTools/cu2qu/cu2qu.py":347
  4997. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  4998. * if abs(mid) > tolerance:
  4999. * return False # <<<<<<<<<<<<<<
  5000. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  5001. * return cubic_farthest_fit_inside(
  5002. */
  5003. __pyx_r = 0;
  5004. goto __pyx_L0;
  5005. /* "fontTools/cu2qu/cu2qu.py":346
  5006. * # Split.
  5007. * mid = (p0 + 3 * (p1 + p2) + p3) * 0.125
  5008. * if abs(mid) > tolerance: # <<<<<<<<<<<<<<
  5009. * return False
  5010. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  5011. */
  5012. }
  5013. /* "fontTools/cu2qu/cu2qu.py":348
  5014. * if abs(mid) > tolerance:
  5015. * return False
  5016. * deriv3 = (p3 + p2 - p1 - p0) * 0.125 # <<<<<<<<<<<<<<
  5017. * return cubic_farthest_fit_inside(
  5018. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  5019. */
  5020. __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));
  5021. /* "fontTools/cu2qu/cu2qu.py":349
  5022. * return False
  5023. * deriv3 = (p3 + p2 - p1 - p0) * 0.125
  5024. * return cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5025. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  5026. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance)
  5027. */
  5028. __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_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, 349, __pyx_L1_error)
  5029. if (__pyx_t_4) {
  5030. } else {
  5031. __pyx_t_3 = __pyx_t_4;
  5032. goto __pyx_L7_bool_binop_done;
  5033. }
  5034. /* "fontTools/cu2qu/cu2qu.py":351
  5035. * return cubic_farthest_fit_inside(
  5036. * p0, (p0 + p1) * 0.5, mid - deriv3, mid, tolerance
  5037. * ) and cubic_farthest_fit_inside(mid, mid + deriv3, (p2 + p3) * 0.5, p3, tolerance) # <<<<<<<<<<<<<<
  5038. *
  5039. *
  5040. */
  5041. __pyx_t_4 = __pyx_f_9fontTools_5cu2qu_5cu2qu_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, 351, __pyx_L1_error)
  5042. __pyx_t_3 = __pyx_t_4;
  5043. __pyx_L7_bool_binop_done:;
  5044. __pyx_r = __pyx_t_3;
  5045. goto __pyx_L0;
  5046. /* "fontTools/cu2qu/cu2qu.py":312
  5047. *
  5048. *
  5049. * @cython.cfunc # <<<<<<<<<<<<<<
  5050. * @cython.returns(cython.int)
  5051. * @cython.locals(
  5052. */
  5053. /* function exit code */
  5054. __pyx_L1_error:;
  5055. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_farthest_fit_inside", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5056. __pyx_r = -1;
  5057. __pyx_L0:;
  5058. return __pyx_r;
  5059. }
  5060. /* "fontTools/cu2qu/cu2qu.py":354
  5061. *
  5062. *
  5063. * @cython.cfunc # <<<<<<<<<<<<<<
  5064. * @cython.inline
  5065. * @cython.locals(tolerance=cython.double)
  5066. */
  5067. static CYTHON_INLINE PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(PyObject *__pyx_v_cubic, double __pyx_v_tolerance) {
  5068. __pyx_t_double_complex __pyx_v_q1;
  5069. __pyx_t_double_complex __pyx_v_c0;
  5070. __pyx_t_double_complex __pyx_v_c1;
  5071. __pyx_t_double_complex __pyx_v_c2;
  5072. __pyx_t_double_complex __pyx_v_c3;
  5073. PyObject *__pyx_r = NULL;
  5074. __Pyx_RefNannyDeclarations
  5075. PyObject *__pyx_t_1 = NULL;
  5076. __pyx_t_double_complex __pyx_t_2;
  5077. __pyx_t_double_complex __pyx_t_3;
  5078. __pyx_t_double_complex __pyx_t_4;
  5079. __pyx_t_double_complex __pyx_t_5;
  5080. __pyx_t_double_complex __pyx_t_6;
  5081. PyObject *__pyx_t_7 = NULL;
  5082. PyObject *__pyx_t_8 = NULL;
  5083. PyObject *__pyx_t_9 = NULL;
  5084. size_t __pyx_t_10;
  5085. int __pyx_t_11;
  5086. int __pyx_t_12;
  5087. int __pyx_lineno = 0;
  5088. const char *__pyx_filename = NULL;
  5089. int __pyx_clineno = 0;
  5090. __Pyx_RefNannySetupContext("cubic_approx_quadratic", 0);
  5091. /* "fontTools/cu2qu/cu2qu.py":378
  5092. * """
  5093. *
  5094. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3]) # <<<<<<<<<<<<<<
  5095. * if math.isnan(q1.imag):
  5096. * return None
  5097. */
  5098. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error)
  5099. __Pyx_GOTREF(__pyx_t_1);
  5100. __pyx_t_2 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5101. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5102. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error)
  5103. __Pyx_GOTREF(__pyx_t_1);
  5104. __pyx_t_3 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5105. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5106. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error)
  5107. __Pyx_GOTREF(__pyx_t_1);
  5108. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5109. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5110. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 378, __pyx_L1_error)
  5111. __Pyx_GOTREF(__pyx_t_1);
  5112. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5113. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5114. __pyx_t_6 = __pyx_f_9fontTools_5cu2qu_5cu2qu_calc_intersect(__pyx_t_2, __pyx_t_3, __pyx_t_4, __pyx_t_5); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 378, __pyx_L1_error)
  5115. __pyx_v_q1 = __pyx_t_6;
  5116. /* "fontTools/cu2qu/cu2qu.py":379
  5117. *
  5118. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3])
  5119. * if math.isnan(q1.imag): # <<<<<<<<<<<<<<
  5120. * return None
  5121. * c0 = cubic[0]
  5122. */
  5123. __pyx_t_7 = NULL;
  5124. __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_math); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 379, __pyx_L1_error)
  5125. __Pyx_GOTREF(__pyx_t_8);
  5126. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_isnan); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 379, __pyx_L1_error)
  5127. __Pyx_GOTREF(__pyx_t_9);
  5128. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5129. __pyx_t_8 = PyFloat_FromDouble(__Pyx_CIMAG(__pyx_v_q1)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 379, __pyx_L1_error)
  5130. __Pyx_GOTREF(__pyx_t_8);
  5131. __pyx_t_10 = 1;
  5132. #if CYTHON_UNPACK_METHODS
  5133. if (unlikely(PyMethod_Check(__pyx_t_9))) {
  5134. __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
  5135. assert(__pyx_t_7);
  5136. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
  5137. __Pyx_INCREF(__pyx_t_7);
  5138. __Pyx_INCREF(__pyx__function);
  5139. __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
  5140. __pyx_t_10 = 0;
  5141. }
  5142. #endif
  5143. {
  5144. PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_8};
  5145. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  5146. __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
  5147. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5148. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  5149. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 379, __pyx_L1_error)
  5150. __Pyx_GOTREF(__pyx_t_1);
  5151. }
  5152. __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 379, __pyx_L1_error)
  5153. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5154. if (__pyx_t_11) {
  5155. /* "fontTools/cu2qu/cu2qu.py":380
  5156. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3])
  5157. * if math.isnan(q1.imag):
  5158. * return None # <<<<<<<<<<<<<<
  5159. * c0 = cubic[0]
  5160. * c3 = cubic[3]
  5161. */
  5162. __Pyx_XDECREF(__pyx_r);
  5163. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5164. goto __pyx_L0;
  5165. /* "fontTools/cu2qu/cu2qu.py":379
  5166. *
  5167. * q1 = calc_intersect(cubic[0], cubic[1], cubic[2], cubic[3])
  5168. * if math.isnan(q1.imag): # <<<<<<<<<<<<<<
  5169. * return None
  5170. * c0 = cubic[0]
  5171. */
  5172. }
  5173. /* "fontTools/cu2qu/cu2qu.py":381
  5174. * if math.isnan(q1.imag):
  5175. * return None
  5176. * c0 = cubic[0] # <<<<<<<<<<<<<<
  5177. * c3 = cubic[3]
  5178. * c1 = c0 + (q1 - c0) * (2 / 3)
  5179. */
  5180. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 381, __pyx_L1_error)
  5181. __Pyx_GOTREF(__pyx_t_1);
  5182. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 381, __pyx_L1_error)
  5183. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5184. __pyx_v_c0 = __pyx_t_6;
  5185. /* "fontTools/cu2qu/cu2qu.py":382
  5186. * return None
  5187. * c0 = cubic[0]
  5188. * c3 = cubic[3] # <<<<<<<<<<<<<<
  5189. * c1 = c0 + (q1 - c0) * (2 / 3)
  5190. * c2 = c3 + (q1 - c3) * (2 / 3)
  5191. */
  5192. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 382, __pyx_L1_error)
  5193. __Pyx_GOTREF(__pyx_t_1);
  5194. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 382, __pyx_L1_error)
  5195. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5196. __pyx_v_c3 = __pyx_t_6;
  5197. /* "fontTools/cu2qu/cu2qu.py":383
  5198. * c0 = cubic[0]
  5199. * c3 = cubic[3]
  5200. * c1 = c0 + (q1 - c0) * (2 / 3) # <<<<<<<<<<<<<<
  5201. * c2 = c3 + (q1 - c3) * (2 / 3)
  5202. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5203. */
  5204. __pyx_v_c1 = __Pyx_c_sum_double(__pyx_v_c0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_c0), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0)));
  5205. /* "fontTools/cu2qu/cu2qu.py":384
  5206. * c3 = cubic[3]
  5207. * c1 = c0 + (q1 - c0) * (2 / 3)
  5208. * c2 = c3 + (q1 - c3) * (2 / 3) # <<<<<<<<<<<<<<
  5209. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5210. * return None
  5211. */
  5212. __pyx_v_c2 = __Pyx_c_sum_double(__pyx_v_c3, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_c3), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0)));
  5213. /* "fontTools/cu2qu/cu2qu.py":385
  5214. * c1 = c0 + (q1 - c0) * (2 / 3)
  5215. * c2 = c3 + (q1 - c3) * (2 / 3)
  5216. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<<
  5217. * return None
  5218. * return c0, q1, c3
  5219. */
  5220. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  5221. __Pyx_GOTREF(__pyx_t_1);
  5222. __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 385, __pyx_L1_error)
  5223. __Pyx_GOTREF(__pyx_t_9);
  5224. __pyx_t_8 = PyNumber_Subtract(__pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L1_error)
  5225. __Pyx_GOTREF(__pyx_t_8);
  5226. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5227. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  5228. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 385, __pyx_L1_error)
  5229. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5230. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_c2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 385, __pyx_L1_error)
  5231. __Pyx_GOTREF(__pyx_t_8);
  5232. __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 385, __pyx_L1_error)
  5233. __Pyx_GOTREF(__pyx_t_9);
  5234. __pyx_t_1 = PyNumber_Subtract(__pyx_t_8, __pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 385, __pyx_L1_error)
  5235. __Pyx_GOTREF(__pyx_t_1);
  5236. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5237. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  5238. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_1); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 385, __pyx_L1_error)
  5239. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  5240. __pyx_t_12 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_t_double_complex_from_parts(0, 0), __pyx_t_6, __pyx_t_5, __pyx_t_double_complex_from_parts(0, 0), __pyx_v_tolerance); if (unlikely(__pyx_t_12 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 385, __pyx_L1_error)
  5241. __pyx_t_11 = (!(__pyx_t_12 != 0));
  5242. if (__pyx_t_11) {
  5243. /* "fontTools/cu2qu/cu2qu.py":386
  5244. * c2 = c3 + (q1 - c3) * (2 / 3)
  5245. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5246. * return None # <<<<<<<<<<<<<<
  5247. * return c0, q1, c3
  5248. *
  5249. */
  5250. __Pyx_XDECREF(__pyx_r);
  5251. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5252. goto __pyx_L0;
  5253. /* "fontTools/cu2qu/cu2qu.py":385
  5254. * c1 = c0 + (q1 - c0) * (2 / 3)
  5255. * c2 = c3 + (q1 - c3) * (2 / 3)
  5256. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance): # <<<<<<<<<<<<<<
  5257. * return None
  5258. * return c0, q1, c3
  5259. */
  5260. }
  5261. /* "fontTools/cu2qu/cu2qu.py":387
  5262. * if not cubic_farthest_fit_inside(0, c1 - cubic[1], c2 - cubic[2], 0, tolerance):
  5263. * return None
  5264. * return c0, q1, c3 # <<<<<<<<<<<<<<
  5265. *
  5266. *
  5267. */
  5268. __Pyx_XDECREF(__pyx_r);
  5269. __pyx_t_1 = __pyx_PyComplex_FromComplex(__pyx_v_c0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L1_error)
  5270. __Pyx_GOTREF(__pyx_t_1);
  5271. __pyx_t_9 = __pyx_PyComplex_FromComplex(__pyx_v_q1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 387, __pyx_L1_error)
  5272. __Pyx_GOTREF(__pyx_t_9);
  5273. __pyx_t_8 = __pyx_PyComplex_FromComplex(__pyx_v_c3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 387, __pyx_L1_error)
  5274. __Pyx_GOTREF(__pyx_t_8);
  5275. __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 387, __pyx_L1_error)
  5276. __Pyx_GOTREF(__pyx_t_7);
  5277. __Pyx_GIVEREF(__pyx_t_1);
  5278. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 387, __pyx_L1_error);
  5279. __Pyx_GIVEREF(__pyx_t_9);
  5280. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 387, __pyx_L1_error);
  5281. __Pyx_GIVEREF(__pyx_t_8);
  5282. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_8) != (0)) __PYX_ERR(0, 387, __pyx_L1_error);
  5283. __pyx_t_1 = 0;
  5284. __pyx_t_9 = 0;
  5285. __pyx_t_8 = 0;
  5286. __pyx_r = __pyx_t_7;
  5287. __pyx_t_7 = 0;
  5288. goto __pyx_L0;
  5289. /* "fontTools/cu2qu/cu2qu.py":354
  5290. *
  5291. *
  5292. * @cython.cfunc # <<<<<<<<<<<<<<
  5293. * @cython.inline
  5294. * @cython.locals(tolerance=cython.double)
  5295. */
  5296. /* function exit code */
  5297. __pyx_L1_error:;
  5298. __Pyx_XDECREF(__pyx_t_1);
  5299. __Pyx_XDECREF(__pyx_t_7);
  5300. __Pyx_XDECREF(__pyx_t_8);
  5301. __Pyx_XDECREF(__pyx_t_9);
  5302. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5303. __pyx_r = 0;
  5304. __pyx_L0:;
  5305. __Pyx_XGIVEREF(__pyx_r);
  5306. __Pyx_RefNannyFinishContext();
  5307. return __pyx_r;
  5308. }
  5309. /* "fontTools/cu2qu/cu2qu.py":390
  5310. *
  5311. *
  5312. * @cython.cfunc # <<<<<<<<<<<<<<
  5313. * @cython.locals(n=cython.int, tolerance=cython.double)
  5314. * @cython.locals(i=cython.int)
  5315. */
  5316. static PyObject *__pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(PyObject *__pyx_v_cubic, int __pyx_v_n, double __pyx_v_tolerance, int __pyx_v_all_quadratic) {
  5317. __pyx_t_double_complex __pyx_v_q0;
  5318. __pyx_t_double_complex __pyx_v_q1;
  5319. __pyx_t_double_complex __pyx_v_next_q1;
  5320. __pyx_t_double_complex __pyx_v_q2;
  5321. __pyx_t_double_complex __pyx_v_d1;
  5322. CYTHON_UNUSED __pyx_t_double_complex __pyx_v_c0;
  5323. __pyx_t_double_complex __pyx_v_c1;
  5324. __pyx_t_double_complex __pyx_v_c2;
  5325. __pyx_t_double_complex __pyx_v_c3;
  5326. int __pyx_v_i;
  5327. PyObject *__pyx_v_cubics = NULL;
  5328. PyObject *__pyx_v_next_cubic = NULL;
  5329. PyObject *__pyx_v_spline = NULL;
  5330. __pyx_t_double_complex __pyx_v_d0;
  5331. PyObject *__pyx_r = NULL;
  5332. __Pyx_RefNannyDeclarations
  5333. int __pyx_t_1;
  5334. PyObject *__pyx_t_2 = NULL;
  5335. int __pyx_t_3;
  5336. __pyx_t_double_complex __pyx_t_4;
  5337. __pyx_t_double_complex __pyx_t_5;
  5338. __pyx_t_double_complex __pyx_t_6;
  5339. __pyx_t_double_complex __pyx_t_7;
  5340. PyObject *__pyx_t_8 = NULL;
  5341. __pyx_t_double_complex __pyx_t_9;
  5342. PyObject *__pyx_t_10 = NULL;
  5343. long __pyx_t_11;
  5344. long __pyx_t_12;
  5345. int __pyx_t_13;
  5346. PyObject *__pyx_t_14 = NULL;
  5347. PyObject *__pyx_t_15 = NULL;
  5348. PyObject *(*__pyx_t_16)(PyObject *);
  5349. long __pyx_t_17;
  5350. int __pyx_t_18;
  5351. int __pyx_t_19;
  5352. int __pyx_lineno = 0;
  5353. const char *__pyx_filename = NULL;
  5354. int __pyx_clineno = 0;
  5355. __Pyx_RefNannySetupContext("cubic_approx_spline", 0);
  5356. /* "fontTools/cu2qu/cu2qu.py":419
  5357. * """
  5358. *
  5359. * if n == 1: # <<<<<<<<<<<<<<
  5360. * return cubic_approx_quadratic(cubic, tolerance)
  5361. * if n == 2 and all_quadratic == False:
  5362. */
  5363. __pyx_t_1 = (__pyx_v_n == 1);
  5364. if (__pyx_t_1) {
  5365. /* "fontTools/cu2qu/cu2qu.py":420
  5366. *
  5367. * if n == 1:
  5368. * return cubic_approx_quadratic(cubic, tolerance) # <<<<<<<<<<<<<<
  5369. * if n == 2 and all_quadratic == False:
  5370. * return cubic
  5371. */
  5372. __Pyx_XDECREF(__pyx_r);
  5373. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_quadratic(__pyx_v_cubic, __pyx_v_tolerance); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 420, __pyx_L1_error)
  5374. __Pyx_GOTREF(__pyx_t_2);
  5375. __pyx_r = __pyx_t_2;
  5376. __pyx_t_2 = 0;
  5377. goto __pyx_L0;
  5378. /* "fontTools/cu2qu/cu2qu.py":419
  5379. * """
  5380. *
  5381. * if n == 1: # <<<<<<<<<<<<<<
  5382. * return cubic_approx_quadratic(cubic, tolerance)
  5383. * if n == 2 and all_quadratic == False:
  5384. */
  5385. }
  5386. /* "fontTools/cu2qu/cu2qu.py":421
  5387. * if n == 1:
  5388. * return cubic_approx_quadratic(cubic, tolerance)
  5389. * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<<
  5390. * return cubic
  5391. *
  5392. */
  5393. __pyx_t_3 = (__pyx_v_n == 2);
  5394. if (__pyx_t_3) {
  5395. } else {
  5396. __pyx_t_1 = __pyx_t_3;
  5397. goto __pyx_L5_bool_binop_done;
  5398. }
  5399. __pyx_t_3 = (__pyx_v_all_quadratic == 0);
  5400. __pyx_t_1 = __pyx_t_3;
  5401. __pyx_L5_bool_binop_done:;
  5402. if (__pyx_t_1) {
  5403. /* "fontTools/cu2qu/cu2qu.py":422
  5404. * return cubic_approx_quadratic(cubic, tolerance)
  5405. * if n == 2 and all_quadratic == False:
  5406. * return cubic # <<<<<<<<<<<<<<
  5407. *
  5408. * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n)
  5409. */
  5410. __Pyx_XDECREF(__pyx_r);
  5411. __Pyx_INCREF(__pyx_v_cubic);
  5412. __pyx_r = __pyx_v_cubic;
  5413. goto __pyx_L0;
  5414. /* "fontTools/cu2qu/cu2qu.py":421
  5415. * if n == 1:
  5416. * return cubic_approx_quadratic(cubic, tolerance)
  5417. * if n == 2 and all_quadratic == False: # <<<<<<<<<<<<<<
  5418. * return cubic
  5419. *
  5420. */
  5421. }
  5422. /* "fontTools/cu2qu/cu2qu.py":424
  5423. * return cubic
  5424. *
  5425. * cubics = split_cubic_into_n_iter(cubic[0], cubic[1], cubic[2], cubic[3], n) # <<<<<<<<<<<<<<
  5426. *
  5427. * # calculate the spline of quadratics and check errors at the same time.
  5428. */
  5429. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  5430. __Pyx_GOTREF(__pyx_t_2);
  5431. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5432. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5433. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  5434. __Pyx_GOTREF(__pyx_t_2);
  5435. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5436. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5437. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  5438. __Pyx_GOTREF(__pyx_t_2);
  5439. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5440. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5441. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  5442. __Pyx_GOTREF(__pyx_t_2);
  5443. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 424, __pyx_L1_error)
  5444. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5445. __pyx_t_2 = __Pyx_PyLong_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 424, __pyx_L1_error)
  5446. __Pyx_GOTREF(__pyx_t_2);
  5447. __pyx_t_8 = __pyx_f_9fontTools_5cu2qu_5cu2qu_split_cubic_into_n_iter(__pyx_t_4, __pyx_t_5, __pyx_t_6, __pyx_t_7, __pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 424, __pyx_L1_error)
  5448. __Pyx_GOTREF(__pyx_t_8);
  5449. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5450. __pyx_v_cubics = __pyx_t_8;
  5451. __pyx_t_8 = 0;
  5452. /* "fontTools/cu2qu/cu2qu.py":427
  5453. *
  5454. * # calculate the spline of quadratics and check errors at the same time.
  5455. * next_cubic = next(cubics) # <<<<<<<<<<<<<<
  5456. * next_q1 = cubic_approx_control(
  5457. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5458. */
  5459. __pyx_t_8 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 427, __pyx_L1_error)
  5460. __Pyx_GOTREF(__pyx_t_8);
  5461. __pyx_v_next_cubic = __pyx_t_8;
  5462. __pyx_t_8 = 0;
  5463. /* "fontTools/cu2qu/cu2qu.py":429
  5464. * next_cubic = next(cubics)
  5465. * next_q1 = cubic_approx_control(
  5466. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<<
  5467. * )
  5468. * q2 = cubic[0]
  5469. */
  5470. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 429, __pyx_L1_error)
  5471. __Pyx_GOTREF(__pyx_t_8);
  5472. __pyx_t_7 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5473. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5474. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 429, __pyx_L1_error)
  5475. __Pyx_GOTREF(__pyx_t_8);
  5476. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5477. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5478. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 429, __pyx_L1_error)
  5479. __Pyx_GOTREF(__pyx_t_8);
  5480. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5481. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5482. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_next_cubic, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 429, __pyx_L1_error)
  5483. __Pyx_GOTREF(__pyx_t_8);
  5484. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 429, __pyx_L1_error)
  5485. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5486. /* "fontTools/cu2qu/cu2qu.py":428
  5487. * # calculate the spline of quadratics and check errors at the same time.
  5488. * next_cubic = next(cubics)
  5489. * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<<
  5490. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5491. * )
  5492. */
  5493. __pyx_t_9 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control(0.0, __pyx_t_7, __pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 428, __pyx_L1_error)
  5494. __pyx_v_next_q1 = __pyx_t_9;
  5495. /* "fontTools/cu2qu/cu2qu.py":431
  5496. * 0, next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5497. * )
  5498. * q2 = cubic[0] # <<<<<<<<<<<<<<
  5499. * d1 = 0j
  5500. * spline = [cubic[0], next_q1]
  5501. */
  5502. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 431, __pyx_L1_error)
  5503. __Pyx_GOTREF(__pyx_t_8);
  5504. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 431, __pyx_L1_error)
  5505. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5506. __pyx_v_q2 = __pyx_t_9;
  5507. /* "fontTools/cu2qu/cu2qu.py":432
  5508. * )
  5509. * q2 = cubic[0]
  5510. * d1 = 0j # <<<<<<<<<<<<<<
  5511. * spline = [cubic[0], next_q1]
  5512. * for i in range(1, n + 1):
  5513. */
  5514. __pyx_v_d1 = __pyx_t_double_complex_from_parts(0, 0.0);
  5515. /* "fontTools/cu2qu/cu2qu.py":433
  5516. * q2 = cubic[0]
  5517. * d1 = 0j
  5518. * spline = [cubic[0], next_q1] # <<<<<<<<<<<<<<
  5519. * for i in range(1, n + 1):
  5520. * # Current cubic to convert
  5521. */
  5522. __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_cubic, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 433, __pyx_L1_error)
  5523. __Pyx_GOTREF(__pyx_t_8);
  5524. __pyx_t_2 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 433, __pyx_L1_error)
  5525. __Pyx_GOTREF(__pyx_t_2);
  5526. __pyx_t_10 = PyList_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 433, __pyx_L1_error)
  5527. __Pyx_GOTREF(__pyx_t_10);
  5528. __Pyx_GIVEREF(__pyx_t_8);
  5529. if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 0, __pyx_t_8) != (0)) __PYX_ERR(0, 433, __pyx_L1_error);
  5530. __Pyx_GIVEREF(__pyx_t_2);
  5531. if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 1, __pyx_t_2) != (0)) __PYX_ERR(0, 433, __pyx_L1_error);
  5532. __pyx_t_8 = 0;
  5533. __pyx_t_2 = 0;
  5534. __pyx_v_spline = ((PyObject*)__pyx_t_10);
  5535. __pyx_t_10 = 0;
  5536. /* "fontTools/cu2qu/cu2qu.py":434
  5537. * d1 = 0j
  5538. * spline = [cubic[0], next_q1]
  5539. * for i in range(1, n + 1): # <<<<<<<<<<<<<<
  5540. * # Current cubic to convert
  5541. * c0, c1, c2, c3 = next_cubic
  5542. */
  5543. __pyx_t_11 = (__pyx_v_n + 1);
  5544. __pyx_t_12 = __pyx_t_11;
  5545. for (__pyx_t_13 = 1; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
  5546. __pyx_v_i = __pyx_t_13;
  5547. /* "fontTools/cu2qu/cu2qu.py":436
  5548. * for i in range(1, n + 1):
  5549. * # Current cubic to convert
  5550. * c0, c1, c2, c3 = next_cubic # <<<<<<<<<<<<<<
  5551. *
  5552. * # Current quadratic approximation of current cubic
  5553. */
  5554. if ((likely(PyTuple_CheckExact(__pyx_v_next_cubic))) || (PyList_CheckExact(__pyx_v_next_cubic))) {
  5555. PyObject* sequence = __pyx_v_next_cubic;
  5556. Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
  5557. if (unlikely(size != 4)) {
  5558. if (size > 4) __Pyx_RaiseTooManyValuesError(4);
  5559. else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
  5560. __PYX_ERR(0, 436, __pyx_L1_error)
  5561. }
  5562. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  5563. if (likely(PyTuple_CheckExact(sequence))) {
  5564. __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0);
  5565. __Pyx_INCREF(__pyx_t_10);
  5566. __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
  5567. __Pyx_INCREF(__pyx_t_2);
  5568. __pyx_t_8 = PyTuple_GET_ITEM(sequence, 2);
  5569. __Pyx_INCREF(__pyx_t_8);
  5570. __pyx_t_14 = PyTuple_GET_ITEM(sequence, 3);
  5571. __Pyx_INCREF(__pyx_t_14);
  5572. } else {
  5573. __pyx_t_10 = __Pyx_PyList_GetItemRefFast(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
  5574. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 436, __pyx_L1_error)
  5575. __Pyx_XGOTREF(__pyx_t_10);
  5576. __pyx_t_2 = __Pyx_PyList_GetItemRefFast(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
  5577. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 436, __pyx_L1_error)
  5578. __Pyx_XGOTREF(__pyx_t_2);
  5579. __pyx_t_8 = __Pyx_PyList_GetItemRefFast(sequence, 2, __Pyx_ReferenceSharing_SharedReference);
  5580. if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 436, __pyx_L1_error)
  5581. __Pyx_XGOTREF(__pyx_t_8);
  5582. __pyx_t_14 = __Pyx_PyList_GetItemRefFast(sequence, 3, __Pyx_ReferenceSharing_SharedReference);
  5583. if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 436, __pyx_L1_error)
  5584. __Pyx_XGOTREF(__pyx_t_14);
  5585. }
  5586. #else
  5587. {
  5588. Py_ssize_t i;
  5589. PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_2,&__pyx_t_8,&__pyx_t_14};
  5590. for (i=0; i < 4; i++) {
  5591. PyObject* item = __Pyx_PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 436, __pyx_L1_error)
  5592. __Pyx_GOTREF(item);
  5593. *(temps[i]) = item;
  5594. }
  5595. }
  5596. #endif
  5597. } else {
  5598. Py_ssize_t index = -1;
  5599. PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_2,&__pyx_t_8,&__pyx_t_14};
  5600. __pyx_t_15 = PyObject_GetIter(__pyx_v_next_cubic); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 436, __pyx_L1_error)
  5601. __Pyx_GOTREF(__pyx_t_15);
  5602. __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_15);
  5603. for (index=0; index < 4; index++) {
  5604. PyObject* item = __pyx_t_16(__pyx_t_15); if (unlikely(!item)) goto __pyx_L9_unpacking_failed;
  5605. __Pyx_GOTREF(item);
  5606. *(temps[index]) = item;
  5607. }
  5608. if (__Pyx_IternextUnpackEndCheck(__pyx_t_16(__pyx_t_15), 4) < (0)) __PYX_ERR(0, 436, __pyx_L1_error)
  5609. __pyx_t_16 = NULL;
  5610. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  5611. goto __pyx_L10_unpacking_done;
  5612. __pyx_L9_unpacking_failed:;
  5613. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  5614. __pyx_t_16 = NULL;
  5615. if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
  5616. __PYX_ERR(0, 436, __pyx_L1_error)
  5617. __pyx_L10_unpacking_done:;
  5618. }
  5619. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_10); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5620. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  5621. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_2); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5622. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  5623. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_8); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5624. __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  5625. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 436, __pyx_L1_error)
  5626. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5627. __pyx_v_c0 = __pyx_t_9;
  5628. __pyx_v_c1 = __pyx_t_4;
  5629. __pyx_v_c2 = __pyx_t_5;
  5630. __pyx_v_c3 = __pyx_t_6;
  5631. /* "fontTools/cu2qu/cu2qu.py":439
  5632. *
  5633. * # Current quadratic approximation of current cubic
  5634. * q0 = q2 # <<<<<<<<<<<<<<
  5635. * q1 = next_q1
  5636. * if i < n:
  5637. */
  5638. __pyx_v_q0 = __pyx_v_q2;
  5639. /* "fontTools/cu2qu/cu2qu.py":440
  5640. * # Current quadratic approximation of current cubic
  5641. * q0 = q2
  5642. * q1 = next_q1 # <<<<<<<<<<<<<<
  5643. * if i < n:
  5644. * next_cubic = next(cubics)
  5645. */
  5646. __pyx_v_q1 = __pyx_v_next_q1;
  5647. /* "fontTools/cu2qu/cu2qu.py":441
  5648. * q0 = q2
  5649. * q1 = next_q1
  5650. * if i < n: # <<<<<<<<<<<<<<
  5651. * next_cubic = next(cubics)
  5652. * next_q1 = cubic_approx_control(
  5653. */
  5654. __pyx_t_1 = (__pyx_v_i < __pyx_v_n);
  5655. if (__pyx_t_1) {
  5656. /* "fontTools/cu2qu/cu2qu.py":442
  5657. * q1 = next_q1
  5658. * if i < n:
  5659. * next_cubic = next(cubics) # <<<<<<<<<<<<<<
  5660. * next_q1 = cubic_approx_control(
  5661. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5662. */
  5663. __pyx_t_14 = __Pyx_PyIter_Next(__pyx_v_cubics); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 442, __pyx_L1_error)
  5664. __Pyx_GOTREF(__pyx_t_14);
  5665. __Pyx_DECREF_SET(__pyx_v_next_cubic, __pyx_t_14);
  5666. __pyx_t_14 = 0;
  5667. /* "fontTools/cu2qu/cu2qu.py":444
  5668. * next_cubic = next(cubics)
  5669. * next_q1 = cubic_approx_control(
  5670. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3] # <<<<<<<<<<<<<<
  5671. * )
  5672. * spline.append(next_q1)
  5673. */
  5674. __pyx_t_17 = (__pyx_v_n - 1);
  5675. if (unlikely(__pyx_t_17 == 0)) {
  5676. PyErr_SetString(PyExc_ZeroDivisionError, "float division");
  5677. __PYX_ERR(0, 444, __pyx_L1_error)
  5678. }
  5679. __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 444, __pyx_L1_error)
  5680. __Pyx_GOTREF(__pyx_t_14);
  5681. __pyx_t_6 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5682. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5683. __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 444, __pyx_L1_error)
  5684. __Pyx_GOTREF(__pyx_t_14);
  5685. __pyx_t_5 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5686. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5687. __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 2, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 444, __pyx_L1_error)
  5688. __Pyx_GOTREF(__pyx_t_14);
  5689. __pyx_t_4 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5690. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5691. __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_next_cubic, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 444, __pyx_L1_error)
  5692. __Pyx_GOTREF(__pyx_t_14);
  5693. __pyx_t_9 = __Pyx_PyComplex_As___pyx_t_double_complex(__pyx_t_14); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 444, __pyx_L1_error)
  5694. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5695. /* "fontTools/cu2qu/cu2qu.py":443
  5696. * if i < n:
  5697. * next_cubic = next(cubics)
  5698. * next_q1 = cubic_approx_control( # <<<<<<<<<<<<<<
  5699. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5700. * )
  5701. */
  5702. __pyx_t_7 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_control((((double)__pyx_v_i) / ((double)__pyx_t_17)), __pyx_t_6, __pyx_t_5, __pyx_t_4, __pyx_t_9); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 443, __pyx_L1_error)
  5703. __pyx_v_next_q1 = __pyx_t_7;
  5704. /* "fontTools/cu2qu/cu2qu.py":446
  5705. * i / (n - 1), next_cubic[0], next_cubic[1], next_cubic[2], next_cubic[3]
  5706. * )
  5707. * spline.append(next_q1) # <<<<<<<<<<<<<<
  5708. * q2 = (q1 + next_q1) * 0.5
  5709. * else:
  5710. */
  5711. __pyx_t_14 = __pyx_PyComplex_FromComplex(__pyx_v_next_q1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 446, __pyx_L1_error)
  5712. __Pyx_GOTREF(__pyx_t_14);
  5713. __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_spline, __pyx_t_14); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 446, __pyx_L1_error)
  5714. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5715. /* "fontTools/cu2qu/cu2qu.py":447
  5716. * )
  5717. * spline.append(next_q1)
  5718. * q2 = (q1 + next_q1) * 0.5 # <<<<<<<<<<<<<<
  5719. * else:
  5720. * q2 = c3
  5721. */
  5722. __pyx_v_q2 = __Pyx_c_prod_double(__Pyx_c_sum_double(__pyx_v_q1, __pyx_v_next_q1), __pyx_t_double_complex_from_parts(0.5, 0));
  5723. /* "fontTools/cu2qu/cu2qu.py":441
  5724. * q0 = q2
  5725. * q1 = next_q1
  5726. * if i < n: # <<<<<<<<<<<<<<
  5727. * next_cubic = next(cubics)
  5728. * next_q1 = cubic_approx_control(
  5729. */
  5730. goto __pyx_L11;
  5731. }
  5732. /* "fontTools/cu2qu/cu2qu.py":449
  5733. * q2 = (q1 + next_q1) * 0.5
  5734. * else:
  5735. * q2 = c3 # <<<<<<<<<<<<<<
  5736. *
  5737. * # End-point deltas
  5738. */
  5739. /*else*/ {
  5740. __pyx_v_q2 = __pyx_v_c3;
  5741. }
  5742. __pyx_L11:;
  5743. /* "fontTools/cu2qu/cu2qu.py":452
  5744. *
  5745. * # End-point deltas
  5746. * d0 = d1 # <<<<<<<<<<<<<<
  5747. * d1 = q2 - c3
  5748. *
  5749. */
  5750. __pyx_v_d0 = __pyx_v_d1;
  5751. /* "fontTools/cu2qu/cu2qu.py":453
  5752. * # End-point deltas
  5753. * d0 = d1
  5754. * d1 = q2 - c3 # <<<<<<<<<<<<<<
  5755. *
  5756. * if abs(d1) > tolerance or not cubic_farthest_fit_inside(
  5757. */
  5758. __pyx_v_d1 = __Pyx_c_diff_double(__pyx_v_q2, __pyx_v_c3);
  5759. /* "fontTools/cu2qu/cu2qu.py":455
  5760. * d1 = q2 - c3
  5761. *
  5762. * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5763. * d0,
  5764. * q0 + (q1 - q0) * (2 / 3) - c1,
  5765. */
  5766. __pyx_t_3 = (__Pyx_c_abs_double(__pyx_v_d1) > __pyx_v_tolerance);
  5767. if (!__pyx_t_3) {
  5768. } else {
  5769. __pyx_t_1 = __pyx_t_3;
  5770. goto __pyx_L13_bool_binop_done;
  5771. }
  5772. /* "fontTools/cu2qu/cu2qu.py":460
  5773. * q2 + (q1 - q2) * (2 / 3) - c2,
  5774. * d1,
  5775. * tolerance, # <<<<<<<<<<<<<<
  5776. * ):
  5777. * return None
  5778. */
  5779. __pyx_t_19 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_farthest_fit_inside(__pyx_v_d0, __Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_q0, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_q0), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))), __pyx_v_c1), __Pyx_c_diff_double(__Pyx_c_sum_double(__pyx_v_q2, __Pyx_c_prod_double(__Pyx_c_diff_double(__pyx_v_q1, __pyx_v_q2), __pyx_t_double_complex_from_parts((2.0 / 3.0), 0))), __pyx_v_c2), __pyx_v_d1, __pyx_v_tolerance); if (unlikely(__pyx_t_19 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 455, __pyx_L1_error)
  5780. /* "fontTools/cu2qu/cu2qu.py":455
  5781. * d1 = q2 - c3
  5782. *
  5783. * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5784. * d0,
  5785. * q0 + (q1 - q0) * (2 / 3) - c1,
  5786. */
  5787. __pyx_t_3 = (!(__pyx_t_19 != 0));
  5788. __pyx_t_1 = __pyx_t_3;
  5789. __pyx_L13_bool_binop_done:;
  5790. if (__pyx_t_1) {
  5791. /* "fontTools/cu2qu/cu2qu.py":462
  5792. * tolerance,
  5793. * ):
  5794. * return None # <<<<<<<<<<<<<<
  5795. * spline.append(cubic[3])
  5796. *
  5797. */
  5798. __Pyx_XDECREF(__pyx_r);
  5799. __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  5800. goto __pyx_L0;
  5801. /* "fontTools/cu2qu/cu2qu.py":455
  5802. * d1 = q2 - c3
  5803. *
  5804. * if abs(d1) > tolerance or not cubic_farthest_fit_inside( # <<<<<<<<<<<<<<
  5805. * d0,
  5806. * q0 + (q1 - q0) * (2 / 3) - c1,
  5807. */
  5808. }
  5809. }
  5810. /* "fontTools/cu2qu/cu2qu.py":463
  5811. * ):
  5812. * return None
  5813. * spline.append(cubic[3]) # <<<<<<<<<<<<<<
  5814. *
  5815. * return spline
  5816. */
  5817. __pyx_t_14 = __Pyx_GetItemInt(__pyx_v_cubic, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 463, __pyx_L1_error)
  5818. __Pyx_GOTREF(__pyx_t_14);
  5819. __pyx_t_18 = __Pyx_PyList_Append(__pyx_v_spline, __pyx_t_14); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 463, __pyx_L1_error)
  5820. __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  5821. /* "fontTools/cu2qu/cu2qu.py":465
  5822. * spline.append(cubic[3])
  5823. *
  5824. * return spline # <<<<<<<<<<<<<<
  5825. *
  5826. *
  5827. */
  5828. __Pyx_XDECREF(__pyx_r);
  5829. __Pyx_INCREF(__pyx_v_spline);
  5830. __pyx_r = __pyx_v_spline;
  5831. goto __pyx_L0;
  5832. /* "fontTools/cu2qu/cu2qu.py":390
  5833. *
  5834. *
  5835. * @cython.cfunc # <<<<<<<<<<<<<<
  5836. * @cython.locals(n=cython.int, tolerance=cython.double)
  5837. * @cython.locals(i=cython.int)
  5838. */
  5839. /* function exit code */
  5840. __pyx_L1_error:;
  5841. __Pyx_XDECREF(__pyx_t_2);
  5842. __Pyx_XDECREF(__pyx_t_8);
  5843. __Pyx_XDECREF(__pyx_t_10);
  5844. __Pyx_XDECREF(__pyx_t_14);
  5845. __Pyx_XDECREF(__pyx_t_15);
  5846. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.cubic_approx_spline", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5847. __pyx_r = 0;
  5848. __pyx_L0:;
  5849. __Pyx_XDECREF(__pyx_v_cubics);
  5850. __Pyx_XDECREF(__pyx_v_next_cubic);
  5851. __Pyx_XDECREF(__pyx_v_spline);
  5852. __Pyx_XGIVEREF(__pyx_r);
  5853. __Pyx_RefNannyFinishContext();
  5854. return __pyx_r;
  5855. }
  5856. /* "fontTools/cu2qu/cu2qu.py":468
  5857. *
  5858. *
  5859. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  5860. * @cython.locals(n=cython.int)
  5861. * @cython.locals(all_quadratic=cython.int)
  5862. */
  5863. /* Python wrapper */
  5864. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self,
  5865. #if CYTHON_METH_FASTCALL
  5866. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  5867. #else
  5868. PyObject *__pyx_args, PyObject *__pyx_kwds
  5869. #endif
  5870. ); /*proto*/
  5871. PyDoc_STRVAR(__pyx_doc_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic, "curve_to_quadratic(curve, double max_err, int all_quadratic=True)\n\nApproximate a cubic Bezier curve with a spline of n quadratics.\n\nArgs:\n cubic (sequence): Four 2D tuples representing control points of\n the cubic Bezier curve.\n max_err (double): Permitted deviation from the original curve.\n all_quadratic (bool): If True (default) returned value is a\n quadratic spline. If False, it's either a single quadratic\n curve or a single cubic curve.\n\nReturns:\n If all_quadratic is True: A list of 2D tuples, representing\n control points of the quadratic spline if it fits within the\n given tolerance, or ``None`` if no suitable spline could be\n calculated.\n\n If all_quadratic is False: Either a quadratic curve (if length\n of output is 3), or a cubic curve (if length of output is 4).");
  5872. static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic = {"curve_to_quadratic", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic};
  5873. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic(PyObject *__pyx_self,
  5874. #if CYTHON_METH_FASTCALL
  5875. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  5876. #else
  5877. PyObject *__pyx_args, PyObject *__pyx_kwds
  5878. #endif
  5879. ) {
  5880. PyObject *__pyx_v_curve = 0;
  5881. double __pyx_v_max_err;
  5882. int __pyx_v_all_quadratic;
  5883. #if !CYTHON_METH_FASTCALL
  5884. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  5885. #endif
  5886. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  5887. PyObject* values[3] = {0,0,0};
  5888. int __pyx_lineno = 0;
  5889. const char *__pyx_filename = NULL;
  5890. int __pyx_clineno = 0;
  5891. PyObject *__pyx_r = 0;
  5892. __Pyx_RefNannyDeclarations
  5893. __Pyx_RefNannySetupContext("curve_to_quadratic (wrapper)", 0);
  5894. #if !CYTHON_METH_FASTCALL
  5895. #if CYTHON_ASSUME_SAFE_SIZE
  5896. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  5897. #else
  5898. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  5899. #endif
  5900. #endif
  5901. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  5902. {
  5903. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_curve,&__pyx_mstate_global->__pyx_n_u_max_err,&__pyx_mstate_global->__pyx_n_u_all_quadratic,0};
  5904. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  5905. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 468, __pyx_L3_error)
  5906. if (__pyx_kwds_len > 0) {
  5907. switch (__pyx_nargs) {
  5908. case 3:
  5909. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5910. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 468, __pyx_L3_error)
  5911. CYTHON_FALLTHROUGH;
  5912. case 2:
  5913. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5914. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 468, __pyx_L3_error)
  5915. CYTHON_FALLTHROUGH;
  5916. case 1:
  5917. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  5918. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 468, __pyx_L3_error)
  5919. CYTHON_FALLTHROUGH;
  5920. case 0: break;
  5921. default: goto __pyx_L5_argtuple_error;
  5922. }
  5923. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  5924. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "curve_to_quadratic", 0) < (0)) __PYX_ERR(0, 468, __pyx_L3_error)
  5925. for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
  5926. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, i); __PYX_ERR(0, 468, __pyx_L3_error) }
  5927. }
  5928. } else {
  5929. switch (__pyx_nargs) {
  5930. case 3:
  5931. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  5932. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 468, __pyx_L3_error)
  5933. CYTHON_FALLTHROUGH;
  5934. case 2:
  5935. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  5936. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 468, __pyx_L3_error)
  5937. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  5938. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 468, __pyx_L3_error)
  5939. break;
  5940. default: goto __pyx_L5_argtuple_error;
  5941. }
  5942. }
  5943. __pyx_v_curve = values[0];
  5944. __pyx_v_max_err = __Pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_max_err == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 471, __pyx_L3_error)
  5945. if (values[2]) {
  5946. __pyx_v_all_quadratic = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_all_quadratic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 471, __pyx_L3_error)
  5947. } else {
  5948. /* "fontTools/cu2qu/cu2qu.py":471
  5949. * @cython.locals(n=cython.int)
  5950. * @cython.locals(all_quadratic=cython.int)
  5951. * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<<
  5952. * """Approximate a cubic Bezier curve with a spline of n quadratics.
  5953. *
  5954. */
  5955. __pyx_v_all_quadratic = ((int)((int)1));
  5956. }
  5957. }
  5958. goto __pyx_L6_skip;
  5959. __pyx_L5_argtuple_error:;
  5960. __Pyx_RaiseArgtupleInvalid("curve_to_quadratic", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 468, __pyx_L3_error)
  5961. __pyx_L6_skip:;
  5962. goto __pyx_L4_argument_unpacking_done;
  5963. __pyx_L3_error:;
  5964. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5965. Py_XDECREF(values[__pyx_temp]);
  5966. }
  5967. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  5968. __Pyx_RefNannyFinishContext();
  5969. return NULL;
  5970. __pyx_L4_argument_unpacking_done:;
  5971. __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(__pyx_self, __pyx_v_curve, __pyx_v_max_err, __pyx_v_all_quadratic);
  5972. /* "fontTools/cu2qu/cu2qu.py":468
  5973. *
  5974. *
  5975. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  5976. * @cython.locals(n=cython.int)
  5977. * @cython.locals(all_quadratic=cython.int)
  5978. */
  5979. /* function exit code */
  5980. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  5981. Py_XDECREF(values[__pyx_temp]);
  5982. }
  5983. __Pyx_RefNannyFinishContext();
  5984. return __pyx_r;
  5985. }
  5986. static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_3curve_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curve, double __pyx_v_max_err, int __pyx_v_all_quadratic) {
  5987. int __pyx_v_n;
  5988. PyObject *__pyx_v_spline = NULL;
  5989. PyObject *__pyx_7genexpr__pyx_v_p = NULL;
  5990. PyObject *__pyx_8genexpr1__pyx_v_s = NULL;
  5991. PyObject *__pyx_r = NULL;
  5992. __Pyx_RefNannyDeclarations
  5993. PyObject *__pyx_t_1 = NULL;
  5994. PyObject *__pyx_t_2 = NULL;
  5995. Py_ssize_t __pyx_t_3;
  5996. PyObject *(*__pyx_t_4)(PyObject *);
  5997. PyObject *__pyx_t_5 = NULL;
  5998. PyObject *__pyx_t_6 = NULL;
  5999. Py_ssize_t __pyx_t_7;
  6000. int __pyx_t_8;
  6001. int __pyx_t_9;
  6002. Py_ssize_t __pyx_t_10;
  6003. PyObject *__pyx_t_11 = NULL;
  6004. size_t __pyx_t_12;
  6005. int __pyx_lineno = 0;
  6006. const char *__pyx_filename = NULL;
  6007. int __pyx_clineno = 0;
  6008. __Pyx_RefNannySetupContext("curve_to_quadratic", 0);
  6009. __Pyx_INCREF(__pyx_v_curve);
  6010. /* "fontTools/cu2qu/cu2qu.py":492
  6011. * """
  6012. *
  6013. * curve = [complex(*p) for p in curve] # <<<<<<<<<<<<<<
  6014. *
  6015. * for n in range(1, MAX_N + 1):
  6016. */
  6017. { /* enter inner scope */
  6018. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 492, __pyx_L5_error)
  6019. __Pyx_GOTREF(__pyx_t_1);
  6020. if (likely(PyList_CheckExact(__pyx_v_curve)) || PyTuple_CheckExact(__pyx_v_curve)) {
  6021. __pyx_t_2 = __pyx_v_curve; __Pyx_INCREF(__pyx_t_2);
  6022. __pyx_t_3 = 0;
  6023. __pyx_t_4 = NULL;
  6024. } else {
  6025. __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curve); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 492, __pyx_L5_error)
  6026. __Pyx_GOTREF(__pyx_t_2);
  6027. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 492, __pyx_L5_error)
  6028. }
  6029. for (;;) {
  6030. if (likely(!__pyx_t_4)) {
  6031. if (likely(PyList_CheckExact(__pyx_t_2))) {
  6032. {
  6033. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
  6034. #if !CYTHON_ASSUME_SAFE_SIZE
  6035. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 492, __pyx_L5_error)
  6036. #endif
  6037. if (__pyx_t_3 >= __pyx_temp) break;
  6038. }
  6039. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_3, __Pyx_ReferenceSharing_OwnStrongReference);
  6040. ++__pyx_t_3;
  6041. } else {
  6042. {
  6043. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
  6044. #if !CYTHON_ASSUME_SAFE_SIZE
  6045. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 492, __pyx_L5_error)
  6046. #endif
  6047. if (__pyx_t_3 >= __pyx_temp) break;
  6048. }
  6049. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6050. __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3));
  6051. #else
  6052. __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3);
  6053. #endif
  6054. ++__pyx_t_3;
  6055. }
  6056. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 492, __pyx_L5_error)
  6057. } else {
  6058. __pyx_t_5 = __pyx_t_4(__pyx_t_2);
  6059. if (unlikely(!__pyx_t_5)) {
  6060. PyObject* exc_type = PyErr_Occurred();
  6061. if (exc_type) {
  6062. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 492, __pyx_L5_error)
  6063. PyErr_Clear();
  6064. }
  6065. break;
  6066. }
  6067. }
  6068. __Pyx_GOTREF(__pyx_t_5);
  6069. __Pyx_XDECREF_SET(__pyx_7genexpr__pyx_v_p, __pyx_t_5);
  6070. __pyx_t_5 = 0;
  6071. __pyx_t_5 = __Pyx_PySequence_Tuple(__pyx_7genexpr__pyx_v_p); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 492, __pyx_L5_error)
  6072. __Pyx_GOTREF(__pyx_t_5);
  6073. __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 492, __pyx_L5_error)
  6074. __Pyx_GOTREF(__pyx_t_6);
  6075. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6076. if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_6))) __PYX_ERR(0, 492, __pyx_L5_error)
  6077. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6078. }
  6079. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6080. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0;
  6081. goto __pyx_L9_exit_scope;
  6082. __pyx_L5_error:;
  6083. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p); __pyx_7genexpr__pyx_v_p = 0;
  6084. goto __pyx_L1_error;
  6085. __pyx_L9_exit_scope:;
  6086. } /* exit inner scope */
  6087. __Pyx_DECREF_SET(__pyx_v_curve, __pyx_t_1);
  6088. __pyx_t_1 = 0;
  6089. /* "fontTools/cu2qu/cu2qu.py":494
  6090. * curve = [complex(*p) for p in curve]
  6091. *
  6092. * for n in range(1, MAX_N + 1): # <<<<<<<<<<<<<<
  6093. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic)
  6094. * if spline is not None:
  6095. */
  6096. __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_MAX_N); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 494, __pyx_L1_error)
  6097. __Pyx_GOTREF(__pyx_t_1);
  6098. __pyx_t_2 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 494, __pyx_L1_error)
  6099. __Pyx_GOTREF(__pyx_t_2);
  6100. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6101. __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 494, __pyx_L1_error)
  6102. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6103. __pyx_t_7 = __pyx_t_3;
  6104. for (__pyx_t_8 = 1; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
  6105. __pyx_v_n = __pyx_t_8;
  6106. /* "fontTools/cu2qu/cu2qu.py":495
  6107. *
  6108. * for n in range(1, MAX_N + 1):
  6109. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic) # <<<<<<<<<<<<<<
  6110. * if spline is not None:
  6111. * # done. go home
  6112. */
  6113. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(__pyx_v_curve, __pyx_v_n, __pyx_v_max_err, __pyx_v_all_quadratic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 495, __pyx_L1_error)
  6114. __Pyx_GOTREF(__pyx_t_2);
  6115. __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2);
  6116. __pyx_t_2 = 0;
  6117. /* "fontTools/cu2qu/cu2qu.py":496
  6118. * for n in range(1, MAX_N + 1):
  6119. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic)
  6120. * if spline is not None: # <<<<<<<<<<<<<<
  6121. * # done. go home
  6122. * return [(s.real, s.imag) for s in spline]
  6123. */
  6124. __pyx_t_9 = (__pyx_v_spline != Py_None);
  6125. if (__pyx_t_9) {
  6126. /* "fontTools/cu2qu/cu2qu.py":498
  6127. * if spline is not None:
  6128. * # done. go home
  6129. * return [(s.real, s.imag) for s in spline] # <<<<<<<<<<<<<<
  6130. *
  6131. * raise ApproxNotFoundError(curve)
  6132. */
  6133. __Pyx_XDECREF(__pyx_r);
  6134. { /* enter inner scope */
  6135. __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 498, __pyx_L15_error)
  6136. __Pyx_GOTREF(__pyx_t_2);
  6137. if (likely(PyList_CheckExact(__pyx_v_spline)) || PyTuple_CheckExact(__pyx_v_spline)) {
  6138. __pyx_t_1 = __pyx_v_spline; __Pyx_INCREF(__pyx_t_1);
  6139. __pyx_t_10 = 0;
  6140. __pyx_t_4 = NULL;
  6141. } else {
  6142. __pyx_t_10 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_spline); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 498, __pyx_L15_error)
  6143. __Pyx_GOTREF(__pyx_t_1);
  6144. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 498, __pyx_L15_error)
  6145. }
  6146. for (;;) {
  6147. if (likely(!__pyx_t_4)) {
  6148. if (likely(PyList_CheckExact(__pyx_t_1))) {
  6149. {
  6150. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
  6151. #if !CYTHON_ASSUME_SAFE_SIZE
  6152. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 498, __pyx_L15_error)
  6153. #endif
  6154. if (__pyx_t_10 >= __pyx_temp) break;
  6155. }
  6156. __pyx_t_6 = __Pyx_PyList_GetItemRefFast(__pyx_t_1, __pyx_t_10, __Pyx_ReferenceSharing_OwnStrongReference);
  6157. ++__pyx_t_10;
  6158. } else {
  6159. {
  6160. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
  6161. #if !CYTHON_ASSUME_SAFE_SIZE
  6162. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 498, __pyx_L15_error)
  6163. #endif
  6164. if (__pyx_t_10 >= __pyx_temp) break;
  6165. }
  6166. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6167. __pyx_t_6 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_10));
  6168. #else
  6169. __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_10);
  6170. #endif
  6171. ++__pyx_t_10;
  6172. }
  6173. if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 498, __pyx_L15_error)
  6174. } else {
  6175. __pyx_t_6 = __pyx_t_4(__pyx_t_1);
  6176. if (unlikely(!__pyx_t_6)) {
  6177. PyObject* exc_type = PyErr_Occurred();
  6178. if (exc_type) {
  6179. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 498, __pyx_L15_error)
  6180. PyErr_Clear();
  6181. }
  6182. break;
  6183. }
  6184. }
  6185. __Pyx_GOTREF(__pyx_t_6);
  6186. __Pyx_XDECREF_SET(__pyx_8genexpr1__pyx_v_s, __pyx_t_6);
  6187. __pyx_t_6 = 0;
  6188. __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_s, __pyx_mstate_global->__pyx_n_u_real); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 498, __pyx_L15_error)
  6189. __Pyx_GOTREF(__pyx_t_6);
  6190. __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr1__pyx_v_s, __pyx_mstate_global->__pyx_n_u_imag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 498, __pyx_L15_error)
  6191. __Pyx_GOTREF(__pyx_t_5);
  6192. __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 498, __pyx_L15_error)
  6193. __Pyx_GOTREF(__pyx_t_11);
  6194. __Pyx_GIVEREF(__pyx_t_6);
  6195. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 498, __pyx_L15_error);
  6196. __Pyx_GIVEREF(__pyx_t_5);
  6197. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 498, __pyx_L15_error);
  6198. __pyx_t_6 = 0;
  6199. __pyx_t_5 = 0;
  6200. if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_11))) __PYX_ERR(0, 498, __pyx_L15_error)
  6201. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6202. }
  6203. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6204. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0;
  6205. goto __pyx_L19_exit_scope;
  6206. __pyx_L15_error:;
  6207. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s); __pyx_8genexpr1__pyx_v_s = 0;
  6208. goto __pyx_L1_error;
  6209. __pyx_L19_exit_scope:;
  6210. } /* exit inner scope */
  6211. __pyx_r = __pyx_t_2;
  6212. __pyx_t_2 = 0;
  6213. goto __pyx_L0;
  6214. /* "fontTools/cu2qu/cu2qu.py":496
  6215. * for n in range(1, MAX_N + 1):
  6216. * spline = cubic_approx_spline(curve, n, max_err, all_quadratic)
  6217. * if spline is not None: # <<<<<<<<<<<<<<
  6218. * # done. go home
  6219. * return [(s.real, s.imag) for s in spline]
  6220. */
  6221. }
  6222. }
  6223. /* "fontTools/cu2qu/cu2qu.py":500
  6224. * return [(s.real, s.imag) for s in spline]
  6225. *
  6226. * raise ApproxNotFoundError(curve) # <<<<<<<<<<<<<<
  6227. *
  6228. *
  6229. */
  6230. __pyx_t_1 = NULL;
  6231. __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_ApproxNotFoundError); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 500, __pyx_L1_error)
  6232. __Pyx_GOTREF(__pyx_t_11);
  6233. __pyx_t_12 = 1;
  6234. #if CYTHON_UNPACK_METHODS
  6235. if (unlikely(PyMethod_Check(__pyx_t_11))) {
  6236. __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
  6237. assert(__pyx_t_1);
  6238. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
  6239. __Pyx_INCREF(__pyx_t_1);
  6240. __Pyx_INCREF(__pyx__function);
  6241. __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
  6242. __pyx_t_12 = 0;
  6243. }
  6244. #endif
  6245. {
  6246. PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_v_curve};
  6247. __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_12, (2-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  6248. __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
  6249. __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  6250. if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 500, __pyx_L1_error)
  6251. __Pyx_GOTREF(__pyx_t_2);
  6252. }
  6253. __Pyx_Raise(__pyx_t_2, 0, 0, 0);
  6254. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6255. __PYX_ERR(0, 500, __pyx_L1_error)
  6256. /* "fontTools/cu2qu/cu2qu.py":468
  6257. *
  6258. *
  6259. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  6260. * @cython.locals(n=cython.int)
  6261. * @cython.locals(all_quadratic=cython.int)
  6262. */
  6263. /* function exit code */
  6264. __pyx_L1_error:;
  6265. __Pyx_XDECREF(__pyx_t_1);
  6266. __Pyx_XDECREF(__pyx_t_2);
  6267. __Pyx_XDECREF(__pyx_t_5);
  6268. __Pyx_XDECREF(__pyx_t_6);
  6269. __Pyx_XDECREF(__pyx_t_11);
  6270. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curve_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6271. __pyx_r = NULL;
  6272. __pyx_L0:;
  6273. __Pyx_XDECREF(__pyx_v_spline);
  6274. __Pyx_XDECREF(__pyx_7genexpr__pyx_v_p);
  6275. __Pyx_XDECREF(__pyx_8genexpr1__pyx_v_s);
  6276. __Pyx_XDECREF(__pyx_v_curve);
  6277. __Pyx_XGIVEREF(__pyx_r);
  6278. __Pyx_RefNannyFinishContext();
  6279. return __pyx_r;
  6280. }
  6281. /* "fontTools/cu2qu/cu2qu.py":503
  6282. *
  6283. *
  6284. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  6285. * @cython.locals(all_quadratic=cython.int)
  6286. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  6287. */
  6288. /* Python wrapper */
  6289. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self,
  6290. #if CYTHON_METH_FASTCALL
  6291. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  6292. #else
  6293. PyObject *__pyx_args, PyObject *__pyx_kwds
  6294. #endif
  6295. ); /*proto*/
  6296. PyDoc_STRVAR(__pyx_doc_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic, "curves_to_quadratic(curves, max_errors, int all_quadratic=True)\n\nReturn quadratic Bezier splines approximating the input cubic Beziers.\n\nArgs:\n curves: A sequence of *n* curves, each curve being a sequence of four\n 2D tuples.\n max_errors: A sequence of *n* floats representing the maximum permissible\n deviation from each of the cubic Bezier curves.\n all_quadratic (bool): If True (default) returned values are a\n quadratic spline. If False, they are either a single quadratic\n curve or a single cubic curve.\n\nExample::\n\n >>> curves_to_quadratic( [\n ... [ (50,50), (100,100), (150,100), (200,50) ],\n ... [ (75,50), (120,100), (150,75), (200,60) ]\n ... ], [1,1] )\n [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]]\n\nThe returned splines have \"implied oncurve points\" suitable for use in\nTrueType ``glif`` outlines - i.e. in the first spline returned above,\nthe first quadratic segment runs from (50,50) to\n( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...).\n\nReturns:\n If all_quadratic is True, a list of splines, each spline being a list\n of 2D tuples.\n\n If all_quadratic is False, a list of curves, each curve being a quadratic\n (length 3), or cubic (length 4).\n\nRaises:\n fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation\n can be found for all curves with the given parameters.");
  6297. static PyMethodDef __pyx_mdef_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic = {"curves_to_quadratic", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic};
  6298. static PyObject *__pyx_pw_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic(PyObject *__pyx_self,
  6299. #if CYTHON_METH_FASTCALL
  6300. PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
  6301. #else
  6302. PyObject *__pyx_args, PyObject *__pyx_kwds
  6303. #endif
  6304. ) {
  6305. PyObject *__pyx_v_curves = 0;
  6306. PyObject *__pyx_v_max_errors = 0;
  6307. int __pyx_v_all_quadratic;
  6308. #if !CYTHON_METH_FASTCALL
  6309. CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  6310. #endif
  6311. CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  6312. PyObject* values[3] = {0,0,0};
  6313. int __pyx_lineno = 0;
  6314. const char *__pyx_filename = NULL;
  6315. int __pyx_clineno = 0;
  6316. PyObject *__pyx_r = 0;
  6317. __Pyx_RefNannyDeclarations
  6318. __Pyx_RefNannySetupContext("curves_to_quadratic (wrapper)", 0);
  6319. #if !CYTHON_METH_FASTCALL
  6320. #if CYTHON_ASSUME_SAFE_SIZE
  6321. __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  6322. #else
  6323. __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  6324. #endif
  6325. #endif
  6326. __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  6327. {
  6328. PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_curves,&__pyx_mstate_global->__pyx_n_u_max_errors,&__pyx_mstate_global->__pyx_n_u_all_quadratic,0};
  6329. const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
  6330. if (unlikely(__pyx_kwds_len) < 0) __PYX_ERR(0, 503, __pyx_L3_error)
  6331. if (__pyx_kwds_len > 0) {
  6332. switch (__pyx_nargs) {
  6333. case 3:
  6334. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  6335. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 503, __pyx_L3_error)
  6336. CYTHON_FALLTHROUGH;
  6337. case 2:
  6338. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  6339. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 503, __pyx_L3_error)
  6340. CYTHON_FALLTHROUGH;
  6341. case 1:
  6342. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  6343. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 503, __pyx_L3_error)
  6344. CYTHON_FALLTHROUGH;
  6345. case 0: break;
  6346. default: goto __pyx_L5_argtuple_error;
  6347. }
  6348. const Py_ssize_t kwd_pos_args = __pyx_nargs;
  6349. if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "curves_to_quadratic", 0) < (0)) __PYX_ERR(0, 503, __pyx_L3_error)
  6350. for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
  6351. if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, i); __PYX_ERR(0, 503, __pyx_L3_error) }
  6352. }
  6353. } else {
  6354. switch (__pyx_nargs) {
  6355. case 3:
  6356. values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
  6357. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 503, __pyx_L3_error)
  6358. CYTHON_FALLTHROUGH;
  6359. case 2:
  6360. values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
  6361. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 503, __pyx_L3_error)
  6362. values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
  6363. if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 503, __pyx_L3_error)
  6364. break;
  6365. default: goto __pyx_L5_argtuple_error;
  6366. }
  6367. }
  6368. __pyx_v_curves = values[0];
  6369. __pyx_v_max_errors = values[1];
  6370. if (values[2]) {
  6371. __pyx_v_all_quadratic = __Pyx_PyLong_As_int(values[2]); if (unlikely((__pyx_v_all_quadratic == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 505, __pyx_L3_error)
  6372. } else {
  6373. /* "fontTools/cu2qu/cu2qu.py":505
  6374. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int)
  6375. * @cython.locals(all_quadratic=cython.int)
  6376. * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<<
  6377. * """Return quadratic Bezier splines approximating the input cubic Beziers.
  6378. *
  6379. */
  6380. __pyx_v_all_quadratic = ((int)((int)1));
  6381. }
  6382. }
  6383. goto __pyx_L6_skip;
  6384. __pyx_L5_argtuple_error:;
  6385. __Pyx_RaiseArgtupleInvalid("curves_to_quadratic", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 503, __pyx_L3_error)
  6386. __pyx_L6_skip:;
  6387. goto __pyx_L4_argument_unpacking_done;
  6388. __pyx_L3_error:;
  6389. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  6390. Py_XDECREF(values[__pyx_temp]);
  6391. }
  6392. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6393. __Pyx_RefNannyFinishContext();
  6394. return NULL;
  6395. __pyx_L4_argument_unpacking_done:;
  6396. __pyx_r = __pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(__pyx_self, __pyx_v_curves, __pyx_v_max_errors, __pyx_v_all_quadratic);
  6397. /* "fontTools/cu2qu/cu2qu.py":503
  6398. *
  6399. *
  6400. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  6401. * @cython.locals(all_quadratic=cython.int)
  6402. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  6403. */
  6404. /* function exit code */
  6405. for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
  6406. Py_XDECREF(values[__pyx_temp]);
  6407. }
  6408. __Pyx_RefNannyFinishContext();
  6409. return __pyx_r;
  6410. }
  6411. static PyObject *__pyx_pf_9fontTools_5cu2qu_5cu2qu_5curves_to_quadratic(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_curves, PyObject *__pyx_v_max_errors, int __pyx_v_all_quadratic) {
  6412. int __pyx_v_l;
  6413. int __pyx_v_last_i;
  6414. int __pyx_v_i;
  6415. PyObject *__pyx_v_splines = NULL;
  6416. PyObject *__pyx_v_n = NULL;
  6417. PyObject *__pyx_v_spline = NULL;
  6418. PyObject *__pyx_8genexpr2__pyx_v_curve = NULL;
  6419. PyObject *__pyx_8genexpr3__pyx_v_p = NULL;
  6420. PyObject *__pyx_8genexpr4__pyx_v_spline = NULL;
  6421. PyObject *__pyx_8genexpr5__pyx_v_s = NULL;
  6422. PyObject *__pyx_r = NULL;
  6423. __Pyx_RefNannyDeclarations
  6424. PyObject *__pyx_t_1 = NULL;
  6425. PyObject *__pyx_t_2 = NULL;
  6426. Py_ssize_t __pyx_t_3;
  6427. PyObject *(*__pyx_t_4)(PyObject *);
  6428. PyObject *__pyx_t_5 = NULL;
  6429. PyObject *__pyx_t_6 = NULL;
  6430. Py_ssize_t __pyx_t_7;
  6431. PyObject *(*__pyx_t_8)(PyObject *);
  6432. PyObject *__pyx_t_9 = NULL;
  6433. PyObject *__pyx_t_10 = NULL;
  6434. int __pyx_t_11;
  6435. int __pyx_t_12;
  6436. double __pyx_t_13;
  6437. long __pyx_t_14;
  6438. PyObject *__pyx_t_15 = NULL;
  6439. size_t __pyx_t_16;
  6440. int __pyx_lineno = 0;
  6441. const char *__pyx_filename = NULL;
  6442. int __pyx_clineno = 0;
  6443. __Pyx_RefNannySetupContext("curves_to_quadratic", 0);
  6444. __Pyx_INCREF(__pyx_v_curves);
  6445. /* "fontTools/cu2qu/cu2qu.py":542
  6446. * """
  6447. *
  6448. * curves = [[complex(*p) for p in curve] for curve in curves] # <<<<<<<<<<<<<<
  6449. * assert len(max_errors) == len(curves)
  6450. *
  6451. */
  6452. { /* enter inner scope */
  6453. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 542, __pyx_L5_error)
  6454. __Pyx_GOTREF(__pyx_t_1);
  6455. if (likely(PyList_CheckExact(__pyx_v_curves)) || PyTuple_CheckExact(__pyx_v_curves)) {
  6456. __pyx_t_2 = __pyx_v_curves; __Pyx_INCREF(__pyx_t_2);
  6457. __pyx_t_3 = 0;
  6458. __pyx_t_4 = NULL;
  6459. } else {
  6460. __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_curves); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 542, __pyx_L5_error)
  6461. __Pyx_GOTREF(__pyx_t_2);
  6462. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 542, __pyx_L5_error)
  6463. }
  6464. for (;;) {
  6465. if (likely(!__pyx_t_4)) {
  6466. if (likely(PyList_CheckExact(__pyx_t_2))) {
  6467. {
  6468. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
  6469. #if !CYTHON_ASSUME_SAFE_SIZE
  6470. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 542, __pyx_L5_error)
  6471. #endif
  6472. if (__pyx_t_3 >= __pyx_temp) break;
  6473. }
  6474. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_3, __Pyx_ReferenceSharing_OwnStrongReference);
  6475. ++__pyx_t_3;
  6476. } else {
  6477. {
  6478. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
  6479. #if !CYTHON_ASSUME_SAFE_SIZE
  6480. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 542, __pyx_L5_error)
  6481. #endif
  6482. if (__pyx_t_3 >= __pyx_temp) break;
  6483. }
  6484. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6485. __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3));
  6486. #else
  6487. __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_3);
  6488. #endif
  6489. ++__pyx_t_3;
  6490. }
  6491. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 542, __pyx_L5_error)
  6492. } else {
  6493. __pyx_t_5 = __pyx_t_4(__pyx_t_2);
  6494. if (unlikely(!__pyx_t_5)) {
  6495. PyObject* exc_type = PyErr_Occurred();
  6496. if (exc_type) {
  6497. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 542, __pyx_L5_error)
  6498. PyErr_Clear();
  6499. }
  6500. break;
  6501. }
  6502. }
  6503. __Pyx_GOTREF(__pyx_t_5);
  6504. __Pyx_XDECREF_SET(__pyx_8genexpr2__pyx_v_curve, __pyx_t_5);
  6505. __pyx_t_5 = 0;
  6506. { /* enter inner scope */
  6507. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 542, __pyx_L10_error)
  6508. __Pyx_GOTREF(__pyx_t_5);
  6509. if (likely(PyList_CheckExact(__pyx_8genexpr2__pyx_v_curve)) || PyTuple_CheckExact(__pyx_8genexpr2__pyx_v_curve)) {
  6510. __pyx_t_6 = __pyx_8genexpr2__pyx_v_curve; __Pyx_INCREF(__pyx_t_6);
  6511. __pyx_t_7 = 0;
  6512. __pyx_t_8 = NULL;
  6513. } else {
  6514. __pyx_t_7 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr2__pyx_v_curve); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 542, __pyx_L10_error)
  6515. __Pyx_GOTREF(__pyx_t_6);
  6516. __pyx_t_8 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 542, __pyx_L10_error)
  6517. }
  6518. for (;;) {
  6519. if (likely(!__pyx_t_8)) {
  6520. if (likely(PyList_CheckExact(__pyx_t_6))) {
  6521. {
  6522. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6523. #if !CYTHON_ASSUME_SAFE_SIZE
  6524. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 542, __pyx_L10_error)
  6525. #endif
  6526. if (__pyx_t_7 >= __pyx_temp) break;
  6527. }
  6528. __pyx_t_9 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_7, __Pyx_ReferenceSharing_OwnStrongReference);
  6529. ++__pyx_t_7;
  6530. } else {
  6531. {
  6532. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  6533. #if !CYTHON_ASSUME_SAFE_SIZE
  6534. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 542, __pyx_L10_error)
  6535. #endif
  6536. if (__pyx_t_7 >= __pyx_temp) break;
  6537. }
  6538. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6539. __pyx_t_9 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_7));
  6540. #else
  6541. __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_7);
  6542. #endif
  6543. ++__pyx_t_7;
  6544. }
  6545. if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 542, __pyx_L10_error)
  6546. } else {
  6547. __pyx_t_9 = __pyx_t_8(__pyx_t_6);
  6548. if (unlikely(!__pyx_t_9)) {
  6549. PyObject* exc_type = PyErr_Occurred();
  6550. if (exc_type) {
  6551. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 542, __pyx_L10_error)
  6552. PyErr_Clear();
  6553. }
  6554. break;
  6555. }
  6556. }
  6557. __Pyx_GOTREF(__pyx_t_9);
  6558. __Pyx_XDECREF_SET(__pyx_8genexpr3__pyx_v_p, __pyx_t_9);
  6559. __pyx_t_9 = 0;
  6560. __pyx_t_9 = __Pyx_PySequence_Tuple(__pyx_8genexpr3__pyx_v_p); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 542, __pyx_L10_error)
  6561. __Pyx_GOTREF(__pyx_t_9);
  6562. __pyx_t_10 = __Pyx_PyObject_Call(((PyObject *)(&PyComplex_Type)), __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 542, __pyx_L10_error)
  6563. __Pyx_GOTREF(__pyx_t_10);
  6564. __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  6565. if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_10))) __PYX_ERR(0, 542, __pyx_L10_error)
  6566. __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  6567. }
  6568. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6569. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0;
  6570. goto __pyx_L14_exit_scope;
  6571. __pyx_L10_error:;
  6572. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p); __pyx_8genexpr3__pyx_v_p = 0;
  6573. goto __pyx_L5_error;
  6574. __pyx_L14_exit_scope:;
  6575. } /* exit inner scope */
  6576. if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 542, __pyx_L5_error)
  6577. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6578. }
  6579. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6580. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0;
  6581. goto __pyx_L16_exit_scope;
  6582. __pyx_L5_error:;
  6583. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve); __pyx_8genexpr2__pyx_v_curve = 0;
  6584. goto __pyx_L1_error;
  6585. __pyx_L16_exit_scope:;
  6586. } /* exit inner scope */
  6587. __Pyx_DECREF_SET(__pyx_v_curves, __pyx_t_1);
  6588. __pyx_t_1 = 0;
  6589. /* "fontTools/cu2qu/cu2qu.py":543
  6590. *
  6591. * curves = [[complex(*p) for p in curve] for curve in curves]
  6592. * assert len(max_errors) == len(curves) # <<<<<<<<<<<<<<
  6593. *
  6594. * l = len(curves)
  6595. */
  6596. #ifndef CYTHON_WITHOUT_ASSERTIONS
  6597. if (unlikely(__pyx_assertions_enabled())) {
  6598. __pyx_t_3 = PyObject_Length(__pyx_v_max_errors); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 543, __pyx_L1_error)
  6599. __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 543, __pyx_L1_error)
  6600. __pyx_t_11 = (__pyx_t_3 == __pyx_t_7);
  6601. if (unlikely(!__pyx_t_11)) {
  6602. __Pyx_Raise(((PyObject *)(((PyTypeObject*)PyExc_AssertionError))), 0, 0, 0);
  6603. __PYX_ERR(0, 543, __pyx_L1_error)
  6604. }
  6605. }
  6606. #else
  6607. if ((1)); else __PYX_ERR(0, 543, __pyx_L1_error)
  6608. #endif
  6609. /* "fontTools/cu2qu/cu2qu.py":545
  6610. * assert len(max_errors) == len(curves)
  6611. *
  6612. * l = len(curves) # <<<<<<<<<<<<<<
  6613. * splines = [None] * l
  6614. * last_i = i = 0
  6615. */
  6616. __pyx_t_7 = PyObject_Length(__pyx_v_curves); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 545, __pyx_L1_error)
  6617. __pyx_v_l = __pyx_t_7;
  6618. /* "fontTools/cu2qu/cu2qu.py":546
  6619. *
  6620. * l = len(curves)
  6621. * splines = [None] * l # <<<<<<<<<<<<<<
  6622. * last_i = i = 0
  6623. * n = 1
  6624. */
  6625. __pyx_t_1 = PyList_New(1 * ((__pyx_v_l<0) ? 0:__pyx_v_l)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 546, __pyx_L1_error)
  6626. __Pyx_GOTREF(__pyx_t_1);
  6627. { Py_ssize_t __pyx_temp;
  6628. for (__pyx_temp=0; __pyx_temp < __pyx_v_l; __pyx_temp++) {
  6629. __Pyx_INCREF(Py_None);
  6630. __Pyx_GIVEREF(Py_None);
  6631. if (__Pyx_PyList_SET_ITEM(__pyx_t_1, __pyx_temp, Py_None) != (0)) __PYX_ERR(0, 546, __pyx_L1_error);
  6632. }
  6633. }
  6634. __pyx_v_splines = ((PyObject*)__pyx_t_1);
  6635. __pyx_t_1 = 0;
  6636. /* "fontTools/cu2qu/cu2qu.py":547
  6637. * l = len(curves)
  6638. * splines = [None] * l
  6639. * last_i = i = 0 # <<<<<<<<<<<<<<
  6640. * n = 1
  6641. * while True:
  6642. */
  6643. __pyx_v_last_i = 0;
  6644. __pyx_v_i = 0;
  6645. /* "fontTools/cu2qu/cu2qu.py":548
  6646. * splines = [None] * l
  6647. * last_i = i = 0
  6648. * n = 1 # <<<<<<<<<<<<<<
  6649. * while True:
  6650. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6651. */
  6652. __Pyx_INCREF(__pyx_mstate_global->__pyx_int_1);
  6653. __pyx_v_n = __pyx_mstate_global->__pyx_int_1;
  6654. /* "fontTools/cu2qu/cu2qu.py":549
  6655. * last_i = i = 0
  6656. * n = 1
  6657. * while True: # <<<<<<<<<<<<<<
  6658. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6659. * if spline is None:
  6660. */
  6661. while (1) {
  6662. /* "fontTools/cu2qu/cu2qu.py":550
  6663. * n = 1
  6664. * while True:
  6665. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic) # <<<<<<<<<<<<<<
  6666. * if spline is None:
  6667. * if n == MAX_N:
  6668. */
  6669. __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curves, __pyx_v_i, int, 1, __Pyx_PyLong_From_int, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 550, __pyx_L1_error)
  6670. __Pyx_GOTREF(__pyx_t_1);
  6671. __pyx_t_12 = __Pyx_PyLong_As_int(__pyx_v_n); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 550, __pyx_L1_error)
  6672. __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_max_errors, __pyx_v_i, int, 1, __Pyx_PyLong_From_int, 0, 1, 1, 1, __Pyx_ReferenceSharing_FunctionArgument); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 550, __pyx_L1_error)
  6673. __Pyx_GOTREF(__pyx_t_2);
  6674. __pyx_t_13 = __Pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 550, __pyx_L1_error)
  6675. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6676. __pyx_t_2 = __pyx_f_9fontTools_5cu2qu_5cu2qu_cubic_approx_spline(__pyx_t_1, __pyx_t_12, __pyx_t_13, __pyx_v_all_quadratic); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 550, __pyx_L1_error)
  6677. __Pyx_GOTREF(__pyx_t_2);
  6678. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6679. __Pyx_XDECREF_SET(__pyx_v_spline, __pyx_t_2);
  6680. __pyx_t_2 = 0;
  6681. /* "fontTools/cu2qu/cu2qu.py":551
  6682. * while True:
  6683. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6684. * if spline is None: # <<<<<<<<<<<<<<
  6685. * if n == MAX_N:
  6686. * break
  6687. */
  6688. __pyx_t_11 = (__pyx_v_spline == Py_None);
  6689. if (__pyx_t_11) {
  6690. /* "fontTools/cu2qu/cu2qu.py":552
  6691. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6692. * if spline is None:
  6693. * if n == MAX_N: # <<<<<<<<<<<<<<
  6694. * break
  6695. * n += 1
  6696. */
  6697. __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_MAX_N); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 552, __pyx_L1_error)
  6698. __Pyx_GOTREF(__pyx_t_2);
  6699. __pyx_t_1 = PyObject_RichCompare(__pyx_v_n, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 552, __pyx_L1_error)
  6700. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6701. __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 552, __pyx_L1_error)
  6702. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6703. if (__pyx_t_11) {
  6704. /* "fontTools/cu2qu/cu2qu.py":553
  6705. * if spline is None:
  6706. * if n == MAX_N:
  6707. * break # <<<<<<<<<<<<<<
  6708. * n += 1
  6709. * last_i = i
  6710. */
  6711. goto __pyx_L18_break;
  6712. /* "fontTools/cu2qu/cu2qu.py":552
  6713. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6714. * if spline is None:
  6715. * if n == MAX_N: # <<<<<<<<<<<<<<
  6716. * break
  6717. * n += 1
  6718. */
  6719. }
  6720. /* "fontTools/cu2qu/cu2qu.py":554
  6721. * if n == MAX_N:
  6722. * break
  6723. * n += 1 # <<<<<<<<<<<<<<
  6724. * last_i = i
  6725. * continue
  6726. */
  6727. __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_v_n, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 554, __pyx_L1_error)
  6728. __Pyx_GOTREF(__pyx_t_1);
  6729. __Pyx_DECREF_SET(__pyx_v_n, __pyx_t_1);
  6730. __pyx_t_1 = 0;
  6731. /* "fontTools/cu2qu/cu2qu.py":555
  6732. * break
  6733. * n += 1
  6734. * last_i = i # <<<<<<<<<<<<<<
  6735. * continue
  6736. * splines[i] = spline
  6737. */
  6738. __pyx_v_last_i = __pyx_v_i;
  6739. /* "fontTools/cu2qu/cu2qu.py":556
  6740. * n += 1
  6741. * last_i = i
  6742. * continue # <<<<<<<<<<<<<<
  6743. * splines[i] = spline
  6744. * i = (i + 1) % l
  6745. */
  6746. goto __pyx_L17_continue;
  6747. /* "fontTools/cu2qu/cu2qu.py":551
  6748. * while True:
  6749. * spline = cubic_approx_spline(curves[i], n, max_errors[i], all_quadratic)
  6750. * if spline is None: # <<<<<<<<<<<<<<
  6751. * if n == MAX_N:
  6752. * break
  6753. */
  6754. }
  6755. /* "fontTools/cu2qu/cu2qu.py":557
  6756. * last_i = i
  6757. * continue
  6758. * splines[i] = spline # <<<<<<<<<<<<<<
  6759. * i = (i + 1) % l
  6760. * if i == last_i:
  6761. */
  6762. if (unlikely((__Pyx_SetItemInt(__pyx_v_splines, __pyx_v_i, __pyx_v_spline, int, 1, __Pyx_PyLong_From_int, 1, 1, 1, 1, __Pyx_ReferenceSharing_OwnStrongReference) < 0))) __PYX_ERR(0, 557, __pyx_L1_error)
  6763. /* "fontTools/cu2qu/cu2qu.py":558
  6764. * continue
  6765. * splines[i] = spline
  6766. * i = (i + 1) % l # <<<<<<<<<<<<<<
  6767. * if i == last_i:
  6768. * # done. go home
  6769. */
  6770. __pyx_t_14 = (__pyx_v_i + 1);
  6771. if (unlikely(__pyx_v_l == 0)) {
  6772. PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero");
  6773. __PYX_ERR(0, 558, __pyx_L1_error)
  6774. }
  6775. __pyx_v_i = __Pyx_mod_long(__pyx_t_14, __pyx_v_l, 0);
  6776. /* "fontTools/cu2qu/cu2qu.py":559
  6777. * splines[i] = spline
  6778. * i = (i + 1) % l
  6779. * if i == last_i: # <<<<<<<<<<<<<<
  6780. * # done. go home
  6781. * return [[(s.real, s.imag) for s in spline] for spline in splines]
  6782. */
  6783. __pyx_t_11 = (__pyx_v_i == __pyx_v_last_i);
  6784. if (__pyx_t_11) {
  6785. /* "fontTools/cu2qu/cu2qu.py":561
  6786. * if i == last_i:
  6787. * # done. go home
  6788. * return [[(s.real, s.imag) for s in spline] for spline in splines] # <<<<<<<<<<<<<<
  6789. *
  6790. * raise ApproxNotFoundError(curves)
  6791. */
  6792. __Pyx_XDECREF(__pyx_r);
  6793. { /* enter inner scope */
  6794. __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 561, __pyx_L24_error)
  6795. __Pyx_GOTREF(__pyx_t_1);
  6796. __pyx_t_2 = __pyx_v_splines; __Pyx_INCREF(__pyx_t_2);
  6797. __pyx_t_7 = 0;
  6798. for (;;) {
  6799. {
  6800. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
  6801. #if !CYTHON_ASSUME_SAFE_SIZE
  6802. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 561, __pyx_L24_error)
  6803. #endif
  6804. if (__pyx_t_7 >= __pyx_temp) break;
  6805. }
  6806. __pyx_t_5 = __Pyx_PyList_GetItemRefFast(__pyx_t_2, __pyx_t_7, __Pyx_ReferenceSharing_OwnStrongReference);
  6807. ++__pyx_t_7;
  6808. if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 561, __pyx_L24_error)
  6809. __Pyx_GOTREF(__pyx_t_5);
  6810. __Pyx_XDECREF_SET(__pyx_8genexpr4__pyx_v_spline, __pyx_t_5);
  6811. __pyx_t_5 = 0;
  6812. { /* enter inner scope */
  6813. __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 561, __pyx_L29_error)
  6814. __Pyx_GOTREF(__pyx_t_5);
  6815. if (likely(PyList_CheckExact(__pyx_8genexpr4__pyx_v_spline)) || PyTuple_CheckExact(__pyx_8genexpr4__pyx_v_spline)) {
  6816. __pyx_t_6 = __pyx_8genexpr4__pyx_v_spline; __Pyx_INCREF(__pyx_t_6);
  6817. __pyx_t_3 = 0;
  6818. __pyx_t_4 = NULL;
  6819. } else {
  6820. __pyx_t_3 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_8genexpr4__pyx_v_spline); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 561, __pyx_L29_error)
  6821. __Pyx_GOTREF(__pyx_t_6);
  6822. __pyx_t_4 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 561, __pyx_L29_error)
  6823. }
  6824. for (;;) {
  6825. if (likely(!__pyx_t_4)) {
  6826. if (likely(PyList_CheckExact(__pyx_t_6))) {
  6827. {
  6828. Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
  6829. #if !CYTHON_ASSUME_SAFE_SIZE
  6830. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 561, __pyx_L29_error)
  6831. #endif
  6832. if (__pyx_t_3 >= __pyx_temp) break;
  6833. }
  6834. __pyx_t_10 = __Pyx_PyList_GetItemRefFast(__pyx_t_6, __pyx_t_3, __Pyx_ReferenceSharing_OwnStrongReference);
  6835. ++__pyx_t_3;
  6836. } else {
  6837. {
  6838. Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
  6839. #if !CYTHON_ASSUME_SAFE_SIZE
  6840. if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 561, __pyx_L29_error)
  6841. #endif
  6842. if (__pyx_t_3 >= __pyx_temp) break;
  6843. }
  6844. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  6845. __pyx_t_10 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_3));
  6846. #else
  6847. __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_3);
  6848. #endif
  6849. ++__pyx_t_3;
  6850. }
  6851. if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 561, __pyx_L29_error)
  6852. } else {
  6853. __pyx_t_10 = __pyx_t_4(__pyx_t_6);
  6854. if (unlikely(!__pyx_t_10)) {
  6855. PyObject* exc_type = PyErr_Occurred();
  6856. if (exc_type) {
  6857. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 561, __pyx_L29_error)
  6858. PyErr_Clear();
  6859. }
  6860. break;
  6861. }
  6862. }
  6863. __Pyx_GOTREF(__pyx_t_10);
  6864. __Pyx_XDECREF_SET(__pyx_8genexpr5__pyx_v_s, __pyx_t_10);
  6865. __pyx_t_10 = 0;
  6866. __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_s, __pyx_mstate_global->__pyx_n_u_real); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 561, __pyx_L29_error)
  6867. __Pyx_GOTREF(__pyx_t_10);
  6868. __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_8genexpr5__pyx_v_s, __pyx_mstate_global->__pyx_n_u_imag); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 561, __pyx_L29_error)
  6869. __Pyx_GOTREF(__pyx_t_9);
  6870. __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 561, __pyx_L29_error)
  6871. __Pyx_GOTREF(__pyx_t_15);
  6872. __Pyx_GIVEREF(__pyx_t_10);
  6873. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10) != (0)) __PYX_ERR(0, 561, __pyx_L29_error);
  6874. __Pyx_GIVEREF(__pyx_t_9);
  6875. if (__Pyx_PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_9) != (0)) __PYX_ERR(0, 561, __pyx_L29_error);
  6876. __pyx_t_10 = 0;
  6877. __pyx_t_9 = 0;
  6878. if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_15))) __PYX_ERR(0, 561, __pyx_L29_error)
  6879. __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  6880. }
  6881. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  6882. __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0;
  6883. goto __pyx_L33_exit_scope;
  6884. __pyx_L29_error:;
  6885. __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s); __pyx_8genexpr5__pyx_v_s = 0;
  6886. goto __pyx_L24_error;
  6887. __pyx_L33_exit_scope:;
  6888. } /* exit inner scope */
  6889. if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 561, __pyx_L24_error)
  6890. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6891. }
  6892. __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  6893. __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0;
  6894. goto __pyx_L35_exit_scope;
  6895. __pyx_L24_error:;
  6896. __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline); __pyx_8genexpr4__pyx_v_spline = 0;
  6897. goto __pyx_L1_error;
  6898. __pyx_L35_exit_scope:;
  6899. } /* exit inner scope */
  6900. __pyx_r = __pyx_t_1;
  6901. __pyx_t_1 = 0;
  6902. goto __pyx_L0;
  6903. /* "fontTools/cu2qu/cu2qu.py":559
  6904. * splines[i] = spline
  6905. * i = (i + 1) % l
  6906. * if i == last_i: # <<<<<<<<<<<<<<
  6907. * # done. go home
  6908. * return [[(s.real, s.imag) for s in spline] for spline in splines]
  6909. */
  6910. }
  6911. __pyx_L17_continue:;
  6912. }
  6913. __pyx_L18_break:;
  6914. /* "fontTools/cu2qu/cu2qu.py":563
  6915. * return [[(s.real, s.imag) for s in spline] for spline in splines]
  6916. *
  6917. * raise ApproxNotFoundError(curves) # <<<<<<<<<<<<<<
  6918. */
  6919. __pyx_t_2 = NULL;
  6920. __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ApproxNotFoundError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 563, __pyx_L1_error)
  6921. __Pyx_GOTREF(__pyx_t_5);
  6922. __pyx_t_16 = 1;
  6923. #if CYTHON_UNPACK_METHODS
  6924. if (unlikely(PyMethod_Check(__pyx_t_5))) {
  6925. __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
  6926. assert(__pyx_t_2);
  6927. PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
  6928. __Pyx_INCREF(__pyx_t_2);
  6929. __Pyx_INCREF(__pyx__function);
  6930. __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
  6931. __pyx_t_16 = 0;
  6932. }
  6933. #endif
  6934. {
  6935. PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_curves};
  6936. __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_16, (2-__pyx_t_16) | (__pyx_t_16*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
  6937. __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
  6938. __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  6939. if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L1_error)
  6940. __Pyx_GOTREF(__pyx_t_1);
  6941. }
  6942. __Pyx_Raise(__pyx_t_1, 0, 0, 0);
  6943. __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  6944. __PYX_ERR(0, 563, __pyx_L1_error)
  6945. /* "fontTools/cu2qu/cu2qu.py":503
  6946. *
  6947. *
  6948. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  6949. * @cython.locals(all_quadratic=cython.int)
  6950. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  6951. */
  6952. /* function exit code */
  6953. __pyx_L1_error:;
  6954. __Pyx_XDECREF(__pyx_t_1);
  6955. __Pyx_XDECREF(__pyx_t_2);
  6956. __Pyx_XDECREF(__pyx_t_5);
  6957. __Pyx_XDECREF(__pyx_t_6);
  6958. __Pyx_XDECREF(__pyx_t_9);
  6959. __Pyx_XDECREF(__pyx_t_10);
  6960. __Pyx_XDECREF(__pyx_t_15);
  6961. __Pyx_AddTraceback("fontTools.cu2qu.cu2qu.curves_to_quadratic", __pyx_clineno, __pyx_lineno, __pyx_filename);
  6962. __pyx_r = NULL;
  6963. __pyx_L0:;
  6964. __Pyx_XDECREF(__pyx_v_splines);
  6965. __Pyx_XDECREF(__pyx_v_n);
  6966. __Pyx_XDECREF(__pyx_v_spline);
  6967. __Pyx_XDECREF(__pyx_8genexpr2__pyx_v_curve);
  6968. __Pyx_XDECREF(__pyx_8genexpr3__pyx_v_p);
  6969. __Pyx_XDECREF(__pyx_8genexpr4__pyx_v_spline);
  6970. __Pyx_XDECREF(__pyx_8genexpr5__pyx_v_s);
  6971. __Pyx_XDECREF(__pyx_v_curves);
  6972. __Pyx_XGIVEREF(__pyx_r);
  6973. __Pyx_RefNannyFinishContext();
  6974. return __pyx_r;
  6975. }
  6976. /* #### Code section: module_exttypes ### */
  6977. static PyObject *__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  6978. PyObject *o;
  6979. #if CYTHON_USE_FREELISTS
  6980. if (likely((int)(__pyx_mstate_global->__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen))))
  6981. {
  6982. o = (PyObject*)__pyx_mstate_global->__pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[--__pyx_mstate_global->__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen];
  6983. #if CYTHON_USE_TYPE_SPECS
  6984. Py_DECREF(Py_TYPE(o));
  6985. #endif
  6986. memset(o, 0, sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen));
  6987. #if CYTHON_COMPILING_IN_LIMITED_API
  6988. (void) PyObject_Init(o, t);
  6989. #else
  6990. (void) PyObject_INIT(o, t);
  6991. #endif
  6992. } else
  6993. #endif
  6994. {
  6995. o = __Pyx_AllocateExtensionType(t, 1);
  6996. if (unlikely(!o)) return 0;
  6997. }
  6998. return o;
  6999. }
  7000. static void __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen(PyObject *o) {
  7001. #if CYTHON_USE_TP_FINALIZE
  7002. if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && (!PyType_IS_GC(Py_TYPE(o)) || !__Pyx_PyObject_GC_IsFinalized(o))) {
  7003. if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) {
  7004. if (PyObject_CallFinalizerFromDealloc(o)) return;
  7005. }
  7006. }
  7007. #endif
  7008. #if CYTHON_USE_FREELISTS
  7009. if (likely((int)(__pyx_mstate_global->__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen))))
  7010. {
  7011. __pyx_mstate_global->__pyx_freelist_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen[__pyx_mstate_global->__pyx_freecount_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen++] = ((struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen *)o);
  7012. } else
  7013. #endif
  7014. {
  7015. PyTypeObject *tp = Py_TYPE(o);
  7016. #if CYTHON_USE_TYPE_SLOTS
  7017. (*tp->tp_free)(o);
  7018. #else
  7019. {
  7020. freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
  7021. if (tp_free) tp_free(o);
  7022. }
  7023. #endif
  7024. #if CYTHON_USE_TYPE_SPECS
  7025. Py_DECREF(tp);
  7026. #endif
  7027. }
  7028. }
  7029. #if CYTHON_USE_TYPE_SPECS
  7030. static PyType_Slot __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_slots[] = {
  7031. {Py_tp_dealloc, (void *)__pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen},
  7032. {Py_tp_new, (void *)__pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen},
  7033. {0, 0},
  7034. };
  7035. static PyType_Spec __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_spec = {
  7036. "fontTools.cu2qu.cu2qu.__pyx_scope_struct___split_cubic_into_n_gen",
  7037. sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen),
  7038. 0,
  7039. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER,
  7040. __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_slots,
  7041. };
  7042. #else
  7043. static PyTypeObject __pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = {
  7044. PyVarObject_HEAD_INIT(0, 0)
  7045. "fontTools.cu2qu.cu2qu.""__pyx_scope_struct___split_cubic_into_n_gen", /*tp_name*/
  7046. sizeof(struct __pyx_obj_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen), /*tp_basicsize*/
  7047. 0, /*tp_itemsize*/
  7048. __pyx_tp_dealloc_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_dealloc*/
  7049. 0, /*tp_vectorcall_offset*/
  7050. 0, /*tp_getattr*/
  7051. 0, /*tp_setattr*/
  7052. 0, /*tp_as_async*/
  7053. 0, /*tp_repr*/
  7054. 0, /*tp_as_number*/
  7055. 0, /*tp_as_sequence*/
  7056. 0, /*tp_as_mapping*/
  7057. 0, /*tp_hash*/
  7058. 0, /*tp_call*/
  7059. 0, /*tp_str*/
  7060. 0, /*tp_getattro*/
  7061. 0, /*tp_setattro*/
  7062. 0, /*tp_as_buffer*/
  7063. Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
  7064. 0, /*tp_doc*/
  7065. 0, /*tp_traverse*/
  7066. 0, /*tp_clear*/
  7067. 0, /*tp_richcompare*/
  7068. 0, /*tp_weaklistoffset*/
  7069. 0, /*tp_iter*/
  7070. 0, /*tp_iternext*/
  7071. 0, /*tp_methods*/
  7072. 0, /*tp_members*/
  7073. 0, /*tp_getset*/
  7074. 0, /*tp_base*/
  7075. 0, /*tp_dict*/
  7076. 0, /*tp_descr_get*/
  7077. 0, /*tp_descr_set*/
  7078. #if !CYTHON_USE_TYPE_SPECS
  7079. 0, /*tp_dictoffset*/
  7080. #endif
  7081. 0, /*tp_init*/
  7082. 0, /*tp_alloc*/
  7083. __pyx_tp_new_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen, /*tp_new*/
  7084. 0, /*tp_free*/
  7085. 0, /*tp_is_gc*/
  7086. 0, /*tp_bases*/
  7087. 0, /*tp_mro*/
  7088. 0, /*tp_cache*/
  7089. 0, /*tp_subclasses*/
  7090. 0, /*tp_weaklist*/
  7091. 0, /*tp_del*/
  7092. 0, /*tp_version_tag*/
  7093. #if CYTHON_USE_TP_FINALIZE
  7094. 0, /*tp_finalize*/
  7095. #else
  7096. NULL, /*tp_finalize*/
  7097. #endif
  7098. #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  7099. 0, /*tp_vectorcall*/
  7100. #endif
  7101. #if __PYX_NEED_TP_PRINT_SLOT == 1
  7102. 0, /*tp_print*/
  7103. #endif
  7104. #if PY_VERSION_HEX >= 0x030C0000
  7105. 0, /*tp_watched*/
  7106. #endif
  7107. #if PY_VERSION_HEX >= 0x030d00A4
  7108. 0, /*tp_versions_used*/
  7109. #endif
  7110. #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  7111. 0, /*tp_pypy_flags*/
  7112. #endif
  7113. };
  7114. #endif
  7115. static PyMethodDef __pyx_methods[] = {
  7116. {0, 0, 0, 0}
  7117. };
  7118. /* #### Code section: initfunc_declarations ### */
  7119. static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7120. static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7121. static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/
  7122. static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7123. static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7124. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7125. static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7126. static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7127. static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7128. static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7129. static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7130. static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/
  7131. /* #### Code section: init_module ### */
  7132. static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) {
  7133. __Pyx_RefNannyDeclarations
  7134. CYTHON_UNUSED_VAR(__pyx_mstate);
  7135. __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  7136. /*--- Global init code ---*/
  7137. __Pyx_RefNannyFinishContext();
  7138. return 0;
  7139. }
  7140. static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) {
  7141. __Pyx_RefNannyDeclarations
  7142. CYTHON_UNUSED_VAR(__pyx_mstate);
  7143. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  7144. /*--- Variable export code ---*/
  7145. __Pyx_RefNannyFinishContext();
  7146. return 0;
  7147. }
  7148. static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) {
  7149. __Pyx_RefNannyDeclarations
  7150. CYTHON_UNUSED_VAR(__pyx_mstate);
  7151. __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  7152. /*--- Function export code ---*/
  7153. __Pyx_RefNannyFinishContext();
  7154. return 0;
  7155. }
  7156. static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) {
  7157. __Pyx_RefNannyDeclarations
  7158. CYTHON_UNUSED_VAR(__pyx_mstate);
  7159. int __pyx_lineno = 0;
  7160. const char *__pyx_filename = NULL;
  7161. int __pyx_clineno = 0;
  7162. __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  7163. /*--- Type init code ---*/
  7164. #if CYTHON_USE_TYPE_SPECS
  7165. __pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen)) __PYX_ERR(0, 150, __pyx_L1_error)
  7166. if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen_spec, __pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) < (0)) __PYX_ERR(0, 150, __pyx_L1_error)
  7167. #else
  7168. __pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen = &__pyx_type_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen;
  7169. #endif
  7170. #if !CYTHON_COMPILING_IN_LIMITED_API
  7171. #endif
  7172. #if !CYTHON_USE_TYPE_SPECS
  7173. if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen) < (0)) __PYX_ERR(0, 150, __pyx_L1_error)
  7174. #endif
  7175. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7176. PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen);
  7177. #endif
  7178. #if !CYTHON_COMPILING_IN_LIMITED_API
  7179. if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_dictoffset && __pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_getattro == PyObject_GenericGetAttr)) {
  7180. __pyx_mstate->__pyx_ptype_9fontTools_5cu2qu_5cu2qu___pyx_scope_struct___split_cubic_into_n_gen->tp_getattro = PyObject_GenericGetAttr;
  7181. }
  7182. #endif
  7183. __Pyx_RefNannyFinishContext();
  7184. return 0;
  7185. __pyx_L1_error:;
  7186. __Pyx_RefNannyFinishContext();
  7187. return -1;
  7188. }
  7189. static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) {
  7190. __Pyx_RefNannyDeclarations
  7191. CYTHON_UNUSED_VAR(__pyx_mstate);
  7192. __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  7193. /*--- Type import code ---*/
  7194. __Pyx_RefNannyFinishContext();
  7195. return 0;
  7196. }
  7197. static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) {
  7198. __Pyx_RefNannyDeclarations
  7199. CYTHON_UNUSED_VAR(__pyx_mstate);
  7200. __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  7201. /*--- Variable import code ---*/
  7202. __Pyx_RefNannyFinishContext();
  7203. return 0;
  7204. }
  7205. static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) {
  7206. __Pyx_RefNannyDeclarations
  7207. CYTHON_UNUSED_VAR(__pyx_mstate);
  7208. __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  7209. /*--- Function import code ---*/
  7210. __Pyx_RefNannyFinishContext();
  7211. return 0;
  7212. }
  7213. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7214. static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
  7215. static int __pyx_pymod_exec_cu2qu(PyObject* module); /*proto*/
  7216. static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  7217. {Py_mod_create, (void*)__pyx_pymod_create},
  7218. {Py_mod_exec, (void*)__pyx_pymod_exec_cu2qu},
  7219. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7220. {Py_mod_gil, Py_MOD_GIL_USED},
  7221. #endif
  7222. #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE
  7223. {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
  7224. #endif
  7225. {0, NULL}
  7226. };
  7227. #endif
  7228. #ifdef __cplusplus
  7229. namespace {
  7230. struct PyModuleDef __pyx_moduledef =
  7231. #else
  7232. static struct PyModuleDef __pyx_moduledef =
  7233. #endif
  7234. {
  7235. PyModuleDef_HEAD_INIT,
  7236. "cu2qu",
  7237. 0, /* m_doc */
  7238. #if CYTHON_USE_MODULE_STATE
  7239. sizeof(__pyx_mstatetype), /* m_size */
  7240. #else
  7241. (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */
  7242. #endif
  7243. __pyx_methods /* m_methods */,
  7244. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7245. __pyx_moduledef_slots, /* m_slots */
  7246. #else
  7247. NULL, /* m_reload */
  7248. #endif
  7249. #if CYTHON_USE_MODULE_STATE
  7250. __pyx_m_traverse, /* m_traverse */
  7251. __pyx_m_clear, /* m_clear */
  7252. NULL /* m_free */
  7253. #else
  7254. NULL, /* m_traverse */
  7255. NULL, /* m_clear */
  7256. NULL /* m_free */
  7257. #endif
  7258. };
  7259. #ifdef __cplusplus
  7260. } /* anonymous namespace */
  7261. #endif
  7262. /* PyModInitFuncType */
  7263. #ifndef CYTHON_NO_PYINIT_EXPORT
  7264. #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
  7265. #else
  7266. #ifdef __cplusplus
  7267. #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
  7268. #else
  7269. #define __Pyx_PyMODINIT_FUNC PyObject *
  7270. #endif
  7271. #endif
  7272. __Pyx_PyMODINIT_FUNC PyInit_cu2qu(void) CYTHON_SMALL_CODE; /*proto*/
  7273. __Pyx_PyMODINIT_FUNC PyInit_cu2qu(void)
  7274. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7275. {
  7276. return PyModuleDef_Init(&__pyx_moduledef);
  7277. }
  7278. /* ModuleCreationPEP489 */
  7279. #if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  7280. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  7281. static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) {
  7282. {
  7283. PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think
  7284. if (!module) {
  7285. PyErr_Clear(); // just try the 3.8-3.12 version
  7286. module = PyImport_ImportModule("_xxsubinterpreters");
  7287. if (!module) goto bad;
  7288. }
  7289. PyObject *current = PyObject_CallMethod(module, "get_current", NULL);
  7290. Py_DECREF(module);
  7291. if (!current) goto bad;
  7292. if (PyTuple_Check(current)) {
  7293. PyObject *new_current = PySequence_GetItem(current, 0);
  7294. Py_DECREF(current);
  7295. current = new_current;
  7296. if (!new_current) goto bad;
  7297. }
  7298. long long as_c_int = PyLong_AsLongLong(current);
  7299. Py_DECREF(current);
  7300. return as_c_int;
  7301. }
  7302. bad:
  7303. PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n");
  7304. return -1;
  7305. }
  7306. #endif
  7307. #if !CYTHON_USE_MODULE_STATE
  7308. static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
  7309. static PY_INT64_T main_interpreter_id = -1;
  7310. #if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  7311. PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  7312. #elif CYTHON_COMPILING_IN_GRAAL
  7313. PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
  7314. #elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
  7315. || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
  7316. PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId();
  7317. #elif CYTHON_COMPILING_IN_LIMITED_API
  7318. PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get());
  7319. #else
  7320. PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
  7321. #endif
  7322. if (unlikely(current_id == -1)) {
  7323. return -1;
  7324. }
  7325. if (main_interpreter_id == -1) {
  7326. main_interpreter_id = current_id;
  7327. return 0;
  7328. } else if (unlikely(main_interpreter_id != current_id)) {
  7329. PyErr_SetString(
  7330. PyExc_ImportError,
  7331. "Interpreter change detected - this module can only be loaded into one interpreter per process.");
  7332. return -1;
  7333. }
  7334. return 0;
  7335. }
  7336. #endif
  7337. 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)
  7338. {
  7339. PyObject *value = PyObject_GetAttrString(spec, from_name);
  7340. int result = 0;
  7341. if (likely(value)) {
  7342. if (allow_none || value != Py_None) {
  7343. result = PyDict_SetItemString(moddict, to_name, value);
  7344. }
  7345. Py_DECREF(value);
  7346. } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
  7347. PyErr_Clear();
  7348. } else {
  7349. result = -1;
  7350. }
  7351. return result;
  7352. }
  7353. static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) {
  7354. PyObject *module = NULL, *moddict, *modname;
  7355. CYTHON_UNUSED_VAR(def);
  7356. #if !CYTHON_USE_MODULE_STATE
  7357. if (__Pyx_check_single_interpreter())
  7358. return NULL;
  7359. #endif
  7360. if (__pyx_m)
  7361. return __Pyx_NewRef(__pyx_m);
  7362. modname = PyObject_GetAttrString(spec, "name");
  7363. if (unlikely(!modname)) goto bad;
  7364. module = PyModule_NewObject(modname);
  7365. Py_DECREF(modname);
  7366. if (unlikely(!module)) goto bad;
  7367. moddict = PyModule_GetDict(module);
  7368. if (unlikely(!moddict)) goto bad;
  7369. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
  7370. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
  7371. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
  7372. if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
  7373. return module;
  7374. bad:
  7375. Py_XDECREF(module);
  7376. return NULL;
  7377. }
  7378. static CYTHON_SMALL_CODE int __pyx_pymod_exec_cu2qu(PyObject *__pyx_pyinit_module)
  7379. #endif
  7380. {
  7381. int stringtab_initialized = 0;
  7382. #if CYTHON_USE_MODULE_STATE
  7383. int pystate_addmodule_run = 0;
  7384. #endif
  7385. __pyx_mstatetype *__pyx_mstate = NULL;
  7386. PyObject *__pyx_t_1 = NULL;
  7387. PyObject *__pyx_t_2 = NULL;
  7388. PyObject *__pyx_t_3 = NULL;
  7389. PyObject *__pyx_t_4 = NULL;
  7390. Py_ssize_t __pyx_t_5;
  7391. PyObject *__pyx_t_6 = NULL;
  7392. double __pyx_t_7;
  7393. int __pyx_lineno = 0;
  7394. const char *__pyx_filename = NULL;
  7395. int __pyx_clineno = 0;
  7396. __Pyx_RefNannyDeclarations
  7397. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7398. if (__pyx_m) {
  7399. if (__pyx_m == __pyx_pyinit_module) return 0;
  7400. PyErr_SetString(PyExc_RuntimeError, "Module 'cu2qu' has already been imported. Re-initialisation is not supported.");
  7401. return -1;
  7402. }
  7403. #else
  7404. if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  7405. #endif
  7406. /*--- Module creation code ---*/
  7407. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7408. __pyx_t_1 = __pyx_pyinit_module;
  7409. Py_INCREF(__pyx_t_1);
  7410. #else
  7411. __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  7412. #endif
  7413. #if CYTHON_USE_MODULE_STATE
  7414. {
  7415. int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef);
  7416. __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "cu2qu" pseudovariable */
  7417. if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7418. pystate_addmodule_run = 1;
  7419. }
  7420. #else
  7421. __pyx_m = __pyx_t_1;
  7422. #endif
  7423. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7424. PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED);
  7425. #endif
  7426. __pyx_mstate = __pyx_mstate_global;
  7427. CYTHON_UNUSED_VAR(__pyx_t_1);
  7428. __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  7429. Py_INCREF(__pyx_mstate->__pyx_d);
  7430. __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  7431. __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  7432. if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  7433. /* ImportRefnannyAPI */
  7434. #if CYTHON_REFNANNY
  7435. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  7436. if (!__Pyx_RefNanny) {
  7437. PyErr_Clear();
  7438. __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
  7439. if (!__Pyx_RefNanny)
  7440. Py_FatalError("failed to import 'refnanny' module");
  7441. }
  7442. #endif
  7443. __Pyx_RefNannySetupContext("PyInit_cu2qu", 0);
  7444. __Pyx_init_runtime_version();
  7445. 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)
  7446. __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  7447. __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  7448. __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  7449. /*--- Library function declarations ---*/
  7450. /*--- Initialize various global constants etc. ---*/
  7451. if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7452. stringtab_initialized = 1;
  7453. if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7454. if (__pyx_module_is_main_fontTools__cu2qu__cu2qu) {
  7455. 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)
  7456. }
  7457. {
  7458. PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
  7459. if (!PyDict_GetItemString(modules, "fontTools.cu2qu.cu2qu")) {
  7460. if (unlikely((PyDict_SetItemString(modules, "fontTools.cu2qu.cu2qu", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7461. }
  7462. }
  7463. /*--- Builtin init code ---*/
  7464. if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7465. /*--- Constants init code ---*/
  7466. if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7467. if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7468. /*--- Global type/function init code ---*/
  7469. (void)__Pyx_modinit_global_init_code(__pyx_mstate);
  7470. (void)__Pyx_modinit_variable_export_code(__pyx_mstate);
  7471. (void)__Pyx_modinit_function_export_code(__pyx_mstate);
  7472. if (unlikely((__Pyx_modinit_type_init_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  7473. (void)__Pyx_modinit_type_import_code(__pyx_mstate);
  7474. (void)__Pyx_modinit_variable_import_code(__pyx_mstate);
  7475. (void)__Pyx_modinit_function_import_code(__pyx_mstate);
  7476. /*--- Execution code ---*/
  7477. /* "fontTools/cu2qu/cu2qu.py":18
  7478. * # limitations under the License.
  7479. *
  7480. * try: # <<<<<<<<<<<<<<
  7481. * import cython
  7482. * except (AttributeError, ImportError):
  7483. */
  7484. {
  7485. (void)__pyx_t_1; (void)__pyx_t_2; (void)__pyx_t_3; /* mark used */
  7486. /*try:*/ {
  7487. /* "fontTools/cu2qu/cu2qu.py":19
  7488. *
  7489. * try:
  7490. * import cython # <<<<<<<<<<<<<<
  7491. * except (AttributeError, ImportError):
  7492. * # if cython not installed, use mock module with no-op decorators and types
  7493. */
  7494. }
  7495. }
  7496. /* "fontTools/cu2qu/cu2qu.py":23
  7497. * # if cython not installed, use mock module with no-op decorators and types
  7498. * from fontTools.misc import cython
  7499. * COMPILED = cython.compiled # <<<<<<<<<<<<<<
  7500. *
  7501. * import math
  7502. */
  7503. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_COMPILED, Py_True) < (0)) __PYX_ERR(0, 23, __pyx_L1_error)
  7504. /* "fontTools/cu2qu/cu2qu.py":25
  7505. * COMPILED = cython.compiled
  7506. *
  7507. * import math # <<<<<<<<<<<<<<
  7508. *
  7509. * from .errors import Error as Cu2QuError, ApproxNotFoundError
  7510. */
  7511. __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_math, 0, 0, NULL, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error)
  7512. __pyx_t_4 = __pyx_t_3;
  7513. __Pyx_GOTREF(__pyx_t_4);
  7514. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_math, __pyx_t_4) < (0)) __PYX_ERR(0, 25, __pyx_L1_error)
  7515. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7516. /* "fontTools/cu2qu/cu2qu.py":27
  7517. * import math
  7518. *
  7519. * from .errors import Error as Cu2QuError, ApproxNotFoundError # <<<<<<<<<<<<<<
  7520. *
  7521. *
  7522. */
  7523. {
  7524. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Error,__pyx_mstate_global->__pyx_n_u_ApproxNotFoundError};
  7525. __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_errors, __pyx_imported_names, 2, __pyx_mstate_global->__pyx_kp_u_fontTools_cu2qu_errors, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
  7526. }
  7527. __pyx_t_4 = __pyx_t_3;
  7528. __Pyx_GOTREF(__pyx_t_4);
  7529. {
  7530. PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Error,__pyx_mstate_global->__pyx_n_u_ApproxNotFoundError};
  7531. for (__pyx_t_5=0; __pyx_t_5 < 2; __pyx_t_5++) {
  7532. __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)
  7533. __Pyx_GOTREF(__pyx_t_6);
  7534. switch (__pyx_t_5) {
  7535. case 0:
  7536. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_Cu2QuError, __pyx_t_6) < (0)) __PYX_ERR(0, 27, __pyx_L1_error)
  7537. break;
  7538. default:;
  7539. 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)
  7540. }
  7541. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7542. }
  7543. }
  7544. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7545. /* "fontTools/cu2qu/cu2qu.py":30
  7546. *
  7547. *
  7548. * __all__ = ["curve_to_quadratic", "curves_to_quadratic"] # <<<<<<<<<<<<<<
  7549. *
  7550. * MAX_N = 100
  7551. */
  7552. __pyx_t_4 = __Pyx_PyList_Pack(2, __pyx_mstate_global->__pyx_n_u_curve_to_quadratic, __pyx_mstate_global->__pyx_n_u_curves_to_quadratic); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error)
  7553. __Pyx_GOTREF(__pyx_t_4);
  7554. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_all, __pyx_t_4) < (0)) __PYX_ERR(0, 30, __pyx_L1_error)
  7555. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7556. /* "fontTools/cu2qu/cu2qu.py":32
  7557. * __all__ = ["curve_to_quadratic", "curves_to_quadratic"]
  7558. *
  7559. * MAX_N = 100 # <<<<<<<<<<<<<<
  7560. *
  7561. * NAN = float("NaN")
  7562. */
  7563. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_MAX_N, __pyx_mstate_global->__pyx_int_100) < (0)) __PYX_ERR(0, 32, __pyx_L1_error)
  7564. /* "fontTools/cu2qu/cu2qu.py":34
  7565. * MAX_N = 100
  7566. *
  7567. * NAN = float("NaN") # <<<<<<<<<<<<<<
  7568. *
  7569. *
  7570. */
  7571. __pyx_t_7 = __Pyx_PyUnicode_AsDouble(__pyx_mstate_global->__pyx_n_u_NaN); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_7, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 34, __pyx_L1_error)
  7572. __pyx_t_4 = PyFloat_FromDouble(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error)
  7573. __Pyx_GOTREF(__pyx_t_4);
  7574. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_NAN, __pyx_t_4) < (0)) __PYX_ERR(0, 34, __pyx_L1_error)
  7575. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7576. /* "fontTools/cu2qu/cu2qu.py":150
  7577. *
  7578. *
  7579. * @cython.locals( # <<<<<<<<<<<<<<
  7580. * p0=cython.complex,
  7581. * p1=cython.complex,
  7582. */
  7583. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_1_split_cubic_into_n_gen, 0, __pyx_mstate_global->__pyx_n_u_split_cubic_into_n_gen, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_cu2qu_cu2qu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 150, __pyx_L1_error)
  7584. __Pyx_GOTREF(__pyx_t_4);
  7585. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7586. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  7587. #endif
  7588. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_split_cubic_into_n_gen, __pyx_t_4) < (0)) __PYX_ERR(0, 150, __pyx_L1_error)
  7589. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7590. /* "fontTools/cu2qu/cu2qu.py":471
  7591. * @cython.locals(n=cython.int)
  7592. * @cython.locals(all_quadratic=cython.int)
  7593. * def curve_to_quadratic(curve, max_err, all_quadratic=True): # <<<<<<<<<<<<<<
  7594. * """Approximate a cubic Bezier curve with a spline of n quadratics.
  7595. *
  7596. */
  7597. __pyx_t_4 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 471, __pyx_L1_error)
  7598. __Pyx_GOTREF(__pyx_t_4);
  7599. /* "fontTools/cu2qu/cu2qu.py":468
  7600. *
  7601. *
  7602. * @cython.locals(max_err=cython.double) # <<<<<<<<<<<<<<
  7603. * @cython.locals(n=cython.int)
  7604. * @cython.locals(all_quadratic=cython.int)
  7605. */
  7606. __pyx_t_6 = PyTuple_Pack(1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 468, __pyx_L1_error)
  7607. __Pyx_GOTREF(__pyx_t_6);
  7608. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7609. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_4curve_to_quadratic, 0, __pyx_mstate_global->__pyx_n_u_curve_to_quadratic, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_cu2qu_cu2qu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 468, __pyx_L1_error)
  7610. __Pyx_GOTREF(__pyx_t_4);
  7611. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7612. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  7613. #endif
  7614. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_6);
  7615. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7616. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_curve_to_quadratic, __pyx_t_4) < (0)) __PYX_ERR(0, 468, __pyx_L1_error)
  7617. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7618. /* "fontTools/cu2qu/cu2qu.py":505
  7619. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int)
  7620. * @cython.locals(all_quadratic=cython.int)
  7621. * def curves_to_quadratic(curves, max_errors, all_quadratic=True): # <<<<<<<<<<<<<<
  7622. * """Return quadratic Bezier splines approximating the input cubic Beziers.
  7623. *
  7624. */
  7625. __pyx_t_4 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 505, __pyx_L1_error)
  7626. __Pyx_GOTREF(__pyx_t_4);
  7627. /* "fontTools/cu2qu/cu2qu.py":503
  7628. *
  7629. *
  7630. * @cython.locals(l=cython.int, last_i=cython.int, i=cython.int) # <<<<<<<<<<<<<<
  7631. * @cython.locals(all_quadratic=cython.int)
  7632. * def curves_to_quadratic(curves, max_errors, all_quadratic=True):
  7633. */
  7634. __pyx_t_6 = PyTuple_Pack(1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 503, __pyx_L1_error)
  7635. __Pyx_GOTREF(__pyx_t_6);
  7636. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7637. __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_9fontTools_5cu2qu_5cu2qu_6curves_to_quadratic, 0, __pyx_mstate_global->__pyx_n_u_curves_to_quadratic, NULL, __pyx_mstate_global->__pyx_n_u_fontTools_cu2qu_cu2qu, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 503, __pyx_L1_error)
  7638. __Pyx_GOTREF(__pyx_t_4);
  7639. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  7640. PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  7641. #endif
  7642. __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_6);
  7643. __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  7644. if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_curves_to_quadratic, __pyx_t_4) < (0)) __PYX_ERR(0, 503, __pyx_L1_error)
  7645. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7646. /* "fontTools/cu2qu/cu2qu.py":1
  7647. * # cython: language_level=3 # <<<<<<<<<<<<<<
  7648. * # distutils: define_macros=CYTHON_TRACE_NOGIL=1
  7649. *
  7650. */
  7651. __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1, __pyx_L1_error)
  7652. __Pyx_GOTREF(__pyx_t_4);
  7653. if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_curves_to_quadratic_line_503, __pyx_mstate_global->__pyx_kp_u_Return_quadratic_Bezier_splines) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  7654. 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)
  7655. __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  7656. /*--- Wrapped vars code ---*/
  7657. goto __pyx_L0;
  7658. __pyx_L1_error:;
  7659. __Pyx_XDECREF(__pyx_t_4);
  7660. __Pyx_XDECREF(__pyx_t_6);
  7661. if (__pyx_m) {
  7662. if (__pyx_mstate->__pyx_d && stringtab_initialized) {
  7663. __Pyx_AddTraceback("init fontTools.cu2qu.cu2qu", __pyx_clineno, __pyx_lineno, __pyx_filename);
  7664. }
  7665. #if !CYTHON_USE_MODULE_STATE
  7666. Py_CLEAR(__pyx_m);
  7667. #else
  7668. Py_DECREF(__pyx_m);
  7669. if (pystate_addmodule_run) {
  7670. PyObject *tp, *value, *tb;
  7671. PyErr_Fetch(&tp, &value, &tb);
  7672. PyState_RemoveModule(&__pyx_moduledef);
  7673. PyErr_Restore(tp, value, tb);
  7674. }
  7675. #endif
  7676. } else if (!PyErr_Occurred()) {
  7677. PyErr_SetString(PyExc_ImportError, "init fontTools.cu2qu.cu2qu");
  7678. }
  7679. __pyx_L0:;
  7680. __Pyx_RefNannyFinishContext();
  7681. #if CYTHON_PEP489_MULTI_PHASE_INIT
  7682. return (__pyx_m != NULL) ? 0 : -1;
  7683. #else
  7684. return __pyx_m;
  7685. #endif
  7686. }
  7687. /* #### Code section: pystring_table ### */
  7688. /* #### Code section: cached_builtins ### */
  7689. static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) {
  7690. CYTHON_UNUSED_VAR(__pyx_mstate);
  7691. /* Cached unbound methods */
  7692. __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  7693. __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items;
  7694. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  7695. __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop;
  7696. __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type;
  7697. __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values;
  7698. return 0;
  7699. }
  7700. /* #### Code section: cached_constants ### */
  7701. static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) {
  7702. __Pyx_RefNannyDeclarations
  7703. CYTHON_UNUSED_VAR(__pyx_mstate);
  7704. __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
  7705. __Pyx_RefNannyFinishContext();
  7706. return 0;
  7707. }
  7708. /* #### Code section: init_constants ### */
  7709. static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) {
  7710. CYTHON_UNUSED_VAR(__pyx_mstate);
  7711. {
  7712. const struct { const unsigned int length: 11; } index[] = {{1},{28},{1566},{1},{30},{7},{6},{22},{2},{9},{19},{8},{10},{5},{5},{3},{3},{20},{1},{2},{7},{13},{18},{1},{2},{1},{2},{18},{5},{5},{18},{6},{19},{1},{2},{7},{7},{2},{6},{21},{8},{1},{4},{13},{5},{5},{1},{6},{8},{4},{7},{10},{10},{1},{8},{4},{1},{2},{2},{2},{2},{3},{12},{4},{1},{4},{12},{10},{6},{7},{23},{2},{4},{8},{5},{5},{6},{97},{211},{2}};
  7713. #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (1382 bytes) */
  7714. const char* const cstring = "BZh91AY&SY\005#\031&\000\0012\377\377\357_\356\002~\377\377\363\277\267\377\312\377\357\377\364@@@@@@@@@\000@@@\000@\000P\004\335\307=\272\353\305\252\2734y\007\23454Hj\031\224\3231\021\372\232\021\221\223#\324\03140\2324\000\000\000a\001\246\231\036\240\320\204\301\032\tO\3224#i=O\n\014 \006@h\000\000\031\032\003& \320\tM\021\032&\204\312~\2044\323T\365?\022\201\221\265\000\321\3522= \r\001\240\001\223M\000=@\323SU7\252z\236\223\323\324\206@\000\003@h\0004\001\220\000\000\001\243G\250\365\000%5S(f\221\352\003L\324\006\232\017P\321\240\032\003C@\000\000\000\000\000\026l\225N@\031\276\264\242\036\352\026\030\277\007\350\005*\002$\001\257;\371\250\230\270\357\001\0310\200\342\364\237\376;\357\302\307\177\257\365\367^\311\226sR\220?\353\341\267\357\373ro\033\022/n\001l\211n\207\210\226a\377\331\034>J\3271\307~\234\346\226\001\204\3145\347\004\031z b\021\341\342\354(4V\215]\236\361\354\366\243\367\354\317\300Z\326\246i-\273\013\232\224\313'\214y\n\024+\264\360HC\000\3338\010L|\030\324L<gX\253y\374\346\370\3443\r\344\311 l\250RwmU\207!\311$q\212\314\353\212\250\334\242\225\274\324\351(Z\251\374\301\245:\327r\211iv\322\207e\212\350\364\210B\254\177\323G,\335\242]\304\237Z\251\000!BA\202\202\350\222\241CN\233\020q\030\273s\007a\231?#\321\324\\\033:\334D j\rj\304\211\225\032\032\247\364&\335\304\324E\232\351]\006\001$)$&d\264\252}\037@H MVp\010\003\361jLTXHp+\014y\030\003\031\211\2202JP\350H$\234\271\211\004O\371\343\356\227\266\220\316\203R\n\317\322\247\213\222,\353\341\305\352\036\276\020\240\003\024\340\275\370\023\240(\306\373o$L\262\2220\203\337\326\203\237\037!\032S\200\367h\013\262\n\306u\304\322wb\223Q\0345T\244\312\244\260\220A \245&\314#\271.\306\342\265\004\307\020-Z\207\222\362\016\230$\252b2W\243\031#\312\272-@\022\225]x\0030b\334@\206(\333W\n\343S+\270\204~\213i@\210\224\244\315\234\325\232i'|\360\216\240\014\203\311R)a\234\345\214\364\324\010E\327<\322\226Dv\205\345\232b#\332\262(\353U\234\311\312\201e\223k@\017\217\211\242\220\365[\332\200\347SX\241\t!\302""\304\"\265Ok\243;\2403_\200\232&i\315\211\340u- ]\301\367\232Y\310\021\233a\334\005\022\215\333\252x\274b\352\344\322\004c3*\363\334\220m6\267+\245\346\323F]\374a\231\211\351c\323V\300\315\222\367\340\\\210\206\251\205\236\213\375\347j4\313\\\034\200Y\215x%`\300\237q,\246\253Z\343,F\204\313\230,\305,\226\220\336\306\276\2676\316]X\367n\234L\333\022q\371\037}\027\265D\353\224N\304\362\325T\326\326\224\364\2020S\331|\303\206L\320\214\2212\014\027\2376l\211\036%\201T\231WH\263@\247\270\264\250Nd!\201\205\366)Bc\261\255\214 \253j\032i3\036u$\257L\260\010q\006RKK\267.\351\r\233m\314q\327)\310\352\323\251\0057g5\002\242\033\370@\366\360z\230f\332\322HL$\334\372\272Z\307\2637\230w\024\314\323\251\213\023\t^\316\\U=\374\223:\344\311\361\316\327\350D\013\343/\372\314.\232F\n\320\263</Qh\205\022\321\t\265\241\n\210\344\n\303\262i\302\033\006\021;@\371\272\2026rk\303F\336Q[\327j-\205\023\227\310*\205!\372\213\036\0317b\310h\255\213\031\001Zf\202\333\242\252\246V\nF\\\356\354]\242\303y\005\3661iBW\206}a\\\244\225A\234L`\345%\347\212EV;\024\355\363sb\256J\253\220)L\016`H\311 | \234\370\321\213\021!a\304b\231\247\315\252\254u\010L?Qp\303\"+\317\246\251\257\214\363\022\207\030#\223\"\205-\026\020\316\261,\226\321\336\000\310U1\031\226D\223\\\222\026\260\226\311\022*pH\245F\013g\301T4e(NG\014\334j\256\256\311\205\t\337X\236\314\t\260\252qF\023\225\303\305\252\345e\010\035o\276,\204\261z\250\035c\232a\261\212\344<\242A\205N0L\265\216\216\226;[\303\177P\314\316\305\354\355F\312e\270\317\305\231\251\240t\305\240\030\364\311\271\243'W\005\201Rm\t\202zk\233\370\226A\272\306\327\003\320\347]\274W\362D\311\265\325\225mo\303\361\017\313wy\346\227\246j\222g\334\025\2265\371lw\2660u\017qt\241\027\3648WoX\336\023I\206Xb\236\t\356\307r\370\247\177\020,\262\310\262\263\364\344`\025_\312\017\344Ru\326\344Fv\rN<}\232B\245\230\253\237\344D\037\004Y\314\246r\337\313\3441A\301\255\n[Xc\333\275\377\027rE8P\220\005#\031&";
  7715. PyObject *data = __Pyx_DecompressString(cstring, 1382, 2);
  7716. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  7717. const char* const bytes = __Pyx_PyBytes_AsString(data);
  7718. #if !CYTHON_ASSUME_SAFE_MACROS
  7719. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  7720. #endif
  7721. #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (1265 bytes) */
  7722. const char* const cstring = "x\332}U\315o\3336\024o\320d\010\322\244\235\321\3658\200\3556\314\356\\\325\262\343\2445\260\016N\323\016\035Z\257\316\322u@\0200\264D;\304dR\241\250|\014;\364\250\243\216:\372\350c\2179\366O\350\321\307\374\t\375\023\366H*\262\335\005%\340g\352\221\357\343\367\276\350\274d\275\207}\301\325\256\020A\364\320\213\353G\261\245Nx\266CU,9:\212\211/\211b\036\332\242\3770*Q\024\006\214\323\010\2210\224\342\224\r\341\214\017\220:\244\210\3610V\310\213{\305\345\310YYA\260\332r\020\265\314N//\226\3074j\2416\212\350QL\271G\221\350\243\373\374~~RE\224x\207\366\003\365\250VO\346\256\366E,\013mz\325\267\221\212\303\200\202\275K\326\220\234b*\245\220W\032\352\007\202\250\010I\032J\032Q^@\000)6\214\207(\244r\310\242\210\365\002:g\310\247\307\014\000\013\216\372R\014\255\237\240R\213\316\342\316\201L\275!A\200\247\221,\367 \336\225\026z\321G\2732\246\250\354\323>\211\003U\001\207t\320\251\217\216I\020\353 K\212\310\234\007S-6\021\216\326\362\234\004\021\255j7\316\214\010e\260\225:j\000,\240S\2419U6\300b\346\236\305`\370y\346\236\235\222!\004\266\325Z)D\237<y\222\343\303JLQ\225\321^q\305q\034\240{\250\334\254U\233\265J\025\225\335Z\255\n?\263m\026\333z\315\234\243\375\352\377E7\233\227\242\3659\321\315&\354\254\350\206\026\235\223\334\257\242=\267\352\356\243J\301\336\333\003/\234Z\025i\252\225l6\365\227\246V\273\371|\354:\033s\313\234\315_\005\223\205\036m(\327t\251\367\361\246\323\234\321\333h:\353\356\254\306*zTwj\217\0323k\306\310\006H\317\030\3310F\366m\324w\241\274\212\312\270\354\277C\002\311\273\307 ;\014\270\202\333l\206\202q\025\335CQ\314\024\201\352\205^\221(\216tsZUPo\273g!E\007\007\203\200\365\017\016\220\210\225U\370\0001\007\312\211qS\316}&#\225\033\233\032'=qLm\262\246\227fJ\222\016\206\320MH\306<\262\035\222W\000R\302\010\225u\370\321O\010\242^yXG6\273\360m\303\3578\232YA?\333zA\217\032\016\004\t\362Z\311\253\321\316\244\231Q\002\265?\337Z,2\020\253P\323\001\003\337\2409\363\200\345S%Gt9V\364\245B\033\\\236\231$_4\222w\334\324\312\027F\327\377\273\257\034P>P\207H""\027\200\220y\333]2\327\013\264\204Et\006l1\251\035;\243\237\231\361\346\264\315 \356\010\365\\\304\3347\314\026b}\304\305\264\nf\206\265\340\323AL88\251\307)\367M\241\000\314\034\010:\201\021br<`\307\224\243\220H2\244\312\214t-\372\313\025\023\000\020\350\3206k\215\212\317\"m\227rM?\367\333\216\345\201\007\350\314\271\177\005\202\247\277\277z\375\342\345\263\355\247q\275\033\033\216!\257\332\177\341N\247\335\351\220\016\306\257\317N\341\267\315<\205;\364T\355\300\020%.\306:Wx.a$:\343\036\023\216'$T\273.\206^\317\365<\327\323\376b\306\261\222\304\243=\342\375\355\005\"\242\006\232!s\360,\342+p\373\276\353\323@\021\\\267\177\r_Y\210\237\0037\024\343~\314=\214\031dc\200Y\204\013\257X\304\tg\212\016\243 \221\302\014\343!\001\357\200\252\303\374=\233>k\300\026~\034P\214\341\006\207\344\000\205(\204a-t\303z\330\010E\210\265\217\201=\223\024*\026\002\356c\034Q\225\013\300.\177z\362&\261\024\353\177\205MYBx\000+\307\003\350kW\271\270\216\261\242\340\034V\207R\234\230g\312\276U\357\026>}u\255\\\371t\377\332\322Z\322N\336\246[\251\227}\223\275\031\335\275X\\N\226\2227\351\335\264\221\366\263\255\214L\226K\037K\337\217\332\243\267\343\247\343\263\363\205\311\362\215d3\3751+]\254\336N\353i7\035d\335l0\332\035\337\031\223\213\305\225\217+\337\3027y\267pQ}\360\351\267\205kK7\223nB\222\223\264\227]\317\326\263x\364\353x\335\250Y\274\2214\340\340\337\254\221y\243\2225|=q\223\366d\361&\360\217\323\235\364h\262\270\226\354\246\245\t\034\201\300R\341\312\237cw\274\375\376\372\373\326y\367\334\377p\327\272\364]\332\235\254\336Jdz;mO\276.MVK \271zGs\327&\313\267\222\243t\t\366\313k\311\216\271\263\225\022-WO\376H\0274\024Ws\322\223\214d'#\177\374\303\370\364\275:o}\350\316B\372\017dB\021\374";
  7723. PyObject *data = __Pyx_DecompressString(cstring, 1265, 1);
  7724. if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
  7725. const char* const bytes = __Pyx_PyBytes_AsString(data);
  7726. #if !CYTHON_ASSUME_SAFE_MACROS
  7727. if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
  7728. #endif
  7729. #else /* compression: none (2435 bytes) */
  7730. const char* const bytes = ".Lib/fontTools/cu2qu/cu2qu.pyReturn quadratic Bezier splines approximating the input cubic Beziers.\n\n Args:\n curves: A sequence of *n* curves, each curve being a sequence of four\n 2D tuples.\n max_errors: A sequence of *n* floats representing the maximum permissible\n deviation from each of the cubic Bezier curves.\n all_quadratic (bool): If True (default) returned values are a\n quadratic spline. If False, they are either a single quadratic\n curve or a single cubic curve.\n\n Example::\n\n >>> curves_to_quadratic( [\n ... [ (50,50), (100,100), (150,100), (200,50) ],\n ... [ (75,50), (120,100), (150,75), (200,60) ]\n ... ], [1,1] )\n [[(50.0, 50.0), (75.0, 75.0), (125.0, 91.66666666666666), (175.0, 75.0), (200.0, 50.0)], [(75.0, 50.0), (97.5, 75.0), (135.41666666666666, 82.08333333333333), (175.0, 67.5), (200.0, 60.0)]]\n\n The returned splines have \"implied oncurve points\" suitable for use in\n TrueType ``glif`` outlines - i.e. in the first spline returned above,\n the first quadratic segment runs from (50,50) to\n ( (75 + 125)/2 , (120 + 91.666..)/2 ) = (100, 83.333...).\n\n Returns:\n If all_quadratic is True, a list of splines, each spline being a list\n of 2D tuples.\n\n If all_quadratic is False, a list of curves, each curve being a quadratic\n (length 3), or cubic (length 4).\n\n Raises:\n fontTools.cu2qu.Errors.ApproxNotFoundError: if no suitable approximation\n can be found for all curves with the given parameters.\n ?curves_to_quadratic (line 503)disableenablefontTools.cu2qu.errorsgcisenabledApproxNotFoundErrorCOMPILEDCu2QuErrorErrorMAX_NNANNaN__Pyx_PyDict_NextRefaa1__all__all_quadraticasyncio.coroutinesbb1cc1cline_in_tracebackclosecurvecurve_to_quadraticcurvescurves_to_quadraticdd1delta_2delta_3dterrorsfontTools.cu2qu.cu2qu__func__iimag_is_coroutineisnanitemsllast_i__main__math""max_errmax_errors__module__n__name__nextpp0p1p2p3pop__qualname__realssend__set_name__setdefaultsplinesplines_split_cubic_into_n_gent1t1_2__test__throwvaluevalues\200\001\360\006\000()\360*\000\005\r\210A\210W\220B\220c\230\024\230U\240!\340\004\010\210\005\210U\220!\2203\220f\230B\230a\330\010\021\320\021$\240A\240W\250C\250y\270\001\330\010\013\2107\220'\230\021\340\014\023\2202\220Q\220g\230Q\230g\240T\250\025\250a\340\004\n\320\n\035\230Q\230a\200\001\340,-\360J\001\000\005\016\210Q\210a\210w\220b\230\003\2304\230u\240G\2504\250y\270\001\330\004\013\2103\210a\210|\2303\230c\240\021\240!\340\004\010\210\003\2101\210A\330\004\016\210a\210v\220R\220q\330\004\r\210T\220\021\330\004\010\210\001\330\004\005\330\010\021\320\021$\240A\240V\2501\250D\260\003\260:\270Q\270d\300!\330\010\013\2107\220#\220Q\330\014\017\210r\220\023\220A\330\020\021\330\014\021\220\021\330\014\025\220Q\330\014\r\330\010\017\210q\220\005\220Q\330\010\r\210R\210r\220\023\220B\220a\330\010\013\2102\210S\220\001\340\014\023\2201\220B\220a\220w\230a\230w\240d\250%\250x\260t\270:\300Q\340\004\n\320\n\035\230Q\230a\200\001";
  7731. PyObject *data = NULL;
  7732. CYTHON_UNUSED_VAR(__Pyx_DecompressString);
  7733. #endif
  7734. PyObject **stringtab = __pyx_mstate->__pyx_string_tab;
  7735. Py_ssize_t pos = 0;
  7736. for (int i = 0; i < 77; i++) {
  7737. Py_ssize_t bytes_length = index[i].length;
  7738. PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL);
  7739. if (likely(string) && i >= 10) PyUnicode_InternInPlace(&string);
  7740. if (unlikely(!string)) {
  7741. Py_XDECREF(data);
  7742. __PYX_ERR(0, 1, __pyx_L1_error)
  7743. }
  7744. stringtab[i] = string;
  7745. pos += bytes_length;
  7746. }
  7747. for (int i = 77; i < 80; i++) {
  7748. Py_ssize_t bytes_length = index[i].length;
  7749. PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length);
  7750. stringtab[i] = string;
  7751. pos += bytes_length;
  7752. if (unlikely(!string)) {
  7753. Py_XDECREF(data);
  7754. __PYX_ERR(0, 1, __pyx_L1_error)
  7755. }
  7756. }
  7757. Py_XDECREF(data);
  7758. for (Py_ssize_t i = 0; i < 80; i++) {
  7759. if (unlikely(PyObject_Hash(stringtab[i]) == -1)) {
  7760. __PYX_ERR(0, 1, __pyx_L1_error)
  7761. }
  7762. }
  7763. #if CYTHON_IMMORTAL_CONSTANTS
  7764. {
  7765. PyObject **table = stringtab + 77;
  7766. for (Py_ssize_t i=0; i<3; ++i) {
  7767. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7768. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  7769. #else
  7770. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  7771. #endif
  7772. }
  7773. }
  7774. #endif
  7775. }
  7776. {
  7777. PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 0;
  7778. int8_t const cint_constants_1[] = {1,2,3,4,6,100};
  7779. for (int i = 0; i < 6; i++) {
  7780. numbertab[i] = PyLong_FromLong(cint_constants_1[i - 0]);
  7781. if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error)
  7782. }
  7783. }
  7784. #if CYTHON_IMMORTAL_CONSTANTS
  7785. {
  7786. PyObject **table = __pyx_mstate->__pyx_number_tab;
  7787. for (Py_ssize_t i=0; i<6; ++i) {
  7788. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  7789. Py_SET_REFCNT(table[i], _Py_IMMORTAL_REFCNT_LOCAL);
  7790. #else
  7791. Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
  7792. #endif
  7793. }
  7794. }
  7795. #endif
  7796. return 0;
  7797. __pyx_L1_error:;
  7798. return -1;
  7799. }
  7800. /* #### Code section: init_codeobjects ### */
  7801. typedef struct {
  7802. unsigned int argcount : 3;
  7803. unsigned int num_posonly_args : 1;
  7804. unsigned int num_kwonly_args : 1;
  7805. unsigned int nlocals : 5;
  7806. unsigned int flags : 10;
  7807. unsigned int first_line : 9;
  7808. } __Pyx_PyCode_New_function_description;
  7809. /* NewCodeObj.proto */
  7810. static PyObject* __Pyx_PyCode_New(
  7811. const __Pyx_PyCode_New_function_description descr,
  7812. PyObject * const *varnames,
  7813. PyObject *filename,
  7814. PyObject *funcname,
  7815. PyObject *line_table,
  7816. PyObject *tuple_dedup_map
  7817. );
  7818. static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) {
  7819. PyObject* tuple_dedup_map = PyDict_New();
  7820. if (unlikely(!tuple_dedup_map)) return -1;
  7821. {
  7822. const __Pyx_PyCode_New_function_description descr = {5, 0, 0, 19, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 150};
  7823. 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_p3, __pyx_mstate->__pyx_n_u_n, __pyx_mstate->__pyx_n_u_a1, __pyx_mstate->__pyx_n_u_b1, __pyx_mstate->__pyx_n_u_c1, __pyx_mstate->__pyx_n_u_d1, __pyx_mstate->__pyx_n_u_dt, __pyx_mstate->__pyx_n_u_delta_2, __pyx_mstate->__pyx_n_u_delta_3, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_a, __pyx_mstate->__pyx_n_u_b, __pyx_mstate->__pyx_n_u_c, __pyx_mstate->__pyx_n_u_d, __pyx_mstate->__pyx_n_u_t1, __pyx_mstate->__pyx_n_u_t1_2};
  7824. __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_cu2qu_cu2qu_py, __pyx_mstate->__pyx_n_u_split_cubic_into_n_gen, __pyx_mstate->__pyx_kp_b_iso88591__3, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad;
  7825. }
  7826. {
  7827. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 468};
  7828. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_curve, __pyx_mstate->__pyx_n_u_max_err, __pyx_mstate->__pyx_n_u_all_quadratic, __pyx_mstate->__pyx_n_u_n, __pyx_mstate->__pyx_n_u_spline, __pyx_mstate->__pyx_n_u_p, __pyx_mstate->__pyx_n_u_s};
  7829. __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_cu2qu_cu2qu_py, __pyx_mstate->__pyx_n_u_curve_to_quadratic, __pyx_mstate->__pyx_kp_b_iso88591_AWBc_U_U_3fBa_AWCy_7_2QgQgT_a_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad;
  7830. }
  7831. {
  7832. const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 503};
  7833. PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_curves, __pyx_mstate->__pyx_n_u_max_errors, __pyx_mstate->__pyx_n_u_all_quadratic, __pyx_mstate->__pyx_n_u_l, __pyx_mstate->__pyx_n_u_last_i, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_splines, __pyx_mstate->__pyx_n_u_n, __pyx_mstate->__pyx_n_u_spline, __pyx_mstate->__pyx_n_u_curve, __pyx_mstate->__pyx_n_u_p, __pyx_mstate->__pyx_n_u_spline, __pyx_mstate->__pyx_n_u_s};
  7834. __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_Lib_fontTools_cu2qu_cu2qu_py, __pyx_mstate->__pyx_n_u_curves_to_quadratic, __pyx_mstate->__pyx_kp_b_iso88591_J_Qawb_4uG4y_3a_3c_1A_avRq_T_AV, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad;
  7835. }
  7836. Py_DECREF(tuple_dedup_map);
  7837. return 0;
  7838. bad:
  7839. Py_DECREF(tuple_dedup_map);
  7840. return -1;
  7841. }
  7842. /* #### Code section: init_globals ### */
  7843. static int __Pyx_InitGlobals(void) {
  7844. /* PythonCompatibility.init */
  7845. if (likely(__Pyx_init_co_variables() == 0)); else
  7846. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7847. /* AssertionsEnabled.init */
  7848. if (likely(__Pyx_init_assertions_enabled() == 0)); else
  7849. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7850. /* CommonTypesMetaclass.init */
  7851. if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else
  7852. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7853. /* CachedMethodType.init */
  7854. #if CYTHON_COMPILING_IN_LIMITED_API
  7855. {
  7856. PyObject *typesModule=NULL;
  7857. typesModule = PyImport_ImportModule("types");
  7858. if (typesModule) {
  7859. __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType");
  7860. Py_DECREF(typesModule);
  7861. }
  7862. } // error handling follows
  7863. #endif
  7864. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7865. /* CythonFunctionShared.init */
  7866. if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else
  7867. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7868. /* Generator.init */
  7869. if (likely(__pyx_Generator_init(__pyx_m) == 0)); else
  7870. if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)
  7871. return 0;
  7872. __pyx_L1_error:;
  7873. return -1;
  7874. }
  7875. /* #### Code section: cleanup_globals ### */
  7876. /* #### Code section: cleanup_module ### */
  7877. /* #### Code section: main_method ### */
  7878. /* #### Code section: utility_code_pragmas ### */
  7879. #ifdef _MSC_VER
  7880. #pragma warning( push )
  7881. /* Warning 4127: conditional expression is constant
  7882. * Cython uses constant conditional expressions to allow in inline functions to be optimized at
  7883. * compile-time, so this warning is not useful
  7884. */
  7885. #pragma warning( disable : 4127 )
  7886. #endif
  7887. /* #### Code section: utility_code_def ### */
  7888. /* --- Runtime support code --- */
  7889. /* Refnanny */
  7890. #if CYTHON_REFNANNY
  7891. static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
  7892. PyObject *m = NULL, *p = NULL;
  7893. void *r = NULL;
  7894. m = PyImport_ImportModule(modname);
  7895. if (!m) goto end;
  7896. p = PyObject_GetAttrString(m, "RefNannyAPI");
  7897. if (!p) goto end;
  7898. r = PyLong_AsVoidPtr(p);
  7899. end:
  7900. Py_XDECREF(p);
  7901. Py_XDECREF(m);
  7902. return (__Pyx_RefNannyAPIStruct *)r;
  7903. }
  7904. #endif
  7905. /* PyObjectCall (used by PyObjectFastCall) */
  7906. #if CYTHON_COMPILING_IN_CPYTHON
  7907. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  7908. PyObject *result;
  7909. ternaryfunc call = Py_TYPE(func)->tp_call;
  7910. if (unlikely(!call))
  7911. return PyObject_Call(func, arg, kw);
  7912. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  7913. return NULL;
  7914. result = (*call)(func, arg, kw);
  7915. Py_LeaveRecursiveCall();
  7916. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  7917. PyErr_SetString(
  7918. PyExc_SystemError,
  7919. "NULL result without error in PyObject_Call");
  7920. }
  7921. return result;
  7922. }
  7923. #endif
  7924. /* PyObjectCallMethO (used by PyObjectFastCall) */
  7925. #if CYTHON_COMPILING_IN_CPYTHON
  7926. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
  7927. PyObject *self, *result;
  7928. PyCFunction cfunc;
  7929. cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func);
  7930. self = __Pyx_CyOrPyCFunction_GET_SELF(func);
  7931. if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
  7932. return NULL;
  7933. result = cfunc(self, arg);
  7934. Py_LeaveRecursiveCall();
  7935. if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
  7936. PyErr_SetString(
  7937. PyExc_SystemError,
  7938. "NULL result without error in PyObject_Call");
  7939. }
  7940. return result;
  7941. }
  7942. #endif
  7943. /* PyObjectFastCall */
  7944. #if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
  7945. static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) {
  7946. PyObject *argstuple;
  7947. PyObject *result = 0;
  7948. size_t i;
  7949. argstuple = PyTuple_New((Py_ssize_t)nargs);
  7950. if (unlikely(!argstuple)) return NULL;
  7951. for (i = 0; i < nargs; i++) {
  7952. Py_INCREF(args[i]);
  7953. if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad;
  7954. }
  7955. result = __Pyx_PyObject_Call(func, argstuple, kwargs);
  7956. bad:
  7957. Py_DECREF(argstuple);
  7958. return result;
  7959. }
  7960. #endif
  7961. #if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API
  7962. #if PY_VERSION_HEX < 0x03090000
  7963. #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable)
  7964. #elif CYTHON_COMPILING_IN_CPYTHON
  7965. static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) {
  7966. PyTypeObject *tp = Py_TYPE(callable);
  7967. #if defined(__Pyx_CyFunction_USED)
  7968. if (__Pyx_CyFunction_CheckExact(callable)) {
  7969. return __Pyx_CyFunction_func_vectorcall(callable);
  7970. }
  7971. #endif
  7972. if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) {
  7973. return NULL;
  7974. }
  7975. assert(PyCallable_Check(callable));
  7976. Py_ssize_t offset = tp->tp_vectorcall_offset;
  7977. assert(offset > 0);
  7978. vectorcallfunc ptr;
  7979. memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
  7980. return ptr;
  7981. }
  7982. #else
  7983. #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable)
  7984. #endif
  7985. #endif
  7986. static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) {
  7987. Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
  7988. #if CYTHON_COMPILING_IN_CPYTHON
  7989. if (nargs == 0 && kwargs == NULL) {
  7990. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
  7991. return __Pyx_PyObject_CallMethO(func, NULL);
  7992. }
  7993. else if (nargs == 1 && kwargs == NULL) {
  7994. if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O))
  7995. return __Pyx_PyObject_CallMethO(func, args[0]);
  7996. }
  7997. #endif
  7998. if (kwargs == NULL) {
  7999. #if CYTHON_VECTORCALL
  8000. #if CYTHON_COMPILING_IN_LIMITED_API
  8001. return PyObject_Vectorcall(func, args, _nargs, NULL);
  8002. #else
  8003. vectorcallfunc f = __Pyx_PyVectorcall_Function(func);
  8004. if (f) {
  8005. return f(func, args, _nargs, NULL);
  8006. }
  8007. #endif
  8008. #endif
  8009. }
  8010. if (nargs == 0) {
  8011. return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs);
  8012. }
  8013. #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
  8014. return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
  8015. #else
  8016. return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
  8017. #endif
  8018. }
  8019. /* PyLongCompare */
  8020. static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) {
  8021. CYTHON_MAYBE_UNUSED_VAR(intval);
  8022. CYTHON_UNUSED_VAR(inplace);
  8023. if (op1 == op2) {
  8024. return 1;
  8025. }
  8026. #if CYTHON_USE_PYLONG_INTERNALS
  8027. if (likely(PyLong_CheckExact(op1))) {
  8028. int unequal;
  8029. unsigned long uintval;
  8030. Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
  8031. const digit* digits = __Pyx_PyLong_Digits(op1);
  8032. if (intval == 0) {
  8033. return (__Pyx_PyLong_IsZero(op1) == 1);
  8034. } else if (intval < 0) {
  8035. if (__Pyx_PyLong_IsNonNeg(op1))
  8036. return 0;
  8037. intval = -intval;
  8038. } else {
  8039. if (__Pyx_PyLong_IsNeg(op1))
  8040. return 0;
  8041. }
  8042. uintval = (unsigned long) intval;
  8043. #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
  8044. if (uintval >> (PyLong_SHIFT * 4)) {
  8045. unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8046. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  8047. } else
  8048. #endif
  8049. #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
  8050. if (uintval >> (PyLong_SHIFT * 3)) {
  8051. unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8052. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  8053. } else
  8054. #endif
  8055. #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
  8056. if (uintval >> (PyLong_SHIFT * 2)) {
  8057. unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8058. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  8059. } else
  8060. #endif
  8061. #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
  8062. if (uintval >> (PyLong_SHIFT * 1)) {
  8063. unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
  8064. | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
  8065. } else
  8066. #endif
  8067. unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
  8068. return (unequal == 0);
  8069. }
  8070. #endif
  8071. if (PyFloat_CheckExact(op1)) {
  8072. const long b = intval;
  8073. double a = __Pyx_PyFloat_AS_DOUBLE(op1);
  8074. return ((double)a == (double)b);
  8075. }
  8076. return __Pyx_PyObject_IsTrueAndDecref(
  8077. PyObject_RichCompare(op1, op2, Py_EQ));
  8078. }
  8079. /* RaiseTooManyValuesToUnpack */
  8080. static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
  8081. PyErr_Format(PyExc_ValueError,
  8082. "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  8083. }
  8084. /* RaiseNeedMoreValuesToUnpack */
  8085. static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
  8086. PyErr_Format(PyExc_ValueError,
  8087. "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
  8088. index, (index == 1) ? "" : "s");
  8089. }
  8090. /* PyErrFetchRestore (used by IterFinish) */
  8091. #if CYTHON_FAST_THREAD_STATE
  8092. static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  8093. #if PY_VERSION_HEX >= 0x030C00A6
  8094. PyObject *tmp_value;
  8095. assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
  8096. if (value) {
  8097. #if CYTHON_COMPILING_IN_CPYTHON
  8098. if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
  8099. #endif
  8100. PyException_SetTraceback(value, tb);
  8101. }
  8102. tmp_value = tstate->current_exception;
  8103. tstate->current_exception = value;
  8104. Py_XDECREF(tmp_value);
  8105. Py_XDECREF(type);
  8106. Py_XDECREF(tb);
  8107. #else
  8108. PyObject *tmp_type, *tmp_value, *tmp_tb;
  8109. tmp_type = tstate->curexc_type;
  8110. tmp_value = tstate->curexc_value;
  8111. tmp_tb = tstate->curexc_traceback;
  8112. tstate->curexc_type = type;
  8113. tstate->curexc_value = value;
  8114. tstate->curexc_traceback = tb;
  8115. Py_XDECREF(tmp_type);
  8116. Py_XDECREF(tmp_value);
  8117. Py_XDECREF(tmp_tb);
  8118. #endif
  8119. }
  8120. static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  8121. #if PY_VERSION_HEX >= 0x030C00A6
  8122. PyObject* exc_value;
  8123. exc_value = tstate->current_exception;
  8124. tstate->current_exception = 0;
  8125. *value = exc_value;
  8126. *type = NULL;
  8127. *tb = NULL;
  8128. if (exc_value) {
  8129. *type = (PyObject*) Py_TYPE(exc_value);
  8130. Py_INCREF(*type);
  8131. #if CYTHON_COMPILING_IN_CPYTHON
  8132. *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
  8133. Py_XINCREF(*tb);
  8134. #else
  8135. *tb = PyException_GetTraceback(exc_value);
  8136. #endif
  8137. }
  8138. #else
  8139. *type = tstate->curexc_type;
  8140. *value = tstate->curexc_value;
  8141. *tb = tstate->curexc_traceback;
  8142. tstate->curexc_type = 0;
  8143. tstate->curexc_value = 0;
  8144. tstate->curexc_traceback = 0;
  8145. #endif
  8146. }
  8147. #endif
  8148. /* IterFinish */
  8149. static CYTHON_INLINE int __Pyx_IterFinish(void) {
  8150. PyObject* exc_type;
  8151. __Pyx_PyThreadState_declare
  8152. __Pyx_PyThreadState_assign
  8153. exc_type = __Pyx_PyErr_CurrentExceptionType();
  8154. if (unlikely(exc_type)) {
  8155. if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
  8156. return -1;
  8157. __Pyx_PyErr_Clear();
  8158. return 0;
  8159. }
  8160. return 0;
  8161. }
  8162. /* UnpackItemEndCheck */
  8163. static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
  8164. if (unlikely(retval)) {
  8165. Py_DECREF(retval);
  8166. __Pyx_RaiseTooManyValuesError(expected);
  8167. return -1;
  8168. }
  8169. return __Pyx_IterFinish();
  8170. }
  8171. /* GetItemInt */
  8172. static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
  8173. PyObject *r;
  8174. if (unlikely(!j)) return NULL;
  8175. r = PyObject_GetItem(o, j);
  8176. Py_DECREF(j);
  8177. return r;
  8178. }
  8179. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
  8180. int wraparound, int boundscheck, int unsafe_shared) {
  8181. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  8182. #if CYTHON_ASSUME_SAFE_SIZE
  8183. Py_ssize_t wrapped_i = i;
  8184. if (wraparound & unlikely(i < 0)) {
  8185. wrapped_i += PyList_GET_SIZE(o);
  8186. }
  8187. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS)) {
  8188. return __Pyx_PyList_GetItemRefFast(o, wrapped_i, unsafe_shared);
  8189. } else
  8190. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
  8191. return __Pyx_NewRef(PyList_GET_ITEM(o, wrapped_i));
  8192. }
  8193. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  8194. #else
  8195. (void)wraparound;
  8196. (void)boundscheck;
  8197. return PySequence_GetItem(o, i);
  8198. #endif
  8199. }
  8200. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
  8201. int wraparound, int boundscheck, int unsafe_shared) {
  8202. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  8203. #if CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  8204. Py_ssize_t wrapped_i = i;
  8205. if (wraparound & unlikely(i < 0)) {
  8206. wrapped_i += PyTuple_GET_SIZE(o);
  8207. }
  8208. if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
  8209. return __Pyx_NewRef(PyTuple_GET_ITEM(o, wrapped_i));
  8210. }
  8211. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  8212. #else
  8213. (void)wraparound;
  8214. (void)boundscheck;
  8215. return PySequence_GetItem(o, i);
  8216. #endif
  8217. }
  8218. static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
  8219. int wraparound, int boundscheck, int unsafe_shared) {
  8220. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  8221. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  8222. if (is_list || PyList_CheckExact(o)) {
  8223. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
  8224. if ((CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)) {
  8225. return __Pyx_PyList_GetItemRefFast(o, n, unsafe_shared);
  8226. } else if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
  8227. return __Pyx_NewRef(PyList_GET_ITEM(o, n));
  8228. }
  8229. } else
  8230. #if !CYTHON_AVOID_BORROWED_REFS
  8231. if (PyTuple_CheckExact(o)) {
  8232. Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
  8233. if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
  8234. return __Pyx_NewRef(PyTuple_GET_ITEM(o, n));
  8235. }
  8236. } else
  8237. #endif
  8238. #endif
  8239. #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
  8240. {
  8241. PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
  8242. PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
  8243. if (!is_list && mm && mm->mp_subscript) {
  8244. PyObject *r, *key = PyLong_FromSsize_t(i);
  8245. if (unlikely(!key)) return NULL;
  8246. r = mm->mp_subscript(o, key);
  8247. Py_DECREF(key);
  8248. return r;
  8249. }
  8250. if (is_list || likely(sm && sm->sq_item)) {
  8251. if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
  8252. Py_ssize_t l = sm->sq_length(o);
  8253. if (likely(l >= 0)) {
  8254. i += l;
  8255. } else {
  8256. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  8257. return NULL;
  8258. PyErr_Clear();
  8259. }
  8260. }
  8261. return sm->sq_item(o, i);
  8262. }
  8263. }
  8264. #else
  8265. if (is_list || !PyMapping_Check(o)) {
  8266. return PySequence_GetItem(o, i);
  8267. }
  8268. #endif
  8269. (void)wraparound;
  8270. (void)boundscheck;
  8271. return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  8272. }
  8273. /* PyErrExceptionMatches (used by PyObjectGetAttrStrNoError) */
  8274. #if CYTHON_FAST_THREAD_STATE
  8275. static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  8276. Py_ssize_t i, n;
  8277. n = PyTuple_GET_SIZE(tuple);
  8278. for (i=0; i<n; i++) {
  8279. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  8280. }
  8281. for (i=0; i<n; i++) {
  8282. if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
  8283. }
  8284. return 0;
  8285. }
  8286. static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
  8287. int result;
  8288. PyObject *exc_type;
  8289. #if PY_VERSION_HEX >= 0x030C00A6
  8290. PyObject *current_exception = tstate->current_exception;
  8291. if (unlikely(!current_exception)) return 0;
  8292. exc_type = (PyObject*) Py_TYPE(current_exception);
  8293. if (exc_type == err) return 1;
  8294. #else
  8295. exc_type = tstate->curexc_type;
  8296. if (exc_type == err) return 1;
  8297. if (unlikely(!exc_type)) return 0;
  8298. #endif
  8299. #if CYTHON_AVOID_BORROWED_REFS
  8300. Py_INCREF(exc_type);
  8301. #endif
  8302. if (unlikely(PyTuple_Check(err))) {
  8303. result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
  8304. } else {
  8305. result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
  8306. }
  8307. #if CYTHON_AVOID_BORROWED_REFS
  8308. Py_DECREF(exc_type);
  8309. #endif
  8310. return result;
  8311. }
  8312. #endif
  8313. /* PyObjectGetAttrStr (used by PyObjectGetAttrStrNoError) */
  8314. #if CYTHON_USE_TYPE_SLOTS
  8315. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
  8316. PyTypeObject* tp = Py_TYPE(obj);
  8317. if (likely(tp->tp_getattro))
  8318. return tp->tp_getattro(obj, attr_name);
  8319. return PyObject_GetAttr(obj, attr_name);
  8320. }
  8321. #endif
  8322. /* PyObjectGetAttrStrNoError (used by GetBuiltinName) */
  8323. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  8324. static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
  8325. __Pyx_PyThreadState_declare
  8326. __Pyx_PyThreadState_assign
  8327. if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
  8328. __Pyx_PyErr_Clear();
  8329. }
  8330. #endif
  8331. static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
  8332. PyObject *result;
  8333. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  8334. (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
  8335. return result;
  8336. #else
  8337. #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS
  8338. PyTypeObject* tp = Py_TYPE(obj);
  8339. if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
  8340. return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
  8341. }
  8342. #endif
  8343. result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
  8344. if (unlikely(!result)) {
  8345. __Pyx_PyObject_GetAttrStr_ClearAttributeError();
  8346. }
  8347. return result;
  8348. #endif
  8349. }
  8350. /* GetBuiltinName (used by GetModuleGlobalName) */
  8351. static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
  8352. PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name);
  8353. if (unlikely(!result) && !PyErr_Occurred()) {
  8354. PyErr_Format(PyExc_NameError,
  8355. "name '%U' is not defined", name);
  8356. }
  8357. return result;
  8358. }
  8359. /* PyDictVersioning (used by GetModuleGlobalName) */
  8360. #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
  8361. static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
  8362. PyObject *dict = Py_TYPE(obj)->tp_dict;
  8363. return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
  8364. }
  8365. static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
  8366. PyObject **dictptr = NULL;
  8367. Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
  8368. if (offset) {
  8369. #if CYTHON_COMPILING_IN_CPYTHON
  8370. dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
  8371. #else
  8372. dictptr = _PyObject_GetDictPtr(obj);
  8373. #endif
  8374. }
  8375. return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
  8376. }
  8377. static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
  8378. PyObject *dict = Py_TYPE(obj)->tp_dict;
  8379. if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
  8380. return 0;
  8381. return obj_dict_version == __Pyx_get_object_dict_version(obj);
  8382. }
  8383. #endif
  8384. /* GetModuleGlobalName */
  8385. #if CYTHON_USE_DICT_VERSIONS
  8386. static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
  8387. #else
  8388. static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
  8389. #endif
  8390. {
  8391. PyObject *result;
  8392. #if CYTHON_COMPILING_IN_LIMITED_API
  8393. if (unlikely(!__pyx_m)) {
  8394. if (!PyErr_Occurred())
  8395. PyErr_SetNone(PyExc_NameError);
  8396. return NULL;
  8397. }
  8398. result = PyObject_GetAttr(__pyx_m, name);
  8399. if (likely(result)) {
  8400. return result;
  8401. }
  8402. PyErr_Clear();
  8403. #elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  8404. if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear();
  8405. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  8406. if (likely(result)) {
  8407. return result;
  8408. }
  8409. #else
  8410. result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash);
  8411. __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
  8412. if (likely(result)) {
  8413. return __Pyx_NewRef(result);
  8414. }
  8415. PyErr_Clear();
  8416. #endif
  8417. return __Pyx_GetBuiltinName(name);
  8418. }
  8419. /* TupleAndListFromArray (used by fastcall) */
  8420. #if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL
  8421. static CYTHON_INLINE PyObject *
  8422. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  8423. {
  8424. PyObject *res;
  8425. Py_ssize_t i;
  8426. if (n <= 0) {
  8427. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  8428. }
  8429. res = PyTuple_New(n);
  8430. if (unlikely(res == NULL)) return NULL;
  8431. for (i = 0; i < n; i++) {
  8432. if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) {
  8433. Py_DECREF(res);
  8434. return NULL;
  8435. }
  8436. Py_INCREF(src[i]);
  8437. }
  8438. return res;
  8439. }
  8440. #elif CYTHON_COMPILING_IN_CPYTHON
  8441. static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
  8442. PyObject *v;
  8443. Py_ssize_t i;
  8444. for (i = 0; i < length; i++) {
  8445. v = dest[i] = src[i];
  8446. Py_INCREF(v);
  8447. }
  8448. }
  8449. static CYTHON_INLINE PyObject *
  8450. __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
  8451. {
  8452. PyObject *res;
  8453. if (n <= 0) {
  8454. return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
  8455. }
  8456. res = PyTuple_New(n);
  8457. if (unlikely(res == NULL)) return NULL;
  8458. __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
  8459. return res;
  8460. }
  8461. static CYTHON_INLINE PyObject *
  8462. __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
  8463. {
  8464. PyObject *res;
  8465. if (n <= 0) {
  8466. return PyList_New(0);
  8467. }
  8468. res = PyList_New(n);
  8469. if (unlikely(res == NULL)) return NULL;
  8470. __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
  8471. return res;
  8472. }
  8473. #endif
  8474. /* BytesEquals (used by UnicodeEquals) */
  8475. static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
  8476. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\
  8477. !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS)
  8478. return PyObject_RichCompareBool(s1, s2, equals);
  8479. #else
  8480. if (s1 == s2) {
  8481. return (equals == Py_EQ);
  8482. } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
  8483. const char *ps1, *ps2;
  8484. Py_ssize_t length = PyBytes_GET_SIZE(s1);
  8485. if (length != PyBytes_GET_SIZE(s2))
  8486. return (equals == Py_NE);
  8487. ps1 = PyBytes_AS_STRING(s1);
  8488. ps2 = PyBytes_AS_STRING(s2);
  8489. if (ps1[0] != ps2[0]) {
  8490. return (equals == Py_NE);
  8491. } else if (length == 1) {
  8492. return (equals == Py_EQ);
  8493. } else {
  8494. int result;
  8495. #if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
  8496. Py_hash_t hash1, hash2;
  8497. hash1 = ((PyBytesObject*)s1)->ob_shash;
  8498. hash2 = ((PyBytesObject*)s2)->ob_shash;
  8499. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  8500. return (equals == Py_NE);
  8501. }
  8502. #endif
  8503. result = memcmp(ps1, ps2, (size_t)length);
  8504. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  8505. }
  8506. } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
  8507. return (equals == Py_NE);
  8508. } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
  8509. return (equals == Py_NE);
  8510. } else {
  8511. int result;
  8512. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  8513. if (!py_result)
  8514. return -1;
  8515. result = __Pyx_PyObject_IsTrue(py_result);
  8516. Py_DECREF(py_result);
  8517. return result;
  8518. }
  8519. #endif
  8520. }
  8521. /* UnicodeEquals (used by fastcall) */
  8522. static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
  8523. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  8524. return PyObject_RichCompareBool(s1, s2, equals);
  8525. #else
  8526. int s1_is_unicode, s2_is_unicode;
  8527. if (s1 == s2) {
  8528. goto return_eq;
  8529. }
  8530. s1_is_unicode = PyUnicode_CheckExact(s1);
  8531. s2_is_unicode = PyUnicode_CheckExact(s2);
  8532. if (s1_is_unicode & s2_is_unicode) {
  8533. Py_ssize_t length, length2;
  8534. int kind;
  8535. void *data1, *data2;
  8536. #if !CYTHON_COMPILING_IN_LIMITED_API
  8537. if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
  8538. return -1;
  8539. #endif
  8540. length = __Pyx_PyUnicode_GET_LENGTH(s1);
  8541. #if !CYTHON_ASSUME_SAFE_SIZE
  8542. if (unlikely(length < 0)) return -1;
  8543. #endif
  8544. length2 = __Pyx_PyUnicode_GET_LENGTH(s2);
  8545. #if !CYTHON_ASSUME_SAFE_SIZE
  8546. if (unlikely(length2 < 0)) return -1;
  8547. #endif
  8548. if (length != length2) {
  8549. goto return_ne;
  8550. }
  8551. #if CYTHON_USE_UNICODE_INTERNALS
  8552. {
  8553. Py_hash_t hash1, hash2;
  8554. hash1 = ((PyASCIIObject*)s1)->hash;
  8555. hash2 = ((PyASCIIObject*)s2)->hash;
  8556. if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
  8557. goto return_ne;
  8558. }
  8559. }
  8560. #endif
  8561. kind = __Pyx_PyUnicode_KIND(s1);
  8562. if (kind != __Pyx_PyUnicode_KIND(s2)) {
  8563. goto return_ne;
  8564. }
  8565. data1 = __Pyx_PyUnicode_DATA(s1);
  8566. data2 = __Pyx_PyUnicode_DATA(s2);
  8567. if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
  8568. goto return_ne;
  8569. } else if (length == 1) {
  8570. goto return_eq;
  8571. } else {
  8572. int result = memcmp(data1, data2, (size_t)(length * kind));
  8573. return (equals == Py_EQ) ? (result == 0) : (result != 0);
  8574. }
  8575. } else if ((s1 == Py_None) & s2_is_unicode) {
  8576. goto return_ne;
  8577. } else if ((s2 == Py_None) & s1_is_unicode) {
  8578. goto return_ne;
  8579. } else {
  8580. int result;
  8581. PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
  8582. if (!py_result)
  8583. return -1;
  8584. result = __Pyx_PyObject_IsTrue(py_result);
  8585. Py_DECREF(py_result);
  8586. return result;
  8587. }
  8588. return_eq:
  8589. return (equals == Py_EQ);
  8590. return_ne:
  8591. return (equals == Py_NE);
  8592. #endif
  8593. }
  8594. /* fastcall */
  8595. #if CYTHON_METH_FASTCALL
  8596. static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
  8597. {
  8598. Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames);
  8599. #if !CYTHON_ASSUME_SAFE_SIZE
  8600. if (unlikely(n == -1)) return NULL;
  8601. #endif
  8602. for (i = 0; i < n; i++)
  8603. {
  8604. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  8605. #if !CYTHON_ASSUME_SAFE_MACROS
  8606. if (unlikely(!namei)) return NULL;
  8607. #endif
  8608. if (s == namei) return kwvalues[i];
  8609. }
  8610. for (i = 0; i < n; i++)
  8611. {
  8612. PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
  8613. #if !CYTHON_ASSUME_SAFE_MACROS
  8614. if (unlikely(!namei)) return NULL;
  8615. #endif
  8616. int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ);
  8617. if (unlikely(eq != 0)) {
  8618. if (unlikely(eq < 0)) return NULL;
  8619. return kwvalues[i];
  8620. }
  8621. }
  8622. return NULL;
  8623. }
  8624. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
  8625. CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
  8626. Py_ssize_t i, nkwargs;
  8627. PyObject *dict;
  8628. #if !CYTHON_ASSUME_SAFE_SIZE
  8629. nkwargs = PyTuple_Size(kwnames);
  8630. if (unlikely(nkwargs < 0)) return NULL;
  8631. #else
  8632. nkwargs = PyTuple_GET_SIZE(kwnames);
  8633. #endif
  8634. dict = PyDict_New();
  8635. if (unlikely(!dict))
  8636. return NULL;
  8637. for (i=0; i<nkwargs; i++) {
  8638. #if !CYTHON_ASSUME_SAFE_MACROS
  8639. PyObject *key = PyTuple_GetItem(kwnames, i);
  8640. if (!key) goto bad;
  8641. #else
  8642. PyObject *key = PyTuple_GET_ITEM(kwnames, i);
  8643. #endif
  8644. if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
  8645. goto bad;
  8646. }
  8647. return dict;
  8648. bad:
  8649. Py_DECREF(dict);
  8650. return NULL;
  8651. }
  8652. #endif
  8653. #endif
  8654. /* PyObjectCallOneArg (used by CallUnboundCMethod0) */
  8655. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
  8656. PyObject *args[2] = {NULL, arg};
  8657. return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  8658. }
  8659. /* UnpackUnboundCMethod (used by CallUnboundCMethod0) */
  8660. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  8661. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) {
  8662. PyObject *result;
  8663. PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
  8664. if (unlikely(!selfless_args)) return NULL;
  8665. result = PyObject_Call(method, selfless_args, kwargs);
  8666. Py_DECREF(selfless_args);
  8667. return result;
  8668. }
  8669. #elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000
  8670. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) {
  8671. return _PyObject_Vectorcall
  8672. (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames);
  8673. }
  8674. #else
  8675. static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) {
  8676. return
  8677. #if PY_VERSION_HEX < 0x03090000
  8678. _PyObject_Vectorcall
  8679. #else
  8680. PyObject_Vectorcall
  8681. #endif
  8682. (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames);
  8683. }
  8684. #endif
  8685. static PyMethodDef __Pyx_UnboundCMethod_Def = {
  8686. "CythonUnboundCMethod",
  8687. __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall),
  8688. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
  8689. METH_VARARGS | METH_KEYWORDS,
  8690. #else
  8691. METH_FASTCALL | METH_KEYWORDS,
  8692. #endif
  8693. NULL
  8694. };
  8695. static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
  8696. PyObject *method, *result=NULL;
  8697. method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
  8698. if (unlikely(!method))
  8699. return -1;
  8700. result = method;
  8701. #if CYTHON_COMPILING_IN_CPYTHON
  8702. if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
  8703. {
  8704. PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
  8705. target->func = descr->d_method->ml_meth;
  8706. target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
  8707. } else
  8708. #endif
  8709. #if CYTHON_COMPILING_IN_PYPY
  8710. #else
  8711. if (PyCFunction_Check(method))
  8712. #endif
  8713. {
  8714. PyObject *self;
  8715. int self_found;
  8716. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  8717. self = PyObject_GetAttrString(method, "__self__");
  8718. if (!self) {
  8719. PyErr_Clear();
  8720. }
  8721. #else
  8722. self = PyCFunction_GET_SELF(method);
  8723. #endif
  8724. self_found = (self && self != Py_None);
  8725. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  8726. Py_XDECREF(self);
  8727. #endif
  8728. if (self_found) {
  8729. PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method);
  8730. if (unlikely(!unbound_method)) return -1;
  8731. Py_DECREF(method);
  8732. result = unbound_method;
  8733. }
  8734. }
  8735. #if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8736. if (unlikely(target->method)) {
  8737. Py_DECREF(result);
  8738. } else
  8739. #endif
  8740. target->method = result;
  8741. return 0;
  8742. }
  8743. /* CallUnboundCMethod0 */
  8744. #if CYTHON_COMPILING_IN_CPYTHON
  8745. static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  8746. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  8747. if (likely(was_initialized == 2 && cfunc->func)) {
  8748. if (likely(cfunc->flag == METH_NOARGS))
  8749. return __Pyx_CallCFunction(cfunc, self, NULL);
  8750. if (likely(cfunc->flag == METH_FASTCALL))
  8751. return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0);
  8752. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  8753. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL);
  8754. if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS)))
  8755. return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  8756. if (cfunc->flag == METH_VARARGS)
  8757. return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple);
  8758. return __Pyx__CallUnboundCMethod0(cfunc, self);
  8759. }
  8760. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8761. else if (unlikely(was_initialized == 1)) {
  8762. __Pyx_CachedCFunction tmp_cfunc = {
  8763. #ifndef __cplusplus
  8764. 0
  8765. #endif
  8766. };
  8767. tmp_cfunc.type = cfunc->type;
  8768. tmp_cfunc.method_name = cfunc->method_name;
  8769. return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self);
  8770. }
  8771. #endif
  8772. PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self);
  8773. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  8774. return result;
  8775. }
  8776. #endif
  8777. static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
  8778. PyObject *result;
  8779. if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  8780. result = __Pyx_PyObject_CallOneArg(cfunc->method, self);
  8781. return result;
  8782. }
  8783. /* py_dict_items (used by OwnedDictNext) */
  8784. static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
  8785. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d);
  8786. }
  8787. /* py_dict_values (used by OwnedDictNext) */
  8788. static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
  8789. return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d);
  8790. }
  8791. /* OwnedDictNext (used by ParseKeywordsImpl) */
  8792. #if CYTHON_AVOID_BORROWED_REFS
  8793. static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) {
  8794. PyObject *next = NULL;
  8795. if (!*ppos) {
  8796. if (pvalue) {
  8797. PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p);
  8798. if (unlikely(!dictview)) goto bad;
  8799. *ppos = PyObject_GetIter(dictview);
  8800. Py_DECREF(dictview);
  8801. } else {
  8802. *ppos = PyObject_GetIter(p);
  8803. }
  8804. if (unlikely(!*ppos)) goto bad;
  8805. }
  8806. next = PyIter_Next(*ppos);
  8807. if (!next) {
  8808. if (PyErr_Occurred()) goto bad;
  8809. return 0;
  8810. }
  8811. if (pkey && pvalue) {
  8812. *pkey = __Pyx_PySequence_ITEM(next, 0);
  8813. if (unlikely(*pkey)) goto bad;
  8814. *pvalue = __Pyx_PySequence_ITEM(next, 1);
  8815. if (unlikely(*pvalue)) goto bad;
  8816. Py_DECREF(next);
  8817. } else if (pkey) {
  8818. *pkey = next;
  8819. } else {
  8820. assert(pvalue);
  8821. *pvalue = next;
  8822. }
  8823. return 1;
  8824. bad:
  8825. Py_XDECREF(next);
  8826. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  8827. PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef");
  8828. #else
  8829. PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef);
  8830. #endif
  8831. if (pkey) *pkey = NULL;
  8832. if (pvalue) *pvalue = NULL;
  8833. return 0;
  8834. }
  8835. #else // !CYTHON_AVOID_BORROWED_REFS
  8836. static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) {
  8837. int result = PyDict_Next(p, ppos, pkey, pvalue);
  8838. if (likely(result == 1)) {
  8839. if (pkey) Py_INCREF(*pkey);
  8840. if (pvalue) Py_INCREF(*pvalue);
  8841. }
  8842. return result;
  8843. }
  8844. #endif
  8845. /* RaiseDoubleKeywords (used by ParseKeywordsImpl) */
  8846. static void __Pyx_RaiseDoubleKeywordsError(
  8847. const char* func_name,
  8848. PyObject* kw_name)
  8849. {
  8850. PyErr_Format(PyExc_TypeError,
  8851. "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
  8852. }
  8853. /* CallUnboundCMethod2 */
  8854. #if CYTHON_COMPILING_IN_CPYTHON
  8855. static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
  8856. int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
  8857. if (likely(was_initialized == 2 && cfunc->func)) {
  8858. PyObject *args[2] = {arg1, arg2};
  8859. if (cfunc->flag == METH_FASTCALL) {
  8860. return __Pyx_CallCFunctionFast(cfunc, self, args, 2);
  8861. }
  8862. if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
  8863. return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL);
  8864. }
  8865. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  8866. else if (unlikely(was_initialized == 1)) {
  8867. __Pyx_CachedCFunction tmp_cfunc = {
  8868. #ifndef __cplusplus
  8869. 0
  8870. #endif
  8871. };
  8872. tmp_cfunc.type = cfunc->type;
  8873. tmp_cfunc.method_name = cfunc->method_name;
  8874. return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2);
  8875. }
  8876. #endif
  8877. PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
  8878. __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
  8879. return result;
  8880. }
  8881. #endif
  8882. static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
  8883. if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  8884. #if CYTHON_COMPILING_IN_CPYTHON
  8885. if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
  8886. PyObject *result = NULL;
  8887. PyObject *args = PyTuple_New(2);
  8888. if (unlikely(!args)) return NULL;
  8889. Py_INCREF(arg1);
  8890. PyTuple_SET_ITEM(args, 0, arg1);
  8891. Py_INCREF(arg2);
  8892. PyTuple_SET_ITEM(args, 1, arg2);
  8893. if (cfunc->flag & METH_KEYWORDS)
  8894. result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL);
  8895. else
  8896. result = __Pyx_CallCFunction(cfunc, self, args);
  8897. Py_DECREF(args);
  8898. return result;
  8899. }
  8900. #endif
  8901. {
  8902. PyObject *args[4] = {NULL, self, arg1, arg2};
  8903. return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  8904. }
  8905. }
  8906. /* ParseKeywordsImpl (used by ParseKeywords) */
  8907. static int __Pyx_ValidateDuplicatePosArgs(
  8908. PyObject *kwds,
  8909. PyObject ** const argnames[],
  8910. PyObject ** const *first_kw_arg,
  8911. const char* function_name)
  8912. {
  8913. PyObject ** const *name = argnames;
  8914. while (name != first_kw_arg) {
  8915. PyObject *key = **name;
  8916. int found = PyDict_Contains(kwds, key);
  8917. if (unlikely(found)) {
  8918. if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key);
  8919. goto bad;
  8920. }
  8921. name++;
  8922. }
  8923. return 0;
  8924. bad:
  8925. return -1;
  8926. }
  8927. #if CYTHON_USE_UNICODE_INTERNALS
  8928. static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) {
  8929. int kind;
  8930. Py_ssize_t len = PyUnicode_GET_LENGTH(s1);
  8931. if (len != PyUnicode_GET_LENGTH(s2)) return 0;
  8932. kind = PyUnicode_KIND(s1);
  8933. if (kind != PyUnicode_KIND(s2)) return 0;
  8934. const void *data1 = PyUnicode_DATA(s1);
  8935. const void *data2 = PyUnicode_DATA(s2);
  8936. return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0);
  8937. }
  8938. #endif
  8939. static int __Pyx_MatchKeywordArg_str(
  8940. PyObject *key,
  8941. PyObject ** const argnames[],
  8942. PyObject ** const *first_kw_arg,
  8943. size_t *index_found,
  8944. const char *function_name)
  8945. {
  8946. PyObject ** const *name;
  8947. #if CYTHON_USE_UNICODE_INTERNALS
  8948. Py_hash_t key_hash = ((PyASCIIObject*)key)->hash;
  8949. if (unlikely(key_hash == -1)) {
  8950. key_hash = PyObject_Hash(key);
  8951. if (unlikely(key_hash == -1))
  8952. goto bad;
  8953. }
  8954. #endif
  8955. name = first_kw_arg;
  8956. while (*name) {
  8957. PyObject *name_str = **name;
  8958. #if CYTHON_USE_UNICODE_INTERNALS
  8959. if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) {
  8960. *index_found = (size_t) (name - argnames);
  8961. return 1;
  8962. }
  8963. #else
  8964. #if CYTHON_ASSUME_SAFE_SIZE
  8965. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  8966. #endif
  8967. {
  8968. int cmp = PyUnicode_Compare(name_str, key);
  8969. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  8970. if (cmp == 0) {
  8971. *index_found = (size_t) (name - argnames);
  8972. return 1;
  8973. }
  8974. }
  8975. #endif
  8976. name++;
  8977. }
  8978. name = argnames;
  8979. while (name != first_kw_arg) {
  8980. PyObject *name_str = **name;
  8981. #if CYTHON_USE_UNICODE_INTERNALS
  8982. if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) {
  8983. if (__Pyx_UnicodeKeywordsEqual(name_str, key))
  8984. goto arg_passed_twice;
  8985. }
  8986. #else
  8987. #if CYTHON_ASSUME_SAFE_SIZE
  8988. if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
  8989. #endif
  8990. {
  8991. if (unlikely(name_str == key)) goto arg_passed_twice;
  8992. int cmp = PyUnicode_Compare(name_str, key);
  8993. if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
  8994. if (cmp == 0) goto arg_passed_twice;
  8995. }
  8996. #endif
  8997. name++;
  8998. }
  8999. return 0;
  9000. arg_passed_twice:
  9001. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9002. goto bad;
  9003. bad:
  9004. return -1;
  9005. }
  9006. static int __Pyx_MatchKeywordArg_nostr(
  9007. PyObject *key,
  9008. PyObject ** const argnames[],
  9009. PyObject ** const *first_kw_arg,
  9010. size_t *index_found,
  9011. const char *function_name)
  9012. {
  9013. PyObject ** const *name;
  9014. if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type;
  9015. name = first_kw_arg;
  9016. while (*name) {
  9017. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  9018. if (cmp == 1) {
  9019. *index_found = (size_t) (name - argnames);
  9020. return 1;
  9021. }
  9022. if (unlikely(cmp == -1)) goto bad;
  9023. name++;
  9024. }
  9025. name = argnames;
  9026. while (name != first_kw_arg) {
  9027. int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
  9028. if (unlikely(cmp != 0)) {
  9029. if (cmp == 1) goto arg_passed_twice;
  9030. else goto bad;
  9031. }
  9032. name++;
  9033. }
  9034. return 0;
  9035. arg_passed_twice:
  9036. __Pyx_RaiseDoubleKeywordsError(function_name, key);
  9037. goto bad;
  9038. invalid_keyword_type:
  9039. PyErr_Format(PyExc_TypeError,
  9040. "%.200s() keywords must be strings", function_name);
  9041. goto bad;
  9042. bad:
  9043. return -1;
  9044. }
  9045. static CYTHON_INLINE int __Pyx_MatchKeywordArg(
  9046. PyObject *key,
  9047. PyObject ** const argnames[],
  9048. PyObject ** const *first_kw_arg,
  9049. size_t *index_found,
  9050. const char *function_name)
  9051. {
  9052. return likely(PyUnicode_CheckExact(key)) ?
  9053. __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) :
  9054. __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name);
  9055. }
  9056. static void __Pyx_RejectUnknownKeyword(
  9057. PyObject *kwds,
  9058. PyObject ** const argnames[],
  9059. PyObject ** const *first_kw_arg,
  9060. const char *function_name)
  9061. {
  9062. #if CYTHON_AVOID_BORROWED_REFS
  9063. PyObject *pos = NULL;
  9064. #else
  9065. Py_ssize_t pos = 0;
  9066. #endif
  9067. PyObject *key = NULL;
  9068. __Pyx_BEGIN_CRITICAL_SECTION(kwds);
  9069. while (
  9070. #if CYTHON_AVOID_BORROWED_REFS
  9071. __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL)
  9072. #else
  9073. PyDict_Next(kwds, &pos, &key, NULL)
  9074. #endif
  9075. ) {
  9076. PyObject** const *name = first_kw_arg;
  9077. while (*name && (**name != key)) name++;
  9078. if (!*name) {
  9079. size_t index_found = 0;
  9080. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  9081. if (cmp != 1) {
  9082. if (cmp == 0) {
  9083. PyErr_Format(PyExc_TypeError,
  9084. "%s() got an unexpected keyword argument '%U'",
  9085. function_name, key);
  9086. }
  9087. #if CYTHON_AVOID_BORROWED_REFS
  9088. Py_DECREF(key);
  9089. #endif
  9090. break;
  9091. }
  9092. }
  9093. #if CYTHON_AVOID_BORROWED_REFS
  9094. Py_DECREF(key);
  9095. #endif
  9096. }
  9097. __Pyx_END_CRITICAL_SECTION();
  9098. #if CYTHON_AVOID_BORROWED_REFS
  9099. Py_XDECREF(pos);
  9100. #endif
  9101. assert(PyErr_Occurred());
  9102. }
  9103. static int __Pyx_ParseKeywordDict(
  9104. PyObject *kwds,
  9105. PyObject ** const argnames[],
  9106. PyObject *values[],
  9107. Py_ssize_t num_pos_args,
  9108. Py_ssize_t num_kwargs,
  9109. const char* function_name,
  9110. int ignore_unknown_kwargs)
  9111. {
  9112. PyObject** const *name;
  9113. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9114. Py_ssize_t extracted = 0;
  9115. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  9116. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  9117. #endif
  9118. name = first_kw_arg;
  9119. while (*name && num_kwargs > extracted) {
  9120. PyObject * key = **name;
  9121. PyObject *value;
  9122. int found = 0;
  9123. #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  9124. found = PyDict_GetItemRef(kwds, key, &value);
  9125. #else
  9126. value = PyDict_GetItemWithError(kwds, key);
  9127. if (value) {
  9128. Py_INCREF(value);
  9129. found = 1;
  9130. } else {
  9131. if (unlikely(PyErr_Occurred())) goto bad;
  9132. }
  9133. #endif
  9134. if (found) {
  9135. if (unlikely(found < 0)) goto bad;
  9136. values[name-argnames] = value;
  9137. extracted++;
  9138. }
  9139. name++;
  9140. }
  9141. if (num_kwargs > extracted) {
  9142. if (ignore_unknown_kwargs) {
  9143. if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1))
  9144. goto bad;
  9145. } else {
  9146. __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name);
  9147. goto bad;
  9148. }
  9149. }
  9150. return 0;
  9151. bad:
  9152. return -1;
  9153. }
  9154. static int __Pyx_ParseKeywordDictToDict(
  9155. PyObject *kwds,
  9156. PyObject ** const argnames[],
  9157. PyObject *kwds2,
  9158. PyObject *values[],
  9159. Py_ssize_t num_pos_args,
  9160. const char* function_name)
  9161. {
  9162. PyObject** const *name;
  9163. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9164. Py_ssize_t len;
  9165. #if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
  9166. if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
  9167. #endif
  9168. if (PyDict_Update(kwds2, kwds) < 0) goto bad;
  9169. name = first_kw_arg;
  9170. while (*name) {
  9171. PyObject *key = **name;
  9172. PyObject *value;
  9173. #if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop))
  9174. int found = PyDict_Pop(kwds2, key, &value);
  9175. if (found) {
  9176. if (unlikely(found < 0)) goto bad;
  9177. values[name-argnames] = value;
  9178. }
  9179. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  9180. int found = PyDict_GetItemRef(kwds2, key, &value);
  9181. if (found) {
  9182. if (unlikely(found < 0)) goto bad;
  9183. values[name-argnames] = value;
  9184. if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad;
  9185. }
  9186. #else
  9187. #if CYTHON_COMPILING_IN_CPYTHON
  9188. value = _PyDict_Pop(kwds2, key, kwds2);
  9189. #else
  9190. value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2);
  9191. #endif
  9192. if (value == kwds2) {
  9193. Py_DECREF(value);
  9194. } else {
  9195. if (unlikely(!value)) goto bad;
  9196. values[name-argnames] = value;
  9197. }
  9198. #endif
  9199. name++;
  9200. }
  9201. len = PyDict_Size(kwds2);
  9202. if (len > 0) {
  9203. return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name);
  9204. } else if (unlikely(len == -1)) {
  9205. goto bad;
  9206. }
  9207. return 0;
  9208. bad:
  9209. return -1;
  9210. }
  9211. static int __Pyx_ParseKeywordsTuple(
  9212. PyObject *kwds,
  9213. PyObject * const *kwvalues,
  9214. PyObject ** const argnames[],
  9215. PyObject *kwds2,
  9216. PyObject *values[],
  9217. Py_ssize_t num_pos_args,
  9218. Py_ssize_t num_kwargs,
  9219. const char* function_name,
  9220. int ignore_unknown_kwargs)
  9221. {
  9222. PyObject *key = NULL;
  9223. PyObject** const * name;
  9224. PyObject** const *first_kw_arg = argnames + num_pos_args;
  9225. for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
  9226. #if CYTHON_AVOID_BORROWED_REFS
  9227. key = __Pyx_PySequence_ITEM(kwds, pos);
  9228. #else
  9229. key = __Pyx_PyTuple_GET_ITEM(kwds, pos);
  9230. #endif
  9231. #if !CYTHON_ASSUME_SAFE_MACROS
  9232. if (unlikely(!key)) goto bad;
  9233. #endif
  9234. name = first_kw_arg;
  9235. while (*name && (**name != key)) name++;
  9236. if (*name) {
  9237. PyObject *value = kwvalues[pos];
  9238. values[name-argnames] = __Pyx_NewRef(value);
  9239. } else {
  9240. size_t index_found = 0;
  9241. int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
  9242. if (cmp == 1) {
  9243. PyObject *value = kwvalues[pos];
  9244. values[index_found] = __Pyx_NewRef(value);
  9245. } else {
  9246. if (unlikely(cmp == -1)) goto bad;
  9247. if (kwds2) {
  9248. PyObject *value = kwvalues[pos];
  9249. if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
  9250. } else if (!ignore_unknown_kwargs) {
  9251. goto invalid_keyword;
  9252. }
  9253. }
  9254. }
  9255. #if CYTHON_AVOID_BORROWED_REFS
  9256. Py_DECREF(key);
  9257. key = NULL;
  9258. #endif
  9259. }
  9260. return 0;
  9261. invalid_keyword:
  9262. PyErr_Format(PyExc_TypeError,
  9263. "%s() got an unexpected keyword argument '%U'",
  9264. function_name, key);
  9265. goto bad;
  9266. bad:
  9267. #if CYTHON_AVOID_BORROWED_REFS
  9268. Py_XDECREF(key);
  9269. #endif
  9270. return -1;
  9271. }
  9272. /* ParseKeywords */
  9273. static int __Pyx_ParseKeywords(
  9274. PyObject *kwds,
  9275. PyObject * const *kwvalues,
  9276. PyObject ** const argnames[],
  9277. PyObject *kwds2,
  9278. PyObject *values[],
  9279. Py_ssize_t num_pos_args,
  9280. Py_ssize_t num_kwargs,
  9281. const char* function_name,
  9282. int ignore_unknown_kwargs)
  9283. {
  9284. if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)))
  9285. return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  9286. else if (kwds2)
  9287. return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name);
  9288. else
  9289. return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
  9290. }
  9291. /* RaiseArgTupleInvalid */
  9292. static void __Pyx_RaiseArgtupleInvalid(
  9293. const char* func_name,
  9294. int exact,
  9295. Py_ssize_t num_min,
  9296. Py_ssize_t num_max,
  9297. Py_ssize_t num_found)
  9298. {
  9299. Py_ssize_t num_expected;
  9300. const char *more_or_less;
  9301. if (num_found < num_min) {
  9302. num_expected = num_min;
  9303. more_or_less = "at least";
  9304. } else {
  9305. num_expected = num_max;
  9306. more_or_less = "at most";
  9307. }
  9308. if (exact) {
  9309. more_or_less = "exactly";
  9310. }
  9311. PyErr_Format(PyExc_TypeError,
  9312. "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  9313. func_name, more_or_less, num_expected,
  9314. (num_expected == 1) ? "" : "s", num_found);
  9315. }
  9316. /* GetException (used by pep479) */
  9317. #if CYTHON_FAST_THREAD_STATE
  9318. static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
  9319. #else
  9320. static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
  9321. #endif
  9322. {
  9323. PyObject *local_type = NULL, *local_value, *local_tb = NULL;
  9324. #if CYTHON_FAST_THREAD_STATE
  9325. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9326. #if PY_VERSION_HEX >= 0x030C0000
  9327. local_value = tstate->current_exception;
  9328. tstate->current_exception = 0;
  9329. #else
  9330. local_type = tstate->curexc_type;
  9331. local_value = tstate->curexc_value;
  9332. local_tb = tstate->curexc_traceback;
  9333. tstate->curexc_type = 0;
  9334. tstate->curexc_value = 0;
  9335. tstate->curexc_traceback = 0;
  9336. #endif
  9337. #elif __PYX_LIMITED_VERSION_HEX > 0x030C0000
  9338. local_value = PyErr_GetRaisedException();
  9339. #else
  9340. PyErr_Fetch(&local_type, &local_value, &local_tb);
  9341. #endif
  9342. #if __PYX_LIMITED_VERSION_HEX > 0x030C0000
  9343. if (likely(local_value)) {
  9344. local_type = (PyObject*) Py_TYPE(local_value);
  9345. Py_INCREF(local_type);
  9346. local_tb = PyException_GetTraceback(local_value);
  9347. }
  9348. #else
  9349. PyErr_NormalizeException(&local_type, &local_value, &local_tb);
  9350. #if CYTHON_FAST_THREAD_STATE
  9351. if (unlikely(tstate->curexc_type))
  9352. #else
  9353. if (unlikely(PyErr_Occurred()))
  9354. #endif
  9355. goto bad;
  9356. if (local_tb) {
  9357. if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
  9358. goto bad;
  9359. }
  9360. #endif // __PYX_LIMITED_VERSION_HEX > 0x030C0000
  9361. Py_XINCREF(local_tb);
  9362. Py_XINCREF(local_type);
  9363. Py_XINCREF(local_value);
  9364. *type = local_type;
  9365. *value = local_value;
  9366. *tb = local_tb;
  9367. #if CYTHON_FAST_THREAD_STATE
  9368. #if CYTHON_USE_EXC_INFO_STACK
  9369. {
  9370. _PyErr_StackItem *exc_info = tstate->exc_info;
  9371. #if PY_VERSION_HEX >= 0x030B00a4
  9372. tmp_value = exc_info->exc_value;
  9373. exc_info->exc_value = local_value;
  9374. tmp_type = NULL;
  9375. tmp_tb = NULL;
  9376. Py_XDECREF(local_type);
  9377. Py_XDECREF(local_tb);
  9378. #else
  9379. tmp_type = exc_info->exc_type;
  9380. tmp_value = exc_info->exc_value;
  9381. tmp_tb = exc_info->exc_traceback;
  9382. exc_info->exc_type = local_type;
  9383. exc_info->exc_value = local_value;
  9384. exc_info->exc_traceback = local_tb;
  9385. #endif
  9386. }
  9387. #else
  9388. tmp_type = tstate->exc_type;
  9389. tmp_value = tstate->exc_value;
  9390. tmp_tb = tstate->exc_traceback;
  9391. tstate->exc_type = local_type;
  9392. tstate->exc_value = local_value;
  9393. tstate->exc_traceback = local_tb;
  9394. #endif
  9395. Py_XDECREF(tmp_type);
  9396. Py_XDECREF(tmp_value);
  9397. Py_XDECREF(tmp_tb);
  9398. #elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  9399. PyErr_SetHandledException(local_value);
  9400. Py_XDECREF(local_value);
  9401. Py_XDECREF(local_type);
  9402. Py_XDECREF(local_tb);
  9403. #else
  9404. PyErr_SetExcInfo(local_type, local_value, local_tb);
  9405. #endif
  9406. return 0;
  9407. #if __PYX_LIMITED_VERSION_HEX <= 0x030C0000
  9408. bad:
  9409. *type = 0;
  9410. *value = 0;
  9411. *tb = 0;
  9412. Py_XDECREF(local_type);
  9413. Py_XDECREF(local_value);
  9414. Py_XDECREF(local_tb);
  9415. return -1;
  9416. #endif
  9417. }
  9418. /* pep479 */
  9419. static void __Pyx_Generator_Replace_StopIteration(int in_async_gen) {
  9420. PyObject *exc, *val, *tb, *cur_exc, *new_exc;
  9421. __Pyx_PyThreadState_declare
  9422. int is_async_stopiteration = 0;
  9423. CYTHON_MAYBE_UNUSED_VAR(in_async_gen);
  9424. __Pyx_PyThreadState_assign
  9425. cur_exc = __Pyx_PyErr_CurrentExceptionType();
  9426. if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) {
  9427. if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopAsyncIteration))) {
  9428. is_async_stopiteration = 1;
  9429. } else {
  9430. return;
  9431. }
  9432. }
  9433. __Pyx_GetException(&exc, &val, &tb);
  9434. Py_XDECREF(exc);
  9435. Py_XDECREF(tb);
  9436. new_exc = PyObject_CallFunction(PyExc_RuntimeError, "s",
  9437. is_async_stopiteration ? "async generator raised StopAsyncIteration" :
  9438. in_async_gen ? "async generator raised StopIteration" :
  9439. "generator raised StopIteration");
  9440. if (!new_exc) {
  9441. Py_XDECREF(val);
  9442. return;
  9443. }
  9444. PyException_SetCause(new_exc, val); // steals ref to val
  9445. PyErr_SetObject(PyExc_RuntimeError, new_exc);
  9446. }
  9447. /* GetTopmostException (used by SaveResetException) */
  9448. #if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
  9449. static _PyErr_StackItem *
  9450. __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
  9451. {
  9452. _PyErr_StackItem *exc_info = tstate->exc_info;
  9453. while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
  9454. exc_info->previous_item != NULL)
  9455. {
  9456. exc_info = exc_info->previous_item;
  9457. }
  9458. return exc_info;
  9459. }
  9460. #endif
  9461. /* SaveResetException */
  9462. #if CYTHON_FAST_THREAD_STATE
  9463. static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  9464. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  9465. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  9466. PyObject *exc_value = exc_info->exc_value;
  9467. if (exc_value == NULL || exc_value == Py_None) {
  9468. *value = NULL;
  9469. *type = NULL;
  9470. *tb = NULL;
  9471. } else {
  9472. *value = exc_value;
  9473. Py_INCREF(*value);
  9474. *type = (PyObject*) Py_TYPE(exc_value);
  9475. Py_INCREF(*type);
  9476. *tb = PyException_GetTraceback(exc_value);
  9477. }
  9478. #elif CYTHON_USE_EXC_INFO_STACK
  9479. _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
  9480. *type = exc_info->exc_type;
  9481. *value = exc_info->exc_value;
  9482. *tb = exc_info->exc_traceback;
  9483. Py_XINCREF(*type);
  9484. Py_XINCREF(*value);
  9485. Py_XINCREF(*tb);
  9486. #else
  9487. *type = tstate->exc_type;
  9488. *value = tstate->exc_value;
  9489. *tb = tstate->exc_traceback;
  9490. Py_XINCREF(*type);
  9491. Py_XINCREF(*value);
  9492. Py_XINCREF(*tb);
  9493. #endif
  9494. }
  9495. static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  9496. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  9497. _PyErr_StackItem *exc_info = tstate->exc_info;
  9498. PyObject *tmp_value = exc_info->exc_value;
  9499. exc_info->exc_value = value;
  9500. Py_XDECREF(tmp_value);
  9501. Py_XDECREF(type);
  9502. Py_XDECREF(tb);
  9503. #else
  9504. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9505. #if CYTHON_USE_EXC_INFO_STACK
  9506. _PyErr_StackItem *exc_info = tstate->exc_info;
  9507. tmp_type = exc_info->exc_type;
  9508. tmp_value = exc_info->exc_value;
  9509. tmp_tb = exc_info->exc_traceback;
  9510. exc_info->exc_type = type;
  9511. exc_info->exc_value = value;
  9512. exc_info->exc_traceback = tb;
  9513. #else
  9514. tmp_type = tstate->exc_type;
  9515. tmp_value = tstate->exc_value;
  9516. tmp_tb = tstate->exc_traceback;
  9517. tstate->exc_type = type;
  9518. tstate->exc_value = value;
  9519. tstate->exc_traceback = tb;
  9520. #endif
  9521. Py_XDECREF(tmp_type);
  9522. Py_XDECREF(tmp_value);
  9523. Py_XDECREF(tmp_tb);
  9524. #endif
  9525. }
  9526. #endif
  9527. /* IterNextPlain (used by IterNext) */
  9528. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  9529. static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void) {
  9530. if (unlikely(!__pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache))
  9531. __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache = __Pyx_GetBuiltinName(__pyx_mstate_global->__pyx_n_u_next);
  9532. return __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache;
  9533. }
  9534. #endif
  9535. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator) {
  9536. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  9537. PyObject *result;
  9538. PyObject *next = __Pyx_GetBuiltinNext_LimitedAPI();
  9539. if (unlikely(!next)) return NULL;
  9540. result = PyObject_CallFunctionObjArgs(next, iterator, NULL);
  9541. return result;
  9542. #else
  9543. (void)__Pyx_GetBuiltinName; // only for early limited API
  9544. iternextfunc iternext = __Pyx_PyObject_GetIterNextFunc(iterator);
  9545. assert(iternext);
  9546. return iternext(iterator);
  9547. #endif
  9548. }
  9549. /* IterNext */
  9550. static PyObject *__Pyx_PyIter_Next2Default(PyObject* defval) {
  9551. PyObject* exc_type;
  9552. __Pyx_PyThreadState_declare
  9553. __Pyx_PyThreadState_assign
  9554. exc_type = __Pyx_PyErr_CurrentExceptionType();
  9555. if (unlikely(exc_type)) {
  9556. if (!defval || unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
  9557. return NULL;
  9558. __Pyx_PyErr_Clear();
  9559. Py_INCREF(defval);
  9560. return defval;
  9561. }
  9562. if (defval) {
  9563. Py_INCREF(defval);
  9564. return defval;
  9565. }
  9566. __Pyx_PyErr_SetNone(PyExc_StopIteration);
  9567. return NULL;
  9568. }
  9569. static void __Pyx_PyIter_Next_ErrorNoIterator(PyObject *iterator) {
  9570. __Pyx_TypeName iterator_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(iterator));
  9571. PyErr_Format(PyExc_TypeError,
  9572. __Pyx_FMT_TYPENAME " object is not an iterator", iterator_type_name);
  9573. __Pyx_DECREF_TypeName(iterator_type_name);
  9574. }
  9575. static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
  9576. PyObject* next;
  9577. #if !CYTHON_COMPILING_IN_LIMITED_API
  9578. iternextfunc iternext = __Pyx_PyObject_TryGetSlot(iterator, tp_iternext, iternextfunc);
  9579. if (likely(iternext)) {
  9580. next = iternext(iterator);
  9581. if (likely(next))
  9582. return next;
  9583. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
  9584. if (unlikely(iternext == &_PyObject_NextNotImplemented))
  9585. return NULL;
  9586. #endif
  9587. } else if (CYTHON_USE_TYPE_SLOTS) {
  9588. __Pyx_PyIter_Next_ErrorNoIterator(iterator);
  9589. return NULL;
  9590. } else
  9591. #endif
  9592. if (unlikely(!PyIter_Check(iterator))) {
  9593. __Pyx_PyIter_Next_ErrorNoIterator(iterator);
  9594. return NULL;
  9595. } else {
  9596. next = defval ? PyIter_Next(iterator) : __Pyx_PyIter_Next_Plain(iterator);
  9597. if (likely(next))
  9598. return next;
  9599. }
  9600. return __Pyx_PyIter_Next2Default(defval);
  9601. }
  9602. /* PyLongBinop */
  9603. #if !CYTHON_COMPILING_IN_PYPY
  9604. static PyObject* __Pyx_Fallback___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, int inplace) {
  9605. return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
  9606. }
  9607. #if CYTHON_USE_PYLONG_INTERNALS
  9608. static PyObject* __Pyx_Unpacked___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  9609. CYTHON_MAYBE_UNUSED_VAR(inplace);
  9610. CYTHON_UNUSED_VAR(zerodivision_check);
  9611. const long b = intval;
  9612. long a;
  9613. const PY_LONG_LONG llb = intval;
  9614. PY_LONG_LONG lla;
  9615. if (unlikely(__Pyx_PyLong_IsZero(op1))) {
  9616. return __Pyx_NewRef(op2);
  9617. }
  9618. const int is_positive = __Pyx_PyLong_IsPos(op1);
  9619. const digit* digits = __Pyx_PyLong_Digits(op1);
  9620. const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
  9621. if (likely(size == 1)) {
  9622. a = (long) digits[0];
  9623. if (!is_positive) a *= -1;
  9624. } else {
  9625. switch (size) {
  9626. case 2:
  9627. if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
  9628. a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  9629. if (!is_positive) a *= -1;
  9630. goto calculate_long;
  9631. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
  9632. lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
  9633. if (!is_positive) lla *= -1;
  9634. goto calculate_long_long;
  9635. }
  9636. break;
  9637. case 3:
  9638. if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
  9639. a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  9640. if (!is_positive) a *= -1;
  9641. goto calculate_long;
  9642. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
  9643. 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]));
  9644. if (!is_positive) lla *= -1;
  9645. goto calculate_long_long;
  9646. }
  9647. break;
  9648. case 4:
  9649. if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
  9650. a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
  9651. if (!is_positive) a *= -1;
  9652. goto calculate_long;
  9653. } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
  9654. 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]));
  9655. if (!is_positive) lla *= -1;
  9656. goto calculate_long_long;
  9657. }
  9658. break;
  9659. }
  9660. return PyLong_Type.tp_as_number->nb_add(op1, op2);
  9661. }
  9662. calculate_long:
  9663. {
  9664. long x;
  9665. x = a + b;
  9666. return PyLong_FromLong(x);
  9667. }
  9668. calculate_long_long:
  9669. {
  9670. PY_LONG_LONG llx;
  9671. llx = lla + llb;
  9672. return PyLong_FromLongLong(llx);
  9673. }
  9674. }
  9675. #endif
  9676. static PyObject* __Pyx_Float___Pyx_PyLong_AddObjC(PyObject *float_val, long intval, int zerodivision_check) {
  9677. CYTHON_UNUSED_VAR(zerodivision_check);
  9678. const long b = intval;
  9679. double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
  9680. double result;
  9681. result = ((double)a) + (double)b;
  9682. return PyFloat_FromDouble(result);
  9683. }
  9684. static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
  9685. CYTHON_MAYBE_UNUSED_VAR(intval);
  9686. CYTHON_UNUSED_VAR(zerodivision_check);
  9687. #if CYTHON_USE_PYLONG_INTERNALS
  9688. if (likely(PyLong_CheckExact(op1))) {
  9689. return __Pyx_Unpacked___Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check);
  9690. }
  9691. #endif
  9692. if (PyFloat_CheckExact(op1)) {
  9693. return __Pyx_Float___Pyx_PyLong_AddObjC(op1, intval, zerodivision_check);
  9694. }
  9695. return __Pyx_Fallback___Pyx_PyLong_AddObjC(op1, op2, inplace);
  9696. }
  9697. #endif
  9698. /* RaiseException */
  9699. static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
  9700. PyObject* owned_instance = NULL;
  9701. if (tb == Py_None) {
  9702. tb = 0;
  9703. } else if (tb && !PyTraceBack_Check(tb)) {
  9704. PyErr_SetString(PyExc_TypeError,
  9705. "raise: arg 3 must be a traceback or None");
  9706. goto bad;
  9707. }
  9708. if (value == Py_None)
  9709. value = 0;
  9710. if (PyExceptionInstance_Check(type)) {
  9711. if (value) {
  9712. PyErr_SetString(PyExc_TypeError,
  9713. "instance exception may not have a separate value");
  9714. goto bad;
  9715. }
  9716. value = type;
  9717. type = (PyObject*) Py_TYPE(value);
  9718. } else if (PyExceptionClass_Check(type)) {
  9719. PyObject *instance_class = NULL;
  9720. if (value && PyExceptionInstance_Check(value)) {
  9721. instance_class = (PyObject*) Py_TYPE(value);
  9722. if (instance_class != type) {
  9723. int is_subclass = PyObject_IsSubclass(instance_class, type);
  9724. if (!is_subclass) {
  9725. instance_class = NULL;
  9726. } else if (unlikely(is_subclass == -1)) {
  9727. goto bad;
  9728. } else {
  9729. type = instance_class;
  9730. }
  9731. }
  9732. }
  9733. if (!instance_class) {
  9734. PyObject *args;
  9735. if (!value)
  9736. args = PyTuple_New(0);
  9737. else if (PyTuple_Check(value)) {
  9738. Py_INCREF(value);
  9739. args = value;
  9740. } else
  9741. args = PyTuple_Pack(1, value);
  9742. if (!args)
  9743. goto bad;
  9744. owned_instance = PyObject_Call(type, args, NULL);
  9745. Py_DECREF(args);
  9746. if (!owned_instance)
  9747. goto bad;
  9748. value = owned_instance;
  9749. if (!PyExceptionInstance_Check(value)) {
  9750. PyErr_Format(PyExc_TypeError,
  9751. "calling %R should have returned an instance of "
  9752. "BaseException, not %R",
  9753. type, Py_TYPE(value));
  9754. goto bad;
  9755. }
  9756. }
  9757. } else {
  9758. PyErr_SetString(PyExc_TypeError,
  9759. "raise: exception class must be a subclass of BaseException");
  9760. goto bad;
  9761. }
  9762. if (cause) {
  9763. PyObject *fixed_cause;
  9764. if (cause == Py_None) {
  9765. fixed_cause = NULL;
  9766. } else if (PyExceptionClass_Check(cause)) {
  9767. fixed_cause = PyObject_CallObject(cause, NULL);
  9768. if (fixed_cause == NULL)
  9769. goto bad;
  9770. } else if (PyExceptionInstance_Check(cause)) {
  9771. fixed_cause = cause;
  9772. Py_INCREF(fixed_cause);
  9773. } else {
  9774. PyErr_SetString(PyExc_TypeError,
  9775. "exception causes must derive from "
  9776. "BaseException");
  9777. goto bad;
  9778. }
  9779. PyException_SetCause(value, fixed_cause);
  9780. }
  9781. PyErr_SetObject(type, value);
  9782. if (tb) {
  9783. #if PY_VERSION_HEX >= 0x030C00A6
  9784. PyException_SetTraceback(value, tb);
  9785. #elif CYTHON_FAST_THREAD_STATE
  9786. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  9787. PyObject* tmp_tb = tstate->curexc_traceback;
  9788. if (tb != tmp_tb) {
  9789. Py_INCREF(tb);
  9790. tstate->curexc_traceback = tb;
  9791. Py_XDECREF(tmp_tb);
  9792. }
  9793. #else
  9794. PyObject *tmp_type, *tmp_value, *tmp_tb;
  9795. PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
  9796. Py_INCREF(tb);
  9797. PyErr_Restore(tmp_type, tmp_value, tb);
  9798. Py_XDECREF(tmp_tb);
  9799. #endif
  9800. }
  9801. bad:
  9802. Py_XDECREF(owned_instance);
  9803. return;
  9804. }
  9805. /* SetItemInt */
  9806. static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
  9807. int r;
  9808. if (unlikely(!j)) return -1;
  9809. r = PyObject_SetItem(o, j, v);
  9810. Py_DECREF(j);
  9811. return r;
  9812. }
  9813. static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
  9814. int wraparound, int boundscheck, int unsafe_shared) {
  9815. CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  9816. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE && !CYTHON_AVOID_BORROWED_REFS
  9817. if (is_list || PyList_CheckExact(o)) {
  9818. Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
  9819. if ((CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS && !__Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared))) {
  9820. Py_INCREF(v);
  9821. return PyList_SetItem(o, n, v);
  9822. } else if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
  9823. PyObject* old;
  9824. Py_INCREF(v);
  9825. old = PyList_GET_ITEM(o, n);
  9826. PyList_SET_ITEM(o, n, v);
  9827. Py_DECREF(old);
  9828. return 0;
  9829. }
  9830. } else
  9831. #endif
  9832. #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
  9833. {
  9834. PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
  9835. PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
  9836. if (!is_list && mm && mm->mp_ass_subscript) {
  9837. int r;
  9838. PyObject *key = PyLong_FromSsize_t(i);
  9839. if (unlikely(!key)) return -1;
  9840. r = mm->mp_ass_subscript(o, key, v);
  9841. Py_DECREF(key);
  9842. return r;
  9843. }
  9844. if (is_list || likely(sm && sm->sq_ass_item)) {
  9845. if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
  9846. Py_ssize_t l = sm->sq_length(o);
  9847. if (likely(l >= 0)) {
  9848. i += l;
  9849. } else {
  9850. if (!PyErr_ExceptionMatches(PyExc_OverflowError))
  9851. return -1;
  9852. PyErr_Clear();
  9853. }
  9854. }
  9855. return sm->sq_ass_item(o, i, v);
  9856. }
  9857. }
  9858. #else
  9859. if (is_list || !PyMapping_Check(o)) {
  9860. return PySequence_SetItem(o, i, v);
  9861. }
  9862. #endif
  9863. (void)wraparound;
  9864. (void)boundscheck;
  9865. return __Pyx_SetItemInt_Generic(o, PyLong_FromSsize_t(i), v);
  9866. }
  9867. /* ModInt[long] */
  9868. static CYTHON_INLINE long __Pyx_mod_long(long a, long b, int b_is_constant) {
  9869. long r = a % b;
  9870. long adapt_python = (b_is_constant ?
  9871. ((r != 0) & ((r < 0) ^ (b < 0))) :
  9872. ((r != 0) & ((r ^ b) < 0))
  9873. );
  9874. return r + adapt_python * b;
  9875. }
  9876. /* AllocateExtensionType */
  9877. static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) {
  9878. if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) {
  9879. allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc);
  9880. return alloc_func(t, 0);
  9881. } else {
  9882. newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc);
  9883. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  9884. if (!tp_new) {
  9885. PyObject *new_str = PyUnicode_FromString("__new__");
  9886. if (likely(new_str)) {
  9887. PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL);
  9888. Py_DECREF(new_str);
  9889. return o;
  9890. } else
  9891. return NULL;
  9892. } else
  9893. #endif
  9894. return tp_new(t, __pyx_mstate_global->__pyx_empty_tuple, 0);
  9895. }
  9896. }
  9897. /* LimitedApiGetTypeDict (used by SetItemOnTypeDict) */
  9898. #if CYTHON_COMPILING_IN_LIMITED_API
  9899. static Py_ssize_t __Pyx_GetTypeDictOffset(void) {
  9900. PyObject *tp_dictoffset_o;
  9901. Py_ssize_t tp_dictoffset;
  9902. tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__");
  9903. if (unlikely(!tp_dictoffset_o)) return -1;
  9904. tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o);
  9905. Py_DECREF(tp_dictoffset_o);
  9906. if (unlikely(tp_dictoffset == 0)) {
  9907. PyErr_SetString(
  9908. PyExc_TypeError,
  9909. "'type' doesn't have a dictoffset");
  9910. return -1;
  9911. } else if (unlikely(tp_dictoffset < 0)) {
  9912. PyErr_SetString(
  9913. PyExc_TypeError,
  9914. "'type' has an unexpected negative dictoffset. "
  9915. "Please report this as Cython bug");
  9916. return -1;
  9917. }
  9918. return tp_dictoffset;
  9919. }
  9920. static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) {
  9921. static Py_ssize_t tp_dictoffset = 0;
  9922. if (unlikely(tp_dictoffset == 0)) {
  9923. tp_dictoffset = __Pyx_GetTypeDictOffset();
  9924. if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) {
  9925. tp_dictoffset = 0; // try again next time?
  9926. return NULL;
  9927. }
  9928. }
  9929. return *(PyObject**)((char*)tp + tp_dictoffset);
  9930. }
  9931. #endif
  9932. /* SetItemOnTypeDict (used by FixUpExtensionType) */
  9933. static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) {
  9934. int result;
  9935. PyObject *tp_dict;
  9936. #if CYTHON_COMPILING_IN_LIMITED_API
  9937. tp_dict = __Pyx_GetTypeDict(tp);
  9938. if (unlikely(!tp_dict)) return -1;
  9939. #else
  9940. tp_dict = tp->tp_dict;
  9941. #endif
  9942. result = PyDict_SetItem(tp_dict, k, v);
  9943. if (likely(!result)) {
  9944. PyType_Modified(tp);
  9945. if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) {
  9946. PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name, (PyObject *) tp, k, NULL);
  9947. if (!setNameResult) return -1;
  9948. Py_DECREF(setNameResult);
  9949. }
  9950. }
  9951. return result;
  9952. }
  9953. /* FixUpExtensionType */
  9954. static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) {
  9955. #if __PYX_LIMITED_VERSION_HEX > 0x030900B1
  9956. CYTHON_UNUSED_VAR(spec);
  9957. CYTHON_UNUSED_VAR(type);
  9958. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  9959. #else
  9960. const PyType_Slot *slot = spec->slots;
  9961. int changed = 0;
  9962. #if !CYTHON_COMPILING_IN_LIMITED_API
  9963. while (slot && slot->slot && slot->slot != Py_tp_members)
  9964. slot++;
  9965. if (slot && slot->slot == Py_tp_members) {
  9966. #if !CYTHON_COMPILING_IN_CPYTHON
  9967. const
  9968. #endif // !CYTHON_COMPILING_IN_CPYTHON)
  9969. PyMemberDef *memb = (PyMemberDef*) slot->pfunc;
  9970. while (memb && memb->name) {
  9971. if (memb->name[0] == '_' && memb->name[1] == '_') {
  9972. if (strcmp(memb->name, "__weaklistoffset__") == 0) {
  9973. assert(memb->type == T_PYSSIZET);
  9974. assert(memb->flags == READONLY);
  9975. type->tp_weaklistoffset = memb->offset;
  9976. changed = 1;
  9977. }
  9978. else if (strcmp(memb->name, "__dictoffset__") == 0) {
  9979. assert(memb->type == T_PYSSIZET);
  9980. assert(memb->flags == READONLY);
  9981. type->tp_dictoffset = memb->offset;
  9982. changed = 1;
  9983. }
  9984. #if CYTHON_METH_FASTCALL
  9985. else if (strcmp(memb->name, "__vectorcalloffset__") == 0) {
  9986. assert(memb->type == T_PYSSIZET);
  9987. assert(memb->flags == READONLY);
  9988. type->tp_vectorcall_offset = memb->offset;
  9989. changed = 1;
  9990. }
  9991. #endif // CYTHON_METH_FASTCALL
  9992. #if !CYTHON_COMPILING_IN_PYPY
  9993. else if (strcmp(memb->name, "__module__") == 0) {
  9994. PyObject *descr;
  9995. assert(memb->type == T_OBJECT);
  9996. assert(memb->flags == 0 || memb->flags == READONLY);
  9997. descr = PyDescr_NewMember(type, memb);
  9998. if (unlikely(!descr))
  9999. return -1;
  10000. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  10001. Py_DECREF(descr);
  10002. if (unlikely(set_item_result < 0)) {
  10003. return -1;
  10004. }
  10005. changed = 1;
  10006. }
  10007. #endif // !CYTHON_COMPILING_IN_PYPY
  10008. }
  10009. memb++;
  10010. }
  10011. }
  10012. #endif // !CYTHON_COMPILING_IN_LIMITED_API
  10013. #if !CYTHON_COMPILING_IN_PYPY
  10014. slot = spec->slots;
  10015. while (slot && slot->slot && slot->slot != Py_tp_getset)
  10016. slot++;
  10017. if (slot && slot->slot == Py_tp_getset) {
  10018. PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc;
  10019. while (getset && getset->name) {
  10020. if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) {
  10021. PyObject *descr = PyDescr_NewGetSet(type, getset);
  10022. if (unlikely(!descr))
  10023. return -1;
  10024. #if CYTHON_COMPILING_IN_LIMITED_API
  10025. PyObject *pyname = PyUnicode_FromString(getset->name);
  10026. if (unlikely(!pyname)) {
  10027. Py_DECREF(descr);
  10028. return -1;
  10029. }
  10030. int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr);
  10031. Py_DECREF(pyname);
  10032. #else
  10033. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  10034. int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
  10035. #endif
  10036. Py_DECREF(descr);
  10037. if (unlikely(set_item_result < 0)) {
  10038. return -1;
  10039. }
  10040. changed = 1;
  10041. }
  10042. ++getset;
  10043. }
  10044. }
  10045. #else
  10046. CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
  10047. #endif // !CYTHON_COMPILING_IN_PYPY
  10048. if (changed)
  10049. PyType_Modified(type);
  10050. #endif // PY_VERSION_HEX > 0x030900B1
  10051. return 0;
  10052. }
  10053. /* PyObjectCallNoArg (used by PyObjectCallMethod0) */
  10054. static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
  10055. PyObject *arg[2] = {NULL, NULL};
  10056. return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  10057. }
  10058. /* PyObjectGetMethod (used by PyObjectCallMethod0) */
  10059. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  10060. static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
  10061. PyObject *attr;
  10062. #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
  10063. __Pyx_TypeName type_name;
  10064. PyTypeObject *tp = Py_TYPE(obj);
  10065. PyObject *descr;
  10066. descrgetfunc f = NULL;
  10067. PyObject **dictptr, *dict;
  10068. int meth_found = 0;
  10069. assert (*method == NULL);
  10070. if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
  10071. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  10072. goto try_unpack;
  10073. }
  10074. if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
  10075. return 0;
  10076. }
  10077. descr = _PyType_Lookup(tp, name);
  10078. if (likely(descr != NULL)) {
  10079. Py_INCREF(descr);
  10080. #if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR
  10081. if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR))
  10082. #else
  10083. #ifdef __Pyx_CyFunction_USED
  10084. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
  10085. #else
  10086. if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type)))
  10087. #endif
  10088. #endif
  10089. {
  10090. meth_found = 1;
  10091. } else {
  10092. f = Py_TYPE(descr)->tp_descr_get;
  10093. if (f != NULL && PyDescr_IsData(descr)) {
  10094. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  10095. Py_DECREF(descr);
  10096. goto try_unpack;
  10097. }
  10098. }
  10099. }
  10100. dictptr = _PyObject_GetDictPtr(obj);
  10101. if (dictptr != NULL && (dict = *dictptr) != NULL) {
  10102. Py_INCREF(dict);
  10103. attr = __Pyx_PyDict_GetItemStr(dict, name);
  10104. if (attr != NULL) {
  10105. Py_INCREF(attr);
  10106. Py_DECREF(dict);
  10107. Py_XDECREF(descr);
  10108. goto try_unpack;
  10109. }
  10110. Py_DECREF(dict);
  10111. }
  10112. if (meth_found) {
  10113. *method = descr;
  10114. return 1;
  10115. }
  10116. if (f != NULL) {
  10117. attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
  10118. Py_DECREF(descr);
  10119. goto try_unpack;
  10120. }
  10121. if (likely(descr != NULL)) {
  10122. *method = descr;
  10123. return 0;
  10124. }
  10125. type_name = __Pyx_PyType_GetFullyQualifiedName(tp);
  10126. PyErr_Format(PyExc_AttributeError,
  10127. "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
  10128. type_name, name);
  10129. __Pyx_DECREF_TypeName(type_name);
  10130. return 0;
  10131. #else
  10132. attr = __Pyx_PyObject_GetAttrStr(obj, name);
  10133. goto try_unpack;
  10134. #endif
  10135. try_unpack:
  10136. #if CYTHON_UNPACK_METHODS
  10137. if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
  10138. PyObject *function = PyMethod_GET_FUNCTION(attr);
  10139. Py_INCREF(function);
  10140. Py_DECREF(attr);
  10141. *method = function;
  10142. return 1;
  10143. }
  10144. #endif
  10145. *method = attr;
  10146. return 0;
  10147. }
  10148. #endif
  10149. /* PyObjectCallMethod0 (used by PyType_Ready) */
  10150. static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
  10151. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  10152. PyObject *args[1] = {obj};
  10153. (void) __Pyx_PyObject_CallOneArg;
  10154. (void) __Pyx_PyObject_CallNoArg;
  10155. return PyObject_VectorcallMethod(method_name, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  10156. #else
  10157. PyObject *method = NULL, *result = NULL;
  10158. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  10159. if (likely(is_method)) {
  10160. result = __Pyx_PyObject_CallOneArg(method, obj);
  10161. Py_DECREF(method);
  10162. return result;
  10163. }
  10164. if (unlikely(!method)) goto bad;
  10165. result = __Pyx_PyObject_CallNoArg(method);
  10166. Py_DECREF(method);
  10167. bad:
  10168. return result;
  10169. #endif
  10170. }
  10171. /* ValidateBasesTuple (used by PyType_Ready) */
  10172. #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  10173. static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) {
  10174. Py_ssize_t i, n;
  10175. #if CYTHON_ASSUME_SAFE_SIZE
  10176. n = PyTuple_GET_SIZE(bases);
  10177. #else
  10178. n = PyTuple_Size(bases);
  10179. if (unlikely(n < 0)) return -1;
  10180. #endif
  10181. for (i = 1; i < n; i++)
  10182. {
  10183. PyTypeObject *b;
  10184. #if CYTHON_AVOID_BORROWED_REFS
  10185. PyObject *b0 = PySequence_GetItem(bases, i);
  10186. if (!b0) return -1;
  10187. #elif CYTHON_ASSUME_SAFE_MACROS
  10188. PyObject *b0 = PyTuple_GET_ITEM(bases, i);
  10189. #else
  10190. PyObject *b0 = PyTuple_GetItem(bases, i);
  10191. if (!b0) return -1;
  10192. #endif
  10193. b = (PyTypeObject*) b0;
  10194. if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
  10195. {
  10196. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  10197. PyErr_Format(PyExc_TypeError,
  10198. "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name);
  10199. __Pyx_DECREF_TypeName(b_name);
  10200. #if CYTHON_AVOID_BORROWED_REFS
  10201. Py_DECREF(b0);
  10202. #endif
  10203. return -1;
  10204. }
  10205. if (dictoffset == 0)
  10206. {
  10207. Py_ssize_t b_dictoffset = 0;
  10208. #if CYTHON_USE_TYPE_SLOTS
  10209. b_dictoffset = b->tp_dictoffset;
  10210. #else
  10211. PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__");
  10212. if (!py_b_dictoffset) goto dictoffset_return;
  10213. b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset);
  10214. Py_DECREF(py_b_dictoffset);
  10215. if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return;
  10216. #endif
  10217. if (b_dictoffset) {
  10218. {
  10219. __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
  10220. PyErr_Format(PyExc_TypeError,
  10221. "extension type '%.200s' has no __dict__ slot, "
  10222. "but base type '" __Pyx_FMT_TYPENAME "' has: "
  10223. "either add 'cdef dict __dict__' to the extension type "
  10224. "or add '__slots__ = [...]' to the base type",
  10225. type_name, b_name);
  10226. __Pyx_DECREF_TypeName(b_name);
  10227. }
  10228. #if !CYTHON_USE_TYPE_SLOTS
  10229. dictoffset_return:
  10230. #endif
  10231. #if CYTHON_AVOID_BORROWED_REFS
  10232. Py_DECREF(b0);
  10233. #endif
  10234. return -1;
  10235. }
  10236. }
  10237. #if CYTHON_AVOID_BORROWED_REFS
  10238. Py_DECREF(b0);
  10239. #endif
  10240. }
  10241. return 0;
  10242. }
  10243. #endif
  10244. /* PyType_Ready */
  10245. CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) {
  10246. while (t) {
  10247. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  10248. if (bases) {
  10249. return 1;
  10250. }
  10251. t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*);
  10252. }
  10253. return 0;
  10254. }
  10255. static int __Pyx_PyType_Ready(PyTypeObject *t) {
  10256. #if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION)
  10257. (void)__Pyx_PyObject_CallMethod0;
  10258. #if CYTHON_USE_TYPE_SPECS
  10259. (void)__Pyx_validate_bases_tuple;
  10260. #endif
  10261. return PyType_Ready(t);
  10262. #else
  10263. int r;
  10264. if (!__Pyx_PyType_HasMultipleInheritance(t)) {
  10265. return PyType_Ready(t);
  10266. }
  10267. PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
  10268. if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1))
  10269. return -1;
  10270. #if !defined(PYSTON_MAJOR_VERSION)
  10271. {
  10272. int gc_was_enabled;
  10273. #if PY_VERSION_HEX >= 0x030A00b1
  10274. gc_was_enabled = PyGC_Disable();
  10275. (void)__Pyx_PyObject_CallMethod0;
  10276. #else
  10277. PyObject *ret, *py_status;
  10278. PyObject *gc = NULL;
  10279. #if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) &&\
  10280. !CYTHON_COMPILING_IN_GRAAL
  10281. gc = PyImport_GetModule(__pyx_mstate_global->__pyx_kp_u_gc);
  10282. #endif
  10283. if (unlikely(!gc)) gc = PyImport_Import(__pyx_mstate_global->__pyx_kp_u_gc);
  10284. if (unlikely(!gc)) return -1;
  10285. py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_isenabled);
  10286. if (unlikely(!py_status)) {
  10287. Py_DECREF(gc);
  10288. return -1;
  10289. }
  10290. gc_was_enabled = __Pyx_PyObject_IsTrue(py_status);
  10291. Py_DECREF(py_status);
  10292. if (gc_was_enabled > 0) {
  10293. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_disable);
  10294. if (unlikely(!ret)) {
  10295. Py_DECREF(gc);
  10296. return -1;
  10297. }
  10298. Py_DECREF(ret);
  10299. } else if (unlikely(gc_was_enabled == -1)) {
  10300. Py_DECREF(gc);
  10301. return -1;
  10302. }
  10303. #endif
  10304. t->tp_flags |= Py_TPFLAGS_HEAPTYPE;
  10305. #if PY_VERSION_HEX >= 0x030A0000
  10306. t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
  10307. #endif
  10308. #else
  10309. (void)__Pyx_PyObject_CallMethod0;
  10310. #endif
  10311. r = PyType_Ready(t);
  10312. #if !defined(PYSTON_MAJOR_VERSION)
  10313. t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
  10314. #if PY_VERSION_HEX >= 0x030A00b1
  10315. if (gc_was_enabled)
  10316. PyGC_Enable();
  10317. #else
  10318. if (gc_was_enabled) {
  10319. PyObject *tp, *v, *tb;
  10320. PyErr_Fetch(&tp, &v, &tb);
  10321. ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_enable);
  10322. if (likely(ret || r == -1)) {
  10323. Py_XDECREF(ret);
  10324. PyErr_Restore(tp, v, tb);
  10325. } else {
  10326. Py_XDECREF(tp);
  10327. Py_XDECREF(v);
  10328. Py_XDECREF(tb);
  10329. r = -1;
  10330. }
  10331. }
  10332. Py_DECREF(gc);
  10333. #endif
  10334. }
  10335. #endif
  10336. return r;
  10337. #endif
  10338. }
  10339. /* HasAttr (used by ImportImpl) */
  10340. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  10341. static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
  10342. PyObject *r;
  10343. if (unlikely(!PyUnicode_Check(n))) {
  10344. PyErr_SetString(PyExc_TypeError,
  10345. "hasattr(): attribute name must be string");
  10346. return -1;
  10347. }
  10348. r = __Pyx_PyObject_GetAttrStrNoError(o, n);
  10349. if (!r) {
  10350. return (unlikely(PyErr_Occurred())) ? -1 : 0;
  10351. } else {
  10352. Py_DECREF(r);
  10353. return 1;
  10354. }
  10355. }
  10356. #endif
  10357. /* ImportImpl (used by Import) */
  10358. static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) {
  10359. PyObject *imported_module = PyImport_GetModule(qualname);
  10360. if (unlikely(!imported_module)) {
  10361. *module = NULL;
  10362. if (PyErr_Occurred()) {
  10363. return -1;
  10364. }
  10365. return 0;
  10366. }
  10367. *module = imported_module;
  10368. return 1;
  10369. }
  10370. static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) {
  10371. PyObject *imported_module;
  10372. PyObject *top_level_package_name;
  10373. Py_ssize_t i;
  10374. int status, module_found;
  10375. Py_ssize_t dot_index;
  10376. module_found = __Pyx__Import_GetModule(qualname, &imported_module);
  10377. if (unlikely(!module_found || module_found == -1)) {
  10378. *module = NULL;
  10379. return module_found;
  10380. }
  10381. if (imported_names) {
  10382. for (i = 0; i < len_imported_names; i++) {
  10383. PyObject *imported_name = imported_names[i];
  10384. #if __PYX_LIMITED_VERSION_HEX < 0x030d0000
  10385. int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name);
  10386. #else
  10387. int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name);
  10388. if (unlikely(has_imported_attribute == -1)) goto error;
  10389. #endif
  10390. if (!has_imported_attribute) {
  10391. goto not_found;
  10392. }
  10393. }
  10394. *module = imported_module;
  10395. return 1;
  10396. }
  10397. dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1);
  10398. if (dot_index == -1) {
  10399. *module = imported_module;
  10400. return 1;
  10401. }
  10402. if (unlikely(dot_index == -2)) goto error;
  10403. top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index);
  10404. if (unlikely(!top_level_package_name)) goto error;
  10405. Py_DECREF(imported_module);
  10406. status = __Pyx__Import_GetModule(top_level_package_name, module);
  10407. Py_DECREF(top_level_package_name);
  10408. return status;
  10409. error:
  10410. Py_DECREF(imported_module);
  10411. *module = NULL;
  10412. return -1;
  10413. not_found:
  10414. Py_DECREF(imported_module);
  10415. *module = NULL;
  10416. return 0;
  10417. }
  10418. static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level) {
  10419. PyObject *module = 0;
  10420. PyObject *empty_dict = 0;
  10421. PyObject *from_list = 0;
  10422. int module_found;
  10423. if (!qualname) {
  10424. qualname = name;
  10425. }
  10426. module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module);
  10427. if (likely(module_found == 1)) {
  10428. return module;
  10429. } else if (unlikely(module_found == -1)) {
  10430. return NULL;
  10431. }
  10432. empty_dict = PyDict_New();
  10433. if (unlikely(!empty_dict))
  10434. goto bad;
  10435. if (imported_names) {
  10436. #if CYTHON_COMPILING_IN_CPYTHON
  10437. from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names);
  10438. if (unlikely(!from_list))
  10439. goto bad;
  10440. #else
  10441. from_list = PyList_New(len_imported_names);
  10442. if (unlikely(!from_list)) goto bad;
  10443. for (Py_ssize_t i=0; i<len_imported_names; ++i) {
  10444. if (PyList_SetItem(from_list, i, __Pyx_NewRef(imported_names[i])) < 0) goto bad;
  10445. }
  10446. #endif
  10447. }
  10448. if (level == -1) {
  10449. const char* package_sep = strchr(__Pyx_MODULE_NAME, '.');
  10450. if (package_sep != (0)) {
  10451. module = PyImport_ImportModuleLevelObject(
  10452. name, moddict, empty_dict, from_list, 1);
  10453. if (unlikely(!module)) {
  10454. if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
  10455. goto bad;
  10456. PyErr_Clear();
  10457. }
  10458. }
  10459. level = 0;
  10460. }
  10461. if (!module) {
  10462. module = PyImport_ImportModuleLevelObject(
  10463. name, moddict, empty_dict, from_list, level);
  10464. }
  10465. bad:
  10466. Py_XDECREF(from_list);
  10467. Py_XDECREF(empty_dict);
  10468. return module;
  10469. }
  10470. /* Import */
  10471. static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) {
  10472. return __Pyx__Import(name, imported_names, len_imported_names, qualname, __pyx_mstate_global->__pyx_d, level);
  10473. }
  10474. /* ImportFrom */
  10475. static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
  10476. PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
  10477. if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
  10478. const char* module_name_str = 0;
  10479. PyObject* module_name = 0;
  10480. PyObject* module_dot = 0;
  10481. PyObject* full_name = 0;
  10482. PyErr_Clear();
  10483. module_name_str = PyModule_GetName(module);
  10484. if (unlikely(!module_name_str)) { goto modbad; }
  10485. module_name = PyUnicode_FromString(module_name_str);
  10486. if (unlikely(!module_name)) { goto modbad; }
  10487. module_dot = PyUnicode_Concat(module_name, __pyx_mstate_global->__pyx_kp_u_);
  10488. if (unlikely(!module_dot)) { goto modbad; }
  10489. full_name = PyUnicode_Concat(module_dot, name);
  10490. if (unlikely(!full_name)) { goto modbad; }
  10491. #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM < 0x07030400) ||\
  10492. CYTHON_COMPILING_IN_GRAAL
  10493. {
  10494. PyObject *modules = PyImport_GetModuleDict();
  10495. if (unlikely(!modules))
  10496. goto modbad;
  10497. value = PyObject_GetItem(modules, full_name);
  10498. }
  10499. #else
  10500. value = PyImport_GetModule(full_name);
  10501. #endif
  10502. modbad:
  10503. Py_XDECREF(full_name);
  10504. Py_XDECREF(module_dot);
  10505. Py_XDECREF(module_name);
  10506. }
  10507. if (unlikely(!value)) {
  10508. PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
  10509. }
  10510. return value;
  10511. }
  10512. /* ListPack */
  10513. static PyObject *__Pyx_PyList_Pack(Py_ssize_t n, ...) {
  10514. va_list va;
  10515. PyObject *l = PyList_New(n);
  10516. va_start(va, n);
  10517. if (unlikely(!l)) goto end;
  10518. for (Py_ssize_t i=0; i<n; ++i) {
  10519. PyObject *arg = va_arg(va, PyObject*);
  10520. Py_INCREF(arg);
  10521. if (__Pyx_PyList_SET_ITEM(l, i, arg) != (0)) {
  10522. Py_CLEAR(l);
  10523. goto end;
  10524. }
  10525. }
  10526. end:
  10527. va_end(va);
  10528. return l;
  10529. }
  10530. /* pybytes_as_double (used by pyunicode_as_double) */
  10531. static double __Pyx_SlowPyString_AsDouble(PyObject *obj) {
  10532. PyObject *float_value = PyFloat_FromString(obj);
  10533. if (likely(float_value)) {
  10534. double value = __Pyx_PyFloat_AS_DOUBLE(float_value);
  10535. Py_DECREF(float_value);
  10536. return value;
  10537. }
  10538. return (double)-1;
  10539. }
  10540. static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, Py_ssize_t length) {
  10541. int last_was_punctuation = 1;
  10542. int parse_error_found = 0;
  10543. Py_ssize_t i;
  10544. for (i=0; i < length; i++) {
  10545. char chr = start[i];
  10546. int is_punctuation = (chr == '_') | (chr == '.') | (chr == 'e') | (chr == 'E');
  10547. *buffer = chr;
  10548. buffer += (chr != '_');
  10549. parse_error_found |= last_was_punctuation & is_punctuation;
  10550. last_was_punctuation = is_punctuation;
  10551. }
  10552. parse_error_found |= last_was_punctuation;
  10553. *buffer = '\0';
  10554. return unlikely(parse_error_found) ? NULL : buffer;
  10555. }
  10556. static double __Pyx__PyBytes_AsDouble_inf_nan(const char* start, Py_ssize_t length) {
  10557. int matches = 1;
  10558. char sign = start[0];
  10559. int is_signed = (sign == '+') | (sign == '-');
  10560. start += is_signed;
  10561. length -= is_signed;
  10562. switch (start[0]) {
  10563. #ifdef Py_NAN
  10564. case 'n':
  10565. case 'N':
  10566. if (unlikely(length != 3)) goto parse_failure;
  10567. matches &= (start[1] == 'a' || start[1] == 'A');
  10568. matches &= (start[2] == 'n' || start[2] == 'N');
  10569. if (unlikely(!matches)) goto parse_failure;
  10570. return (sign == '-') ? -Py_NAN : Py_NAN;
  10571. #endif
  10572. case 'i':
  10573. case 'I':
  10574. if (unlikely(length < 3)) goto parse_failure;
  10575. matches &= (start[1] == 'n' || start[1] == 'N');
  10576. matches &= (start[2] == 'f' || start[2] == 'F');
  10577. if (likely(length == 3 && matches))
  10578. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  10579. if (unlikely(length != 8)) goto parse_failure;
  10580. matches &= (start[3] == 'i' || start[3] == 'I');
  10581. matches &= (start[4] == 'n' || start[4] == 'N');
  10582. matches &= (start[5] == 'i' || start[5] == 'I');
  10583. matches &= (start[6] == 't' || start[6] == 'T');
  10584. matches &= (start[7] == 'y' || start[7] == 'Y');
  10585. if (unlikely(!matches)) goto parse_failure;
  10586. return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
  10587. case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
  10588. break;
  10589. default:
  10590. goto parse_failure;
  10591. }
  10592. return 0.0;
  10593. parse_failure:
  10594. return -1.0;
  10595. }
  10596. static CYTHON_INLINE int __Pyx__PyBytes_AsDouble_IsSpace(char ch) {
  10597. return (ch == 0x20) | !((ch < 0x9) | (ch > 0xd));
  10598. }
  10599. CYTHON_UNUSED static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) {
  10600. double value;
  10601. Py_ssize_t i, digits;
  10602. const char *last = start + length;
  10603. char *end;
  10604. while (__Pyx__PyBytes_AsDouble_IsSpace(*start))
  10605. start++;
  10606. while (start < last - 1 && __Pyx__PyBytes_AsDouble_IsSpace(last[-1]))
  10607. last--;
  10608. length = last - start;
  10609. if (unlikely(length <= 0)) goto fallback;
  10610. value = __Pyx__PyBytes_AsDouble_inf_nan(start, length);
  10611. if (unlikely(value == -1.0)) goto fallback;
  10612. if (value != 0.0) return value;
  10613. digits = 0;
  10614. for (i=0; i < length; digits += start[i++] != '_');
  10615. if (likely(digits == length)) {
  10616. value = PyOS_string_to_double(start, &end, NULL);
  10617. } else if (digits < 40) {
  10618. char number[40];
  10619. last = __Pyx__PyBytes_AsDouble_Copy(start, number, length);
  10620. if (unlikely(!last)) goto fallback;
  10621. value = PyOS_string_to_double(number, &end, NULL);
  10622. } else {
  10623. char *number = (char*) PyMem_Malloc((digits + 1) * sizeof(char));
  10624. if (unlikely(!number)) goto fallback;
  10625. last = __Pyx__PyBytes_AsDouble_Copy(start, number, length);
  10626. if (unlikely(!last)) {
  10627. PyMem_Free(number);
  10628. goto fallback;
  10629. }
  10630. value = PyOS_string_to_double(number, &end, NULL);
  10631. PyMem_Free(number);
  10632. }
  10633. if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) {
  10634. return value;
  10635. }
  10636. fallback:
  10637. return __Pyx_SlowPyString_AsDouble(obj);
  10638. }
  10639. /* dict_setdefault (used by FetchCommonType) */
  10640. static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) {
  10641. PyObject* value;
  10642. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  10643. PyObject *args[] = {d, key, default_value};
  10644. value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  10645. #elif CYTHON_COMPILING_IN_LIMITED_API
  10646. value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL);
  10647. #elif PY_VERSION_HEX >= 0x030d0000
  10648. PyDict_SetDefaultRef(d, key, default_value, &value);
  10649. #else
  10650. value = PyDict_SetDefault(d, key, default_value);
  10651. if (unlikely(!value)) return NULL;
  10652. Py_INCREF(value);
  10653. #endif
  10654. return value;
  10655. }
  10656. /* AddModuleRef (used by FetchSharedCythonModule) */
  10657. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  10658. static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) {
  10659. PyObject *module_dict = PyImport_GetModuleDict();
  10660. PyObject *m;
  10661. if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) {
  10662. return NULL;
  10663. }
  10664. if (m != NULL && PyModule_Check(m)) {
  10665. return m;
  10666. }
  10667. Py_XDECREF(m);
  10668. m = PyModule_NewObject(name);
  10669. if (m == NULL)
  10670. return NULL;
  10671. if (PyDict_CheckExact(module_dict)) {
  10672. PyObject *new_m;
  10673. (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m);
  10674. Py_DECREF(m);
  10675. return new_m;
  10676. } else {
  10677. if (PyObject_SetItem(module_dict, name, m) != 0) {
  10678. Py_DECREF(m);
  10679. return NULL;
  10680. }
  10681. return m;
  10682. }
  10683. }
  10684. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  10685. PyObject *py_name = PyUnicode_FromString(name);
  10686. if (!py_name) return NULL;
  10687. PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name);
  10688. Py_DECREF(py_name);
  10689. return module;
  10690. }
  10691. #elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  10692. #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
  10693. #else
  10694. static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
  10695. PyObject *module = PyImport_AddModule(name);
  10696. Py_XINCREF(module);
  10697. return module;
  10698. }
  10699. #endif
  10700. /* FetchSharedCythonModule (used by FetchCommonType) */
  10701. static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
  10702. return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME);
  10703. }
  10704. /* FetchCommonType (used by CommonTypesMetaclass) */
  10705. #if __PYX_LIMITED_VERSION_HEX < 0x030C0000
  10706. static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  10707. PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases);
  10708. if (result && metaclass) {
  10709. PyObject *old_tp = (PyObject*)Py_TYPE(result);
  10710. Py_INCREF((PyObject*)metaclass);
  10711. #if __PYX_LIMITED_VERSION_HEX >= 0x03090000
  10712. Py_SET_TYPE(result, metaclass);
  10713. #else
  10714. result->ob_type = metaclass;
  10715. #endif
  10716. Py_DECREF(old_tp);
  10717. }
  10718. return result;
  10719. }
  10720. #else
  10721. #define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b)
  10722. #endif
  10723. static int __Pyx_VerifyCachedType(PyObject *cached_type,
  10724. const char *name,
  10725. Py_ssize_t expected_basicsize) {
  10726. Py_ssize_t basicsize;
  10727. if (!PyType_Check(cached_type)) {
  10728. PyErr_Format(PyExc_TypeError,
  10729. "Shared Cython type %.200s is not a type object", name);
  10730. return -1;
  10731. }
  10732. if (expected_basicsize == 0) {
  10733. return 0; // size is inherited, nothing useful to check
  10734. }
  10735. #if CYTHON_COMPILING_IN_LIMITED_API
  10736. PyObject *py_basicsize;
  10737. py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__");
  10738. if (unlikely(!py_basicsize)) return -1;
  10739. basicsize = PyLong_AsSsize_t(py_basicsize);
  10740. Py_DECREF(py_basicsize);
  10741. py_basicsize = NULL;
  10742. if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1;
  10743. #else
  10744. basicsize = ((PyTypeObject*) cached_type)->tp_basicsize;
  10745. #endif
  10746. if (basicsize != expected_basicsize) {
  10747. PyErr_Format(PyExc_TypeError,
  10748. "Shared Cython type %.200s has the wrong size, try recompiling",
  10749. name);
  10750. return -1;
  10751. }
  10752. return 0;
  10753. }
  10754. static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
  10755. PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name;
  10756. int get_item_ref_result;
  10757. const char* object_name = strrchr(spec->name, '.');
  10758. object_name = object_name ? object_name+1 : spec->name;
  10759. py_object_name = PyUnicode_FromString(object_name);
  10760. if (!py_object_name) return NULL;
  10761. abi_module = __Pyx_FetchSharedCythonABIModule();
  10762. if (!abi_module) goto done;
  10763. abi_module_dict = PyModule_GetDict(abi_module);
  10764. if (!abi_module_dict) goto done;
  10765. get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type);
  10766. if (get_item_ref_result == 1) {
  10767. if (__Pyx_VerifyCachedType(
  10768. cached_type,
  10769. object_name,
  10770. spec->basicsize) < 0) {
  10771. goto bad;
  10772. }
  10773. goto done;
  10774. } else if (unlikely(get_item_ref_result == -1)) {
  10775. goto bad;
  10776. }
  10777. cached_type = __Pyx_PyType_FromMetaclass(
  10778. metaclass,
  10779. CYTHON_USE_MODULE_STATE ? module : abi_module,
  10780. spec, bases);
  10781. if (unlikely(!cached_type)) goto bad;
  10782. if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad;
  10783. new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type);
  10784. if (unlikely(new_cached_type != cached_type)) {
  10785. if (unlikely(!new_cached_type)) goto bad;
  10786. Py_DECREF(cached_type);
  10787. cached_type = new_cached_type;
  10788. if (__Pyx_VerifyCachedType(
  10789. cached_type,
  10790. object_name,
  10791. spec->basicsize) < 0) {
  10792. goto bad;
  10793. }
  10794. goto done;
  10795. } else {
  10796. Py_DECREF(new_cached_type);
  10797. }
  10798. done:
  10799. Py_XDECREF(abi_module);
  10800. Py_DECREF(py_object_name);
  10801. assert(cached_type == NULL || PyType_Check(cached_type));
  10802. return (PyTypeObject *) cached_type;
  10803. bad:
  10804. Py_XDECREF(cached_type);
  10805. cached_type = NULL;
  10806. goto done;
  10807. }
  10808. /* CommonTypesMetaclass (used by CythonFunctionShared) */
  10809. static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) {
  10810. return PyUnicode_FromString(__PYX_ABI_MODULE_NAME);
  10811. }
  10812. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  10813. static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) {
  10814. PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types");
  10815. return NULL;
  10816. }
  10817. static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) {
  10818. PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable");
  10819. return -1;
  10820. }
  10821. #endif
  10822. static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = {
  10823. {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL},
  10824. {0, 0, 0, 0, 0}
  10825. };
  10826. static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = {
  10827. {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset},
  10828. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  10829. {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call},
  10830. {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call},
  10831. {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr},
  10832. #endif
  10833. {0, 0}
  10834. };
  10835. static PyType_Spec __pyx_CommonTypesMetaclass_spec = {
  10836. __PYX_TYPE_MODULE_PREFIX "_common_types_metatype",
  10837. 0,
  10838. 0,
  10839. Py_TPFLAGS_IMMUTABLETYPE |
  10840. Py_TPFLAGS_DISALLOW_INSTANTIATION |
  10841. Py_TPFLAGS_DEFAULT,
  10842. __pyx_CommonTypesMetaclass_slots
  10843. };
  10844. static int __pyx_CommonTypesMetaclass_init(PyObject *module) {
  10845. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  10846. PyObject *bases = PyTuple_Pack(1, &PyType_Type);
  10847. if (unlikely(!bases)) {
  10848. return -1;
  10849. }
  10850. mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases);
  10851. Py_DECREF(bases);
  10852. if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) {
  10853. return -1;
  10854. }
  10855. return 0;
  10856. }
  10857. /* CallTypeTraverse (used by CythonFunctionShared) */
  10858. #if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
  10859. #else
  10860. static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) {
  10861. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000
  10862. if (__Pyx_get_runtime_version() < 0x03090000) return 0;
  10863. #endif
  10864. if (!always_call) {
  10865. PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*);
  10866. unsigned long flags = PyType_GetFlags(base);
  10867. if (flags & Py_TPFLAGS_HEAPTYPE) {
  10868. return 0;
  10869. }
  10870. }
  10871. Py_VISIT((PyObject*)Py_TYPE(o));
  10872. return 0;
  10873. }
  10874. #endif
  10875. /* PyMethodNew (used by CythonFunctionShared) */
  10876. #if CYTHON_COMPILING_IN_LIMITED_API
  10877. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  10878. PyObject *result;
  10879. CYTHON_UNUSED_VAR(typ);
  10880. if (!self)
  10881. return __Pyx_NewRef(func);
  10882. #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
  10883. {
  10884. PyObject *args[] = {func, self};
  10885. result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL);
  10886. }
  10887. #else
  10888. result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL);
  10889. #endif
  10890. return result;
  10891. }
  10892. #else
  10893. static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
  10894. CYTHON_UNUSED_VAR(typ);
  10895. if (!self)
  10896. return __Pyx_NewRef(func);
  10897. return PyMethod_New(func, self);
  10898. }
  10899. #endif
  10900. /* PyVectorcallFastCallDict (used by CythonFunctionShared) */
  10901. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  10902. static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  10903. {
  10904. PyObject *res = NULL;
  10905. PyObject *kwnames;
  10906. PyObject **newargs;
  10907. PyObject **kwvalues;
  10908. Py_ssize_t i;
  10909. #if CYTHON_AVOID_BORROWED_REFS
  10910. PyObject *pos;
  10911. #else
  10912. Py_ssize_t pos;
  10913. #endif
  10914. size_t j;
  10915. PyObject *key, *value;
  10916. unsigned long keys_are_strings;
  10917. #if !CYTHON_ASSUME_SAFE_SIZE
  10918. Py_ssize_t nkw = PyDict_Size(kw);
  10919. if (unlikely(nkw == -1)) return NULL;
  10920. #else
  10921. Py_ssize_t nkw = PyDict_GET_SIZE(kw);
  10922. #endif
  10923. newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0]));
  10924. if (unlikely(newargs == NULL)) {
  10925. PyErr_NoMemory();
  10926. return NULL;
  10927. }
  10928. for (j = 0; j < nargs; j++) newargs[j] = args[j];
  10929. kwnames = PyTuple_New(nkw);
  10930. if (unlikely(kwnames == NULL)) {
  10931. PyMem_Free(newargs);
  10932. return NULL;
  10933. }
  10934. kwvalues = newargs + nargs;
  10935. pos = 0;
  10936. i = 0;
  10937. keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS;
  10938. while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) {
  10939. keys_are_strings &=
  10940. #if CYTHON_COMPILING_IN_LIMITED_API
  10941. PyType_GetFlags(Py_TYPE(key));
  10942. #else
  10943. Py_TYPE(key)->tp_flags;
  10944. #endif
  10945. #if !CYTHON_ASSUME_SAFE_MACROS
  10946. if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup;
  10947. #else
  10948. PyTuple_SET_ITEM(kwnames, i, key);
  10949. #endif
  10950. kwvalues[i] = value;
  10951. i++;
  10952. }
  10953. if (unlikely(!keys_are_strings)) {
  10954. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  10955. goto cleanup;
  10956. }
  10957. res = vc(func, newargs, nargs, kwnames);
  10958. cleanup:
  10959. #if CYTHON_AVOID_BORROWED_REFS
  10960. Py_DECREF(pos);
  10961. #endif
  10962. Py_DECREF(kwnames);
  10963. for (i = 0; i < nkw; i++)
  10964. Py_DECREF(kwvalues[i]);
  10965. PyMem_Free(newargs);
  10966. return res;
  10967. }
  10968. static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  10969. {
  10970. Py_ssize_t kw_size =
  10971. likely(kw == NULL) ?
  10972. 0 :
  10973. #if !CYTHON_ASSUME_SAFE_SIZE
  10974. PyDict_Size(kw);
  10975. #else
  10976. PyDict_GET_SIZE(kw);
  10977. #endif
  10978. if (kw_size == 0) {
  10979. return vc(func, args, nargs, NULL);
  10980. }
  10981. #if !CYTHON_ASSUME_SAFE_SIZE
  10982. else if (unlikely(kw_size == -1)) {
  10983. return NULL;
  10984. }
  10985. #endif
  10986. return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw);
  10987. }
  10988. #endif
  10989. /* CythonFunctionShared (used by CythonFunction) */
  10990. #if CYTHON_COMPILING_IN_LIMITED_API
  10991. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
  10992. if (__Pyx_CyFunction_Check(func)) {
  10993. return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
  10994. } else if (PyCFunction_Check(func)) {
  10995. return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
  10996. }
  10997. return 0;
  10998. }
  10999. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  11000. if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) {
  11001. int result;
  11002. PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func);
  11003. if (unlikely(!newFunc)) {
  11004. PyErr_Clear(); // It's only an optimization, so don't throw an error
  11005. return 0;
  11006. }
  11007. result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
  11008. Py_DECREF(newFunc);
  11009. return result;
  11010. }
  11011. return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
  11012. }
  11013. #else
  11014. static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
  11015. if (PyMethod_Check(func)) {
  11016. func = PyMethod_GET_FUNCTION(func);
  11017. }
  11018. return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  11019. }
  11020. #endif
  11021. static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
  11022. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  11023. __Pyx_Py_XDECREF_SET(
  11024. __Pyx_CyFunction_GetClassObj(f),
  11025. ((classobj) ? __Pyx_NewRef(classobj) : NULL));
  11026. #else
  11027. __Pyx_Py_XDECREF_SET(
  11028. ((PyCMethodObject *) (f))->mm_class,
  11029. (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
  11030. #endif
  11031. }
  11032. static PyObject *
  11033. __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
  11034. {
  11035. if (unlikely(op->func_doc == NULL)) {
  11036. #if CYTHON_COMPILING_IN_LIMITED_API
  11037. op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
  11038. if (unlikely(!op->func_doc)) return NULL;
  11039. #else
  11040. if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
  11041. op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
  11042. if (unlikely(op->func_doc == NULL))
  11043. return NULL;
  11044. } else {
  11045. Py_INCREF(Py_None);
  11046. return Py_None;
  11047. }
  11048. #endif
  11049. }
  11050. Py_INCREF(op->func_doc);
  11051. return op->func_doc;
  11052. }
  11053. static PyObject *
  11054. __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) {
  11055. PyObject *result;
  11056. CYTHON_UNUSED_VAR(closure);
  11057. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11058. result = __Pyx_CyFunction_get_doc_locked(op);
  11059. __Pyx_END_CRITICAL_SECTION();
  11060. return result;
  11061. }
  11062. static int
  11063. __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11064. {
  11065. CYTHON_UNUSED_VAR(context);
  11066. if (value == NULL) {
  11067. value = Py_None;
  11068. }
  11069. Py_INCREF(value);
  11070. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11071. __Pyx_Py_XDECREF_SET(op->func_doc, value);
  11072. __Pyx_END_CRITICAL_SECTION();
  11073. return 0;
  11074. }
  11075. static PyObject *
  11076. __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
  11077. {
  11078. if (unlikely(op->func_name == NULL)) {
  11079. #if CYTHON_COMPILING_IN_LIMITED_API
  11080. op->func_name = PyObject_GetAttrString(op->func, "__name__");
  11081. #else
  11082. op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
  11083. #endif
  11084. if (unlikely(op->func_name == NULL))
  11085. return NULL;
  11086. }
  11087. Py_INCREF(op->func_name);
  11088. return op->func_name;
  11089. }
  11090. static PyObject *
  11091. __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
  11092. {
  11093. PyObject *result = NULL;
  11094. CYTHON_UNUSED_VAR(context);
  11095. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11096. result = __Pyx_CyFunction_get_name_locked(op);
  11097. __Pyx_END_CRITICAL_SECTION();
  11098. return result;
  11099. }
  11100. static int
  11101. __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11102. {
  11103. CYTHON_UNUSED_VAR(context);
  11104. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11105. PyErr_SetString(PyExc_TypeError,
  11106. "__name__ must be set to a string object");
  11107. return -1;
  11108. }
  11109. Py_INCREF(value);
  11110. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11111. __Pyx_Py_XDECREF_SET(op->func_name, value);
  11112. __Pyx_END_CRITICAL_SECTION();
  11113. return 0;
  11114. }
  11115. static PyObject *
  11116. __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
  11117. {
  11118. CYTHON_UNUSED_VAR(context);
  11119. PyObject *result;
  11120. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11121. Py_INCREF(op->func_qualname);
  11122. result = op->func_qualname;
  11123. __Pyx_END_CRITICAL_SECTION();
  11124. return result;
  11125. }
  11126. static int
  11127. __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  11128. {
  11129. CYTHON_UNUSED_VAR(context);
  11130. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  11131. PyErr_SetString(PyExc_TypeError,
  11132. "__qualname__ must be set to a string object");
  11133. return -1;
  11134. }
  11135. Py_INCREF(value);
  11136. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11137. __Pyx_Py_XDECREF_SET(op->func_qualname, value);
  11138. __Pyx_END_CRITICAL_SECTION();
  11139. return 0;
  11140. }
  11141. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11142. static PyObject *
  11143. __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
  11144. {
  11145. CYTHON_UNUSED_VAR(context);
  11146. if (unlikely(op->func_dict == NULL)) {
  11147. op->func_dict = PyDict_New();
  11148. if (unlikely(op->func_dict == NULL))
  11149. return NULL;
  11150. }
  11151. Py_INCREF(op->func_dict);
  11152. return op->func_dict;
  11153. }
  11154. #endif
  11155. static PyObject *
  11156. __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
  11157. {
  11158. CYTHON_UNUSED_VAR(context);
  11159. Py_INCREF(op->func_globals);
  11160. return op->func_globals;
  11161. }
  11162. static PyObject *
  11163. __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
  11164. {
  11165. CYTHON_UNUSED_VAR(op);
  11166. CYTHON_UNUSED_VAR(context);
  11167. Py_INCREF(Py_None);
  11168. return Py_None;
  11169. }
  11170. static PyObject *
  11171. __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
  11172. {
  11173. PyObject* result = (op->func_code) ? op->func_code : Py_None;
  11174. CYTHON_UNUSED_VAR(context);
  11175. Py_INCREF(result);
  11176. return result;
  11177. }
  11178. static int
  11179. __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
  11180. int result = 0;
  11181. PyObject *res = op->defaults_getter((PyObject *) op);
  11182. if (unlikely(!res))
  11183. return -1;
  11184. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11185. op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
  11186. Py_INCREF(op->defaults_tuple);
  11187. op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
  11188. Py_INCREF(op->defaults_kwdict);
  11189. #else
  11190. op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
  11191. if (unlikely(!op->defaults_tuple)) result = -1;
  11192. else {
  11193. op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
  11194. if (unlikely(!op->defaults_kwdict)) result = -1;
  11195. }
  11196. #endif
  11197. Py_DECREF(res);
  11198. return result;
  11199. }
  11200. static int
  11201. __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11202. CYTHON_UNUSED_VAR(context);
  11203. if (!value) {
  11204. value = Py_None;
  11205. } else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
  11206. PyErr_SetString(PyExc_TypeError,
  11207. "__defaults__ must be set to a tuple object");
  11208. return -1;
  11209. }
  11210. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
  11211. "currently affect the values used in function calls", 1);
  11212. Py_INCREF(value);
  11213. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11214. __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
  11215. __Pyx_END_CRITICAL_SECTION();
  11216. return 0;
  11217. }
  11218. static PyObject *
  11219. __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
  11220. PyObject* result = op->defaults_tuple;
  11221. if (unlikely(!result)) {
  11222. if (op->defaults_getter) {
  11223. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  11224. result = op->defaults_tuple;
  11225. } else {
  11226. result = Py_None;
  11227. }
  11228. }
  11229. Py_INCREF(result);
  11230. return result;
  11231. }
  11232. static PyObject *
  11233. __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
  11234. PyObject* result = NULL;
  11235. CYTHON_UNUSED_VAR(context);
  11236. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11237. result = __Pyx_CyFunction_get_defaults_locked(op);
  11238. __Pyx_END_CRITICAL_SECTION();
  11239. return result;
  11240. }
  11241. static int
  11242. __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11243. CYTHON_UNUSED_VAR(context);
  11244. if (!value) {
  11245. value = Py_None;
  11246. } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
  11247. PyErr_SetString(PyExc_TypeError,
  11248. "__kwdefaults__ must be set to a dict object");
  11249. return -1;
  11250. }
  11251. PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
  11252. "currently affect the values used in function calls", 1);
  11253. Py_INCREF(value);
  11254. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11255. __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
  11256. __Pyx_END_CRITICAL_SECTION();
  11257. return 0;
  11258. }
  11259. static PyObject *
  11260. __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
  11261. PyObject* result = op->defaults_kwdict;
  11262. if (unlikely(!result)) {
  11263. if (op->defaults_getter) {
  11264. if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
  11265. result = op->defaults_kwdict;
  11266. } else {
  11267. result = Py_None;
  11268. }
  11269. }
  11270. Py_INCREF(result);
  11271. return result;
  11272. }
  11273. static PyObject *
  11274. __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
  11275. PyObject* result;
  11276. CYTHON_UNUSED_VAR(context);
  11277. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11278. result = __Pyx_CyFunction_get_kwdefaults_locked(op);
  11279. __Pyx_END_CRITICAL_SECTION();
  11280. return result;
  11281. }
  11282. static int
  11283. __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11284. CYTHON_UNUSED_VAR(context);
  11285. if (!value || value == Py_None) {
  11286. value = NULL;
  11287. } else if (unlikely(!PyDict_Check(value))) {
  11288. PyErr_SetString(PyExc_TypeError,
  11289. "__annotations__ must be set to a dict object");
  11290. return -1;
  11291. }
  11292. Py_XINCREF(value);
  11293. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11294. __Pyx_Py_XDECREF_SET(op->func_annotations, value);
  11295. __Pyx_END_CRITICAL_SECTION();
  11296. return 0;
  11297. }
  11298. static PyObject *
  11299. __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
  11300. PyObject* result = op->func_annotations;
  11301. if (unlikely(!result)) {
  11302. result = PyDict_New();
  11303. if (unlikely(!result)) return NULL;
  11304. op->func_annotations = result;
  11305. }
  11306. Py_INCREF(result);
  11307. return result;
  11308. }
  11309. static PyObject *
  11310. __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, void *context) {
  11311. PyObject *result;
  11312. CYTHON_UNUSED_VAR(context);
  11313. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11314. result = __Pyx_CyFunction_get_annotations_locked(op);
  11315. __Pyx_END_CRITICAL_SECTION();
  11316. return result;
  11317. }
  11318. static PyObject *
  11319. __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
  11320. int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
  11321. if (is_coroutine) {
  11322. PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine;
  11323. fromlist = PyList_New(1);
  11324. if (unlikely(!fromlist)) return NULL;
  11325. Py_INCREF(marker);
  11326. #if CYTHON_ASSUME_SAFE_MACROS
  11327. PyList_SET_ITEM(fromlist, 0, marker);
  11328. #else
  11329. if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
  11330. Py_DECREF(marker);
  11331. Py_DECREF(fromlist);
  11332. return NULL;
  11333. }
  11334. #endif
  11335. module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0);
  11336. Py_DECREF(fromlist);
  11337. if (unlikely(!module)) goto ignore;
  11338. is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
  11339. Py_DECREF(module);
  11340. if (likely(is_coroutine_value)) {
  11341. return is_coroutine_value;
  11342. }
  11343. ignore:
  11344. PyErr_Clear();
  11345. }
  11346. return __Pyx_PyBool_FromLong(is_coroutine);
  11347. }
  11348. static PyObject *
  11349. __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
  11350. PyObject *result;
  11351. CYTHON_UNUSED_VAR(context);
  11352. if (op->func_is_coroutine) {
  11353. return __Pyx_NewRef(op->func_is_coroutine);
  11354. }
  11355. result = __Pyx_CyFunction_get_is_coroutine_value(op);
  11356. if (unlikely(!result))
  11357. return NULL;
  11358. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11359. if (op->func_is_coroutine) {
  11360. Py_DECREF(result);
  11361. result = __Pyx_NewRef(op->func_is_coroutine);
  11362. } else {
  11363. op->func_is_coroutine = __Pyx_NewRef(result);
  11364. }
  11365. __Pyx_END_CRITICAL_SECTION();
  11366. return result;
  11367. }
  11368. static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) {
  11369. #if CYTHON_COMPILING_IN_LIMITED_API
  11370. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  11371. if (!py_name) return;
  11372. PyErr_Format(PyExc_TypeError,
  11373. "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  11374. py_name, message, size);
  11375. Py_DECREF(py_name);
  11376. #else
  11377. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  11378. PyErr_Format(PyExc_TypeError,
  11379. "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
  11380. name, message, size);
  11381. #endif
  11382. }
  11383. static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) {
  11384. #if CYTHON_COMPILING_IN_LIMITED_API
  11385. PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
  11386. if (!py_name) return;
  11387. PyErr_Format(PyExc_TypeError,
  11388. "%.200S() %s",
  11389. py_name, message);
  11390. Py_DECREF(py_name);
  11391. #else
  11392. const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
  11393. PyErr_Format(PyExc_TypeError,
  11394. "%.200s() %s",
  11395. name, message);
  11396. #endif
  11397. }
  11398. #if CYTHON_COMPILING_IN_LIMITED_API
  11399. static PyObject *
  11400. __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
  11401. CYTHON_UNUSED_VAR(context);
  11402. return PyObject_GetAttrString(op->func, "__module__");
  11403. }
  11404. static int
  11405. __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
  11406. CYTHON_UNUSED_VAR(context);
  11407. return PyObject_SetAttrString(op->func, "__module__", value);
  11408. }
  11409. #endif
  11410. static PyGetSetDef __pyx_CyFunction_getsets[] = {
  11411. {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  11412. {"__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
  11413. {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  11414. {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
  11415. {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  11416. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  11417. {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  11418. {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  11419. #else
  11420. {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  11421. {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  11422. #endif
  11423. {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  11424. {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
  11425. {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  11426. {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
  11427. {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  11428. {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
  11429. {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  11430. {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
  11431. {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
  11432. {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
  11433. {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
  11434. #if CYTHON_COMPILING_IN_LIMITED_API
  11435. {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
  11436. #endif
  11437. {0, 0, 0, 0, 0}
  11438. };
  11439. static PyMemberDef __pyx_CyFunction_members[] = {
  11440. #if !CYTHON_COMPILING_IN_LIMITED_API
  11441. {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
  11442. #endif
  11443. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11444. {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
  11445. #endif
  11446. #if CYTHON_METH_FASTCALL
  11447. #if CYTHON_COMPILING_IN_LIMITED_API
  11448. {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
  11449. #else
  11450. {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
  11451. #endif
  11452. #if CYTHON_COMPILING_IN_LIMITED_API
  11453. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
  11454. #else
  11455. {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
  11456. #endif
  11457. #endif
  11458. {0, 0, 0, 0, 0}
  11459. };
  11460. static PyObject *
  11461. __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
  11462. {
  11463. PyObject *result = NULL;
  11464. CYTHON_UNUSED_VAR(args);
  11465. __Pyx_BEGIN_CRITICAL_SECTION(m);
  11466. Py_INCREF(m->func_qualname);
  11467. result = m->func_qualname;
  11468. __Pyx_END_CRITICAL_SECTION();
  11469. return result;
  11470. }
  11471. static PyMethodDef __pyx_CyFunction_methods[] = {
  11472. {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
  11473. {0, 0, 0, 0}
  11474. };
  11475. #if CYTHON_COMPILING_IN_LIMITED_API
  11476. #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  11477. #else
  11478. #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
  11479. #endif
  11480. static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
  11481. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  11482. #if !CYTHON_COMPILING_IN_LIMITED_API
  11483. PyCFunctionObject *cf = (PyCFunctionObject*) op;
  11484. #endif
  11485. if (unlikely(op == NULL))
  11486. return NULL;
  11487. #if CYTHON_COMPILING_IN_LIMITED_API
  11488. op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
  11489. if (unlikely(!op->func)) return NULL;
  11490. #endif
  11491. op->flags = flags;
  11492. __Pyx_CyFunction_weakreflist(op) = NULL;
  11493. #if !CYTHON_COMPILING_IN_LIMITED_API
  11494. cf->m_ml = ml;
  11495. cf->m_self = (PyObject *) op;
  11496. #endif
  11497. Py_XINCREF(closure);
  11498. op->func_closure = closure;
  11499. #if !CYTHON_COMPILING_IN_LIMITED_API
  11500. Py_XINCREF(module);
  11501. cf->m_module = module;
  11502. #endif
  11503. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11504. op->func_dict = NULL;
  11505. #endif
  11506. op->func_name = NULL;
  11507. Py_INCREF(qualname);
  11508. op->func_qualname = qualname;
  11509. op->func_doc = NULL;
  11510. #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  11511. op->func_classobj = NULL;
  11512. #else
  11513. ((PyCMethodObject*)op)->mm_class = NULL;
  11514. #endif
  11515. op->func_globals = globals;
  11516. Py_INCREF(op->func_globals);
  11517. Py_XINCREF(code);
  11518. op->func_code = code;
  11519. op->defaults = NULL;
  11520. op->defaults_tuple = NULL;
  11521. op->defaults_kwdict = NULL;
  11522. op->defaults_getter = NULL;
  11523. op->func_annotations = NULL;
  11524. op->func_is_coroutine = NULL;
  11525. #if CYTHON_METH_FASTCALL
  11526. switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
  11527. case METH_NOARGS:
  11528. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
  11529. break;
  11530. case METH_O:
  11531. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
  11532. break;
  11533. case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
  11534. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
  11535. break;
  11536. case METH_FASTCALL | METH_KEYWORDS:
  11537. __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
  11538. break;
  11539. case METH_VARARGS | METH_KEYWORDS:
  11540. __Pyx_CyFunction_func_vectorcall(op) = NULL;
  11541. break;
  11542. default:
  11543. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  11544. Py_DECREF(op);
  11545. return NULL;
  11546. }
  11547. #endif
  11548. return (PyObject *) op;
  11549. }
  11550. static int
  11551. __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  11552. {
  11553. Py_CLEAR(m->func_closure);
  11554. #if CYTHON_COMPILING_IN_LIMITED_API
  11555. Py_CLEAR(m->func);
  11556. #else
  11557. Py_CLEAR(((PyCFunctionObject*)m)->m_module);
  11558. #endif
  11559. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11560. Py_CLEAR(m->func_dict);
  11561. #elif PY_VERSION_HEX < 0x030d0000
  11562. _PyObject_ClearManagedDict((PyObject*)m);
  11563. #else
  11564. PyObject_ClearManagedDict((PyObject*)m);
  11565. #endif
  11566. Py_CLEAR(m->func_name);
  11567. Py_CLEAR(m->func_qualname);
  11568. Py_CLEAR(m->func_doc);
  11569. Py_CLEAR(m->func_globals);
  11570. Py_CLEAR(m->func_code);
  11571. #if !CYTHON_COMPILING_IN_LIMITED_API
  11572. #if PY_VERSION_HEX < 0x030900B1
  11573. Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
  11574. #else
  11575. {
  11576. PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
  11577. ((PyCMethodObject *) (m))->mm_class = NULL;
  11578. Py_XDECREF(cls);
  11579. }
  11580. #endif
  11581. #endif
  11582. Py_CLEAR(m->defaults_tuple);
  11583. Py_CLEAR(m->defaults_kwdict);
  11584. Py_CLEAR(m->func_annotations);
  11585. Py_CLEAR(m->func_is_coroutine);
  11586. Py_CLEAR(m->defaults);
  11587. return 0;
  11588. }
  11589. static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
  11590. {
  11591. if (__Pyx_CyFunction_weakreflist(m) != NULL)
  11592. PyObject_ClearWeakRefs((PyObject *) m);
  11593. __Pyx_CyFunction_clear(m);
  11594. __Pyx_PyHeapTypeObject_GC_Del(m);
  11595. }
  11596. static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  11597. {
  11598. PyObject_GC_UnTrack(m);
  11599. __Pyx__CyFunction_dealloc(m);
  11600. }
  11601. static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  11602. {
  11603. {
  11604. int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg);
  11605. if (e) return e;
  11606. }
  11607. Py_VISIT(m->func_closure);
  11608. #if CYTHON_COMPILING_IN_LIMITED_API
  11609. Py_VISIT(m->func);
  11610. #else
  11611. Py_VISIT(((PyCFunctionObject*)m)->m_module);
  11612. #endif
  11613. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  11614. Py_VISIT(m->func_dict);
  11615. #else
  11616. {
  11617. int e =
  11618. #if PY_VERSION_HEX < 0x030d0000
  11619. _PyObject_VisitManagedDict
  11620. #else
  11621. PyObject_VisitManagedDict
  11622. #endif
  11623. ((PyObject*)m, visit, arg);
  11624. if (e != 0) return e;
  11625. }
  11626. #endif
  11627. __Pyx_VISIT_CONST(m->func_name);
  11628. __Pyx_VISIT_CONST(m->func_qualname);
  11629. Py_VISIT(m->func_doc);
  11630. Py_VISIT(m->func_globals);
  11631. __Pyx_VISIT_CONST(m->func_code);
  11632. #if !CYTHON_COMPILING_IN_LIMITED_API
  11633. Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
  11634. #endif
  11635. Py_VISIT(m->defaults_tuple);
  11636. Py_VISIT(m->defaults_kwdict);
  11637. Py_VISIT(m->func_is_coroutine);
  11638. Py_VISIT(m->defaults);
  11639. return 0;
  11640. }
  11641. static PyObject*
  11642. __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  11643. {
  11644. PyObject *repr;
  11645. __Pyx_BEGIN_CRITICAL_SECTION(op);
  11646. repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
  11647. op->func_qualname, (void *)op);
  11648. __Pyx_END_CRITICAL_SECTION();
  11649. return repr;
  11650. }
  11651. static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  11652. #if CYTHON_COMPILING_IN_LIMITED_API
  11653. PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
  11654. PyCFunction meth;
  11655. int flags;
  11656. meth = PyCFunction_GetFunction(f);
  11657. if (unlikely(!meth)) return NULL;
  11658. flags = PyCFunction_GetFlags(f);
  11659. if (unlikely(flags < 0)) return NULL;
  11660. #else
  11661. PyCFunctionObject* f = (PyCFunctionObject*)func;
  11662. PyCFunction meth = f->m_ml->ml_meth;
  11663. int flags = f->m_ml->ml_flags;
  11664. #endif
  11665. Py_ssize_t size;
  11666. switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
  11667. case METH_VARARGS:
  11668. if (likely(kw == NULL || PyDict_Size(kw) == 0))
  11669. return (*meth)(self, arg);
  11670. break;
  11671. case METH_VARARGS | METH_KEYWORDS:
  11672. return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
  11673. case METH_NOARGS:
  11674. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  11675. #if CYTHON_ASSUME_SAFE_SIZE
  11676. size = PyTuple_GET_SIZE(arg);
  11677. #else
  11678. size = PyTuple_Size(arg);
  11679. if (unlikely(size < 0)) return NULL;
  11680. #endif
  11681. if (likely(size == 0))
  11682. return (*meth)(self, NULL);
  11683. __Pyx_CyFunction_raise_argument_count_error(
  11684. (__pyx_CyFunctionObject*)func,
  11685. "takes no arguments", size);
  11686. return NULL;
  11687. }
  11688. break;
  11689. case METH_O:
  11690. if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  11691. #if CYTHON_ASSUME_SAFE_SIZE
  11692. size = PyTuple_GET_SIZE(arg);
  11693. #else
  11694. size = PyTuple_Size(arg);
  11695. if (unlikely(size < 0)) return NULL;
  11696. #endif
  11697. if (likely(size == 1)) {
  11698. PyObject *result, *arg0;
  11699. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  11700. arg0 = PyTuple_GET_ITEM(arg, 0);
  11701. #else
  11702. arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
  11703. #endif
  11704. result = (*meth)(self, arg0);
  11705. #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
  11706. Py_DECREF(arg0);
  11707. #endif
  11708. return result;
  11709. }
  11710. __Pyx_CyFunction_raise_argument_count_error(
  11711. (__pyx_CyFunctionObject*)func,
  11712. "takes exactly one argument", size);
  11713. return NULL;
  11714. }
  11715. break;
  11716. default:
  11717. PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
  11718. return NULL;
  11719. }
  11720. __Pyx_CyFunction_raise_type_error(
  11721. (__pyx_CyFunctionObject*)func, "takes no keyword arguments");
  11722. return NULL;
  11723. }
  11724. static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
  11725. PyObject *self, *result;
  11726. #if CYTHON_COMPILING_IN_LIMITED_API
  11727. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
  11728. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11729. #else
  11730. self = ((PyCFunctionObject*)func)->m_self;
  11731. #endif
  11732. result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
  11733. return result;
  11734. }
  11735. static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
  11736. PyObject *result;
  11737. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  11738. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  11739. __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
  11740. if (vc) {
  11741. #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
  11742. return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
  11743. #else
  11744. (void) &__Pyx_PyVectorcall_FastCallDict;
  11745. return PyVectorcall_Call(func, args, kw);
  11746. #endif
  11747. }
  11748. #endif
  11749. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  11750. Py_ssize_t argc;
  11751. PyObject *new_args;
  11752. PyObject *self;
  11753. #if CYTHON_ASSUME_SAFE_SIZE
  11754. argc = PyTuple_GET_SIZE(args);
  11755. #else
  11756. argc = PyTuple_Size(args);
  11757. if (unlikely(argc < 0)) return NULL;
  11758. #endif
  11759. new_args = PyTuple_GetSlice(args, 1, argc);
  11760. if (unlikely(!new_args))
  11761. return NULL;
  11762. self = PyTuple_GetItem(args, 0);
  11763. if (unlikely(!self)) {
  11764. Py_DECREF(new_args);
  11765. PyErr_Format(PyExc_TypeError,
  11766. "unbound method %.200S() needs an argument",
  11767. cyfunc->func_qualname);
  11768. return NULL;
  11769. }
  11770. result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
  11771. Py_DECREF(new_args);
  11772. } else {
  11773. result = __Pyx_CyFunction_Call(func, args, kw);
  11774. }
  11775. return result;
  11776. }
  11777. #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  11778. static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
  11779. {
  11780. int ret = 0;
  11781. if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
  11782. if (unlikely(nargs < 1)) {
  11783. __Pyx_CyFunction_raise_type_error(
  11784. cyfunc, "needs an argument");
  11785. return -1;
  11786. }
  11787. ret = 1;
  11788. }
  11789. if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
  11790. __Pyx_CyFunction_raise_type_error(
  11791. cyfunc, "takes no keyword arguments");
  11792. return -1;
  11793. }
  11794. return ret;
  11795. }
  11796. static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11797. {
  11798. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11799. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11800. PyObject *self;
  11801. #if CYTHON_COMPILING_IN_LIMITED_API
  11802. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11803. if (unlikely(!meth)) return NULL;
  11804. #else
  11805. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11806. #endif
  11807. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  11808. case 1:
  11809. self = args[0];
  11810. args += 1;
  11811. nargs -= 1;
  11812. break;
  11813. case 0:
  11814. #if CYTHON_COMPILING_IN_LIMITED_API
  11815. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11816. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11817. #else
  11818. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11819. #endif
  11820. break;
  11821. default:
  11822. return NULL;
  11823. }
  11824. if (unlikely(nargs != 0)) {
  11825. __Pyx_CyFunction_raise_argument_count_error(
  11826. cyfunc, "takes no arguments", nargs);
  11827. return NULL;
  11828. }
  11829. return meth(self, NULL);
  11830. }
  11831. static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11832. {
  11833. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11834. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11835. PyObject *self;
  11836. #if CYTHON_COMPILING_IN_LIMITED_API
  11837. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11838. if (unlikely(!meth)) return NULL;
  11839. #else
  11840. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11841. #endif
  11842. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
  11843. case 1:
  11844. self = args[0];
  11845. args += 1;
  11846. nargs -= 1;
  11847. break;
  11848. case 0:
  11849. #if CYTHON_COMPILING_IN_LIMITED_API
  11850. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11851. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11852. #else
  11853. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11854. #endif
  11855. break;
  11856. default:
  11857. return NULL;
  11858. }
  11859. if (unlikely(nargs != 1)) {
  11860. __Pyx_CyFunction_raise_argument_count_error(
  11861. cyfunc, "takes exactly one argument", nargs);
  11862. return NULL;
  11863. }
  11864. return meth(self, args[0]);
  11865. }
  11866. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11867. {
  11868. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11869. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11870. PyObject *self;
  11871. #if CYTHON_COMPILING_IN_LIMITED_API
  11872. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11873. if (unlikely(!meth)) return NULL;
  11874. #else
  11875. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11876. #endif
  11877. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  11878. case 1:
  11879. self = args[0];
  11880. args += 1;
  11881. nargs -= 1;
  11882. break;
  11883. case 0:
  11884. #if CYTHON_COMPILING_IN_LIMITED_API
  11885. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11886. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11887. #else
  11888. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11889. #endif
  11890. break;
  11891. default:
  11892. return NULL;
  11893. }
  11894. return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
  11895. }
  11896. static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  11897. {
  11898. __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
  11899. PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
  11900. Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
  11901. PyObject *self;
  11902. #if CYTHON_COMPILING_IN_LIMITED_API
  11903. PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
  11904. if (unlikely(!meth)) return NULL;
  11905. #else
  11906. PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  11907. #endif
  11908. switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
  11909. case 1:
  11910. self = args[0];
  11911. args += 1;
  11912. nargs -= 1;
  11913. break;
  11914. case 0:
  11915. #if CYTHON_COMPILING_IN_LIMITED_API
  11916. self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
  11917. if (unlikely(!self) && PyErr_Occurred()) return NULL;
  11918. #else
  11919. self = ((PyCFunctionObject*)cyfunc)->m_self;
  11920. #endif
  11921. break;
  11922. default:
  11923. return NULL;
  11924. }
  11925. #if PY_VERSION_HEX < 0x030e00A6
  11926. size_t nargs_value = (size_t) nargs;
  11927. #else
  11928. Py_ssize_t nargs_value = nargs;
  11929. #endif
  11930. return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames);
  11931. }
  11932. #endif
  11933. static PyType_Slot __pyx_CyFunctionType_slots[] = {
  11934. {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
  11935. {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
  11936. {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
  11937. {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
  11938. {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
  11939. {Py_tp_methods, (void *)__pyx_CyFunction_methods},
  11940. {Py_tp_members, (void *)__pyx_CyFunction_members},
  11941. {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
  11942. {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
  11943. {0, 0},
  11944. };
  11945. static PyType_Spec __pyx_CyFunctionType_spec = {
  11946. __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
  11947. sizeof(__pyx_CyFunctionObject),
  11948. 0,
  11949. #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
  11950. Py_TPFLAGS_METHOD_DESCRIPTOR |
  11951. #endif
  11952. #if CYTHON_METH_FASTCALL
  11953. #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
  11954. Py_TPFLAGS_HAVE_VECTORCALL |
  11955. #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
  11956. _Py_TPFLAGS_HAVE_VECTORCALL |
  11957. #endif
  11958. #endif // CYTHON_METH_FASTCALL
  11959. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  11960. Py_TPFLAGS_MANAGED_DICT |
  11961. #endif
  11962. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  11963. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
  11964. __pyx_CyFunctionType_slots
  11965. };
  11966. static int __pyx_CyFunction_init(PyObject *module) {
  11967. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  11968. mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(
  11969. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL);
  11970. if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
  11971. return -1;
  11972. }
  11973. return 0;
  11974. }
  11975. static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
  11976. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11977. m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
  11978. if (unlikely(!m->defaults))
  11979. return NULL;
  11980. return m->defaults;
  11981. }
  11982. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
  11983. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11984. m->defaults_tuple = tuple;
  11985. Py_INCREF(tuple);
  11986. }
  11987. static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
  11988. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11989. m->defaults_kwdict = dict;
  11990. Py_INCREF(dict);
  11991. }
  11992. static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
  11993. __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
  11994. m->func_annotations = dict;
  11995. Py_INCREF(dict);
  11996. }
  11997. /* CythonFunction */
  11998. static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
  11999. PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  12000. PyObject *op = __Pyx_CyFunction_Init(
  12001. PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType),
  12002. ml, flags, qualname, closure, module, globals, code
  12003. );
  12004. if (likely(op)) {
  12005. PyObject_GC_Track(op);
  12006. }
  12007. return op;
  12008. }
  12009. /* CLineInTraceback (used by AddTraceback) */
  12010. #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  12011. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  12012. #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
  12013. #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12014. #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
  12015. #else
  12016. PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
  12017. PyObject **dict_ptr = _PyObject_GetDictPtr(o);
  12018. return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
  12019. }
  12020. #endif
  12021. static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
  12022. PyObject *use_cline = NULL;
  12023. PyObject *ptype, *pvalue, *ptraceback;
  12024. PyObject *cython_runtime_dict;
  12025. CYTHON_MAYBE_UNUSED_VAR(tstate);
  12026. if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) {
  12027. return c_line;
  12028. }
  12029. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  12030. cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime);
  12031. if (likely(cython_runtime_dict)) {
  12032. __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
  12033. use_cline, cython_runtime_dict,
  12034. __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False))
  12035. }
  12036. if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
  12037. c_line = 0;
  12038. }
  12039. Py_XDECREF(use_cline);
  12040. Py_XDECREF(cython_runtime_dict);
  12041. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  12042. return c_line;
  12043. }
  12044. #endif
  12045. /* CodeObjectCache (used by AddTraceback) */
  12046. static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
  12047. int start = 0, mid = 0, end = count - 1;
  12048. if (end >= 0 && code_line > entries[end].code_line) {
  12049. return count;
  12050. }
  12051. while (start < end) {
  12052. mid = start + (end - start) / 2;
  12053. if (code_line < entries[mid].code_line) {
  12054. end = mid;
  12055. } else if (code_line > entries[mid].code_line) {
  12056. start = mid + 1;
  12057. } else {
  12058. return mid;
  12059. }
  12060. }
  12061. if (code_line <= entries[mid].code_line) {
  12062. return mid;
  12063. } else {
  12064. return mid + 1;
  12065. }
  12066. }
  12067. static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) {
  12068. __Pyx_CachedCodeObjectType* code_object;
  12069. int pos;
  12070. if (unlikely(!code_line) || unlikely(!code_cache->entries)) {
  12071. return NULL;
  12072. }
  12073. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  12074. if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) {
  12075. return NULL;
  12076. }
  12077. code_object = code_cache->entries[pos].code_object;
  12078. Py_INCREF(code_object);
  12079. return code_object;
  12080. }
  12081. static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) {
  12082. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  12083. (void)__pyx__find_code_object;
  12084. return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss.
  12085. #else
  12086. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  12087. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12088. __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count);
  12089. if (old_count < 0) {
  12090. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  12091. return NULL;
  12092. }
  12093. #endif
  12094. __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line);
  12095. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12096. __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  12097. #endif
  12098. return result;
  12099. #endif
  12100. }
  12101. static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object)
  12102. {
  12103. int pos, i;
  12104. __Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
  12105. if (unlikely(!code_line)) {
  12106. return;
  12107. }
  12108. if (unlikely(!entries)) {
  12109. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
  12110. if (likely(entries)) {
  12111. code_cache->entries = entries;
  12112. code_cache->max_count = 64;
  12113. code_cache->count = 1;
  12114. entries[0].code_line = code_line;
  12115. entries[0].code_object = code_object;
  12116. Py_INCREF(code_object);
  12117. }
  12118. return;
  12119. }
  12120. pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
  12121. if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) {
  12122. __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object;
  12123. entries[pos].code_object = code_object;
  12124. Py_INCREF(code_object);
  12125. Py_DECREF(tmp);
  12126. return;
  12127. }
  12128. if (code_cache->count == code_cache->max_count) {
  12129. int new_max = code_cache->max_count + 64;
  12130. entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
  12131. code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
  12132. if (unlikely(!entries)) {
  12133. return;
  12134. }
  12135. code_cache->entries = entries;
  12136. code_cache->max_count = new_max;
  12137. }
  12138. for (i=code_cache->count; i>pos; i--) {
  12139. entries[i] = entries[i-1];
  12140. }
  12141. entries[pos].code_line = code_line;
  12142. entries[pos].code_object = code_object;
  12143. code_cache->count++;
  12144. Py_INCREF(code_object);
  12145. }
  12146. static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) {
  12147. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
  12148. (void)__pyx__insert_code_object;
  12149. return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail.
  12150. #else
  12151. struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  12152. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12153. __pyx_nonatomic_int_type expected = 0;
  12154. if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) {
  12155. return;
  12156. }
  12157. #endif
  12158. __pyx__insert_code_object(code_cache, code_line, code_object);
  12159. #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  12160. __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN);
  12161. #endif
  12162. #endif
  12163. }
  12164. /* AddTraceback */
  12165. #include "compile.h"
  12166. #include "frameobject.h"
  12167. #include "traceback.h"
  12168. #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
  12169. #ifndef Py_BUILD_CORE
  12170. #define Py_BUILD_CORE 1
  12171. #endif
  12172. #include "internal/pycore_frame.h"
  12173. #endif
  12174. #if CYTHON_COMPILING_IN_LIMITED_API
  12175. static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
  12176. PyObject *firstlineno, PyObject *name) {
  12177. PyObject *replace = NULL;
  12178. if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
  12179. if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
  12180. replace = PyObject_GetAttrString(code, "replace");
  12181. if (likely(replace)) {
  12182. PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict);
  12183. Py_DECREF(replace);
  12184. return result;
  12185. }
  12186. PyErr_Clear();
  12187. return NULL;
  12188. }
  12189. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  12190. int py_line, const char *filename) {
  12191. PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
  12192. PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
  12193. PyObject *exc_type, *exc_value, *exc_traceback;
  12194. int success = 0;
  12195. if (c_line) {
  12196. c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
  12197. }
  12198. PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
  12199. code_object = __pyx_find_code_object(c_line ? -c_line : py_line);
  12200. if (!code_object) {
  12201. code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
  12202. if (unlikely(!code_object)) goto bad;
  12203. py_py_line = PyLong_FromLong(py_line);
  12204. if (unlikely(!py_py_line)) goto bad;
  12205. if (c_line) {
  12206. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  12207. } else {
  12208. py_funcname = PyUnicode_FromString(funcname);
  12209. }
  12210. if (unlikely(!py_funcname)) goto bad;
  12211. dict = PyDict_New();
  12212. if (unlikely(!dict)) goto bad;
  12213. {
  12214. PyObject *old_code_object = code_object;
  12215. code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
  12216. Py_DECREF(old_code_object);
  12217. }
  12218. if (unlikely(!code_object)) goto bad;
  12219. __pyx_insert_code_object(c_line ? -c_line : py_line, code_object);
  12220. } else {
  12221. dict = PyDict_New();
  12222. }
  12223. getframe = PySys_GetObject("_getframe");
  12224. if (unlikely(!getframe)) goto bad;
  12225. if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
  12226. frame = PyEval_EvalCode(code_object, dict, dict);
  12227. if (unlikely(!frame) || frame == Py_None) goto bad;
  12228. success = 1;
  12229. bad:
  12230. PyErr_Restore(exc_type, exc_value, exc_traceback);
  12231. Py_XDECREF(code_object);
  12232. Py_XDECREF(py_py_line);
  12233. Py_XDECREF(py_funcname);
  12234. Py_XDECREF(dict);
  12235. Py_XDECREF(replace);
  12236. if (success) {
  12237. PyTraceBack_Here(
  12238. (struct _frame*)frame);
  12239. }
  12240. Py_XDECREF(frame);
  12241. }
  12242. #else
  12243. static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
  12244. const char *funcname, int c_line,
  12245. int py_line, const char *filename) {
  12246. PyCodeObject *py_code = NULL;
  12247. PyObject *py_funcname = NULL;
  12248. if (c_line) {
  12249. py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
  12250. if (!py_funcname) goto bad;
  12251. funcname = PyUnicode_AsUTF8(py_funcname);
  12252. if (!funcname) goto bad;
  12253. }
  12254. py_code = PyCode_NewEmpty(filename, funcname, py_line);
  12255. Py_XDECREF(py_funcname);
  12256. return py_code;
  12257. bad:
  12258. Py_XDECREF(py_funcname);
  12259. return NULL;
  12260. }
  12261. static void __Pyx_AddTraceback(const char *funcname, int c_line,
  12262. int py_line, const char *filename) {
  12263. PyCodeObject *py_code = 0;
  12264. PyFrameObject *py_frame = 0;
  12265. PyThreadState *tstate = __Pyx_PyThreadState_Current;
  12266. PyObject *ptype, *pvalue, *ptraceback;
  12267. if (c_line) {
  12268. c_line = __Pyx_CLineForTraceback(tstate, c_line);
  12269. }
  12270. py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
  12271. if (!py_code) {
  12272. __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
  12273. py_code = __Pyx_CreateCodeObjectForTraceback(
  12274. funcname, c_line, py_line, filename);
  12275. if (!py_code) {
  12276. /* If the code object creation fails, then we should clear the
  12277. fetched exception references and propagate the new exception */
  12278. Py_XDECREF(ptype);
  12279. Py_XDECREF(pvalue);
  12280. Py_XDECREF(ptraceback);
  12281. goto bad;
  12282. }
  12283. __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
  12284. __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
  12285. }
  12286. py_frame = PyFrame_New(
  12287. tstate, /*PyThreadState *tstate,*/
  12288. py_code, /*PyCodeObject *code,*/
  12289. __pyx_mstate_global->__pyx_d, /*PyObject *globals,*/
  12290. 0 /*PyObject *locals*/
  12291. );
  12292. if (!py_frame) goto bad;
  12293. __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
  12294. PyTraceBack_Here(py_frame);
  12295. bad:
  12296. Py_XDECREF(py_code);
  12297. Py_XDECREF(py_frame);
  12298. }
  12299. #endif
  12300. /* Declarations */
  12301. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  12302. #ifdef __cplusplus
  12303. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  12304. return ::std::complex< double >(x, y);
  12305. }
  12306. #else
  12307. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  12308. return x + y*(__pyx_t_double_complex)_Complex_I;
  12309. }
  12310. #endif
  12311. #else
  12312. static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
  12313. __pyx_t_double_complex z;
  12314. z.real = x;
  12315. z.imag = y;
  12316. return z;
  12317. }
  12318. #endif
  12319. /* Arithmetic */
  12320. #if CYTHON_CCOMPLEX && (1) && (!0 || __cplusplus)
  12321. #else
  12322. static CYTHON_INLINE int __Pyx_c_eq_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12323. return (a.real == b.real) && (a.imag == b.imag);
  12324. }
  12325. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12326. __pyx_t_double_complex z;
  12327. z.real = a.real + b.real;
  12328. z.imag = a.imag + b.imag;
  12329. return z;
  12330. }
  12331. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12332. __pyx_t_double_complex z;
  12333. z.real = a.real - b.real;
  12334. z.imag = a.imag - b.imag;
  12335. return z;
  12336. }
  12337. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12338. __pyx_t_double_complex z;
  12339. z.real = a.real * b.real - a.imag * b.imag;
  12340. z.imag = a.real * b.imag + a.imag * b.real;
  12341. return z;
  12342. }
  12343. #if 1
  12344. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12345. if (b.imag == 0) {
  12346. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  12347. } else if (fabs(b.real) >= fabs(b.imag)) {
  12348. if (b.real == 0 && b.imag == 0) {
  12349. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.imag);
  12350. } else {
  12351. double r = b.imag / b.real;
  12352. double s = (double)(1.0) / (b.real + b.imag * r);
  12353. return __pyx_t_double_complex_from_parts(
  12354. (a.real + a.imag * r) * s, (a.imag - a.real * r) * s);
  12355. }
  12356. } else {
  12357. double r = b.real / b.imag;
  12358. double s = (double)(1.0) / (b.imag + b.real * r);
  12359. return __pyx_t_double_complex_from_parts(
  12360. (a.real * r + a.imag) * s, (a.imag * r - a.real) * s);
  12361. }
  12362. }
  12363. #else
  12364. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12365. if (b.imag == 0) {
  12366. return __pyx_t_double_complex_from_parts(a.real / b.real, a.imag / b.real);
  12367. } else {
  12368. double denom = b.real * b.real + b.imag * b.imag;
  12369. return __pyx_t_double_complex_from_parts(
  12370. (a.real * b.real + a.imag * b.imag) / denom,
  12371. (a.imag * b.real - a.real * b.imag) / denom);
  12372. }
  12373. }
  12374. #endif
  12375. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg_double(__pyx_t_double_complex a) {
  12376. __pyx_t_double_complex z;
  12377. z.real = -a.real;
  12378. z.imag = -a.imag;
  12379. return z;
  12380. }
  12381. static CYTHON_INLINE int __Pyx_c_is_zero_double(__pyx_t_double_complex a) {
  12382. return (a.real == 0) && (a.imag == 0);
  12383. }
  12384. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj_double(__pyx_t_double_complex a) {
  12385. __pyx_t_double_complex z;
  12386. z.real = a.real;
  12387. z.imag = -a.imag;
  12388. return z;
  12389. }
  12390. #if 1
  12391. static CYTHON_INLINE double __Pyx_c_abs_double(__pyx_t_double_complex z) {
  12392. #if !defined(HAVE_HYPOT) || defined(_MSC_VER)
  12393. return sqrt(z.real*z.real + z.imag*z.imag);
  12394. #else
  12395. return hypot(z.real, z.imag);
  12396. #endif
  12397. }
  12398. static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow_double(__pyx_t_double_complex a, __pyx_t_double_complex b) {
  12399. __pyx_t_double_complex z;
  12400. double r, lnr, theta, z_r, z_theta;
  12401. if (b.imag == 0 && b.real == (int)b.real) {
  12402. if (b.real < 0) {
  12403. double denom = a.real * a.real + a.imag * a.imag;
  12404. a.real = a.real / denom;
  12405. a.imag = -a.imag / denom;
  12406. b.real = -b.real;
  12407. }
  12408. switch ((int)b.real) {
  12409. case 0:
  12410. z.real = 1;
  12411. z.imag = 0;
  12412. return z;
  12413. case 1:
  12414. return a;
  12415. case 2:
  12416. return __Pyx_c_prod_double(a, a);
  12417. case 3:
  12418. z = __Pyx_c_prod_double(a, a);
  12419. return __Pyx_c_prod_double(z, a);
  12420. case 4:
  12421. z = __Pyx_c_prod_double(a, a);
  12422. return __Pyx_c_prod_double(z, z);
  12423. }
  12424. }
  12425. if (a.imag == 0) {
  12426. if (a.real == 0) {
  12427. return a;
  12428. } else if ((b.imag == 0) && (a.real >= 0)) {
  12429. z.real = pow(a.real, b.real);
  12430. z.imag = 0;
  12431. return z;
  12432. } else if (a.real > 0) {
  12433. r = a.real;
  12434. theta = 0;
  12435. } else {
  12436. r = -a.real;
  12437. theta = atan2(0.0, -1.0);
  12438. }
  12439. } else {
  12440. r = __Pyx_c_abs_double(a);
  12441. theta = atan2(a.imag, a.real);
  12442. }
  12443. lnr = log(r);
  12444. z_r = exp(lnr * b.real - theta * b.imag);
  12445. z_theta = theta * b.real + lnr * b.imag;
  12446. z.real = z_r * cos(z_theta);
  12447. z.imag = z_r * sin(z_theta);
  12448. return z;
  12449. }
  12450. #endif
  12451. #endif
  12452. /* FromPy */
  12453. static __pyx_t_double_complex __Pyx_PyComplex_As___pyx_t_double_complex(PyObject* o) {
  12454. #if CYTHON_COMPILING_IN_LIMITED_API
  12455. double real=-1.0, imag=-1.0;
  12456. real = PyComplex_RealAsDouble(o);
  12457. if (unlikely(real == -1.0 && PyErr_Occurred())) goto end;
  12458. imag = PyComplex_ImagAsDouble(o);
  12459. end:
  12460. return __pyx_t_double_complex_from_parts(
  12461. (double)real, (double)imag
  12462. );
  12463. #else
  12464. Py_complex cval;
  12465. #if !CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_GRAAL
  12466. if (PyComplex_CheckExact(o))
  12467. cval = ((PyComplexObject *)o)->cval;
  12468. else
  12469. #endif
  12470. cval = PyComplex_AsCComplex(o);
  12471. return __pyx_t_double_complex_from_parts(
  12472. (double)cval.real,
  12473. (double)cval.imag);
  12474. #endif
  12475. }
  12476. /* CIntFromPyVerify */
  12477. #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
  12478. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  12479. #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
  12480. __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  12481. #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
  12482. {\
  12483. func_type value = func_value;\
  12484. if (sizeof(target_type) < sizeof(func_type)) {\
  12485. if (unlikely(value != (func_type) (target_type) value)) {\
  12486. func_type zero = 0;\
  12487. if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
  12488. return (target_type) -1;\
  12489. if (is_unsigned && unlikely(value < zero))\
  12490. goto raise_neg_overflow;\
  12491. else\
  12492. goto raise_overflow;\
  12493. }\
  12494. }\
  12495. return (target_type) value;\
  12496. }
  12497. /* CIntFromPy */
  12498. static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) {
  12499. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12500. #pragma GCC diagnostic push
  12501. #pragma GCC diagnostic ignored "-Wconversion"
  12502. #endif
  12503. const int neg_one = (int) -1, const_zero = (int) 0;
  12504. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12505. #pragma GCC diagnostic pop
  12506. #endif
  12507. const int is_unsigned = neg_one > const_zero;
  12508. if (unlikely(!PyLong_Check(x))) {
  12509. int val;
  12510. PyObject *tmp = __Pyx_PyNumber_Long(x);
  12511. if (!tmp) return (int) -1;
  12512. val = __Pyx_PyLong_As_int(tmp);
  12513. Py_DECREF(tmp);
  12514. return val;
  12515. }
  12516. if (is_unsigned) {
  12517. #if CYTHON_USE_PYLONG_INTERNALS
  12518. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  12519. goto raise_neg_overflow;
  12520. } else if (__Pyx_PyLong_IsCompact(x)) {
  12521. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  12522. } else {
  12523. const digit* digits = __Pyx_PyLong_Digits(x);
  12524. assert(__Pyx_PyLong_DigitCount(x) > 1);
  12525. switch (__Pyx_PyLong_DigitCount(x)) {
  12526. case 2:
  12527. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  12528. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  12529. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12530. } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
  12531. return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12532. }
  12533. }
  12534. break;
  12535. case 3:
  12536. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  12537. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  12538. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12539. } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
  12540. return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12541. }
  12542. }
  12543. break;
  12544. case 4:
  12545. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  12546. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  12547. __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])))
  12548. } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
  12549. return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
  12550. }
  12551. }
  12552. break;
  12553. }
  12554. }
  12555. #endif
  12556. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  12557. if (unlikely(Py_SIZE(x) < 0)) {
  12558. goto raise_neg_overflow;
  12559. }
  12560. #else
  12561. {
  12562. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  12563. if (unlikely(result < 0))
  12564. return (int) -1;
  12565. if (unlikely(result == 1))
  12566. goto raise_neg_overflow;
  12567. }
  12568. #endif
  12569. if ((sizeof(int) <= sizeof(unsigned long))) {
  12570. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
  12571. } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
  12572. __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  12573. }
  12574. } else {
  12575. #if CYTHON_USE_PYLONG_INTERNALS
  12576. if (__Pyx_PyLong_IsCompact(x)) {
  12577. __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  12578. } else {
  12579. const digit* digits = __Pyx_PyLong_Digits(x);
  12580. assert(__Pyx_PyLong_DigitCount(x) > 1);
  12581. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  12582. case -2:
  12583. if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
  12584. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  12585. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12586. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  12587. return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12588. }
  12589. }
  12590. break;
  12591. case 2:
  12592. if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
  12593. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  12594. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12595. } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  12596. return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12597. }
  12598. }
  12599. break;
  12600. case -3:
  12601. if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
  12602. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  12603. __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12604. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  12605. return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12606. }
  12607. }
  12608. break;
  12609. case 3:
  12610. if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
  12611. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  12612. __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12613. } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  12614. return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12615. }
  12616. }
  12617. break;
  12618. case -4:
  12619. if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
  12620. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  12621. __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])))
  12622. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  12623. return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12624. }
  12625. }
  12626. break;
  12627. case 4:
  12628. if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
  12629. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  12630. __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])))
  12631. } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
  12632. return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
  12633. }
  12634. }
  12635. break;
  12636. }
  12637. }
  12638. #endif
  12639. if ((sizeof(int) <= sizeof(long))) {
  12640. __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
  12641. } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
  12642. __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
  12643. }
  12644. }
  12645. {
  12646. int val;
  12647. int ret = -1;
  12648. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  12649. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  12650. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  12651. if (unlikely(bytes_copied == -1)) {
  12652. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  12653. goto raise_overflow;
  12654. } else {
  12655. ret = 0;
  12656. }
  12657. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  12658. int one = 1; int is_little = (int)*(unsigned char *)&one;
  12659. unsigned char *bytes = (unsigned char *)&val;
  12660. ret = _PyLong_AsByteArray((PyLongObject *)x,
  12661. bytes, sizeof(val),
  12662. is_little, !is_unsigned);
  12663. #else
  12664. PyObject *v;
  12665. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  12666. int bits, remaining_bits, is_negative = 0;
  12667. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  12668. if (likely(PyLong_CheckExact(x))) {
  12669. v = __Pyx_NewRef(x);
  12670. } else {
  12671. v = PyNumber_Long(x);
  12672. if (unlikely(!v)) return (int) -1;
  12673. assert(PyLong_CheckExact(v));
  12674. }
  12675. {
  12676. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  12677. if (unlikely(result < 0)) {
  12678. Py_DECREF(v);
  12679. return (int) -1;
  12680. }
  12681. is_negative = result == 1;
  12682. }
  12683. if (is_unsigned && unlikely(is_negative)) {
  12684. Py_DECREF(v);
  12685. goto raise_neg_overflow;
  12686. } else if (is_negative) {
  12687. stepval = PyNumber_Invert(v);
  12688. Py_DECREF(v);
  12689. if (unlikely(!stepval))
  12690. return (int) -1;
  12691. } else {
  12692. stepval = v;
  12693. }
  12694. v = NULL;
  12695. val = (int) 0;
  12696. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  12697. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  12698. for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
  12699. PyObject *tmp, *digit;
  12700. long idigit;
  12701. digit = PyNumber_And(stepval, mask);
  12702. if (unlikely(!digit)) goto done;
  12703. idigit = PyLong_AsLong(digit);
  12704. Py_DECREF(digit);
  12705. if (unlikely(idigit < 0)) goto done;
  12706. val |= ((int) idigit) << bits;
  12707. tmp = PyNumber_Rshift(stepval, shift);
  12708. if (unlikely(!tmp)) goto done;
  12709. Py_DECREF(stepval); stepval = tmp;
  12710. }
  12711. Py_DECREF(shift); shift = NULL;
  12712. Py_DECREF(mask); mask = NULL;
  12713. {
  12714. long idigit = PyLong_AsLong(stepval);
  12715. if (unlikely(idigit < 0)) goto done;
  12716. remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
  12717. if (unlikely(idigit >= (1L << remaining_bits)))
  12718. goto raise_overflow;
  12719. val |= ((int) idigit) << bits;
  12720. }
  12721. if (!is_unsigned) {
  12722. if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
  12723. goto raise_overflow;
  12724. if (is_negative)
  12725. val = ~val;
  12726. }
  12727. ret = 0;
  12728. done:
  12729. Py_XDECREF(shift);
  12730. Py_XDECREF(mask);
  12731. Py_XDECREF(stepval);
  12732. #endif
  12733. if (unlikely(ret))
  12734. return (int) -1;
  12735. return val;
  12736. }
  12737. raise_overflow:
  12738. PyErr_SetString(PyExc_OverflowError,
  12739. "value too large to convert to int");
  12740. return (int) -1;
  12741. raise_neg_overflow:
  12742. PyErr_SetString(PyExc_OverflowError,
  12743. "can't convert negative value to int");
  12744. return (int) -1;
  12745. }
  12746. /* PyObjectVectorCallKwBuilder (used by CIntToPy) */
  12747. #if CYTHON_VECTORCALL
  12748. static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  12749. (void)__Pyx_PyObject_FastCallDict;
  12750. if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1;
  12751. Py_INCREF(key);
  12752. args[n] = value;
  12753. return 0;
  12754. }
  12755. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  12756. (void)__Pyx_VectorcallBuilder_AddArgStr;
  12757. if (unlikely(!PyUnicode_Check(key))) {
  12758. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  12759. return -1;
  12760. }
  12761. return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n);
  12762. }
  12763. static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
  12764. PyObject *pyKey = PyUnicode_FromString(key);
  12765. if (!pyKey) return -1;
  12766. return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n);
  12767. }
  12768. #else // CYTHON_VECTORCALL
  12769. CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) {
  12770. if (unlikely(!PyUnicode_Check(key))) {
  12771. PyErr_SetString(PyExc_TypeError, "keywords must be strings");
  12772. return -1;
  12773. }
  12774. return PyDict_SetItem(builder, key, value);
  12775. }
  12776. #endif
  12777. /* CIntToPy */
  12778. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) {
  12779. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12780. #pragma GCC diagnostic push
  12781. #pragma GCC diagnostic ignored "-Wconversion"
  12782. #endif
  12783. const long neg_one = (long) -1, const_zero = (long) 0;
  12784. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12785. #pragma GCC diagnostic pop
  12786. #endif
  12787. const int is_unsigned = neg_one > const_zero;
  12788. if (is_unsigned) {
  12789. if (sizeof(long) < sizeof(long)) {
  12790. return PyLong_FromLong((long) value);
  12791. } else if (sizeof(long) <= sizeof(unsigned long)) {
  12792. return PyLong_FromUnsignedLong((unsigned long) value);
  12793. #if !CYTHON_COMPILING_IN_PYPY
  12794. } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
  12795. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  12796. #endif
  12797. }
  12798. } else {
  12799. if (sizeof(long) <= sizeof(long)) {
  12800. return PyLong_FromLong((long) value);
  12801. } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
  12802. return PyLong_FromLongLong((PY_LONG_LONG) value);
  12803. }
  12804. }
  12805. {
  12806. unsigned char *bytes = (unsigned char *)&value;
  12807. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  12808. if (is_unsigned) {
  12809. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  12810. } else {
  12811. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  12812. }
  12813. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  12814. int one = 1; int little = (int)*(unsigned char *)&one;
  12815. return _PyLong_FromByteArray(bytes, sizeof(long),
  12816. little, !is_unsigned);
  12817. #else
  12818. int one = 1; int little = (int)*(unsigned char *)&one;
  12819. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  12820. PyObject *py_bytes = NULL, *order_str = NULL;
  12821. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  12822. if (!from_bytes) return NULL;
  12823. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long));
  12824. if (!py_bytes) goto limited_bad;
  12825. order_str = PyUnicode_FromString(little ? "little" : "big");
  12826. if (!order_str) goto limited_bad;
  12827. {
  12828. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  12829. if (!is_unsigned) {
  12830. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  12831. if (!kwds) goto limited_bad;
  12832. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  12833. }
  12834. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  12835. }
  12836. limited_bad:
  12837. Py_XDECREF(kwds);
  12838. Py_XDECREF(order_str);
  12839. Py_XDECREF(py_bytes);
  12840. Py_XDECREF(from_bytes);
  12841. return result;
  12842. #endif
  12843. }
  12844. }
  12845. /* CIntToPy */
  12846. static CYTHON_INLINE PyObject* __Pyx_PyLong_From_int(int value) {
  12847. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12848. #pragma GCC diagnostic push
  12849. #pragma GCC diagnostic ignored "-Wconversion"
  12850. #endif
  12851. const int neg_one = (int) -1, const_zero = (int) 0;
  12852. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12853. #pragma GCC diagnostic pop
  12854. #endif
  12855. const int is_unsigned = neg_one > const_zero;
  12856. if (is_unsigned) {
  12857. if (sizeof(int) < sizeof(long)) {
  12858. return PyLong_FromLong((long) value);
  12859. } else if (sizeof(int) <= sizeof(unsigned long)) {
  12860. return PyLong_FromUnsignedLong((unsigned long) value);
  12861. #if !CYTHON_COMPILING_IN_PYPY
  12862. } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
  12863. return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  12864. #endif
  12865. }
  12866. } else {
  12867. if (sizeof(int) <= sizeof(long)) {
  12868. return PyLong_FromLong((long) value);
  12869. } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
  12870. return PyLong_FromLongLong((PY_LONG_LONG) value);
  12871. }
  12872. }
  12873. {
  12874. unsigned char *bytes = (unsigned char *)&value;
  12875. #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
  12876. if (is_unsigned) {
  12877. return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
  12878. } else {
  12879. return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
  12880. }
  12881. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
  12882. int one = 1; int little = (int)*(unsigned char *)&one;
  12883. return _PyLong_FromByteArray(bytes, sizeof(int),
  12884. little, !is_unsigned);
  12885. #else
  12886. int one = 1; int little = (int)*(unsigned char *)&one;
  12887. PyObject *from_bytes, *result = NULL, *kwds = NULL;
  12888. PyObject *py_bytes = NULL, *order_str = NULL;
  12889. from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
  12890. if (!from_bytes) return NULL;
  12891. py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(int));
  12892. if (!py_bytes) goto limited_bad;
  12893. order_str = PyUnicode_FromString(little ? "little" : "big");
  12894. if (!order_str) goto limited_bad;
  12895. {
  12896. PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
  12897. if (!is_unsigned) {
  12898. kwds = __Pyx_MakeVectorcallBuilderKwds(1);
  12899. if (!kwds) goto limited_bad;
  12900. if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
  12901. }
  12902. result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
  12903. }
  12904. limited_bad:
  12905. Py_XDECREF(kwds);
  12906. Py_XDECREF(order_str);
  12907. Py_XDECREF(py_bytes);
  12908. Py_XDECREF(from_bytes);
  12909. return result;
  12910. #endif
  12911. }
  12912. }
  12913. /* FormatTypeName */
  12914. #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
  12915. static __Pyx_TypeName
  12916. __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp)
  12917. {
  12918. PyObject *module = NULL, *name = NULL, *result = NULL;
  12919. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  12920. name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  12921. __pyx_mstate_global->__pyx_n_u_qualname);
  12922. #else
  12923. name = PyType_GetQualName(tp);
  12924. #endif
  12925. if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad;
  12926. module = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
  12927. __pyx_mstate_global->__pyx_n_u_module);
  12928. if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad;
  12929. if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) {
  12930. result = name;
  12931. name = NULL;
  12932. goto done;
  12933. }
  12934. result = PyUnicode_FromFormat("%U.%U", module, name);
  12935. if (unlikely(result == NULL)) goto bad;
  12936. done:
  12937. Py_XDECREF(name);
  12938. Py_XDECREF(module);
  12939. return result;
  12940. bad:
  12941. PyErr_Clear();
  12942. if (name) {
  12943. result = name;
  12944. name = NULL;
  12945. } else {
  12946. result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__2);
  12947. }
  12948. goto done;
  12949. }
  12950. #endif
  12951. /* CIntFromPy */
  12952. static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) {
  12953. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12954. #pragma GCC diagnostic push
  12955. #pragma GCC diagnostic ignored "-Wconversion"
  12956. #endif
  12957. const long neg_one = (long) -1, const_zero = (long) 0;
  12958. #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  12959. #pragma GCC diagnostic pop
  12960. #endif
  12961. const int is_unsigned = neg_one > const_zero;
  12962. if (unlikely(!PyLong_Check(x))) {
  12963. long val;
  12964. PyObject *tmp = __Pyx_PyNumber_Long(x);
  12965. if (!tmp) return (long) -1;
  12966. val = __Pyx_PyLong_As_long(tmp);
  12967. Py_DECREF(tmp);
  12968. return val;
  12969. }
  12970. if (is_unsigned) {
  12971. #if CYTHON_USE_PYLONG_INTERNALS
  12972. if (unlikely(__Pyx_PyLong_IsNeg(x))) {
  12973. goto raise_neg_overflow;
  12974. } else if (__Pyx_PyLong_IsCompact(x)) {
  12975. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
  12976. } else {
  12977. const digit* digits = __Pyx_PyLong_Digits(x);
  12978. assert(__Pyx_PyLong_DigitCount(x) > 1);
  12979. switch (__Pyx_PyLong_DigitCount(x)) {
  12980. case 2:
  12981. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  12982. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  12983. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12984. } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
  12985. return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  12986. }
  12987. }
  12988. break;
  12989. case 3:
  12990. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  12991. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  12992. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  12993. } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
  12994. return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  12995. }
  12996. }
  12997. break;
  12998. case 4:
  12999. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  13000. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13001. __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])))
  13002. } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
  13003. return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
  13004. }
  13005. }
  13006. break;
  13007. }
  13008. }
  13009. #endif
  13010. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
  13011. if (unlikely(Py_SIZE(x) < 0)) {
  13012. goto raise_neg_overflow;
  13013. }
  13014. #else
  13015. {
  13016. int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
  13017. if (unlikely(result < 0))
  13018. return (long) -1;
  13019. if (unlikely(result == 1))
  13020. goto raise_neg_overflow;
  13021. }
  13022. #endif
  13023. if ((sizeof(long) <= sizeof(unsigned long))) {
  13024. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
  13025. } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
  13026. __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
  13027. }
  13028. } else {
  13029. #if CYTHON_USE_PYLONG_INTERNALS
  13030. if (__Pyx_PyLong_IsCompact(x)) {
  13031. __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
  13032. } else {
  13033. const digit* digits = __Pyx_PyLong_Digits(x);
  13034. assert(__Pyx_PyLong_DigitCount(x) > 1);
  13035. switch (__Pyx_PyLong_SignedDigitCount(x)) {
  13036. case -2:
  13037. if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
  13038. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13039. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13040. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13041. return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13042. }
  13043. }
  13044. break;
  13045. case 2:
  13046. if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
  13047. if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
  13048. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13049. } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13050. return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13051. }
  13052. }
  13053. break;
  13054. case -3:
  13055. if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
  13056. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13057. __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13058. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13059. return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13060. }
  13061. }
  13062. break;
  13063. case 3:
  13064. if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
  13065. if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
  13066. __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
  13067. } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13068. return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13069. }
  13070. }
  13071. break;
  13072. case -4:
  13073. if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
  13074. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13075. __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])))
  13076. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  13077. return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13078. }
  13079. }
  13080. break;
  13081. case 4:
  13082. if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
  13083. if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
  13084. __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])))
  13085. } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
  13086. return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
  13087. }
  13088. }
  13089. break;
  13090. }
  13091. }
  13092. #endif
  13093. if ((sizeof(long) <= sizeof(long))) {
  13094. __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
  13095. } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
  13096. __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
  13097. }
  13098. }
  13099. {
  13100. long val;
  13101. int ret = -1;
  13102. #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
  13103. Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
  13104. x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
  13105. if (unlikely(bytes_copied == -1)) {
  13106. } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
  13107. goto raise_overflow;
  13108. } else {
  13109. ret = 0;
  13110. }
  13111. #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
  13112. int one = 1; int is_little = (int)*(unsigned char *)&one;
  13113. unsigned char *bytes = (unsigned char *)&val;
  13114. ret = _PyLong_AsByteArray((PyLongObject *)x,
  13115. bytes, sizeof(val),
  13116. is_little, !is_unsigned);
  13117. #else
  13118. PyObject *v;
  13119. PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
  13120. int bits, remaining_bits, is_negative = 0;
  13121. int chunk_size = (sizeof(long) < 8) ? 30 : 62;
  13122. if (likely(PyLong_CheckExact(x))) {
  13123. v = __Pyx_NewRef(x);
  13124. } else {
  13125. v = PyNumber_Long(x);
  13126. if (unlikely(!v)) return (long) -1;
  13127. assert(PyLong_CheckExact(v));
  13128. }
  13129. {
  13130. int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
  13131. if (unlikely(result < 0)) {
  13132. Py_DECREF(v);
  13133. return (long) -1;
  13134. }
  13135. is_negative = result == 1;
  13136. }
  13137. if (is_unsigned && unlikely(is_negative)) {
  13138. Py_DECREF(v);
  13139. goto raise_neg_overflow;
  13140. } else if (is_negative) {
  13141. stepval = PyNumber_Invert(v);
  13142. Py_DECREF(v);
  13143. if (unlikely(!stepval))
  13144. return (long) -1;
  13145. } else {
  13146. stepval = v;
  13147. }
  13148. v = NULL;
  13149. val = (long) 0;
  13150. mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
  13151. shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
  13152. for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
  13153. PyObject *tmp, *digit;
  13154. long idigit;
  13155. digit = PyNumber_And(stepval, mask);
  13156. if (unlikely(!digit)) goto done;
  13157. idigit = PyLong_AsLong(digit);
  13158. Py_DECREF(digit);
  13159. if (unlikely(idigit < 0)) goto done;
  13160. val |= ((long) idigit) << bits;
  13161. tmp = PyNumber_Rshift(stepval, shift);
  13162. if (unlikely(!tmp)) goto done;
  13163. Py_DECREF(stepval); stepval = tmp;
  13164. }
  13165. Py_DECREF(shift); shift = NULL;
  13166. Py_DECREF(mask); mask = NULL;
  13167. {
  13168. long idigit = PyLong_AsLong(stepval);
  13169. if (unlikely(idigit < 0)) goto done;
  13170. remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
  13171. if (unlikely(idigit >= (1L << remaining_bits)))
  13172. goto raise_overflow;
  13173. val |= ((long) idigit) << bits;
  13174. }
  13175. if (!is_unsigned) {
  13176. if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
  13177. goto raise_overflow;
  13178. if (is_negative)
  13179. val = ~val;
  13180. }
  13181. ret = 0;
  13182. done:
  13183. Py_XDECREF(shift);
  13184. Py_XDECREF(mask);
  13185. Py_XDECREF(stepval);
  13186. #endif
  13187. if (unlikely(ret))
  13188. return (long) -1;
  13189. return val;
  13190. }
  13191. raise_overflow:
  13192. PyErr_SetString(PyExc_OverflowError,
  13193. "value too large to convert to long");
  13194. return (long) -1;
  13195. raise_neg_overflow:
  13196. PyErr_SetString(PyExc_OverflowError,
  13197. "can't convert negative value to long");
  13198. return (long) -1;
  13199. }
  13200. /* FastTypeChecks */
  13201. #if CYTHON_COMPILING_IN_CPYTHON
  13202. static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
  13203. while (a) {
  13204. a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
  13205. if (a == b)
  13206. return 1;
  13207. }
  13208. return b == &PyBaseObject_Type;
  13209. }
  13210. static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
  13211. PyObject *mro;
  13212. if (a == b) return 1;
  13213. mro = a->tp_mro;
  13214. if (likely(mro)) {
  13215. Py_ssize_t i, n;
  13216. n = PyTuple_GET_SIZE(mro);
  13217. for (i = 0; i < n; i++) {
  13218. if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
  13219. return 1;
  13220. }
  13221. return 0;
  13222. }
  13223. return __Pyx_InBases(a, b);
  13224. }
  13225. static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
  13226. PyObject *mro;
  13227. if (cls == a || cls == b) return 1;
  13228. mro = cls->tp_mro;
  13229. if (likely(mro)) {
  13230. Py_ssize_t i, n;
  13231. n = PyTuple_GET_SIZE(mro);
  13232. for (i = 0; i < n; i++) {
  13233. PyObject *base = PyTuple_GET_ITEM(mro, i);
  13234. if (base == (PyObject *)a || base == (PyObject *)b)
  13235. return 1;
  13236. }
  13237. return 0;
  13238. }
  13239. return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
  13240. }
  13241. static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
  13242. if (exc_type1) {
  13243. return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2);
  13244. } else {
  13245. return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
  13246. }
  13247. }
  13248. static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
  13249. Py_ssize_t i, n;
  13250. assert(PyExceptionClass_Check(exc_type));
  13251. n = PyTuple_GET_SIZE(tuple);
  13252. for (i=0; i<n; i++) {
  13253. if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
  13254. }
  13255. for (i=0; i<n; i++) {
  13256. PyObject *t = PyTuple_GET_ITEM(tuple, i);
  13257. if (likely(PyExceptionClass_Check(t))) {
  13258. if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
  13259. } else {
  13260. }
  13261. }
  13262. return 0;
  13263. }
  13264. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
  13265. if (likely(err == exc_type)) return 1;
  13266. if (likely(PyExceptionClass_Check(err))) {
  13267. if (likely(PyExceptionClass_Check(exc_type))) {
  13268. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
  13269. } else if (likely(PyTuple_Check(exc_type))) {
  13270. return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
  13271. } else {
  13272. }
  13273. }
  13274. return PyErr_GivenExceptionMatches(err, exc_type);
  13275. }
  13276. static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
  13277. assert(PyExceptionClass_Check(exc_type1));
  13278. assert(PyExceptionClass_Check(exc_type2));
  13279. if (likely(err == exc_type1 || err == exc_type2)) return 1;
  13280. if (likely(PyExceptionClass_Check(err))) {
  13281. return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
  13282. }
  13283. return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
  13284. }
  13285. #endif
  13286. /* GetRuntimeVersion */
  13287. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  13288. void __Pyx_init_runtime_version(void) {
  13289. if (__Pyx_cached_runtime_version == 0) {
  13290. const char* rt_version = Py_GetVersion();
  13291. unsigned long version = 0;
  13292. unsigned long factor = 0x01000000UL;
  13293. unsigned int digit = 0;
  13294. int i = 0;
  13295. while (factor) {
  13296. while ('0' <= rt_version[i] && rt_version[i] <= '9') {
  13297. digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
  13298. ++i;
  13299. }
  13300. version += factor * digit;
  13301. if (rt_version[i] != '.')
  13302. break;
  13303. digit = 0;
  13304. factor >>= 8;
  13305. ++i;
  13306. }
  13307. __Pyx_cached_runtime_version = version;
  13308. }
  13309. }
  13310. #endif
  13311. static unsigned long __Pyx_get_runtime_version(void) {
  13312. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  13313. return Py_Version & ~0xFFUL;
  13314. #else
  13315. return __Pyx_cached_runtime_version;
  13316. #endif
  13317. }
  13318. /* SwapException (used by CoroutineBase) */
  13319. #if CYTHON_FAST_THREAD_STATE
  13320. static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  13321. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13322. #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
  13323. _PyErr_StackItem *exc_info = tstate->exc_info;
  13324. tmp_value = exc_info->exc_value;
  13325. exc_info->exc_value = *value;
  13326. if (tmp_value == NULL || tmp_value == Py_None) {
  13327. Py_XDECREF(tmp_value);
  13328. tmp_value = NULL;
  13329. tmp_type = NULL;
  13330. tmp_tb = NULL;
  13331. } else {
  13332. tmp_type = (PyObject*) Py_TYPE(tmp_value);
  13333. Py_INCREF(tmp_type);
  13334. #if CYTHON_COMPILING_IN_CPYTHON
  13335. tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
  13336. Py_XINCREF(tmp_tb);
  13337. #else
  13338. tmp_tb = PyException_GetTraceback(tmp_value);
  13339. #endif
  13340. }
  13341. #elif CYTHON_USE_EXC_INFO_STACK
  13342. _PyErr_StackItem *exc_info = tstate->exc_info;
  13343. tmp_type = exc_info->exc_type;
  13344. tmp_value = exc_info->exc_value;
  13345. tmp_tb = exc_info->exc_traceback;
  13346. exc_info->exc_type = *type;
  13347. exc_info->exc_value = *value;
  13348. exc_info->exc_traceback = *tb;
  13349. #else
  13350. tmp_type = tstate->exc_type;
  13351. tmp_value = tstate->exc_value;
  13352. tmp_tb = tstate->exc_traceback;
  13353. tstate->exc_type = *type;
  13354. tstate->exc_value = *value;
  13355. tstate->exc_traceback = *tb;
  13356. #endif
  13357. *type = tmp_type;
  13358. *value = tmp_value;
  13359. *tb = tmp_tb;
  13360. }
  13361. #else
  13362. static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
  13363. PyObject *tmp_type, *tmp_value, *tmp_tb;
  13364. PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
  13365. PyErr_SetExcInfo(*type, *value, *tb);
  13366. *type = tmp_type;
  13367. *value = tmp_value;
  13368. *tb = tmp_tb;
  13369. }
  13370. #endif
  13371. /* PyObjectCall2Args (used by PyObjectCallMethod1) */
  13372. static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
  13373. PyObject *args[3] = {NULL, arg1, arg2};
  13374. return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  13375. }
  13376. /* PyObjectCallMethod1 (used by CoroutineBase) */
  13377. #if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
  13378. static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
  13379. PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
  13380. Py_DECREF(method);
  13381. return result;
  13382. }
  13383. #endif
  13384. static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
  13385. #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
  13386. PyObject *args[2] = {obj, arg};
  13387. (void) __Pyx_PyObject_CallOneArg;
  13388. (void) __Pyx_PyObject_Call2Args;
  13389. return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  13390. #else
  13391. PyObject *method = NULL, *result;
  13392. int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
  13393. if (likely(is_method)) {
  13394. result = __Pyx_PyObject_Call2Args(method, obj, arg);
  13395. Py_DECREF(method);
  13396. return result;
  13397. }
  13398. if (unlikely(!method)) return NULL;
  13399. return __Pyx__PyObject_CallMethod1(method, arg);
  13400. #endif
  13401. }
  13402. /* ReturnWithStopIteration (used by CoroutineBase) */
  13403. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async);
  13404. static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext) {
  13405. if (value == Py_None) {
  13406. if (async || !iternext)
  13407. PyErr_SetNone(async ? PyExc_StopAsyncIteration : PyExc_StopIteration);
  13408. return;
  13409. }
  13410. __Pyx__ReturnWithStopIteration(value, async);
  13411. }
  13412. static void __Pyx__ReturnWithStopIteration(PyObject* value, int async) {
  13413. #if CYTHON_COMPILING_IN_CPYTHON
  13414. __Pyx_PyThreadState_declare
  13415. #endif
  13416. PyObject *exc;
  13417. PyObject *exc_type = async ? PyExc_StopAsyncIteration : PyExc_StopIteration;
  13418. #if CYTHON_COMPILING_IN_CPYTHON
  13419. if ((PY_VERSION_HEX >= (0x030C00A6)) || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
  13420. if (PY_VERSION_HEX >= (0x030e00A1)) {
  13421. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  13422. } else {
  13423. PyObject *args_tuple = PyTuple_New(1);
  13424. if (unlikely(!args_tuple)) return;
  13425. Py_INCREF(value);
  13426. PyTuple_SET_ITEM(args_tuple, 0, value);
  13427. exc = PyObject_Call(exc_type, args_tuple, NULL);
  13428. Py_DECREF(args_tuple);
  13429. }
  13430. if (unlikely(!exc)) return;
  13431. } else {
  13432. Py_INCREF(value);
  13433. exc = value;
  13434. }
  13435. #if CYTHON_FAST_THREAD_STATE
  13436. __Pyx_PyThreadState_assign
  13437. #if CYTHON_USE_EXC_INFO_STACK
  13438. if (!__pyx_tstate->exc_info->exc_value)
  13439. #else
  13440. if (!__pyx_tstate->exc_type)
  13441. #endif
  13442. {
  13443. Py_INCREF(exc_type);
  13444. __Pyx_ErrRestore(exc_type, exc, NULL);
  13445. return;
  13446. }
  13447. #endif
  13448. #else
  13449. exc = __Pyx_PyObject_CallOneArg(exc_type, value);
  13450. if (unlikely(!exc)) return;
  13451. #endif
  13452. PyErr_SetObject(exc_type, exc);
  13453. Py_DECREF(exc);
  13454. }
  13455. /* CoroutineBase (used by Generator) */
  13456. #if !CYTHON_COMPILING_IN_LIMITED_API
  13457. #include <frameobject.h>
  13458. #if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
  13459. #ifndef Py_BUILD_CORE
  13460. #define Py_BUILD_CORE 1
  13461. #endif
  13462. #include "internal/pycore_frame.h"
  13463. #endif
  13464. #endif // CYTHON_COMPILING_IN_LIMITED_API
  13465. static CYTHON_INLINE void
  13466. __Pyx_Coroutine_Undelegate(__pyx_CoroutineObject *gen) {
  13467. #if CYTHON_USE_AM_SEND
  13468. gen->yieldfrom_am_send = NULL;
  13469. #endif
  13470. Py_CLEAR(gen->yieldfrom);
  13471. }
  13472. static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *__pyx_tstate, PyObject **pvalue) {
  13473. PyObject *et, *ev, *tb;
  13474. PyObject *value = NULL;
  13475. CYTHON_UNUSED_VAR(__pyx_tstate);
  13476. __Pyx_ErrFetch(&et, &ev, &tb);
  13477. if (!et) {
  13478. Py_XDECREF(tb);
  13479. Py_XDECREF(ev);
  13480. Py_INCREF(Py_None);
  13481. *pvalue = Py_None;
  13482. return 0;
  13483. }
  13484. if (likely(et == PyExc_StopIteration)) {
  13485. if (!ev) {
  13486. Py_INCREF(Py_None);
  13487. value = Py_None;
  13488. }
  13489. else if (likely(__Pyx_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) {
  13490. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
  13491. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  13492. if (unlikely(!value)) goto limited_api_failure;
  13493. #else
  13494. value = ((PyStopIterationObject *)ev)->value;
  13495. Py_INCREF(value);
  13496. #endif
  13497. Py_DECREF(ev);
  13498. }
  13499. else if (unlikely(PyTuple_Check(ev))) {
  13500. Py_ssize_t tuple_size = __Pyx_PyTuple_GET_SIZE(ev);
  13501. #if !CYTHON_ASSUME_SAFE_SIZE
  13502. if (unlikely(tuple_size < 0)) {
  13503. Py_XDECREF(tb);
  13504. Py_DECREF(ev);
  13505. Py_DECREF(et);
  13506. return -1;
  13507. }
  13508. #endif
  13509. if (tuple_size >= 1) {
  13510. #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
  13511. value = PyTuple_GET_ITEM(ev, 0);
  13512. Py_INCREF(value);
  13513. #elif CYTHON_ASSUME_SAFE_MACROS
  13514. value = PySequence_ITEM(ev, 0);
  13515. #else
  13516. value = PySequence_GetItem(ev, 0);
  13517. if (!value) goto limited_api_failure;
  13518. #endif
  13519. } else {
  13520. Py_INCREF(Py_None);
  13521. value = Py_None;
  13522. }
  13523. Py_DECREF(ev);
  13524. }
  13525. else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
  13526. value = ev;
  13527. }
  13528. if (likely(value)) {
  13529. Py_XDECREF(tb);
  13530. Py_DECREF(et);
  13531. *pvalue = value;
  13532. return 0;
  13533. }
  13534. } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
  13535. __Pyx_ErrRestore(et, ev, tb);
  13536. return -1;
  13537. }
  13538. PyErr_NormalizeException(&et, &ev, &tb);
  13539. if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
  13540. __Pyx_ErrRestore(et, ev, tb);
  13541. return -1;
  13542. }
  13543. Py_XDECREF(tb);
  13544. Py_DECREF(et);
  13545. #if CYTHON_COMPILING_IN_LIMITED_API
  13546. value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
  13547. #else
  13548. value = ((PyStopIterationObject *)ev)->value;
  13549. Py_INCREF(value);
  13550. #endif
  13551. Py_DECREF(ev);
  13552. #if CYTHON_COMPILING_IN_LIMITED_API
  13553. if (unlikely(!value)) return -1;
  13554. #endif
  13555. *pvalue = value;
  13556. return 0;
  13557. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL || !CYTHON_ASSUME_SAFE_MACROS
  13558. limited_api_failure:
  13559. Py_XDECREF(et);
  13560. Py_XDECREF(tb);
  13561. Py_XDECREF(ev);
  13562. return -1;
  13563. #endif
  13564. }
  13565. static CYTHON_INLINE
  13566. __Pyx_PySendResult __Pyx_Coroutine_status_from_result(PyObject **retval) {
  13567. if (*retval) {
  13568. return PYGEN_NEXT;
  13569. } else if (likely(__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, retval) == 0)) {
  13570. return PYGEN_RETURN;
  13571. } else {
  13572. return PYGEN_ERROR;
  13573. }
  13574. }
  13575. static CYTHON_INLINE
  13576. void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
  13577. #if PY_VERSION_HEX >= 0x030B00a4
  13578. Py_CLEAR(exc_state->exc_value);
  13579. #else
  13580. PyObject *t, *v, *tb;
  13581. t = exc_state->exc_type;
  13582. v = exc_state->exc_value;
  13583. tb = exc_state->exc_traceback;
  13584. exc_state->exc_type = NULL;
  13585. exc_state->exc_value = NULL;
  13586. exc_state->exc_traceback = NULL;
  13587. Py_XDECREF(t);
  13588. Py_XDECREF(v);
  13589. Py_XDECREF(tb);
  13590. #endif
  13591. }
  13592. #define __Pyx_Coroutine_AlreadyRunningError(gen) (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
  13593. static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) {
  13594. const char *msg;
  13595. CYTHON_MAYBE_UNUSED_VAR(gen);
  13596. if ((0)) {
  13597. #ifdef __Pyx_Coroutine_USED
  13598. } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
  13599. msg = "coroutine already executing";
  13600. #endif
  13601. #ifdef __Pyx_AsyncGen_USED
  13602. } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
  13603. msg = "async generator already executing";
  13604. #endif
  13605. } else {
  13606. msg = "generator already executing";
  13607. }
  13608. PyErr_SetString(PyExc_ValueError, msg);
  13609. }
  13610. static void __Pyx_Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) {
  13611. CYTHON_MAYBE_UNUSED_VAR(gen);
  13612. CYTHON_MAYBE_UNUSED_VAR(closing);
  13613. #ifdef __Pyx_Coroutine_USED
  13614. if (!closing && __Pyx_Coroutine_Check(gen)) {
  13615. PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
  13616. } else
  13617. #endif
  13618. if (value) {
  13619. #ifdef __Pyx_AsyncGen_USED
  13620. if (__Pyx_AsyncGen_CheckExact(gen))
  13621. PyErr_SetNone(PyExc_StopAsyncIteration);
  13622. else
  13623. #endif
  13624. PyErr_SetNone(PyExc_StopIteration);
  13625. }
  13626. }
  13627. static
  13628. __Pyx_PySendResult __Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, PyObject **result, int closing) {
  13629. __Pyx_PyThreadState_declare
  13630. PyThreadState *tstate;
  13631. __Pyx_ExcInfoStruct *exc_state;
  13632. PyObject *retval;
  13633. assert(__Pyx_Coroutine_get_is_running(self)); // Callers should ensure is_running
  13634. if (unlikely(self->resume_label == -1)) {
  13635. __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
  13636. return PYGEN_ERROR;
  13637. }
  13638. #if CYTHON_FAST_THREAD_STATE
  13639. __Pyx_PyThreadState_assign
  13640. tstate = __pyx_tstate;
  13641. #else
  13642. tstate = __Pyx_PyThreadState_Current;
  13643. #endif
  13644. exc_state = &self->gi_exc_state;
  13645. if (exc_state->exc_value) {
  13646. #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
  13647. #else
  13648. PyObject *exc_tb;
  13649. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  13650. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  13651. #elif PY_VERSION_HEX >= 0x030B00a4
  13652. exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback;
  13653. #else
  13654. exc_tb = exc_state->exc_traceback;
  13655. #endif
  13656. if (exc_tb) {
  13657. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  13658. PyFrameObject *f = tb->tb_frame;
  13659. assert(f->f_back == NULL);
  13660. #if PY_VERSION_HEX >= 0x030B00A1
  13661. f->f_back = PyThreadState_GetFrame(tstate);
  13662. #else
  13663. Py_XINCREF(tstate->frame);
  13664. f->f_back = tstate->frame;
  13665. #endif
  13666. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
  13667. Py_DECREF(exc_tb);
  13668. #endif
  13669. }
  13670. #endif
  13671. }
  13672. #if CYTHON_USE_EXC_INFO_STACK
  13673. exc_state->previous_item = tstate->exc_info;
  13674. tstate->exc_info = exc_state;
  13675. #else
  13676. if (exc_state->exc_type) {
  13677. __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  13678. } else {
  13679. __Pyx_Coroutine_ExceptionClear(exc_state);
  13680. __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
  13681. }
  13682. #endif
  13683. retval = self->body(self, tstate, value);
  13684. #if CYTHON_USE_EXC_INFO_STACK
  13685. exc_state = &self->gi_exc_state;
  13686. tstate->exc_info = exc_state->previous_item;
  13687. exc_state->previous_item = NULL;
  13688. __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
  13689. #endif
  13690. *result = retval;
  13691. if (self->resume_label == -1) {
  13692. return likely(retval) ? PYGEN_RETURN : PYGEN_ERROR;
  13693. }
  13694. return PYGEN_NEXT;
  13695. }
  13696. static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
  13697. #if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
  13698. CYTHON_UNUSED_VAR(exc_state);
  13699. #else
  13700. PyObject *exc_tb;
  13701. #if PY_VERSION_HEX >= 0x030B00a4
  13702. if (!exc_state->exc_value) return;
  13703. exc_tb = PyException_GetTraceback(exc_state->exc_value);
  13704. #else
  13705. exc_tb = exc_state->exc_traceback;
  13706. #endif
  13707. if (likely(exc_tb)) {
  13708. PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
  13709. PyFrameObject *f = tb->tb_frame;
  13710. Py_CLEAR(f->f_back);
  13711. #if PY_VERSION_HEX >= 0x030B00a4
  13712. Py_DECREF(exc_tb);
  13713. #endif
  13714. }
  13715. #endif
  13716. }
  13717. #define __Pyx_Coroutine_MethodReturnFromResult(gen, result, retval, iternext)\
  13718. ((result) == PYGEN_NEXT ? (retval) : __Pyx__Coroutine_MethodReturnFromResult(gen, result, retval, iternext))
  13719. static PyObject *
  13720. __Pyx__Coroutine_MethodReturnFromResult(PyObject* gen, __Pyx_PySendResult result, PyObject *retval, int iternext) {
  13721. CYTHON_MAYBE_UNUSED_VAR(gen);
  13722. if (likely(result == PYGEN_RETURN)) {
  13723. int is_async = 0;
  13724. #ifdef __Pyx_AsyncGen_USED
  13725. is_async = __Pyx_AsyncGen_CheckExact(gen);
  13726. #endif
  13727. __Pyx_ReturnWithStopIteration(retval, is_async, iternext);
  13728. Py_XDECREF(retval);
  13729. }
  13730. return NULL;
  13731. }
  13732. #if CYTHON_COMPILING_IN_CPYTHON
  13733. static CYTHON_INLINE
  13734. PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
  13735. #if PY_VERSION_HEX <= 0x030A00A1
  13736. return _PyGen_Send(gen, arg);
  13737. #else
  13738. PyObject *result;
  13739. if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
  13740. if (PyAsyncGen_CheckExact(gen)) {
  13741. assert(result == Py_None);
  13742. PyErr_SetNone(PyExc_StopAsyncIteration);
  13743. }
  13744. else if (result == Py_None) {
  13745. PyErr_SetNone(PyExc_StopIteration);
  13746. }
  13747. else {
  13748. #if PY_VERSION_HEX < 0x030d00A1
  13749. _PyGen_SetStopIterationValue(result);
  13750. #else
  13751. if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) {
  13752. PyErr_SetObject(PyExc_StopIteration, result);
  13753. } else {
  13754. PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result);
  13755. if (likely(exc != NULL)) {
  13756. PyErr_SetObject(PyExc_StopIteration, exc);
  13757. Py_DECREF(exc);
  13758. }
  13759. }
  13760. #endif
  13761. }
  13762. Py_DECREF(result);
  13763. result = NULL;
  13764. }
  13765. return result;
  13766. #endif
  13767. }
  13768. #endif
  13769. static CYTHON_INLINE __Pyx_PySendResult
  13770. __Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen, PyObject** retval) {
  13771. __Pyx_PySendResult result;
  13772. PyObject *val = NULL;
  13773. assert(__Pyx_Coroutine_get_is_running(gen));
  13774. __Pyx_Coroutine_Undelegate(gen);
  13775. __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
  13776. result = __Pyx_Coroutine_SendEx(gen, val, retval, 0);
  13777. Py_XDECREF(val);
  13778. return result;
  13779. }
  13780. #if CYTHON_USE_AM_SEND
  13781. static __Pyx_PySendResult
  13782. __Pyx_Coroutine_SendToDelegate(__pyx_CoroutineObject *gen, __Pyx_pyiter_sendfunc gen_am_send, PyObject *value, PyObject **retval) {
  13783. PyObject *ret = NULL;
  13784. __Pyx_PySendResult delegate_result, result;
  13785. assert(__Pyx_Coroutine_get_is_running(gen));
  13786. delegate_result = gen_am_send(gen->yieldfrom, value, &ret);
  13787. if (delegate_result == PYGEN_NEXT) {
  13788. assert (ret != NULL);
  13789. *retval = ret;
  13790. return PYGEN_NEXT;
  13791. }
  13792. assert (delegate_result != PYGEN_ERROR || ret == NULL);
  13793. __Pyx_Coroutine_Undelegate(gen);
  13794. result = __Pyx_Coroutine_SendEx(gen, ret, retval, 0);
  13795. Py_XDECREF(ret);
  13796. return result;
  13797. }
  13798. #endif
  13799. static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
  13800. PyObject *retval = NULL;
  13801. __Pyx_PySendResult result = __Pyx_Coroutine_AmSend(self, value, &retval);
  13802. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  13803. }
  13804. static __Pyx_PySendResult
  13805. __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
  13806. __Pyx_PySendResult result;
  13807. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  13808. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  13809. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  13810. return PYGEN_ERROR;
  13811. }
  13812. #if CYTHON_USE_AM_SEND
  13813. if (gen->yieldfrom_am_send) {
  13814. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, value, retval);
  13815. } else
  13816. #endif
  13817. if (gen->yieldfrom) {
  13818. PyObject *yf = gen->yieldfrom;
  13819. PyObject *ret;
  13820. #if !CYTHON_USE_AM_SEND
  13821. #ifdef __Pyx_Generator_USED
  13822. if (__Pyx_Generator_CheckExact(yf)) {
  13823. ret = __Pyx_Coroutine_Send(yf, value);
  13824. } else
  13825. #endif
  13826. #ifdef __Pyx_Coroutine_USED
  13827. if (__Pyx_Coroutine_Check(yf)) {
  13828. ret = __Pyx_Coroutine_Send(yf, value);
  13829. } else
  13830. #endif
  13831. #ifdef __Pyx_AsyncGen_USED
  13832. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  13833. ret = __Pyx_async_gen_asend_send(yf, value);
  13834. } else
  13835. #endif
  13836. #if CYTHON_COMPILING_IN_CPYTHON
  13837. if (PyGen_CheckExact(yf)) {
  13838. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  13839. } else
  13840. if (PyCoro_CheckExact(yf)) {
  13841. ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
  13842. } else
  13843. #endif
  13844. #endif
  13845. {
  13846. #if !CYTHON_COMPILING_IN_LIMITED_API || __PYX_LIMITED_VERSION_HEX >= 0x03080000
  13847. if (value == Py_None && PyIter_Check(yf))
  13848. ret = __Pyx_PyIter_Next_Plain(yf);
  13849. else
  13850. #endif
  13851. ret = __Pyx_PyObject_CallMethod1(yf, __pyx_mstate_global->__pyx_n_u_send, value);
  13852. }
  13853. if (likely(ret)) {
  13854. __Pyx_Coroutine_unset_is_running(gen);
  13855. *retval = ret;
  13856. return PYGEN_NEXT;
  13857. }
  13858. result = __Pyx_Coroutine_FinishDelegation(gen, retval);
  13859. } else {
  13860. result = __Pyx_Coroutine_SendEx(gen, value, retval, 0);
  13861. }
  13862. __Pyx_Coroutine_unset_is_running(gen);
  13863. return result;
  13864. }
  13865. static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
  13866. __Pyx_PySendResult result;
  13867. PyObject *retval = NULL;
  13868. CYTHON_UNUSED_VAR(gen);
  13869. assert(__Pyx_Coroutine_get_is_running(gen));
  13870. #ifdef __Pyx_Generator_USED
  13871. if (__Pyx_Generator_CheckExact(yf)) {
  13872. result = __Pyx_Coroutine_Close(yf, &retval);
  13873. } else
  13874. #endif
  13875. #ifdef __Pyx_Coroutine_USED
  13876. if (__Pyx_Coroutine_Check(yf)) {
  13877. result = __Pyx_Coroutine_Close(yf, &retval);
  13878. } else
  13879. if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  13880. result = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
  13881. } else
  13882. #endif
  13883. #ifdef __Pyx_AsyncGen_USED
  13884. if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
  13885. retval = __Pyx_async_gen_asend_close(yf, NULL);
  13886. result = PYGEN_RETURN;
  13887. } else
  13888. if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
  13889. retval = __Pyx_async_gen_athrow_close(yf, NULL);
  13890. result = PYGEN_RETURN;
  13891. } else
  13892. #endif
  13893. {
  13894. PyObject *meth;
  13895. result = PYGEN_RETURN;
  13896. meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_close);
  13897. if (unlikely(!meth)) {
  13898. if (unlikely(PyErr_Occurred())) {
  13899. PyErr_WriteUnraisable(yf);
  13900. }
  13901. } else {
  13902. retval = __Pyx_PyObject_CallNoArg(meth);
  13903. Py_DECREF(meth);
  13904. if (unlikely(!retval)) {
  13905. result = PYGEN_ERROR;
  13906. }
  13907. }
  13908. }
  13909. Py_XDECREF(retval);
  13910. return result == PYGEN_ERROR ? -1 : 0;
  13911. }
  13912. static PyObject *__Pyx_Generator_Next(PyObject *self) {
  13913. __Pyx_PySendResult result;
  13914. PyObject *retval = NULL;
  13915. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  13916. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  13917. return __Pyx_Coroutine_AlreadyRunningError(gen);
  13918. }
  13919. #if CYTHON_USE_AM_SEND
  13920. if (gen->yieldfrom_am_send) {
  13921. result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, Py_None, &retval);
  13922. } else
  13923. #endif
  13924. if (gen->yieldfrom) {
  13925. PyObject *yf = gen->yieldfrom;
  13926. PyObject *ret;
  13927. #ifdef __Pyx_Generator_USED
  13928. if (__Pyx_Generator_CheckExact(yf)) {
  13929. ret = __Pyx_Generator_Next(yf);
  13930. } else
  13931. #endif
  13932. #ifdef __Pyx_Coroutine_USED
  13933. if (__Pyx_Coroutine_CheckExact(yf)) {
  13934. ret = __Pyx_Coroutine_Send(yf, Py_None);
  13935. } else
  13936. #endif
  13937. #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX < 0x030A00A3 || !CYTHON_USE_AM_SEND)
  13938. if (PyGen_CheckExact(yf)) {
  13939. ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
  13940. } else
  13941. #endif
  13942. ret = __Pyx_PyIter_Next_Plain(yf);
  13943. if (likely(ret)) {
  13944. __Pyx_Coroutine_unset_is_running(gen);
  13945. return ret;
  13946. }
  13947. result = __Pyx_Coroutine_FinishDelegation(gen, &retval);
  13948. } else {
  13949. result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  13950. }
  13951. __Pyx_Coroutine_unset_is_running(gen);
  13952. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 1);
  13953. }
  13954. static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) {
  13955. PyObject *retval = NULL;
  13956. __Pyx_PySendResult result;
  13957. CYTHON_UNUSED_VAR(arg);
  13958. result = __Pyx_Coroutine_Close(self, &retval);
  13959. if (unlikely(result == PYGEN_ERROR))
  13960. return NULL;
  13961. Py_XDECREF(retval);
  13962. Py_RETURN_NONE;
  13963. }
  13964. static __Pyx_PySendResult
  13965. __Pyx_Coroutine_Close(PyObject *self, PyObject **retval) {
  13966. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  13967. __Pyx_PySendResult result;
  13968. PyObject *yf;
  13969. int err = 0;
  13970. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  13971. *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
  13972. return PYGEN_ERROR;
  13973. }
  13974. yf = gen->yieldfrom;
  13975. if (yf) {
  13976. Py_INCREF(yf);
  13977. err = __Pyx_Coroutine_CloseIter(gen, yf);
  13978. __Pyx_Coroutine_Undelegate(gen);
  13979. Py_DECREF(yf);
  13980. }
  13981. if (err == 0)
  13982. PyErr_SetNone(PyExc_GeneratorExit);
  13983. result = __Pyx_Coroutine_SendEx(gen, NULL, retval, 1);
  13984. if (result == PYGEN_ERROR) {
  13985. __Pyx_PyThreadState_declare
  13986. __Pyx_PyThreadState_assign
  13987. __Pyx_Coroutine_unset_is_running(gen);
  13988. if (!__Pyx_PyErr_Occurred()) {
  13989. return PYGEN_RETURN;
  13990. } else if (likely(__Pyx_PyErr_ExceptionMatches2(PyExc_GeneratorExit, PyExc_StopIteration))) {
  13991. __Pyx_PyErr_Clear();
  13992. return PYGEN_RETURN;
  13993. }
  13994. return PYGEN_ERROR;
  13995. } else if (likely(result == PYGEN_RETURN && *retval == Py_None)) {
  13996. __Pyx_Coroutine_unset_is_running(gen);
  13997. return PYGEN_RETURN;
  13998. } else {
  13999. const char *msg;
  14000. Py_DECREF(*retval);
  14001. *retval = NULL;
  14002. if ((0)) {
  14003. #ifdef __Pyx_Coroutine_USED
  14004. } else if (__Pyx_Coroutine_Check(self)) {
  14005. msg = "coroutine ignored GeneratorExit";
  14006. #endif
  14007. #ifdef __Pyx_AsyncGen_USED
  14008. } else if (__Pyx_AsyncGen_CheckExact(self)) {
  14009. msg = "async generator ignored GeneratorExit";
  14010. #endif
  14011. } else {
  14012. msg = "generator ignored GeneratorExit";
  14013. }
  14014. PyErr_SetString(PyExc_RuntimeError, msg);
  14015. __Pyx_Coroutine_unset_is_running(gen);
  14016. return PYGEN_ERROR;
  14017. }
  14018. }
  14019. static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
  14020. PyObject *args, int close_on_genexit) {
  14021. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14022. PyObject *yf;
  14023. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen)))
  14024. return __Pyx_Coroutine_AlreadyRunningError(gen);
  14025. yf = gen->yieldfrom;
  14026. if (yf) {
  14027. __Pyx_PySendResult result;
  14028. PyObject *ret;
  14029. Py_INCREF(yf);
  14030. if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
  14031. int err = __Pyx_Coroutine_CloseIter(gen, yf);
  14032. Py_DECREF(yf);
  14033. __Pyx_Coroutine_Undelegate(gen);
  14034. if (err < 0)
  14035. goto propagate_exception;
  14036. goto throw_here;
  14037. }
  14038. if (0
  14039. #ifdef __Pyx_Generator_USED
  14040. || __Pyx_Generator_CheckExact(yf)
  14041. #endif
  14042. #ifdef __Pyx_Coroutine_USED
  14043. || __Pyx_Coroutine_Check(yf)
  14044. #endif
  14045. ) {
  14046. ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
  14047. #ifdef __Pyx_Coroutine_USED
  14048. } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
  14049. ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
  14050. #endif
  14051. } else {
  14052. PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_throw);
  14053. if (unlikely(!meth)) {
  14054. Py_DECREF(yf);
  14055. if (unlikely(PyErr_Occurred())) {
  14056. __Pyx_Coroutine_unset_is_running(gen);
  14057. return NULL;
  14058. }
  14059. __Pyx_Coroutine_Undelegate(gen);
  14060. goto throw_here;
  14061. }
  14062. if (likely(args)) {
  14063. ret = __Pyx_PyObject_Call(meth, args, NULL);
  14064. } else {
  14065. PyObject *cargs[4] = {NULL, typ, val, tb};
  14066. ret = __Pyx_PyObject_FastCall(meth, cargs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
  14067. }
  14068. Py_DECREF(meth);
  14069. }
  14070. Py_DECREF(yf);
  14071. if (ret) {
  14072. __Pyx_Coroutine_unset_is_running(gen);
  14073. return ret;
  14074. }
  14075. result = __Pyx_Coroutine_FinishDelegation(gen, &ret);
  14076. __Pyx_Coroutine_unset_is_running(gen);
  14077. return __Pyx_Coroutine_MethodReturnFromResult(self, result, ret, 0);
  14078. }
  14079. throw_here:
  14080. __Pyx_Raise(typ, val, tb, NULL);
  14081. propagate_exception:
  14082. {
  14083. PyObject *retval = NULL;
  14084. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, NULL, &retval, 0);
  14085. __Pyx_Coroutine_unset_is_running(gen);
  14086. return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
  14087. }
  14088. }
  14089. static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
  14090. PyObject *typ;
  14091. PyObject *val = NULL;
  14092. PyObject *tb = NULL;
  14093. if (unlikely(!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)))
  14094. return NULL;
  14095. return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
  14096. }
  14097. static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
  14098. #if PY_VERSION_HEX >= 0x030B00a4
  14099. Py_VISIT(exc_state->exc_value);
  14100. #else
  14101. Py_VISIT(exc_state->exc_type);
  14102. Py_VISIT(exc_state->exc_value);
  14103. Py_VISIT(exc_state->exc_traceback);
  14104. #endif
  14105. return 0;
  14106. }
  14107. static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
  14108. {
  14109. int e = __Pyx_call_type_traverse((PyObject*)gen, 1, visit, arg);
  14110. if (e) return e;
  14111. }
  14112. Py_VISIT(gen->closure);
  14113. Py_VISIT(gen->classobj);
  14114. Py_VISIT(gen->yieldfrom);
  14115. return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
  14116. }
  14117. static int __Pyx_Coroutine_clear(PyObject *self) {
  14118. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14119. Py_CLEAR(gen->closure);
  14120. Py_CLEAR(gen->classobj);
  14121. __Pyx_Coroutine_Undelegate(gen);
  14122. __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
  14123. #ifdef __Pyx_AsyncGen_USED
  14124. if (__Pyx_AsyncGen_CheckExact(self)) {
  14125. Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
  14126. }
  14127. #endif
  14128. Py_CLEAR(gen->gi_code);
  14129. Py_CLEAR(gen->gi_frame);
  14130. Py_CLEAR(gen->gi_name);
  14131. Py_CLEAR(gen->gi_qualname);
  14132. Py_CLEAR(gen->gi_modulename);
  14133. return 0;
  14134. }
  14135. static void __Pyx_Coroutine_dealloc(PyObject *self) {
  14136. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14137. PyObject_GC_UnTrack(gen);
  14138. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  14139. if (gen->gi_weakreflist != NULL)
  14140. #endif
  14141. PyObject_ClearWeakRefs(self);
  14142. if (gen->resume_label >= 0) {
  14143. PyObject_GC_Track(self);
  14144. #if CYTHON_USE_TP_FINALIZE
  14145. if (unlikely(PyObject_CallFinalizerFromDealloc(self)))
  14146. #else
  14147. {
  14148. destructor del = __Pyx_PyObject_GetSlot(gen, tp_del, destructor);
  14149. if (del) del(self);
  14150. }
  14151. if (unlikely(Py_REFCNT(self) > 0))
  14152. #endif
  14153. {
  14154. return;
  14155. }
  14156. PyObject_GC_UnTrack(self);
  14157. }
  14158. #ifdef __Pyx_AsyncGen_USED
  14159. if (__Pyx_AsyncGen_CheckExact(self)) {
  14160. /* We have to handle this case for asynchronous generators
  14161. right here, because this code has to be between UNTRACK
  14162. and GC_Del. */
  14163. Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
  14164. }
  14165. #endif
  14166. __Pyx_Coroutine_clear(self);
  14167. __Pyx_PyHeapTypeObject_GC_Del(gen);
  14168. }
  14169. #if CYTHON_USE_TP_FINALIZE
  14170. static void __Pyx_Coroutine_del(PyObject *self) {
  14171. PyObject *error_type, *error_value, *error_traceback;
  14172. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
  14173. __Pyx_PyThreadState_declare
  14174. if (gen->resume_label < 0) {
  14175. return;
  14176. }
  14177. __Pyx_PyThreadState_assign
  14178. __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
  14179. #ifdef __Pyx_AsyncGen_USED
  14180. if (__Pyx_AsyncGen_CheckExact(self)) {
  14181. __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
  14182. PyObject *finalizer = agen->ag_finalizer;
  14183. if (finalizer && !agen->ag_closed) {
  14184. PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
  14185. if (unlikely(!res)) {
  14186. PyErr_WriteUnraisable(self);
  14187. } else {
  14188. Py_DECREF(res);
  14189. }
  14190. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  14191. return;
  14192. }
  14193. }
  14194. #endif
  14195. if (unlikely(gen->resume_label == 0 && !error_value)) {
  14196. #ifdef __Pyx_Coroutine_USED
  14197. #ifdef __Pyx_Generator_USED
  14198. if (!__Pyx_Generator_CheckExact(self))
  14199. #endif
  14200. {
  14201. PyObject_GC_UnTrack(self);
  14202. if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
  14203. PyErr_WriteUnraisable(self);
  14204. PyObject_GC_Track(self);
  14205. }
  14206. #endif
  14207. } else {
  14208. PyObject *retval = NULL;
  14209. __Pyx_PySendResult result = __Pyx_Coroutine_Close(self, &retval);
  14210. if (result == PYGEN_ERROR) {
  14211. PyErr_WriteUnraisable(self);
  14212. } else {
  14213. Py_XDECREF(retval);
  14214. }
  14215. }
  14216. __Pyx_ErrRestore(error_type, error_value, error_traceback);
  14217. }
  14218. #endif
  14219. static PyObject *
  14220. __Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context)
  14221. {
  14222. PyObject *name = self->gi_name;
  14223. CYTHON_UNUSED_VAR(context);
  14224. if (unlikely(!name)) name = Py_None;
  14225. Py_INCREF(name);
  14226. return name;
  14227. }
  14228. static int
  14229. __Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context)
  14230. {
  14231. CYTHON_UNUSED_VAR(context);
  14232. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  14233. PyErr_SetString(PyExc_TypeError,
  14234. "__name__ must be set to a string object");
  14235. return -1;
  14236. }
  14237. Py_INCREF(value);
  14238. __Pyx_Py_XDECREF_SET(self->gi_name, value);
  14239. return 0;
  14240. }
  14241. static PyObject *
  14242. __Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context)
  14243. {
  14244. PyObject *name = self->gi_qualname;
  14245. CYTHON_UNUSED_VAR(context);
  14246. if (unlikely(!name)) name = Py_None;
  14247. Py_INCREF(name);
  14248. return name;
  14249. }
  14250. static int
  14251. __Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context)
  14252. {
  14253. CYTHON_UNUSED_VAR(context);
  14254. if (unlikely(value == NULL || !PyUnicode_Check(value))) {
  14255. PyErr_SetString(PyExc_TypeError,
  14256. "__qualname__ must be set to a string object");
  14257. return -1;
  14258. }
  14259. Py_INCREF(value);
  14260. __Pyx_Py_XDECREF_SET(self->gi_qualname, value);
  14261. return 0;
  14262. }
  14263. static PyObject *
  14264. __Pyx__Coroutine_get_frame(__pyx_CoroutineObject *self)
  14265. {
  14266. #if !CYTHON_COMPILING_IN_LIMITED_API
  14267. PyObject *frame;
  14268. #if PY_VERSION_HEX >= 0x030d0000
  14269. Py_BEGIN_CRITICAL_SECTION(self);
  14270. #endif
  14271. frame = self->gi_frame;
  14272. if (!frame) {
  14273. if (unlikely(!self->gi_code)) {
  14274. Py_RETURN_NONE;
  14275. }
  14276. PyObject *globals = PyDict_New();
  14277. if (unlikely(!globals)) return NULL;
  14278. frame = (PyObject *) PyFrame_New(
  14279. PyThreadState_Get(), /*PyThreadState *tstate,*/
  14280. (PyCodeObject*) self->gi_code, /*PyCodeObject *code,*/
  14281. globals, /*PyObject *globals,*/
  14282. 0 /*PyObject *locals*/
  14283. );
  14284. Py_DECREF(globals);
  14285. if (unlikely(!frame))
  14286. return NULL;
  14287. if (unlikely(self->gi_frame)) {
  14288. Py_DECREF(frame);
  14289. frame = self->gi_frame;
  14290. } else {
  14291. self->gi_frame = frame;
  14292. }
  14293. }
  14294. Py_INCREF(frame);
  14295. #if PY_VERSION_HEX >= 0x030d0000
  14296. Py_END_CRITICAL_SECTION();
  14297. #endif
  14298. return frame;
  14299. #else
  14300. CYTHON_UNUSED_VAR(self);
  14301. Py_RETURN_NONE;
  14302. #endif
  14303. }
  14304. static PyObject *
  14305. __Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) {
  14306. CYTHON_UNUSED_VAR(context);
  14307. PyObject *frame = self->gi_frame;
  14308. if (frame)
  14309. return __Pyx_NewRef(frame);
  14310. return __Pyx__Coroutine_get_frame(self);
  14311. }
  14312. static __pyx_CoroutineObject *__Pyx__Coroutine_New(
  14313. PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  14314. PyObject *name, PyObject *qualname, PyObject *module_name) {
  14315. __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
  14316. if (unlikely(!gen))
  14317. return NULL;
  14318. return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
  14319. }
  14320. static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
  14321. __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
  14322. PyObject *name, PyObject *qualname, PyObject *module_name) {
  14323. gen->body = body;
  14324. gen->closure = closure;
  14325. Py_XINCREF(closure);
  14326. gen->is_running = 0;
  14327. gen->resume_label = 0;
  14328. gen->classobj = NULL;
  14329. gen->yieldfrom = NULL;
  14330. gen->yieldfrom_am_send = NULL;
  14331. #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_LIMITED_API
  14332. gen->gi_exc_state.exc_value = NULL;
  14333. #else
  14334. gen->gi_exc_state.exc_type = NULL;
  14335. gen->gi_exc_state.exc_value = NULL;
  14336. gen->gi_exc_state.exc_traceback = NULL;
  14337. #endif
  14338. #if CYTHON_USE_EXC_INFO_STACK
  14339. gen->gi_exc_state.previous_item = NULL;
  14340. #endif
  14341. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  14342. gen->gi_weakreflist = NULL;
  14343. #endif
  14344. Py_XINCREF(qualname);
  14345. gen->gi_qualname = qualname;
  14346. Py_XINCREF(name);
  14347. gen->gi_name = name;
  14348. Py_XINCREF(module_name);
  14349. gen->gi_modulename = module_name;
  14350. Py_XINCREF(code);
  14351. gen->gi_code = code;
  14352. gen->gi_frame = NULL;
  14353. PyObject_GC_Track(gen);
  14354. return gen;
  14355. }
  14356. static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen) {
  14357. char result;
  14358. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14359. Py_BEGIN_CRITICAL_SECTION(gen);
  14360. #endif
  14361. result = gen->is_running;
  14362. gen->is_running = 1;
  14363. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14364. Py_END_CRITICAL_SECTION();
  14365. #endif
  14366. return result;
  14367. }
  14368. static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen) {
  14369. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14370. Py_BEGIN_CRITICAL_SECTION(gen);
  14371. #endif
  14372. assert(gen->is_running);
  14373. gen->is_running = 0;
  14374. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14375. Py_END_CRITICAL_SECTION();
  14376. #endif
  14377. }
  14378. static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen) {
  14379. char result;
  14380. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14381. Py_BEGIN_CRITICAL_SECTION(gen);
  14382. #endif
  14383. result = gen->is_running;
  14384. #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14385. Py_END_CRITICAL_SECTION();
  14386. #endif
  14387. return result;
  14388. }
  14389. static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure) {
  14390. CYTHON_UNUSED_VAR(closure);
  14391. char result = __Pyx_Coroutine_get_is_running((__pyx_CoroutineObject*)gen);
  14392. if (result) Py_RETURN_TRUE;
  14393. else Py_RETURN_FALSE;
  14394. }
  14395. #if __PYX_HAS_PY_AM_SEND == 2
  14396. static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send) {
  14397. Py_ssize_t ptr_offset = (char*)(type->tp_as_async) - (char*)type;
  14398. if (ptr_offset < 0 || ptr_offset > type->tp_basicsize) {
  14399. return;
  14400. }
  14401. memcpy((void*)static_amsend_methods, (void*)(type->tp_as_async), sizeof(*type->tp_as_async));
  14402. static_amsend_methods->am_send = am_send;
  14403. type->tp_as_async = __Pyx_SlotTpAsAsync(static_amsend_methods);
  14404. }
  14405. #endif
  14406. static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg) {
  14407. CYTHON_UNUSED_VAR(arg);
  14408. __Pyx_TypeName self_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE((PyObject*)self));
  14409. PyErr_Format(PyExc_TypeError, "cannot pickle '" __Pyx_FMT_TYPENAME "' object",
  14410. self_type_name);
  14411. __Pyx_DECREF_TypeName(self_type_name);
  14412. return NULL;
  14413. }
  14414. /* Generator */
  14415. static PyMethodDef __pyx_Generator_methods[] = {
  14416. {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
  14417. PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
  14418. {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
  14419. PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
  14420. {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
  14421. PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
  14422. {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
  14423. {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
  14424. {0, 0, 0, 0}
  14425. };
  14426. static PyMemberDef __pyx_Generator_memberlist[] = {
  14427. {"gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
  14428. PyDoc_STR("object being iterated by 'yield from', or None")},
  14429. {"gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
  14430. {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
  14431. #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
  14432. {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
  14433. #endif
  14434. {0, 0, 0, 0, 0}
  14435. };
  14436. static PyGetSetDef __pyx_Generator_getsets[] = {
  14437. {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
  14438. PyDoc_STR("name of the generator"), 0},
  14439. {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
  14440. PyDoc_STR("qualified name of the generator"), 0},
  14441. {"gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
  14442. PyDoc_STR("Frame of the generator"), 0},
  14443. {"gi_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
  14444. {0, 0, 0, 0, 0}
  14445. };
  14446. static PyType_Slot __pyx_GeneratorType_slots[] = {
  14447. {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
  14448. {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
  14449. {Py_tp_iter, (void *)PyObject_SelfIter},
  14450. {Py_tp_iternext, (void *)__Pyx_Generator_Next},
  14451. {Py_tp_methods, (void *)__pyx_Generator_methods},
  14452. {Py_tp_members, (void *)__pyx_Generator_memberlist},
  14453. {Py_tp_getset, (void *)__pyx_Generator_getsets},
  14454. {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
  14455. #if CYTHON_USE_TP_FINALIZE
  14456. {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
  14457. #endif
  14458. #if __PYX_HAS_PY_AM_SEND == 1
  14459. {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
  14460. #endif
  14461. {0, 0},
  14462. };
  14463. static PyType_Spec __pyx_GeneratorType_spec = {
  14464. __PYX_TYPE_MODULE_PREFIX "generator",
  14465. sizeof(__pyx_CoroutineObject),
  14466. 0,
  14467. #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
  14468. Py_TPFLAGS_MANAGED_WEAKREF |
  14469. #endif
  14470. Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
  14471. Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND,
  14472. __pyx_GeneratorType_slots
  14473. };
  14474. #if __PYX_HAS_PY_AM_SEND == 2
  14475. static __Pyx_PyAsyncMethodsStruct __pyx_Generator_as_async;
  14476. #endif
  14477. static int __pyx_Generator_init(PyObject *module) {
  14478. __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
  14479. mstate->__pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(
  14480. mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_GeneratorType_spec, NULL);
  14481. if (unlikely(!mstate->__pyx_GeneratorType)) {
  14482. return -1;
  14483. }
  14484. #if __PYX_HAS_PY_AM_SEND == 2
  14485. __Pyx_SetBackportTypeAmSend(mstate->__pyx_GeneratorType, &__pyx_Generator_as_async, &__Pyx_Coroutine_AmSend);
  14486. #endif
  14487. return 0;
  14488. }
  14489. static PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self) {
  14490. __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
  14491. PyObject *retval = NULL;
  14492. if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
  14493. return __Pyx_Coroutine_AlreadyRunningError(gen);
  14494. }
  14495. __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
  14496. __Pyx_Coroutine_unset_is_running(gen);
  14497. (void) result;
  14498. assert (result == PYGEN_RETURN || result == PYGEN_ERROR);
  14499. assert ((result == PYGEN_RETURN && retval != NULL) || (result == PYGEN_ERROR && retval == NULL));
  14500. return retval;
  14501. }
  14502. /* CheckBinaryVersion */
  14503. static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
  14504. const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
  14505. if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
  14506. return 0;
  14507. if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
  14508. return 1;
  14509. {
  14510. char message[200];
  14511. PyOS_snprintf(message, sizeof(message),
  14512. "compile time Python version %d.%d "
  14513. "of module '%.100s' "
  14514. "%s "
  14515. "runtime version %d.%d",
  14516. (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
  14517. __Pyx_MODULE_NAME,
  14518. (allow_newer) ? "was newer than" : "does not match",
  14519. (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
  14520. );
  14521. return PyErr_WarnEx(NULL, message, 1);
  14522. }
  14523. }
  14524. /* NewCodeObj */
  14525. #if CYTHON_COMPILING_IN_LIMITED_API
  14526. static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  14527. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  14528. PyObject *fv, PyObject *cell, PyObject* fn,
  14529. PyObject *name, int fline, PyObject *lnos) {
  14530. PyObject *exception_table = NULL;
  14531. PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
  14532. #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  14533. PyObject *version_info;
  14534. PyObject *py_minor_version = NULL;
  14535. #endif
  14536. long minor_version = 0;
  14537. PyObject *type, *value, *traceback;
  14538. PyErr_Fetch(&type, &value, &traceback);
  14539. #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
  14540. minor_version = 11;
  14541. #else
  14542. if (!(version_info = PySys_GetObject("version_info"))) goto end;
  14543. if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
  14544. minor_version = PyLong_AsLong(py_minor_version);
  14545. Py_DECREF(py_minor_version);
  14546. if (minor_version == -1 && PyErr_Occurred()) goto end;
  14547. #endif
  14548. if (!(types_module = PyImport_ImportModule("types"))) goto end;
  14549. if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
  14550. if (minor_version <= 7) {
  14551. (void)p;
  14552. result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code,
  14553. c, n, v, fn, name, fline, lnos, fv, cell);
  14554. } else if (minor_version <= 10) {
  14555. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code,
  14556. c, n, v, fn, name, fline, lnos, fv, cell);
  14557. } else {
  14558. if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
  14559. result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code,
  14560. c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
  14561. }
  14562. end:
  14563. Py_XDECREF(code_type);
  14564. Py_XDECREF(exception_table);
  14565. Py_XDECREF(types_module);
  14566. if (type) {
  14567. PyErr_Restore(type, value, traceback);
  14568. }
  14569. return result;
  14570. }
  14571. #elif PY_VERSION_HEX >= 0x030B0000
  14572. static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
  14573. PyObject *code, PyObject *c, PyObject* n, PyObject *v,
  14574. PyObject *fv, PyObject *cell, PyObject* fn,
  14575. PyObject *name, int fline, PyObject *lnos) {
  14576. PyCodeObject *result;
  14577. result =
  14578. #if PY_VERSION_HEX >= 0x030C0000
  14579. PyUnstable_Code_NewWithPosOnlyArgs
  14580. #else
  14581. PyCode_NewWithPosOnlyArgs
  14582. #endif
  14583. (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes);
  14584. #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1
  14585. if (likely(result))
  14586. result->_co_firsttraceable = 0;
  14587. #endif
  14588. return result;
  14589. }
  14590. #elif !CYTHON_COMPILING_IN_PYPY
  14591. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  14592. PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  14593. #else
  14594. #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
  14595. PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  14596. #endif
  14597. static PyObject* __Pyx_PyCode_New(
  14598. const __Pyx_PyCode_New_function_description descr,
  14599. PyObject * const *varnames,
  14600. PyObject *filename,
  14601. PyObject *funcname,
  14602. PyObject *line_table,
  14603. PyObject *tuple_dedup_map
  14604. ) {
  14605. PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL;
  14606. Py_ssize_t var_count = (Py_ssize_t) descr.nlocals;
  14607. PyObject *varnames_tuple = PyTuple_New(var_count);
  14608. if (unlikely(!varnames_tuple)) return NULL;
  14609. for (Py_ssize_t i=0; i < var_count; i++) {
  14610. Py_INCREF(varnames[i]);
  14611. if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done;
  14612. }
  14613. #if CYTHON_COMPILING_IN_LIMITED_API
  14614. varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple);
  14615. if (!varnames_tuple_dedup) {
  14616. if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done;
  14617. varnames_tuple_dedup = varnames_tuple;
  14618. }
  14619. #else
  14620. varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple);
  14621. if (unlikely(!varnames_tuple_dedup)) goto done;
  14622. #endif
  14623. #if CYTHON_AVOID_BORROWED_REFS
  14624. Py_INCREF(varnames_tuple_dedup);
  14625. #endif
  14626. if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) {
  14627. Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table);
  14628. #if !CYTHON_ASSUME_SAFE_SIZE
  14629. if (unlikely(line_table_length == -1)) goto done;
  14630. #endif
  14631. Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL;
  14632. code_bytes = PyBytes_FromStringAndSize(NULL, code_len);
  14633. if (unlikely(!code_bytes)) goto done;
  14634. char* c_code_bytes = PyBytes_AsString(code_bytes);
  14635. if (unlikely(!c_code_bytes)) goto done;
  14636. memset(c_code_bytes, 0, (size_t) code_len);
  14637. }
  14638. code_obj = (PyObject*) __Pyx__PyCode_New(
  14639. (int) descr.argcount,
  14640. (int) descr.num_posonly_args,
  14641. (int) descr.num_kwonly_args,
  14642. (int) descr.nlocals,
  14643. 0,
  14644. (int) descr.flags,
  14645. code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes,
  14646. __pyx_mstate_global->__pyx_empty_tuple,
  14647. __pyx_mstate_global->__pyx_empty_tuple,
  14648. varnames_tuple_dedup,
  14649. __pyx_mstate_global->__pyx_empty_tuple,
  14650. __pyx_mstate_global->__pyx_empty_tuple,
  14651. filename,
  14652. funcname,
  14653. (int) descr.first_line,
  14654. (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes
  14655. );
  14656. done:
  14657. Py_XDECREF(code_bytes);
  14658. #if CYTHON_AVOID_BORROWED_REFS
  14659. Py_XDECREF(varnames_tuple_dedup);
  14660. #endif
  14661. Py_DECREF(varnames_tuple);
  14662. return code_obj;
  14663. }
  14664. /* DecompressString */
  14665. static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) {
  14666. PyObject *module, *decompress, *compressed_bytes, *decompressed;
  14667. const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib";
  14668. PyObject *methodname = PyUnicode_FromString("decompress");
  14669. if (unlikely(!methodname)) return NULL;
  14670. #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000
  14671. if (algo == 3) {
  14672. PyObject *fromlist = Py_BuildValue("[O]", methodname);
  14673. if (unlikely(!fromlist)) return NULL;
  14674. module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0);
  14675. Py_DECREF(fromlist);
  14676. } else
  14677. #endif
  14678. module = PyImport_ImportModule(module_name);
  14679. if (unlikely(!module)) goto import_failed;
  14680. decompress = PyObject_GetAttr(module, methodname);
  14681. if (unlikely(!decompress)) goto import_failed;
  14682. {
  14683. #ifdef __cplusplus
  14684. char *memview_bytes = const_cast<char*>(s);
  14685. #else
  14686. #if defined(__clang__)
  14687. #pragma clang diagnostic push
  14688. #pragma clang diagnostic ignored "-Wcast-qual"
  14689. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  14690. #pragma GCC diagnostic push
  14691. #pragma GCC diagnostic ignored "-Wcast-qual"
  14692. #endif
  14693. char *memview_bytes = (char*) s;
  14694. #if defined(__clang__)
  14695. #pragma clang diagnostic pop
  14696. #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
  14697. #pragma GCC diagnostic pop
  14698. #endif
  14699. #endif
  14700. #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ)
  14701. int memview_flags = 0x100;
  14702. #else
  14703. int memview_flags = PyBUF_READ;
  14704. #endif
  14705. compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags);
  14706. }
  14707. if (unlikely(!compressed_bytes)) {
  14708. Py_DECREF(decompress);
  14709. goto bad;
  14710. }
  14711. decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL);
  14712. Py_DECREF(compressed_bytes);
  14713. Py_DECREF(decompress);
  14714. Py_DECREF(module);
  14715. Py_DECREF(methodname);
  14716. return decompressed;
  14717. import_failed:
  14718. PyErr_Format(PyExc_ImportError,
  14719. "Failed to import '%.20s.decompress' - cannot initialise module strings. "
  14720. "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.",
  14721. module_name, algo);
  14722. bad:
  14723. Py_XDECREF(module);
  14724. Py_DECREF(methodname);
  14725. return NULL;
  14726. }
  14727. #include <string.h>
  14728. static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) {
  14729. size_t len = strlen(s);
  14730. if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) {
  14731. PyErr_SetString(PyExc_OverflowError, "byte string is too long");
  14732. return -1;
  14733. }
  14734. return (Py_ssize_t) len;
  14735. }
  14736. static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
  14737. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  14738. if (unlikely(len < 0)) return NULL;
  14739. return __Pyx_PyUnicode_FromStringAndSize(c_str, len);
  14740. }
  14741. static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) {
  14742. Py_ssize_t len = __Pyx_ssize_strlen(c_str);
  14743. if (unlikely(len < 0)) return NULL;
  14744. return PyByteArray_FromStringAndSize(c_str, len);
  14745. }
  14746. static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
  14747. Py_ssize_t ignore;
  14748. return __Pyx_PyObject_AsStringAndSize(o, &ignore);
  14749. }
  14750. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  14751. static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  14752. if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
  14753. #if CYTHON_COMPILING_IN_LIMITED_API
  14754. {
  14755. const char* result;
  14756. Py_ssize_t unicode_length;
  14757. CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  14758. #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
  14759. if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL;
  14760. #else
  14761. result = PyUnicode_AsUTF8AndSize(o, length);
  14762. #endif
  14763. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  14764. unicode_length = PyUnicode_GetLength(o);
  14765. if (unlikely(unicode_length < 0)) return NULL;
  14766. if (unlikely(unicode_length != *length)) {
  14767. PyUnicode_AsASCIIString(o);
  14768. return NULL;
  14769. }
  14770. #endif
  14771. return result;
  14772. }
  14773. #else
  14774. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  14775. if (likely(PyUnicode_IS_ASCII(o))) {
  14776. *length = PyUnicode_GET_LENGTH(o);
  14777. return PyUnicode_AsUTF8(o);
  14778. } else {
  14779. PyUnicode_AsASCIIString(o);
  14780. return NULL;
  14781. }
  14782. #else
  14783. return PyUnicode_AsUTF8AndSize(o, length);
  14784. #endif
  14785. #endif
  14786. }
  14787. #endif
  14788. static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
  14789. #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  14790. if (PyUnicode_Check(o)) {
  14791. return __Pyx_PyUnicode_AsStringAndSize(o, length);
  14792. } else
  14793. #endif
  14794. if (PyByteArray_Check(o)) {
  14795. #if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)))
  14796. *length = PyByteArray_GET_SIZE(o);
  14797. return PyByteArray_AS_STRING(o);
  14798. #else
  14799. *length = PyByteArray_Size(o);
  14800. if (*length == -1) return NULL;
  14801. return PyByteArray_AsString(o);
  14802. #endif
  14803. } else
  14804. {
  14805. char* result;
  14806. int r = PyBytes_AsStringAndSize(o, &result, length);
  14807. if (unlikely(r < 0)) {
  14808. return NULL;
  14809. } else {
  14810. return result;
  14811. }
  14812. }
  14813. }
  14814. static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
  14815. int is_true = x == Py_True;
  14816. if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
  14817. else return PyObject_IsTrue(x);
  14818. }
  14819. static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
  14820. int retval;
  14821. if (unlikely(!x)) return -1;
  14822. retval = __Pyx_PyObject_IsTrue(x);
  14823. Py_DECREF(x);
  14824. return retval;
  14825. }
  14826. static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) {
  14827. __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result));
  14828. if (PyLong_Check(result)) {
  14829. if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
  14830. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME "). "
  14831. "The ability to return an instance of a strict subclass of int is deprecated, "
  14832. "and may be removed in a future version of Python.",
  14833. result_type_name)) {
  14834. __Pyx_DECREF_TypeName(result_type_name);
  14835. Py_DECREF(result);
  14836. return NULL;
  14837. }
  14838. __Pyx_DECREF_TypeName(result_type_name);
  14839. return result;
  14840. }
  14841. PyErr_Format(PyExc_TypeError,
  14842. "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")",
  14843. result_type_name);
  14844. __Pyx_DECREF_TypeName(result_type_name);
  14845. Py_DECREF(result);
  14846. return NULL;
  14847. }
  14848. static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) {
  14849. #if CYTHON_USE_TYPE_SLOTS
  14850. PyNumberMethods *m;
  14851. #endif
  14852. PyObject *res = NULL;
  14853. if (likely(PyLong_Check(x)))
  14854. return __Pyx_NewRef(x);
  14855. #if CYTHON_USE_TYPE_SLOTS
  14856. m = Py_TYPE(x)->tp_as_number;
  14857. if (likely(m && m->nb_int)) {
  14858. res = m->nb_int(x);
  14859. }
  14860. #else
  14861. if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
  14862. res = PyNumber_Long(x);
  14863. }
  14864. #endif
  14865. if (likely(res)) {
  14866. if (unlikely(!PyLong_CheckExact(res))) {
  14867. return __Pyx_PyNumber_LongWrongResultType(res);
  14868. }
  14869. }
  14870. else if (!PyErr_Occurred()) {
  14871. PyErr_SetString(PyExc_TypeError,
  14872. "an integer is required");
  14873. }
  14874. return res;
  14875. }
  14876. static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  14877. Py_ssize_t ival;
  14878. PyObject *x;
  14879. if (likely(PyLong_CheckExact(b))) {
  14880. #if CYTHON_USE_PYLONG_INTERNALS
  14881. if (likely(__Pyx_PyLong_IsCompact(b))) {
  14882. return __Pyx_PyLong_CompactValue(b);
  14883. } else {
  14884. const digit* digits = __Pyx_PyLong_Digits(b);
  14885. const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b);
  14886. switch (size) {
  14887. case 2:
  14888. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  14889. return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14890. }
  14891. break;
  14892. case -2:
  14893. if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
  14894. return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14895. }
  14896. break;
  14897. case 3:
  14898. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  14899. return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14900. }
  14901. break;
  14902. case -3:
  14903. if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
  14904. return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
  14905. }
  14906. break;
  14907. case 4:
  14908. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  14909. 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]));
  14910. }
  14911. break;
  14912. case -4:
  14913. if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
  14914. 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]));
  14915. }
  14916. break;
  14917. }
  14918. }
  14919. #endif
  14920. return PyLong_AsSsize_t(b);
  14921. }
  14922. x = PyNumber_Index(b);
  14923. if (!x) return -1;
  14924. ival = PyLong_AsSsize_t(x);
  14925. Py_DECREF(x);
  14926. return ival;
  14927. }
  14928. static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  14929. if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
  14930. return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
  14931. } else {
  14932. Py_ssize_t ival;
  14933. PyObject *x;
  14934. x = PyNumber_Index(o);
  14935. if (!x) return -1;
  14936. ival = PyLong_AsLong(x);
  14937. Py_DECREF(x);
  14938. return ival;
  14939. }
  14940. }
  14941. static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) {
  14942. CYTHON_UNUSED_VAR(b);
  14943. return __Pyx_NewRef(Py_None);
  14944. }
  14945. static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  14946. return __Pyx_NewRef(b ? Py_True: Py_False);
  14947. }
  14948. static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) {
  14949. return PyLong_FromSize_t(ival);
  14950. }
  14951. /* MultiPhaseInitModuleState */
  14952. #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  14953. #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  14954. #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000)
  14955. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1
  14956. #else
  14957. #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0
  14958. #endif
  14959. #endif
  14960. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS
  14961. #error "Module state with PEP489 requires atomics. Currently that's one of\
  14962. C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics"
  14963. #endif
  14964. #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  14965. #define __Pyx_ModuleStateLookup_Lock()
  14966. #define __Pyx_ModuleStateLookup_Unlock()
  14967. #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  14968. static PyMutex __Pyx_ModuleStateLookup_mutex = {0};
  14969. #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex)
  14970. #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex)
  14971. #elif defined(__cplusplus) && __cplusplus >= 201103L
  14972. #include <mutex>
  14973. static std::mutex __Pyx_ModuleStateLookup_mutex;
  14974. #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock()
  14975. #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock()
  14976. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__)
  14977. #include <threads.h>
  14978. static mtx_t __Pyx_ModuleStateLookup_mutex;
  14979. static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT;
  14980. static void __Pyx_ModuleStateLookup_initialize_mutex(void) {
  14981. mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain);
  14982. }
  14983. #define __Pyx_ModuleStateLookup_Lock()\
  14984. call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\
  14985. mtx_lock(&__Pyx_ModuleStateLookup_mutex)
  14986. #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex)
  14987. #elif defined(HAVE_PTHREAD_H)
  14988. #include <pthread.h>
  14989. static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER;
  14990. #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex)
  14991. #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex)
  14992. #elif defined(_WIN32)
  14993. #include <Windows.h> // synchapi.h on its own doesn't work
  14994. static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT;
  14995. #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  14996. #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  14997. #else
  14998. #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\
  14999. Requires C standard >= C11, or C++ standard >= C++11,\
  15000. or pthreads, or the Windows 32 API, or Python >= 3.13."
  15001. #endif
  15002. typedef struct {
  15003. int64_t id;
  15004. PyObject *module;
  15005. } __Pyx_InterpreterIdAndModule;
  15006. typedef struct {
  15007. char interpreter_id_as_index;
  15008. Py_ssize_t count;
  15009. Py_ssize_t allocated;
  15010. __Pyx_InterpreterIdAndModule table[1];
  15011. } __Pyx_ModuleStateLookupData;
  15012. #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32
  15013. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15014. static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0;
  15015. #endif
  15016. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15017. static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0;
  15018. #else
  15019. static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL;
  15020. #endif
  15021. static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound(
  15022. __Pyx_InterpreterIdAndModule* table,
  15023. Py_ssize_t count,
  15024. int64_t interpreterId) {
  15025. __Pyx_InterpreterIdAndModule* begin = table;
  15026. __Pyx_InterpreterIdAndModule* end = begin + count;
  15027. if (begin->id == interpreterId) {
  15028. return begin;
  15029. }
  15030. while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  15031. __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2;
  15032. if (halfway->id == interpreterId) {
  15033. return halfway;
  15034. }
  15035. if (halfway->id < interpreterId) {
  15036. begin = halfway;
  15037. } else {
  15038. end = halfway;
  15039. }
  15040. }
  15041. for (; begin < end; ++begin) {
  15042. if (begin->id >= interpreterId) return begin;
  15043. }
  15044. return begin;
  15045. }
  15046. static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) {
  15047. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15048. if (interpreter_id == -1) return NULL;
  15049. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15050. __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  15051. {
  15052. __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15053. if (likely(data)) {
  15054. __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data);
  15055. if (likely(data == new_data)) {
  15056. goto read_finished;
  15057. }
  15058. }
  15059. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15060. __Pyx_ModuleStateLookup_Lock();
  15061. __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter);
  15062. data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
  15063. __Pyx_ModuleStateLookup_Unlock();
  15064. }
  15065. read_finished:;
  15066. #else
  15067. __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data;
  15068. #endif
  15069. __Pyx_InterpreterIdAndModule* found = NULL;
  15070. if (unlikely(!data)) goto end;
  15071. if (data->interpreter_id_as_index) {
  15072. if (interpreter_id < data->count) {
  15073. found = data->table+interpreter_id;
  15074. }
  15075. } else {
  15076. found = __Pyx_State_FindModuleStateLookupTableLowerBound(
  15077. data->table, data->count, interpreter_id);
  15078. }
  15079. end:
  15080. {
  15081. PyObject *result=NULL;
  15082. if (found && found->id == interpreter_id) {
  15083. result = found->module;
  15084. }
  15085. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15086. __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  15087. #endif
  15088. return result;
  15089. }
  15090. }
  15091. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15092. static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) {
  15093. while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0);
  15094. }
  15095. #else
  15096. #define __Pyx_ModuleStateLookup_wait_until_no_readers()
  15097. #endif
  15098. static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) {
  15099. Py_ssize_t to_allocate = (*old_data)->allocated;
  15100. while (to_allocate <= interpreter_id) {
  15101. if (to_allocate == 0) to_allocate = 1;
  15102. else to_allocate *= 2;
  15103. }
  15104. __Pyx_ModuleStateLookupData *new_data = *old_data;
  15105. if (to_allocate != (*old_data)->allocated) {
  15106. new_data = (__Pyx_ModuleStateLookupData *)realloc(
  15107. *old_data,
  15108. sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  15109. if (!new_data) {
  15110. PyErr_NoMemory();
  15111. return -1;
  15112. }
  15113. for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) {
  15114. new_data->table[i].id = i;
  15115. new_data->table[i].module = NULL;
  15116. }
  15117. new_data->allocated = to_allocate;
  15118. }
  15119. new_data->table[interpreter_id].module = module;
  15120. if (new_data->count < interpreter_id+1) {
  15121. new_data->count = interpreter_id+1;
  15122. }
  15123. *old_data = new_data;
  15124. return 0;
  15125. }
  15126. static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) {
  15127. __Pyx_InterpreterIdAndModule *read = data->table;
  15128. __Pyx_InterpreterIdAndModule *write = data->table;
  15129. __Pyx_InterpreterIdAndModule *end = read + data->count;
  15130. for (; read<end; ++read) {
  15131. if (read->module) {
  15132. write->id = read->id;
  15133. write->module = read->module;
  15134. ++write;
  15135. }
  15136. }
  15137. data->count = write - data->table;
  15138. for (; write<end; ++write) {
  15139. write->id = 0;
  15140. write->module = NULL;
  15141. }
  15142. data->interpreter_id_as_index = 0;
  15143. }
  15144. static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) {
  15145. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15146. if (interpreter_id == -1) return -1;
  15147. int result = 0;
  15148. __Pyx_ModuleStateLookup_Lock();
  15149. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15150. __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *)
  15151. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  15152. #else
  15153. __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data;
  15154. #endif
  15155. __Pyx_ModuleStateLookupData *new_data = old_data;
  15156. if (!new_data) {
  15157. new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData));
  15158. if (!new_data) {
  15159. result = -1;
  15160. PyErr_NoMemory();
  15161. goto end;
  15162. }
  15163. new_data->allocated = 1;
  15164. new_data->interpreter_id_as_index = 1;
  15165. }
  15166. __Pyx_ModuleStateLookup_wait_until_no_readers();
  15167. if (new_data->interpreter_id_as_index) {
  15168. if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
  15169. result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id);
  15170. goto end;
  15171. }
  15172. __Pyx_State_ConvertFromInterpIdAsIndex(new_data);
  15173. }
  15174. {
  15175. Py_ssize_t insert_at = 0;
  15176. {
  15177. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  15178. new_data->table, new_data->count, interpreter_id);
  15179. assert(lower_bound);
  15180. insert_at = lower_bound - new_data->table;
  15181. if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) {
  15182. lower_bound->module = module;
  15183. goto end; // already in table, nothing more to do
  15184. }
  15185. }
  15186. if (new_data->count+1 >= new_data->allocated) {
  15187. Py_ssize_t to_allocate = (new_data->count+1)*2;
  15188. new_data =
  15189. (__Pyx_ModuleStateLookupData*)realloc(
  15190. new_data,
  15191. sizeof(__Pyx_ModuleStateLookupData) +
  15192. (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
  15193. if (!new_data) {
  15194. result = -1;
  15195. new_data = old_data;
  15196. PyErr_NoMemory();
  15197. goto end;
  15198. }
  15199. new_data->allocated = to_allocate;
  15200. }
  15201. ++new_data->count;
  15202. int64_t last_id = interpreter_id;
  15203. PyObject *last_module = module;
  15204. for (Py_ssize_t i=insert_at; i<new_data->count; ++i) {
  15205. int64_t current_id = new_data->table[i].id;
  15206. new_data->table[i].id = last_id;
  15207. last_id = current_id;
  15208. PyObject *current_module = new_data->table[i].module;
  15209. new_data->table[i].module = last_module;
  15210. last_module = current_module;
  15211. }
  15212. }
  15213. end:
  15214. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15215. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data);
  15216. #else
  15217. __Pyx_ModuleStateLookup_data = new_data;
  15218. #endif
  15219. __Pyx_ModuleStateLookup_Unlock();
  15220. return result;
  15221. }
  15222. static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) {
  15223. int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
  15224. if (interpreter_id == -1) return -1;
  15225. __Pyx_ModuleStateLookup_Lock();
  15226. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15227. __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *)
  15228. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  15229. #else
  15230. __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data;
  15231. #endif
  15232. if (data->interpreter_id_as_index) {
  15233. if (interpreter_id < data->count) {
  15234. data->table[interpreter_id].module = NULL;
  15235. }
  15236. goto done;
  15237. }
  15238. {
  15239. __Pyx_ModuleStateLookup_wait_until_no_readers();
  15240. __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
  15241. data->table, data->count, interpreter_id);
  15242. if (!lower_bound) goto done;
  15243. if (lower_bound->id != interpreter_id) goto done;
  15244. __Pyx_InterpreterIdAndModule *end = data->table+data->count;
  15245. for (;lower_bound<end-1; ++lower_bound) {
  15246. lower_bound->id = (lower_bound+1)->id;
  15247. lower_bound->module = (lower_bound+1)->module;
  15248. }
  15249. }
  15250. --data->count;
  15251. if (data->count == 0) {
  15252. free(data);
  15253. data = NULL;
  15254. }
  15255. done:
  15256. #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  15257. __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data);
  15258. #else
  15259. __Pyx_ModuleStateLookup_data = data;
  15260. #endif
  15261. __Pyx_ModuleStateLookup_Unlock();
  15262. return 0;
  15263. }
  15264. #endif
  15265. /* #### Code section: utility_code_pragmas_end ### */
  15266. #ifdef _MSC_VER
  15267. #pragma warning( pop )
  15268. #endif
  15269. /* #### Code section: end ### */
  15270. #endif /* Py_PYTHON_H */